Skip to content

Commit

Permalink
drivers/base/memory: map MMOP_OFFLINE to 0
Browse files Browse the repository at this point in the history
Historically, we used the value -1.  Just treat 0 as the special case now.
Clarify a comment (which was wrong, when we come via device_online() the
first time, the online_type would have been 0 / MEM_ONLINE).  The default
is now always MMOP_OFFLINE.  This removes the last user of the manual
"-1", which didn't use the enum value.

This is a preparation to use the online_type as an array index.

Signed-off-by: David Hildenbrand <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Wei Yang <[email protected]>
Reviewed-by: Baoquan He <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Acked-by: Pankaj Gupta <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Wei Yang <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Eduardo Habkost <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Yumei Huang <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
davidhildenbrand authored and torvalds committed Apr 7, 2020
1 parent 956f8b4 commit efc978a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,14 @@ static int memory_subsys_online(struct device *dev)
return 0;

/*
* If we are called from state_store(), online_type will be
* set >= 0 Otherwise we were called from the device online
* attribute and need to set the online_type.
* When called via device_online() without configuring the online_type,
* we want to default to MMOP_ONLINE.
*/
if (mem->online_type < 0)
if (mem->online_type == MMOP_OFFLINE)
mem->online_type = MMOP_ONLINE;

ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE);

/* clear online_type */
mem->online_type = -1;
mem->online_type = MMOP_OFFLINE;

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum {
/* Types for control the zone type of onlined and offlined memory */
enum {
/* Offline the memory. */
MMOP_OFFLINE = -1,
MMOP_OFFLINE = 0,
/* Online the memory. Zone depends, see default_zone_for_pfn(). */
MMOP_ONLINE,
/* Online the memory to ZONE_NORMAL. */
Expand Down

0 comments on commit efc978a

Please sign in to comment.