Commit dd625285 authored by David Hildenbrand's avatar David Hildenbrand Committed by Linus Torvalds

drivers/base/memory.c: get rid of find_memory_block_hinted()

No longer needed, let's remove it.  Also, drop the "hint" parameter
completely from "find_memory_block_by_id", as nobody needs it anymore.

[david@redhat.com: v3]
  Link: http://lkml.kernel.org/r/20190620183139.4352-7-david@redhat.com
[david@redhat.com: handle zero-length walks]
  Link: http://lkml.kernel.org/r/1c2edc22-afd7-2211-c4c7-40e54e5007e8@redhat.com
Link: http://lkml.kernel.org/r/20190614100114.311-7-david@redhat.comSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Tested-by: default avatarQian Cai <cai@lca.pw>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Andrew Banman <andrew.banman@hpe.com>
Cc: Mike Travis <mike.travis@hpe.com>
Cc: Oscar Salvador <osalvador@suse.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Arun KS <arunks@codeaurora.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ea884641
...@@ -588,30 +588,13 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) ...@@ -588,30 +588,13 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn)
return 0; return 0;
} }
/* /* A reference for the returned memory block device is acquired. */
* A reference for the returned object is held and the reference for the static struct memory_block *find_memory_block_by_id(unsigned long block_id)
* hinted object is released.
*/
static struct memory_block *find_memory_block_by_id(unsigned long block_id,
struct memory_block *hint)
{ {
struct device *hintdev = hint ? &hint->dev : NULL;
struct device *dev; struct device *dev;
dev = subsys_find_device_by_id(&memory_subsys, block_id, hintdev); dev = subsys_find_device_by_id(&memory_subsys, block_id, NULL);
if (hint) return dev ? to_memory_block(dev) : NULL;
put_device(&hint->dev);
if (!dev)
return NULL;
return to_memory_block(dev);
}
struct memory_block *find_memory_block_hinted(struct mem_section *section,
struct memory_block *hint)
{
unsigned long block_id = base_memory_block_id(__section_nr(section));
return find_memory_block_by_id(block_id, hint);
} }
/* /*
...@@ -624,7 +607,9 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section, ...@@ -624,7 +607,9 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section,
*/ */
struct memory_block *find_memory_block(struct mem_section *section) struct memory_block *find_memory_block(struct mem_section *section)
{ {
return find_memory_block_hinted(section, NULL); unsigned long block_id = base_memory_block_id(__section_nr(section));
return find_memory_block_by_id(block_id);
} }
static struct attribute *memory_memblk_attrs[] = { static struct attribute *memory_memblk_attrs[] = {
...@@ -675,7 +660,7 @@ static int init_memory_block(struct memory_block **memory, ...@@ -675,7 +660,7 @@ static int init_memory_block(struct memory_block **memory,
unsigned long start_pfn; unsigned long start_pfn;
int ret = 0; int ret = 0;
mem = find_memory_block_by_id(block_id, NULL); mem = find_memory_block_by_id(block_id);
if (mem) { if (mem) {
put_device(&mem->dev); put_device(&mem->dev);
return -EEXIST; return -EEXIST;
...@@ -755,7 +740,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size) ...@@ -755,7 +740,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size)
end_block_id = block_id; end_block_id = block_id;
for (block_id = start_block_id; block_id != end_block_id; for (block_id = start_block_id; block_id != end_block_id;
block_id++) { block_id++) {
mem = find_memory_block_by_id(block_id, NULL); mem = find_memory_block_by_id(block_id);
mem->section_count = 0; mem->section_count = 0;
unregister_memory(mem); unregister_memory(mem);
} }
...@@ -782,7 +767,7 @@ void remove_memory_block_devices(unsigned long start, unsigned long size) ...@@ -782,7 +767,7 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
for (block_id = start_block_id; block_id != end_block_id; block_id++) { for (block_id = start_block_id; block_id != end_block_id; block_id++) {
mem = find_memory_block_by_id(block_id, NULL); mem = find_memory_block_by_id(block_id);
if (WARN_ON_ONCE(!mem)) if (WARN_ON_ONCE(!mem))
continue; continue;
mem->section_count = 0; mem->section_count = 0;
...@@ -881,8 +866,11 @@ int walk_memory_blocks(unsigned long start, unsigned long size, ...@@ -881,8 +866,11 @@ int walk_memory_blocks(unsigned long start, unsigned long size,
unsigned long block_id; unsigned long block_id;
int ret = 0; int ret = 0;
if (!size)
return 0;
for (block_id = start_block_id; block_id <= end_block_id; block_id++) { for (block_id = start_block_id; block_id <= end_block_id; block_id++) {
mem = find_memory_block_by_id(block_id, NULL); mem = find_memory_block_by_id(block_id);
if (!mem) if (!mem)
continue; continue;
......
...@@ -116,8 +116,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size); ...@@ -116,8 +116,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size);
extern int memory_dev_init(void); extern int memory_dev_init(void);
extern int memory_notify(unsigned long val, void *v); extern int memory_notify(unsigned long val, void *v);
extern int memory_isolate_notify(unsigned long val, void *v); extern int memory_isolate_notify(unsigned long val, void *v);
extern struct memory_block *find_memory_block_hinted(struct mem_section *,
struct memory_block *);
extern struct memory_block *find_memory_block(struct mem_section *); extern struct memory_block *find_memory_block(struct mem_section *);
typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *);
extern int walk_memory_blocks(unsigned long start, unsigned long size, extern int walk_memory_blocks(unsigned long start, unsigned long size,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment