mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-27 01:11:31 +00:00
mtd: physmap_of: use OF helpers for reading strings
OF core code provides helpers for counting strings and reading them so use them instead of doing this manually. This simplifies the code a bit. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
parent
b3bb6d6a0f
commit
da4b1caa49
1 changed files with 10 additions and 20 deletions
|
|
@ -116,32 +116,22 @@ static const char * const part_probe_types_def[] = {
|
||||||
|
|
||||||
static const char * const *of_get_probes(struct device_node *dp)
|
static const char * const *of_get_probes(struct device_node *dp)
|
||||||
{
|
{
|
||||||
const char *cp;
|
|
||||||
int cplen;
|
|
||||||
unsigned int l;
|
|
||||||
unsigned int count;
|
|
||||||
const char **res;
|
const char **res;
|
||||||
|
int count;
|
||||||
|
|
||||||
cp = of_get_property(dp, "linux,part-probe", &cplen);
|
count = of_property_count_strings(dp, "linux,part-probe");
|
||||||
if (cp == NULL)
|
if (count < 0)
|
||||||
return part_probe_types_def;
|
return part_probe_types_def;
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for (l = 0; l != cplen; l++)
|
|
||||||
if (cp[l] == 0)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
|
res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
count = 0;
|
|
||||||
while (cplen > 0) {
|
count = of_property_read_string_array(dp, "linux,part-probe", res,
|
||||||
res[count] = cp;
|
count);
|
||||||
l = strlen(cp) + 1;
|
if (count < 0)
|
||||||
cp += l;
|
return NULL;
|
||||||
cplen -= l;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue