ata: ide: Allow to set the devicename
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@pengutronix.de>
This commit is contained in:
parent
48939b0b70
commit
2093884040
|
@ -254,12 +254,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);
|
||||
|
@ -326,8 +330,14 @@ int ata_port_register(struct ata_port *port)
|
|||
{
|
||||
int ret;
|
||||
|
||||
port->class_dev.id = DEVICE_ID_DYNAMIC;
|
||||
strcpy(port->class_dev.name, "ata");
|
||||
if (port->devname) {
|
||||
strcpy(port->class_dev.name, port->devname);
|
||||
port->class_dev.id = DEVICE_ID_SINGLE;
|
||||
} else {
|
||||
strcpy(port->class_dev.name, "ata");
|
||||
port->class_dev.id = DEVICE_ID_DYNAMIC;
|
||||
}
|
||||
|
||||
port->class_dev.parent = port->dev;
|
||||
port->class_dev.detect = ata_detect;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -172,7 +172,7 @@ static int imx_pata_probe(struct device_d *dev)
|
|||
|
||||
pata_imx_set_bus_timing(base, clk_get_rate(clk), 4);
|
||||
|
||||
ret= ide_port_register(dev, io);
|
||||
ret = ide_port_register(dev, io, NULL);
|
||||
if (ret) {
|
||||
dev_err(dev, "Cannot register IDE interface: %s\n",
|
||||
strerror(-ret));
|
||||
|
|
|
@ -135,6 +135,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;
|
||||
|
@ -142,7 +143,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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue