Re: [PATCH v7] ata/pata_buddha: Probe via modalias instead of initcall
On 08/23/2019 02:59 PM, Jens Axboe wrote: > On 8/23/19 4:49 AM, Max Staudt wrote: >> Up until now, the pata_buddha driver would only check for cards on >> initcall time. Now, the kernel will call its probe function as soon >> as a compatible card is detected. > > Applied for 5.4, thanks everyone. Thanks Jens and Bartlomiej, and if I may: Thanks Geert for reviewing almost every single one of my m68k patches. This is a warm welcome to a new field. Max
Re: [PATCH v7] ata/pata_buddha: Probe via modalias instead of initcall
On 8/23/19 4:49 AM, Max Staudt wrote: > Up until now, the pata_buddha driver would only check for cards on > initcall time. Now, the kernel will call its probe function as soon > as a compatible card is detected. Applied for 5.4, thanks everyone. -- Jens Axboe
Re: [PATCH v7] ata/pata_buddha: Probe via modalias instead of initcall
On 8/23/19 12:49 PM, Max Staudt wrote: > Up until now, the pata_buddha driver would only check for cards on > initcall time. Now, the kernel will call its probe function as soon > as a compatible card is detected. > > v7: Removed suppress_bind_attrs that slipped in > > v6: Only do the drvdata workaround for X-Surf (remove breaks otherwise) > Style > > v5: Remove module_exit(): There's no good way to handle the X-Surf hack. > Also include a workaround to save X-Surf's drvdata in case zorro8390 > is active. > > v4: Clean up pata_buddha_probe() by using ent->driver_data. > Support X-Surf via late_initcall() > > v3: Clean up devm_*, implement device removal. > > v2: Rename 'zdev' to 'z' to make the patch easy to analyse with > git diff --ignore-space-change > > Signed-off-by: Max Staudt Acked-by: Bartlomiej Zolnierkiewicz Best regards, -- Bartlomiej Zolnierkiewicz Samsung R Institute Poland Samsung Electronics > --- > drivers/ata/pata_buddha.c | 228 > +++--- > 1 file changed, 135 insertions(+), 93 deletions(-) > > diff --git a/drivers/ata/pata_buddha.c b/drivers/ata/pata_buddha.c > index 11a8044ff..27d4c417f 100644 > --- a/drivers/ata/pata_buddha.c > +++ b/drivers/ata/pata_buddha.c > @@ -18,7 +18,9 @@ > #include > #include > #include > +#include > #include > +#include > #include > #include > #include > @@ -29,7 +31,7 @@ > #include > > #define DRV_NAME "pata_buddha" > -#define DRV_VERSION "0.1.0" > +#define DRV_VERSION "0.1.1" > > #define BUDDHA_BASE1 0x800 > #define BUDDHA_BASE2 0xa00 > @@ -47,11 +49,11 @@ enum { > BOARD_XSURF > }; > > -static unsigned int buddha_bases[3] __initdata = { > +static unsigned int buddha_bases[3] = { > BUDDHA_BASE1, BUDDHA_BASE2, BUDDHA_BASE3 > }; > > -static unsigned int xsurf_bases[2] __initdata = { > +static unsigned int xsurf_bases[2] = { > XSURF_BASE1, XSURF_BASE2 > }; > > @@ -145,111 +147,151 @@ static struct ata_port_operations pata_xsurf_ops = { > .set_mode = pata_buddha_set_mode, > }; > > -static int __init pata_buddha_init_one(void) > +static int pata_buddha_probe(struct zorro_dev *z, > + const struct zorro_device_id *ent) > { > - struct zorro_dev *z = NULL; > + static const char * const board_name[] = { > + "Buddha", "Catweasel", "X-Surf" > + }; > + struct ata_host *host; > + void __iomem *buddha_board; > + unsigned long board; > + unsigned int type = ent->driver_data; > + unsigned int nr_ports = (type == BOARD_CATWEASEL) ? 3 : 2; > + void *old_drvdata; > + int i; > + > + dev_info(>dev, "%s IDE controller\n", board_name[type]); > + > + board = z->resource.start; > + > + if (type != BOARD_XSURF) { > + if (!devm_request_mem_region(>dev, > + board + BUDDHA_BASE1, > + 0x800, DRV_NAME)) > + return -ENXIO; > + } else { > + if (!devm_request_mem_region(>dev, > + board + XSURF_BASE1, > + 0x1000, DRV_NAME)) > + return -ENXIO; > + if (!devm_request_mem_region(>dev, > + board + XSURF_BASE2, > + 0x1000, DRV_NAME)) { > + } > + } > + > + /* Workaround for X-Surf: Save drvdata in case zorro8390 has set it */ > + if (type == BOARD_XSURF) > + old_drvdata = dev_get_drvdata(>dev); > + > + /* allocate host */ > + host = ata_host_alloc(>dev, nr_ports); > + if (type == BOARD_XSURF) > + dev_set_drvdata(>dev, old_drvdata); > + if (!host) > + return -ENXIO; > + > + buddha_board = ZTWO_VADDR(board); > + > + /* enable the board IRQ on Buddha/Catweasel */ > + if (type != BOARD_XSURF) > + z_writeb(0, buddha_board + BUDDHA_IRQ_MR); > > - while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { > - static const char *board_name[] > - = { "Buddha", "Catweasel", "X-Surf" }; > - struct ata_host *host; > - void __iomem *buddha_board; > - unsigned long board; > - unsigned int type, nr_ports = 2; > - int i; > - > - if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { > - type = BOARD_BUDDHA; > - } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL) { > - type = BOARD_CATWEASEL; > - nr_ports++; > - } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF) { > - type = BOARD_XSURF; > - } else > - continue; > - > - dev_info(>dev, "%s IDE controller\n", board_name[type]); > - > - board =
[PATCH v7] ata/pata_buddha: Probe via modalias instead of initcall
Up until now, the pata_buddha driver would only check for cards on initcall time. Now, the kernel will call its probe function as soon as a compatible card is detected. v7: Removed suppress_bind_attrs that slipped in v6: Only do the drvdata workaround for X-Surf (remove breaks otherwise) Style v5: Remove module_exit(): There's no good way to handle the X-Surf hack. Also include a workaround to save X-Surf's drvdata in case zorro8390 is active. v4: Clean up pata_buddha_probe() by using ent->driver_data. Support X-Surf via late_initcall() v3: Clean up devm_*, implement device removal. v2: Rename 'zdev' to 'z' to make the patch easy to analyse with git diff --ignore-space-change Signed-off-by: Max Staudt --- drivers/ata/pata_buddha.c | 228 +++--- 1 file changed, 135 insertions(+), 93 deletions(-) diff --git a/drivers/ata/pata_buddha.c b/drivers/ata/pata_buddha.c index 11a8044ff..27d4c417f 100644 --- a/drivers/ata/pata_buddha.c +++ b/drivers/ata/pata_buddha.c @@ -18,7 +18,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -29,7 +31,7 @@ #include #define DRV_NAME "pata_buddha" -#define DRV_VERSION "0.1.0" +#define DRV_VERSION "0.1.1" #define BUDDHA_BASE1 0x800 #define BUDDHA_BASE2 0xa00 @@ -47,11 +49,11 @@ enum { BOARD_XSURF }; -static unsigned int buddha_bases[3] __initdata = { +static unsigned int buddha_bases[3] = { BUDDHA_BASE1, BUDDHA_BASE2, BUDDHA_BASE3 }; -static unsigned int xsurf_bases[2] __initdata = { +static unsigned int xsurf_bases[2] = { XSURF_BASE1, XSURF_BASE2 }; @@ -145,111 +147,151 @@ static struct ata_port_operations pata_xsurf_ops = { .set_mode = pata_buddha_set_mode, }; -static int __init pata_buddha_init_one(void) +static int pata_buddha_probe(struct zorro_dev *z, +const struct zorro_device_id *ent) { - struct zorro_dev *z = NULL; + static const char * const board_name[] = { + "Buddha", "Catweasel", "X-Surf" + }; + struct ata_host *host; + void __iomem *buddha_board; + unsigned long board; + unsigned int type = ent->driver_data; + unsigned int nr_ports = (type == BOARD_CATWEASEL) ? 3 : 2; + void *old_drvdata; + int i; + + dev_info(>dev, "%s IDE controller\n", board_name[type]); + + board = z->resource.start; + + if (type != BOARD_XSURF) { + if (!devm_request_mem_region(>dev, +board + BUDDHA_BASE1, +0x800, DRV_NAME)) + return -ENXIO; + } else { + if (!devm_request_mem_region(>dev, +board + XSURF_BASE1, +0x1000, DRV_NAME)) + return -ENXIO; + if (!devm_request_mem_region(>dev, +board + XSURF_BASE2, +0x1000, DRV_NAME)) { + } + } + + /* Workaround for X-Surf: Save drvdata in case zorro8390 has set it */ + if (type == BOARD_XSURF) + old_drvdata = dev_get_drvdata(>dev); + + /* allocate host */ + host = ata_host_alloc(>dev, nr_ports); + if (type == BOARD_XSURF) + dev_set_drvdata(>dev, old_drvdata); + if (!host) + return -ENXIO; + + buddha_board = ZTWO_VADDR(board); + + /* enable the board IRQ on Buddha/Catweasel */ + if (type != BOARD_XSURF) + z_writeb(0, buddha_board + BUDDHA_IRQ_MR); - while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { - static const char *board_name[] - = { "Buddha", "Catweasel", "X-Surf" }; - struct ata_host *host; - void __iomem *buddha_board; - unsigned long board; - unsigned int type, nr_ports = 2; - int i; - - if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) { - type = BOARD_BUDDHA; - } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_CATWEASEL) { - type = BOARD_CATWEASEL; - nr_ports++; - } else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF) { - type = BOARD_XSURF; - } else - continue; - - dev_info(>dev, "%s IDE controller\n", board_name[type]); - - board = z->resource.start; + for (i = 0; i < nr_ports; i++) { + struct ata_port *ap = host->ports[i]; + void __iomem *base, *irqport; + unsigned long ctl = 0; if (type != BOARD_XSURF) { - if (!devm_request_mem_region(>dev, -