summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/m25p80.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-10-28 12:56:02 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-29 09:10:27 +0100
commit5f0bd3edc277bd2a435d60d1d36ea60738bc9c92 (patch)
tree14cc218ea1e4c5b128cf03012d859ba070d4cf8a /drivers/mtd/devices/m25p80.c
parentd317b1bf8500dc67adfb5903119fef28adb4b4c1 (diff)
downloadbarebox-5f0bd3edc277bd2a435d60d1d36ea60738bc9c92.tar.gz
barebox-5f0bd3edc277bd2a435d60d1d36ea60738bc9c92.tar.xz
mtd: m25p80: Allow to specify devicename via devicetree alias
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/devices/m25p80.c')
-rw-r--r--drivers/mtd/devices/m25p80.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 429ddf6f08..1e3bc936f1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -808,6 +808,8 @@ static int m25p_probe(struct device_d *dev)
struct flash_info *info = NULL;
unsigned i;
unsigned do_jdec_probe = 1;
+ char *flashname = NULL;
+ int device_id;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
@@ -876,10 +878,19 @@ static int m25p_probe(struct device_d *dev)
write_sr(flash, 0);
}
- if (data && data->name)
- flash->mtd.name = data->name;
- else
- flash->mtd.name = "m25p";
+ device_id = DEVICE_ID_SINGLE;
+ if (dev->device_node) {
+ const char *alias = of_alias_get(dev->device_node);
+ if (alias)
+ flashname = xstrdup(alias);
+ } else if (data && data->name) {
+ flashname = data->name;
+ }
+
+ if (!flashname) {
+ device_id = DEVICE_ID_DYNAMIC;
+ flashname = "m25p";
+ }
flash->mtd.type = MTD_NORFLASH;
flash->mtd.writesize = 1;
@@ -942,7 +953,7 @@ static int m25p_probe(struct device_d *dev)
flash->mtd.eraseregions[i].erasesize / 1024,
flash->mtd.eraseregions[i].numblocks);
- return add_mtd_device(&flash->mtd, flash->mtd.name, DEVICE_ID_DYNAMIC);
+ return add_mtd_device(&flash->mtd, flashname, device_id);
}
static __maybe_unused struct of_device_id m25p80_dt_ids[] = {