[PATCH 3/4] ata: ide: Allow to set the devicename
Sascha Hauer
s.hauer at pengutronix.de
Mon Jun 17 04:59:15 EDT 2013
To get persistent devicenames under /dev/ allow to set the
devicename from the driver instead of using "ata" unconditionally.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/ata/disk_ata_drive.c | 14 +++++++++-----
drivers/ata/ide-sff.c | 3 ++-
drivers/ata/intf_platform_ide.c | 2 +-
include/ata_drive.h | 3 ++-
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 4c82797..a25c75e 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -298,12 +298,16 @@ static int ata_port_init(struct ata_port *port)
#ifdef DEBUG
ata_dump_id(port->id);
#endif
- rc = cdev_find_free_index("ata");
- if (rc == -1)
- pr_err("Cannot find a free index for the disk node\n");
+ if (port->devname) {
+ port->blk.cdev.name = xstrdup(port->devname);
+ } else {
+ rc = cdev_find_free_index("ata");
+ if (rc == -1)
+ pr_err("Cannot find a free index for the disk node\n");
+ port->blk.cdev.name = asprintf("ata%d", rc);
+ }
port->blk.num_blocks = ata_id_n_sectors(port->id);
- port->blk.cdev.name = asprintf("ata%d", rc);
port->blk.blockbits = SECTOR_SHIFT;
rc = blockdevice_register(&port->blk);
@@ -378,7 +382,7 @@ int ata_port_register(struct ata_port *port)
int ret;
port->class_dev.id = DEVICE_ID_DYNAMIC;
- strcpy(port->class_dev.name, "ata");
+
port->class_dev.parent = port->dev;
port->class_dev.detect = ata_detect;
diff --git a/drivers/ata/ide-sff.c b/drivers/ata/ide-sff.c
index 632b0e5..ef55357 100644
--- a/drivers/ata/ide-sff.c
+++ b/drivers/ata/ide-sff.c
@@ -324,7 +324,7 @@ static struct ata_port_operations ide_ops = {
.reset = ide_reset,
};
-int ide_port_register(struct device_d *dev, struct ata_ioports *io)
+int ide_port_register(struct device_d *dev, struct ata_ioports *io, const char *devname)
{
struct ide_port *ide;
int ret;
@@ -334,6 +334,7 @@ int ide_port_register(struct device_d *dev, struct ata_ioports *io)
ide->io = io;
ide->port.ops = &ide_ops;
ide->port.dev = dev;
+ ide->port.devname = devname;
ret = ata_port_register(&ide->port);
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index 0b56eb4..455ac28 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -95,7 +95,7 @@ static int platform_ide_probe(struct device_d *dev)
io->reset = pdata->reset;
io->dataif_be = pdata->dataif_be;
- rc = ide_port_register(dev, io);
+ rc = ide_port_register(dev, io, NULL);
if (rc != 0) {
dev_err(dev, "Cannot register IDE interface\n");
free(io);
diff --git a/include/ata_drive.h b/include/ata_drive.h
index fcb3a3c..2499e62 100644
--- a/include/ata_drive.h
+++ b/include/ata_drive.h
@@ -91,6 +91,7 @@ struct ata_port {
struct ata_port_operations *ops;
struct device_d *dev;
struct device_d class_dev;
+ const char *devname;
void *drvdata;
struct block_device blk;
uint16_t *id;
@@ -98,7 +99,7 @@ struct ata_port {
int probe;
};
-int ide_port_register(struct device_d *, struct ata_ioports *);
+int ide_port_register(struct device_d *, struct ata_ioports *, const char *);
int ata_port_register(struct ata_port *port);
int ata_port_detect(struct ata_port *port);
--
1.8.3.1
More information about the barebox
mailing list