Skip to content

Commit

Permalink
mm/swap: fold __swap_info_get() into its sole caller
Browse files Browse the repository at this point in the history
Fold __swap_info_get() into its sole caller to make code more clear. 
Minor readability improvement.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Reviewed-by: Oscar Salvador <[email protected]>
Cc: Alistair Popple <[email protected]>
Cc: David Howells <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: NeilBrown <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
MiaoheLin authored and akpm00 committed May 19, 2022
1 parent 6106b93 commit afba72b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size)
return n_ret;
}

static struct swap_info_struct *__swap_info_get(swp_entry_t entry)
static struct swap_info_struct *_swap_info_get(swp_entry_t entry)
{
struct swap_info_struct *p;
unsigned long offset;
Expand All @@ -1137,8 +1137,13 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry)
offset = swp_offset(entry);
if (offset >= p->max)
goto bad_offset;
if (data_race(!p->swap_map[swp_offset(entry)]))
goto bad_free;
return p;

bad_free:
pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val);
goto out;
bad_offset:
pr_err("%s: %s%08lx\n", __func__, Bad_offset, entry.val);
goto out;
Expand All @@ -1151,23 +1156,6 @@ static struct swap_info_struct *__swap_info_get(swp_entry_t entry)
return NULL;
}

static struct swap_info_struct *_swap_info_get(swp_entry_t entry)
{
struct swap_info_struct *p;

p = __swap_info_get(entry);
if (!p)
goto out;
if (data_race(!p->swap_map[swp_offset(entry)]))
goto bad_free;
return p;

bad_free:
pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val);
out:
return NULL;
}

static struct swap_info_struct *swap_info_get_cont(swp_entry_t entry,
struct swap_info_struct *q)
{
Expand Down

0 comments on commit afba72b

Please sign in to comment.