Skip to content

Commit dd62528

Browse files
davidhildenbrandtorvalds
authored andcommitted
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. [[email protected]: v3] Link: http://lkml.kernel.org/r/[email protected] [[email protected]: handle zero-length walks] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Tested-by: Qian Cai <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Andrew Banman <[email protected]> Cc: Mike Travis <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Wei Yang <[email protected]> Cc: Arun KS <[email protected]> Cc: Stephen Rothwell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ea88464 commit dd62528

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

drivers/base/memory.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -588,30 +588,13 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn)
588588
return 0;
589589
}
590590

591-
/*
592-
* A reference for the returned object is held and the reference for the
593-
* hinted object is released.
594-
*/
595-
static struct memory_block *find_memory_block_by_id(unsigned long block_id,
596-
struct memory_block *hint)
591+
/* A reference for the returned memory block device is acquired. */
592+
static struct memory_block *find_memory_block_by_id(unsigned long block_id)
597593
{
598-
struct device *hintdev = hint ? &hint->dev : NULL;
599594
struct device *dev;
600595

601-
dev = subsys_find_device_by_id(&memory_subsys, block_id, hintdev);
602-
if (hint)
603-
put_device(&hint->dev);
604-
if (!dev)
605-
return NULL;
606-
return to_memory_block(dev);
607-
}
608-
609-
struct memory_block *find_memory_block_hinted(struct mem_section *section,
610-
struct memory_block *hint)
611-
{
612-
unsigned long block_id = base_memory_block_id(__section_nr(section));
613-
614-
return find_memory_block_by_id(block_id, hint);
596+
dev = subsys_find_device_by_id(&memory_subsys, block_id, NULL);
597+
return dev ? to_memory_block(dev) : NULL;
615598
}
616599

617600
/*
@@ -624,7 +607,9 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section,
624607
*/
625608
struct memory_block *find_memory_block(struct mem_section *section)
626609
{
627-
return find_memory_block_hinted(section, NULL);
610+
unsigned long block_id = base_memory_block_id(__section_nr(section));
611+
612+
return find_memory_block_by_id(block_id);
628613
}
629614

630615
static struct attribute *memory_memblk_attrs[] = {
@@ -675,7 +660,7 @@ static int init_memory_block(struct memory_block **memory,
675660
unsigned long start_pfn;
676661
int ret = 0;
677662

678-
mem = find_memory_block_by_id(block_id, NULL);
663+
mem = find_memory_block_by_id(block_id);
679664
if (mem) {
680665
put_device(&mem->dev);
681666
return -EEXIST;
@@ -755,7 +740,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size)
755740
end_block_id = block_id;
756741
for (block_id = start_block_id; block_id != end_block_id;
757742
block_id++) {
758-
mem = find_memory_block_by_id(block_id, NULL);
743+
mem = find_memory_block_by_id(block_id);
759744
mem->section_count = 0;
760745
unregister_memory(mem);
761746
}
@@ -782,7 +767,7 @@ void remove_memory_block_devices(unsigned long start, unsigned long size)
782767

783768
mutex_lock(&mem_sysfs_mutex);
784769
for (block_id = start_block_id; block_id != end_block_id; block_id++) {
785-
mem = find_memory_block_by_id(block_id, NULL);
770+
mem = find_memory_block_by_id(block_id);
786771
if (WARN_ON_ONCE(!mem))
787772
continue;
788773
mem->section_count = 0;
@@ -881,8 +866,11 @@ int walk_memory_blocks(unsigned long start, unsigned long size,
881866
unsigned long block_id;
882867
int ret = 0;
883868

869+
if (!size)
870+
return 0;
871+
884872
for (block_id = start_block_id; block_id <= end_block_id; block_id++) {
885-
mem = find_memory_block_by_id(block_id, NULL);
873+
mem = find_memory_block_by_id(block_id);
886874
if (!mem)
887875
continue;
888876

include/linux/memory.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size);
116116
extern int memory_dev_init(void);
117117
extern int memory_notify(unsigned long val, void *v);
118118
extern int memory_isolate_notify(unsigned long val, void *v);
119-
extern struct memory_block *find_memory_block_hinted(struct mem_section *,
120-
struct memory_block *);
121119
extern struct memory_block *find_memory_block(struct mem_section *);
122120
typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *);
123121
extern int walk_memory_blocks(unsigned long start, unsigned long size,

0 commit comments

Comments
 (0)