Re: [PATCH v3 25/37] sun3_scsi: Convert to platform device
On Wed, 12 Nov 2014, Geert Uytterhoeven wrote: > > > move PAGE_SIZE back to ioremap() arguments. > > Sorry, I think I didn't make myself clear, and you thus misunderstood. I thought your email was clear. Also, no-one objected to ioremap(..., PAGE_SIZE) in the v1 patch. Oh well. > I meant PAGE_SIZE makes sense when ioremap()ing a small region at a > hardcoded address, where you don't care about the exact size, as it will > be rounded up to PAGE_SIZE anyway. > > When ioremap()ing resources, please use the size provided by the resource. > > > +static int __init sun3_scsi_probe(struct platform_device *pdev) > > +{ > > + struct Scsi_Host *instance; > > + int error; > > + struct resource *irq, *mem; > > + unsigned char *ioaddr; > > +#ifdef SUN3_SCSI_VME > > + int i; > > +#endif > > + > > + if (setup_can_queue > 0) > > + sun3_scsi_template.can_queue = setup_can_queue; > > + if (setup_cmd_per_lun > 0) > > + sun3_scsi_template.cmd_per_lun = setup_cmd_per_lun; > > + if (setup_sg_tablesize >= 0) > > + sun3_scsi_template.sg_tablesize = setup_sg_tablesize; > > + if (setup_hostid >= 0) > > + sun3_scsi_template.this_id = setup_hostid & 7; > > + > > +#ifdef SUPPORT_TAGS > > + if (setup_use_tagged_queuing < 0) > > + setup_use_tagged_queuing = 1; > > +#endif > > + > > +#ifdef SUN3_SCSI_VME > > + ioaddr = NULL; > > + for (i = 0; i < 2; i++) { > > + unsigned char x; > > + > > + irq = platform_get_resource(pdev, IORESOURCE_IRQ, i); > > + mem = platform_get_resource(pdev, IORESOURCE_MEM, i); > > + if (!irq || !mem) > > + break; > > + > > + ioaddr = sun3_ioremap(mem->start, PAGE_SIZE, > > Here ... OK. > > > + SUN3_PAGE_TYPE_VME16); > > + dregs = (struct sun3_dma_regs *)(ioaddr + 8); > > + > > + if (sun3_map_test((unsigned long)dregs, &x)) { > > + unsigned short oldcsr; > > + > > + oldcsr = dregs->csr; > > + dregs->csr = 0; > > + udelay(SUN3_DMA_DELAY); > > + if (dregs->csr == 0x1400) > > + break; > > + > > + dregs->csr = oldcsr; > > + } > > + > > + iounmap(ioaddr); > > + ioaddr = NULL; > > + } > > + if (!ioaddr) > > + return -ENODEV; > > +#else > > + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > > + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > + if (!irq || !mem) > > + return -ENODEV; > > + > > + ioaddr = ioremap(mem->start, PAGE_SIZE); > > and here. > OK. -- -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 25/37] sun3_scsi: Convert to platform device
Hi Finn, On Wed, Nov 12, 2014 at 6:12 AM, Finn Thain wrote: > Changes since v2: > - Give more precise addresses in platform resource initializers and Thanks! > move PAGE_SIZE back to ioremap() arguments. Sorry, I think I didn't make myself clear, and you thus misunderstood. I meant PAGE_SIZE makes sense when ioremap()ing a small region at a hardcoded address, where you don't care about the exact size, as it will be rounded up to PAGE_SIZE anyway. When ioremap()ing resources, please use the size provided by the resource. > +static int __init sun3_scsi_probe(struct platform_device *pdev) > +{ > + struct Scsi_Host *instance; > + int error; > + struct resource *irq, *mem; > + unsigned char *ioaddr; > +#ifdef SUN3_SCSI_VME > + int i; > +#endif > + > + if (setup_can_queue > 0) > + sun3_scsi_template.can_queue = setup_can_queue; > + if (setup_cmd_per_lun > 0) > + sun3_scsi_template.cmd_per_lun = setup_cmd_per_lun; > + if (setup_sg_tablesize >= 0) > + sun3_scsi_template.sg_tablesize = setup_sg_tablesize; > + if (setup_hostid >= 0) > + sun3_scsi_template.this_id = setup_hostid & 7; > + > +#ifdef SUPPORT_TAGS > + if (setup_use_tagged_queuing < 0) > + setup_use_tagged_queuing = 1; > +#endif > + > +#ifdef SUN3_SCSI_VME > + ioaddr = NULL; > + for (i = 0; i < 2; i++) { > + unsigned char x; > + > + irq = platform_get_resource(pdev, IORESOURCE_IRQ, i); > + mem = platform_get_resource(pdev, IORESOURCE_MEM, i); > + if (!irq || !mem) > + break; > + > + ioaddr = sun3_ioremap(mem->start, PAGE_SIZE, Here ... > + SUN3_PAGE_TYPE_VME16); > + dregs = (struct sun3_dma_regs *)(ioaddr + 8); > + > + if (sun3_map_test((unsigned long)dregs, &x)) { > + unsigned short oldcsr; > + > + oldcsr = dregs->csr; > + dregs->csr = 0; > + udelay(SUN3_DMA_DELAY); > + if (dregs->csr == 0x1400) > + break; > + > + dregs->csr = oldcsr; > + } > + > + iounmap(ioaddr); > + ioaddr = NULL; > + } > + if (!ioaddr) > + return -ENODEV; > +#else > + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); > + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + if (!irq || !mem) > + return -ENODEV; > + > + ioaddr = ioremap(mem->start, PAGE_SIZE); and here. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 25/37] sun3_scsi: Convert to platform device
Convert sun3_scsi to platform device and eliminate scsi_register(). Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Acked-by: Geert Uytterhoeven --- Changes since v1: - Use NO_IRQ instead of IRQ_NONE. - Move device IRQ and address constants to platform resources. - Test idprom->id_machtype before registering platform device instead of during platform driver probe. - Omit pointless instance->n_io_port assignment. Changes since v2: - Give more precise addresses in platform resource initializers and move PAGE_SIZE back to ioremap() arguments. --- arch/m68k/sun3/config.c | 60 +++ drivers/scsi/sun3_scsi.c | 390 ++- drivers/scsi/sun3_scsi.h | 17 -- 3 files changed, 245 insertions(+), 222 deletions(-) Index: linux/arch/m68k/sun3/config.c === --- linux.orig/arch/m68k/sun3/config.c 2014-11-12 16:10:43.0 +1100 +++ linux/arch/m68k/sun3/config.c 2014-11-12 16:11:29.0 +1100 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -169,3 +171,61 @@ static void __init sun3_sched_init(irq_h intersil_clear(); } +#ifdef CONFIG_SUN3_SCSI + +static const struct resource sun3_scsi_vme_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI0, + .end = SUN3_VEC_VMESCSI0, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff20, + .end = 0xff200021, + }, { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI1, + .end = SUN3_VEC_VMESCSI1, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff204000, + .end = 0xff204021, + }, +}; + +/* + * Int: level 2 autovector + * IO: type 1, base 0x0014, 5 bits phys space: A<4..0> + */ +static const struct resource sun3_scsi_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = 2, + .end = 2, + }, { + .flags = IORESOURCE_MEM, + .start = 0x0014, + .end = 0x0014001f, + }, +}; + +int __init sun3_platform_init(void) +{ + switch (idprom->id_machtype) { + case SM_SUN3 | SM_3_160: + case SM_SUN3 | SM_3_260: + platform_device_register_simple("sun3_scsi_vme", -1, + sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc)); + break; + case SM_SUN3 | SM_3_50: + case SM_SUN3 | SM_3_60: + platform_device_register_simple("sun3_scsi", -1, + sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc)); + break; + } + return 0; +} + +arch_initcall(sun3_platform_init); + +#endif Index: linux/drivers/scsi/sun3_scsi.c === --- linux.orig/drivers/scsi/sun3_scsi.c 2014-11-12 16:11:16.0 +1100 +++ linux/drivers/scsi/sun3_scsi.c 2014-11-12 16:11:29.0 +1100 @@ -23,22 +23,15 @@ */ #include -#include -#include #include - #include -#include #include #include #include +#include #include - -#include #include -#include -#include /* dma on! */ #define REAL_DMA @@ -59,8 +52,6 @@ extern int sun3_map_test(unsigned long, #endif -static irqreturn_t scsi_sun3_intr(int irq, void *dummy); - static int setup_can_queue = -1; module_param(setup_can_queue, int, 0); static int setup_cmd_per_lun = -1; @@ -89,15 +80,14 @@ static struct scsi_cmnd *sun3_dma_setup_ /* minimum number of bytes to do dma on */ #define SUN3_DMA_MINSIZE 128 -static volatile unsigned char *sun3_scsi_regp; +static unsigned char *sun3_scsi_regp; static volatile struct sun3_dma_regs *dregs; -#ifndef SUN3_SCSI_VME -static struct sun3_udc_regs *udc_regs = NULL; -#endif +static struct sun3_udc_regs *udc_regs; static unsigned char *sun3_dma_orig_addr = NULL; static unsigned long sun3_dma_orig_count = 0; static int sun3_dma_active = 0; static unsigned long last_residual = 0; +static struct Scsi_Host *default_instance; /* * NCR 5380 register access functions @@ -105,12 +95,12 @@ static unsigned long last_residual = 0; static inline unsigned char sun3scsi_read(int reg) { - return( sun3_scsi_regp[reg] ); + return in_8(sun3_scsi_regp + reg); } static inline void sun3scsi_write(int reg, int value) { - sun3_scsi_regp[reg] = value; + out_8(sun3_scsi_regp + reg, value); } #ifndef SUN3_SCSI_VME @@ -137,192 +127,7 @@ static inline void sun3_udc_write(unsign } #endif -/* - * XXX: status debug - */ -static struct Scsi_Host *default_instance; - -/* - * Function : int sun3scsi_detect(struct scsi_host_template * tpnt) - * - * Purpose : initializes mac