From acfc8cad9135444fdad5385cd9f795fab469a699 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:48 +1100 Subject: ncr5380: Remove unused hostdata fields Remove unused fields from hostdata structs declared with the NCR5380_implementation_fields macro. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 6a039eb1cbce..dc774959cc20 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -93,35 +93,6 @@ static volatile unsigned char *mac_scsi_nodrq = NULL; * NCR 5380 register access functions */ -#if 0 -/* Debug versions */ -#define CTRL(p,v) (*ctrl = (v)) - -static char macscsi_read(struct Scsi_Host *instance, int reg) -{ - int iobase = instance->io_port; - int i; - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; - - CTRL(iobase, 0); - i = in_8(iobase + (reg<<4)); - CTRL(iobase, 0x40); - - return i; -} - -static void macscsi_write(struct Scsi_Host *instance, int reg, int value) -{ - int iobase = instance->io_port; - int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; - - CTRL(iobase, 0); - out_8(iobase + (reg<<4), value); - CTRL(iobase, 0x40); -} -#else - -/* Fast versions */ static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg) { return in_8(instance->io_port + (reg<<4)); @@ -131,8 +102,6 @@ static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int va { out_8(instance->io_port + (reg<<4), value); } -#endif - /* * Function : mac_scsi_setup(char *str) @@ -279,8 +248,6 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) instance->n_io_port = 255; - ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0; - if (instance->irq != SCSI_IRQ_NONE) if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) { printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n", -- cgit v1.2.1 From 48f16c9bef8ee6b699ab8e7c5c55920ddd1c7e8f Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:50 +1100 Subject: ncr5380: Remove unused macros Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and USE_WRAPPER; and in some drivers, NCR5380_intr and NCR5380_proc_info). DRIVER_SETUP serves no purpose anymore. Remove these macro definitions. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index dc774959cc20..579a3d4177f6 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -55,7 +55,6 @@ #include "NCR5380.h" #define RESET_BOOT -#define DRIVER_SETUP extern void via_scsi_clear(void); @@ -113,7 +112,6 @@ static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int va */ static int __init mac_scsi_setup(char *str) { -#ifdef DRIVER_SETUP int ints[7]; (void)get_options( str, ARRAY_SIZE(ints), ints); @@ -166,7 +164,6 @@ static int __init mac_scsi_setup(char *str) { } #endif /* SUPPORT_TAGS */ -#endif /* DRIVER_SETUP */ return 1; } -- cgit v1.2.1 From ed8b9e7f1827ebae902e868866438d1bcdbef0a2 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:51 +1100 Subject: ncr5380: Remove useless prototypes Add missing static qualifiers and remove the now pointless prototypes. The NCR5380_* prototypes are all declared in NCR5380.h and renamed using macros. Further declarations are redundant (some are completely unused). Remove them. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 579a3d4177f6..aa372ec38507 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -56,8 +56,6 @@ #define RESET_BOOT -extern void via_scsi_clear(void); - #ifdef RESET_BOOT static void mac_scsi_reset_boot(struct Scsi_Host *instance); #endif -- cgit v1.2.1 From 997acab7d593913eaa0606ff257079efcfcb146d Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:54 +1100 Subject: ncr5380: Remove redundant AUTOSENSE macro Every NCR5380 driver sets AUTOSENSE so it need not be optional (and the mid-layer expects it). Remove this redundant macro to improve readability. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index aa372ec38507..3f125838a29d 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -48,8 +48,6 @@ #include #include "mac_scsi.h" -/* These control the behaviour of the generic 5380 core */ -#define AUTOSENSE #define PSEUDO_DMA #include "NCR5380.h" -- cgit v1.2.1 From 3f9e986e2f1df8fa69ffe213098c1ee98f1c9584 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:55 +1100 Subject: ncr5380: Remove duplicate comments The LIMIT_TRANSFERSIZE, PSEUDO_DMA, PARITY and UNSAFE options are all documented in the core drivers where they are used. The same goes for the chip databook reference. Remove the duplicate comments. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 3f125838a29d..4dec06da3f34 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -11,18 +11,6 @@ * Copyright 1995, Russell King * * ALPHA RELEASE 1. - * - * For more information, please consult - * - * NCR 5380 Family - * SCSI Protocol Controller - * Databook - * - * NCR Microelectronics - * 1635 Aeroplaza Drive - * Colorado Springs, CO 80916 - * 1+ (719) 578-3400 - * 1+ (800) 334-5454 */ #include -- cgit v1.2.1 From 22f5f10d2dadc50bf26a482b782a5e04f6e9b362 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:56 +1100 Subject: ncr5380: Fix SCSI_IRQ_NONE bugs Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE if it is to issue IDENTIFY commands that prevent target disconnection. And, as Geert points out, IRQ_NONE is part of enum irqreturn. Other drivers, when they can't get an IRQ or can't use one, will set host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will attempt to free IRQ 255 which was never requested. Fix these bugs by using NO_IRQ in place of SCSI_IRQ_NONE and IRQ_NONE. That means IRQ 0 is no longer probed by ISA drivers but I don't think this matters. Setting IRQ = 255 for these ISA drivers is understood to mean no IRQ. This remains supported so as to avoid breaking existing ISA setups (which can be difficult to get working) and because existing documentation (SANE, TLDP etc) describes this usage for the ISA NCR5380 driver options. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 4dec06da3f34..5d8d75c619cd 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -229,15 +229,15 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) instance->n_io_port = 255; - if (instance->irq != SCSI_IRQ_NONE) + if (instance->irq != NO_IRQ) if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) { printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); - instance->irq = SCSI_IRQ_NONE; + instance->irq = NO_IRQ; } printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port); - if (instance->irq == SCSI_IRQ_NONE) + if (instance->irq == NO_IRQ) printk (KERN_INFO "s disabled"); else printk (KERN_INFO " %d", instance->irq); @@ -252,7 +252,7 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) int macscsi_release (struct Scsi_Host *shpnt) { - if (shpnt->irq != SCSI_IRQ_NONE) + if (shpnt->irq != NO_IRQ) free_irq(shpnt->irq, shpnt); NCR5380_exit(shpnt); -- cgit v1.2.1 From 8c32513bd395dc5d382e4883097482567cf8bbc5 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:58 +1100 Subject: ncr5380: Cleanup host info() methods If the host->info() method is not set, then host->name is used by default. For atari_scsi, that is exactly the same text. So remove the redundant info() method. Keep sun3_scsi.c in line with atari_scsi. Some NCR5380 drivers return an empty string from the info() method (arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default (dmx3191d dtc.c g_NCR5380.c pas16.c t128.c). Implement a common info() method to replace a lot of duplicated code which the various drivers use to announce the same information. This replaces most of the (deprecated) show_info() output and all of the NCR5380_print_info() output. This also eliminates a bunch of code in g_NCR5380 which just duplicates functionality in the core driver. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 5d8d75c619cd..a27216d534ed 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -236,16 +236,6 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) instance->irq = NO_IRQ; } - printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port); - if (instance->irq == NO_IRQ) - printk (KERN_INFO "s disabled"); - else - printk (KERN_INFO " %d", instance->irq); - printk(KERN_INFO " options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - instance->can_queue, instance->cmd_per_lun, MACSCSI_PUBLIC_RELEASE); - printk(KERN_INFO "\nscsi%d:", instance->host_no); - NCR5380_print_options(instance); - printk("\n"); called = 1; return 1; } @@ -297,10 +287,6 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance) } #endif -const char * macscsi_info (struct Scsi_Host *spnt) { - return ""; -} - /* Pseudo-DMA: (Ove Edlund) The code attempts to catch bus errors that occur if one for example -- cgit v1.2.1 From d572f65fdf78a6dcb55b86ad8684f88830bf2e08 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:00 +1100 Subject: ncr5380: Remove pointless compiler command line override macros Compile-time override of scsi host defaults is pointless for drivers that provide module parameters and __setup options for that. Too many macros make the code hard to read so remove them. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index a27216d534ed..f00c987478ec 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -177,13 +177,12 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) if (macintosh_config->scsi_type != MAC_SCSI_OLD) return( 0 ); - /* setup variables */ - tpnt->can_queue = - (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; - tpnt->cmd_per_lun = - (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; - tpnt->sg_tablesize = - (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; + if (setup_can_queue > 0) + tpnt->can_queue = setup_can_queue; + if (setup_cmd_per_lun > 0) + tpnt->cmd_per_lun = setup_cmd_per_lun; + if (setup_sg_tablesize >= 0) + tpnt->sg_tablesize = setup_sg_tablesize; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; @@ -194,7 +193,7 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) - setup_use_tagged_queuing = USE_TAGGED_QUEUING; + setup_use_tagged_queuing = 0; #endif /* Once we support multiple 5380s (e.g. DuoDock) we'll do @@ -496,10 +495,10 @@ static struct scsi_host_template driver_template = { .queuecommand = macscsi_queue_command, .eh_abort_handler = macscsi_abort, .eh_bus_reset_handler = macscsi_bus_reset, - .can_queue = CAN_QUEUE, + .can_queue = 16, .this_id = 7, .sg_tablesize = SG_ALL, - .cmd_per_lun = CMD_PER_LUN, + .cmd_per_lun = 2, .use_clustering = DISABLE_CLUSTERING }; -- cgit v1.2.1 From 96068e6b4d86a397f50ae401723f315110874e1a Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:01 +1100 Subject: ncr5380: Remove *_RELEASE macros The *_RELEASE macros don't tell me anything. In some cases the version in the macro contradicts the version in the comments. Anyway, the Linux kernel version is sufficient information. Remove these macros to improve readability. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index f00c987478ec..54cb1ab2b676 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -9,8 +9,6 @@ * Generic Generic NCR5380 driver * * Copyright 1995, Russell King - * - * ALPHA RELEASE 1. */ #include -- cgit v1.2.1 From 710ddd0d50d22b40e3b644ea35966489ad178978 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:02 +1100 Subject: ncr5380: Drop legacy scsi.h include Convert Scsi_Cmnd to struct scsi_cmnd and drop the #include "scsi.h". The sun3_NCR5380.c core driver already uses struct scsi_cmnd so converting the other core drivers reduces the diff which makes them easier to unify. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 54cb1ab2b676..40cb5f1e8bf9 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -30,7 +30,6 @@ #include #include -#include "scsi.h" #include #include "mac_scsi.h" -- cgit v1.2.1 From 92de383154e98bc0b9c4b3364af3945076f77032 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:04 +1100 Subject: mac_scsi: Remove header The #defines in mac_scsi.h are intended to influence subsequent #includes in mac_scsi.c. IMHO, that's too convoluted. Remove mac_scsi.h by moving those macro definitions to mac_scsi.c, consistent with other NCR5380 drivers. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 40cb5f1e8bf9..2b604a85f7c1 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -31,10 +31,29 @@ #include #include -#include "mac_scsi.h" + +/* Definitions for the core NCR5380 driver. */ #define PSEUDO_DMA +#define NCR5380_implementation_fields /* none */ +#define NCR5380_local_declare() struct Scsi_Host *_instance +#define NCR5380_setup(instance) _instance = instance + +#define NCR5380_read(reg) macscsi_read(_instance, reg) +#define NCR5380_write(reg, value) macscsi_write(_instance, reg, value) + +#define NCR5380_pread macscsi_pread +#define NCR5380_pwrite macscsi_pwrite + +#define NCR5380_intr macscsi_intr +#define NCR5380_queue_command macscsi_queue_command +#define NCR5380_abort macscsi_abort +#define NCR5380_bus_reset macscsi_bus_reset +#define NCR5380_info macscsi_info +#define NCR5380_show_info macscsi_show_info +#define NCR5380_write_info macscsi_write_info + #include "NCR5380.h" #define RESET_BOOT -- cgit v1.2.1 From 6e9ae6d560e1a60113ef2a4d27eeb4931048b674 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:05 +1100 Subject: mac_scsi: Add module option to Kconfig Allow mac_scsi to be built as a module. Replace the old validation of __setup options with code that validates both module and __setup options. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 112 ++++++++++++++++-------------------------------- 1 file changed, 37 insertions(+), 75 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 2b604a85f7c1..3b93f000499a 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -62,15 +62,18 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance); #endif -static int setup_called = 0; static int setup_can_queue = -1; +module_param(setup_can_queue, int, 0); static int setup_cmd_per_lun = -1; +module_param(setup_cmd_per_lun, int, 0); static int setup_sg_tablesize = -1; +module_param(setup_sg_tablesize, int, 0); static int setup_use_pdma = -1; -#ifdef SUPPORT_TAGS +module_param(setup_use_pdma, int, 0); static int setup_use_tagged_queuing = -1; -#endif +module_param(setup_use_tagged_queuing, int, 0); static int setup_hostid = -1; +module_param(setup_hostid, int, 0); /* Time (in jiffies) to wait after a reset; the SCSI standard calls for 250ms, * we usually do 0.5s to be on the safe side. But Toshiba CD-ROMs once more @@ -102,72 +105,34 @@ static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int va out_8(instance->io_port + (reg<<4), value); } -/* - * Function : mac_scsi_setup(char *str) - * - * Purpose : booter command line initialization of the overrides array, - * - * Inputs : str - comma delimited list of options - * - */ - -static int __init mac_scsi_setup(char *str) { +#ifndef MODULE +static int __init mac_scsi_setup(char *str) +{ int ints[7]; - - (void)get_options( str, ARRAY_SIZE(ints), ints); - - if (setup_called++ || ints[0] < 1 || ints[0] > 6) { - printk(KERN_WARNING "scsi: " - " Usage: mac5380=[,,,,,]\n"); - printk(KERN_ALERT "scsi: Bad Penguin parameters?\n"); - return 0; - } - - if (ints[0] >= 1) { - if (ints[1] > 0) - /* no limits on this, just > 0 */ - setup_can_queue = ints[1]; - } - if (ints[0] >= 2) { - if (ints[2] > 0) - setup_cmd_per_lun = ints[2]; - } - if (ints[0] >= 3) { - if (ints[3] >= 0) { - setup_sg_tablesize = ints[3]; - /* Must be <= SG_ALL (255) */ - if (setup_sg_tablesize > SG_ALL) - setup_sg_tablesize = SG_ALL; - } - } - if (ints[0] >= 4) { - /* Must be between 0 and 7 */ - if (ints[4] >= 0 && ints[4] <= 7) - setup_hostid = ints[4]; - else if (ints[4] > 7) - printk(KERN_WARNING "mac_scsi_setup: invalid host ID %d !\n", ints[4] ); - } -#ifdef SUPPORT_TAGS - if (ints[0] >= 5) { - if (ints[5] >= 0) - setup_use_tagged_queuing = !!ints[5]; + + (void)get_options(str, ARRAY_SIZE(ints), ints); + + if (ints[0] < 1 || ints[0] > 6) { + pr_err("Usage: mac5380=[,[,[,[,[,]]]]]\n"); + return 0; } - - if (ints[0] == 6) { - if (ints[6] >= 0) + if (ints[0] >= 1) + setup_can_queue = ints[1]; + if (ints[0] >= 2) + setup_cmd_per_lun = ints[2]; + if (ints[0] >= 3) + setup_sg_tablesize = ints[3]; + if (ints[0] >= 4) + setup_hostid = ints[4]; + if (ints[0] >= 5) + setup_use_tagged_queuing = ints[5]; + if (ints[0] >= 6) setup_use_pdma = ints[6]; - } -#else - if (ints[0] == 5) { - if (ints[5] >= 0) - setup_use_pdma = ints[5]; - } -#endif /* SUPPORT_TAGS */ - return 1; } __setup("mac5380=", mac_scsi_setup); +#endif /* !MODULE */ /* * Function : int macscsi_detect(struct scsi_host_template * tpnt) @@ -199,13 +164,8 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) tpnt->cmd_per_lun = setup_cmd_per_lun; if (setup_sg_tablesize >= 0) tpnt->sg_tablesize = setup_sg_tablesize; - - if (setup_hostid >= 0) - tpnt->this_id = setup_hostid; - else { - /* use 7 as default */ - tpnt->this_id = 7; - } + if (setup_hostid >= 0) + tpnt->this_id = setup_hostid & 7; #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing < 0) @@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) return 0; if (macintosh_config->ident == MAC_MODEL_IIFX) { - mac_scsi_regp = via1+0x8000; - mac_scsi_drq = via1+0xE000; - mac_scsi_nodrq = via1+0xC000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x8000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0xE000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000; /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ flags = FLAG_NO_PSEUDO_DMA; } else { - mac_scsi_regp = via1+0x10000; - mac_scsi_drq = via1+0x6000; - mac_scsi_nodrq = via1+0x12000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x10000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0x6000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000; } if (! setup_use_pdma) @@ -520,3 +480,5 @@ static struct scsi_host_template driver_template = { #include "scsi_module.c" + +MODULE_LICENSE("GPL"); -- cgit v1.2.1 From ffdede67d670e507d5202b8b08733c7a3b8e7fa0 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:06 +1100 Subject: mac_scsi: Cleanup PDMA code Fix whitespace, remove pointless volatile qualifiers and improve code style by use of INPUT_DATA_REG and OUTPUT_DATA_REG macros. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 132 ++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 65 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 3b93f000499a..578207e209e5 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -86,9 +86,9 @@ module_param(setup_hostid, int, 0); #define AFTER_RESET_DELAY (HZ/2) #endif -static volatile unsigned char *mac_scsi_regp = NULL; -static volatile unsigned char *mac_scsi_drq = NULL; -static volatile unsigned char *mac_scsi_nodrq = NULL; +static unsigned char *mac_scsi_regp; +static unsigned char *mac_scsi_drq; +static unsigned char *mac_scsi_nodrq; /* @@ -262,6 +262,7 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance) } #endif +#ifdef PSEUDO_DMA /* Pseudo-DMA: (Ove Edlund) The code attempts to catch bus errors that occur if one for example @@ -331,38 +332,38 @@ __asm__ __volatile__ \ : "0"(s), "1"(d), "2"(len) \ : "d0") - -static int macscsi_pread (struct Scsi_Host *instance, - unsigned char *dst, int len) +static int macscsi_pread(struct Scsi_Host *instance, + unsigned char *dst, int len) { - unsigned char *d; - volatile unsigned char *s; - - NCR5380_local_declare(); - NCR5380_setup(instance); - - s = mac_scsi_drq+0x60; - d = dst; - -/* These conditions are derived from MacOS */ - - while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) - && !(NCR5380_read(STATUS_REG) & SR_REQ)) - ; - if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) - && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) { - printk(KERN_ERR "Error in macscsi_pread\n"); - return -1; - } - - CP_IO_TO_MEM(s, d, len); - - if (len != 0) { - printk(KERN_NOTICE "Bus error in macscsi_pread\n"); - return -1; - } - - return 0; + unsigned char *d; + unsigned char *s; + + NCR5380_local_declare(); + NCR5380_setup(instance); + + s = mac_scsi_drq + (INPUT_DATA_REG << 4); + d = dst; + + /* These conditions are derived from MacOS */ + + while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && + !(NCR5380_read(STATUS_REG) & SR_REQ)) + ; + + if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && + (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) { + pr_err("Error in macscsi_pread\n"); + return -1; + } + + CP_IO_TO_MEM(s, d, len); + + if (len != 0) { + pr_notice("Bus error in macscsi_pread\n"); + return -1; + } + + return 0; } @@ -424,39 +425,40 @@ __asm__ __volatile__ \ : "0"(s), "1"(d), "2"(len) \ : "d0") -static int macscsi_pwrite (struct Scsi_Host *instance, - unsigned char *src, int len) +static int macscsi_pwrite(struct Scsi_Host *instance, + unsigned char *src, int len) { - unsigned char *s; - volatile unsigned char *d; - - NCR5380_local_declare(); - NCR5380_setup(instance); - - s = src; - d = mac_scsi_drq; - -/* These conditions are derived from MacOS */ - - while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) - && (!(NCR5380_read(STATUS_REG) & SR_REQ) - || (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) - ; - if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) { - printk(KERN_ERR "Error in macscsi_pwrite\n"); - return -1; - } - - CP_MEM_TO_IO(s, d, len); - - if (len != 0) { - printk(KERN_NOTICE "Bus error in macscsi_pwrite\n"); - return -1; - } - - return 0; -} + unsigned char *s; + unsigned char *d; + NCR5380_local_declare(); + NCR5380_setup(instance); + + s = src; + d = mac_scsi_drq + (OUTPUT_DATA_REG << 4); + + /* These conditions are derived from MacOS */ + + while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && + (!(NCR5380_read(STATUS_REG) & SR_REQ) || + (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) + ; + + if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) { + pr_err("Error in macscsi_pwrite\n"); + return -1; + } + + CP_MEM_TO_IO(s, d, len); + + if (len != 0) { + pr_notice("Bus error in macscsi_pwrite\n"); + return -1; + } + + return 0; +} +#endif #include "NCR5380.c" -- cgit v1.2.1 From cbad48deb38d8e442db9760ca1f950cd24429707 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:07 +1100 Subject: mac_scsi: Convert to platform device Convert mac_scsi to platform device and eliminate scsi_register(). Platform resources for chip registers now follow the documentation. This should fix issues with the Mac IIci (and possibly other models too). Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Acked-by: Geert Uytterhoeven Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 245 +++++++++++++++++++++++++----------------------- 1 file changed, 126 insertions(+), 119 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 578207e209e5..030f3b0bb53b 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -12,23 +12,18 @@ */ #include -#include -#include #include - #include -#include #include #include #include #include +#include +#include #include -#include - -#include #include -#include +#include #include @@ -36,7 +31,7 @@ #define PSEUDO_DMA -#define NCR5380_implementation_fields /* none */ +#define NCR5380_implementation_fields unsigned char *pdma_base #define NCR5380_local_declare() struct Scsi_Host *_instance #define NCR5380_setup(instance) _instance = instance @@ -58,10 +53,6 @@ #define RESET_BOOT -#ifdef RESET_BOOT -static void mac_scsi_reset_boot(struct Scsi_Host *instance); -#endif - static int setup_can_queue = -1; module_param(setup_can_queue, int, 0); static int setup_cmd_per_lun = -1; @@ -86,23 +77,18 @@ module_param(setup_hostid, int, 0); #define AFTER_RESET_DELAY (HZ/2) #endif -static unsigned char *mac_scsi_regp; -static unsigned char *mac_scsi_drq; -static unsigned char *mac_scsi_nodrq; - - /* * NCR 5380 register access functions */ -static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg) +static inline char macscsi_read(struct Scsi_Host *instance, int reg) { - return in_8(instance->io_port + (reg<<4)); + return in_8(instance->base + (reg << 4)); } -static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int value) +static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value) { - out_8(instance->io_port + (reg<<4), value); + out_8(instance->base + (reg << 4), value); } #ifndef MODULE @@ -134,96 +120,6 @@ static int __init mac_scsi_setup(char *str) __setup("mac5380=", mac_scsi_setup); #endif /* !MODULE */ -/* - * Function : int macscsi_detect(struct scsi_host_template * tpnt) - * - * Purpose : initializes mac NCR5380 driver based on the - * command line / compile time port and irq definitions. - * - * Inputs : tpnt - template for this SCSI adapter. - * - * Returns : 1 if a host adapter was found, 0 if not. - * - */ - -int __init macscsi_detect(struct scsi_host_template * tpnt) -{ - static int called = 0; - int flags = 0; - struct Scsi_Host *instance; - - if (!MACH_IS_MAC || called) - return( 0 ); - - if (macintosh_config->scsi_type != MAC_SCSI_OLD) - return( 0 ); - - if (setup_can_queue > 0) - tpnt->can_queue = setup_can_queue; - if (setup_cmd_per_lun > 0) - tpnt->cmd_per_lun = setup_cmd_per_lun; - if (setup_sg_tablesize >= 0) - tpnt->sg_tablesize = setup_sg_tablesize; - if (setup_hostid >= 0) - tpnt->this_id = setup_hostid & 7; - -#ifdef SUPPORT_TAGS - if (setup_use_tagged_queuing < 0) - setup_use_tagged_queuing = 0; -#endif - - /* Once we support multiple 5380s (e.g. DuoDock) we'll do - something different here */ - instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata)); - if (instance == NULL) - return 0; - - if (macintosh_config->ident == MAC_MODEL_IIFX) { - mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x8000; - mac_scsi_drq = (unsigned char *) VIA1_BASE + 0xE000; - mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000; - /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ - flags = FLAG_NO_PSEUDO_DMA; - } else { - mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x10000; - mac_scsi_drq = (unsigned char *) VIA1_BASE + 0x6000; - mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000; - } - - if (! setup_use_pdma) - flags = FLAG_NO_PSEUDO_DMA; - - instance->io_port = (unsigned long) mac_scsi_regp; - instance->irq = IRQ_MAC_SCSI; - -#ifdef RESET_BOOT - mac_scsi_reset_boot(instance); -#endif - - NCR5380_init(instance, flags); - - instance->n_io_port = 255; - - if (instance->irq != NO_IRQ) - if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) { - printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n", - instance->host_no, instance->irq); - instance->irq = NO_IRQ; - } - - called = 1; - return 1; -} - -int macscsi_release (struct Scsi_Host *shpnt) -{ - if (shpnt->irq != NO_IRQ) - free_irq(shpnt->irq, shpnt); - NCR5380_exit(shpnt); - - return 0; -} - #ifdef RESET_BOOT /* * Our 'bus reset on boot' function @@ -335,13 +231,14 @@ __asm__ __volatile__ \ static int macscsi_pread(struct Scsi_Host *instance, unsigned char *dst, int len) { + struct NCR5380_hostdata *hostdata = shost_priv(instance); unsigned char *d; unsigned char *s; NCR5380_local_declare(); NCR5380_setup(instance); - s = mac_scsi_drq + (INPUT_DATA_REG << 4); + s = hostdata->pdma_base + (INPUT_DATA_REG << 4); d = dst; /* These conditions are derived from MacOS */ @@ -428,6 +325,7 @@ __asm__ __volatile__ \ static int macscsi_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) { + struct NCR5380_hostdata *hostdata = shost_priv(instance); unsigned char *s; unsigned char *d; @@ -435,7 +333,7 @@ static int macscsi_pwrite(struct Scsi_Host *instance, NCR5380_setup(instance); s = src; - d = mac_scsi_drq + (OUTPUT_DATA_REG << 4); + d = hostdata->pdma_base + (OUTPUT_DATA_REG << 4); /* These conditions are derived from MacOS */ @@ -462,13 +360,15 @@ static int macscsi_pwrite(struct Scsi_Host *instance, #include "NCR5380.c" -static struct scsi_host_template driver_template = { - .proc_name = "Mac5380", +#define DRV_MODULE_NAME "mac_scsi" +#define PFX DRV_MODULE_NAME ": " + +static struct scsi_host_template mac_scsi_template = { + .module = THIS_MODULE, + .proc_name = DRV_MODULE_NAME, .show_info = macscsi_show_info, .write_info = macscsi_write_info, .name = "Macintosh NCR5380 SCSI", - .detect = macscsi_detect, - .release = macscsi_release, .info = macscsi_info, .queuecommand = macscsi_queue_command, .eh_abort_handler = macscsi_abort, @@ -480,7 +380,114 @@ static struct scsi_host_template driver_template = { .use_clustering = DISABLE_CLUSTERING }; +static int __init mac_scsi_probe(struct platform_device *pdev) +{ + struct Scsi_Host *instance; + int error; + int host_flags = 0; + struct resource *irq, *pio_mem, *pdma_mem = NULL; + + pio_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!pio_mem) + return -ENODEV; + +#ifdef PSEUDO_DMA + pdma_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); +#endif + + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + + if (!hwreg_present((unsigned char *)pio_mem->start + + (STATUS_REG << 4))) { + pr_info(PFX "no device detected at %pap\n", &pio_mem->start); + return -ENODEV; + } + + if (setup_can_queue > 0) + mac_scsi_template.can_queue = setup_can_queue; + if (setup_cmd_per_lun > 0) + mac_scsi_template.cmd_per_lun = setup_cmd_per_lun; + if (setup_sg_tablesize >= 0) + mac_scsi_template.sg_tablesize = setup_sg_tablesize; + if (setup_hostid >= 0) + mac_scsi_template.this_id = setup_hostid & 7; +#ifdef SUPPORT_TAGS + if (setup_use_tagged_queuing < 0) + setup_use_tagged_queuing = 0; +#endif + if (setup_use_pdma < 0) + setup_use_pdma = 0; + + instance = scsi_host_alloc(&mac_scsi_template, + sizeof(struct NCR5380_hostdata)); + if (!instance) + return -ENOMEM; + + instance->base = pio_mem->start; + if (irq) + instance->irq = irq->start; + else + instance->irq = NO_IRQ; + + if (pdma_mem && setup_use_pdma) { + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + hostdata->pdma_base = (unsigned char *)pdma_mem->start; + } else + host_flags |= FLAG_NO_PSEUDO_DMA; + +#ifdef RESET_BOOT + mac_scsi_reset_boot(instance); +#endif + + NCR5380_init(instance, host_flags); + + if (instance->irq != NO_IRQ) { + error = request_irq(instance->irq, macscsi_intr, IRQF_SHARED, + "NCR5380", instance); + if (error) + goto fail_irq; + } + + error = scsi_add_host(instance, NULL); + if (error) + goto fail_host; + + platform_set_drvdata(pdev, instance); + + scsi_scan_host(instance); + return 0; + +fail_host: + if (instance->irq != NO_IRQ) + free_irq(instance->irq, instance); +fail_irq: + NCR5380_exit(instance); + scsi_host_put(instance); + return error; +} + +static int __exit mac_scsi_remove(struct platform_device *pdev) +{ + struct Scsi_Host *instance = platform_get_drvdata(pdev); + + scsi_remove_host(instance); + if (instance->irq != NO_IRQ) + free_irq(instance->irq, instance); + NCR5380_exit(instance); + scsi_host_put(instance); + return 0; +} + +static struct platform_driver mac_scsi_driver = { + .remove = __exit_p(mac_scsi_remove), + .driver = { + .name = DRV_MODULE_NAME, + .owner = THIS_MODULE, + }, +}; -#include "scsi_module.c" +module_platform_driver_probe(mac_scsi_driver, mac_scsi_probe); +MODULE_ALIAS("platform:" DRV_MODULE_NAME); MODULE_LICENSE("GPL"); -- cgit v1.2.1 From ca513fc948e66ecdd3c75cca9371762bb4c06776 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:19 +1100 Subject: atari_NCR5380: Introduce FLAG_TAGGED_QUEUING The static variable setup_use_tagged_queuing is declared in mac_scsi.c, sun3_scsi.c and atari_scsi.c and doesn't belong in the core driver. None of the other NCR5380 drivers suffer from this layering issue which makes merging the core drivers more difficult and will likely hinder plans for future use of platform data to configure the driver. Replace the static variable with a host flag. This way it can be reported along with the other flags. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/mac_scsi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/mac_scsi.c') diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 030f3b0bb53b..953fd9b953c7 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -411,10 +411,6 @@ static int __init mac_scsi_probe(struct platform_device *pdev) mac_scsi_template.sg_tablesize = setup_sg_tablesize; if (setup_hostid >= 0) mac_scsi_template.this_id = setup_hostid & 7; -#ifdef SUPPORT_TAGS - if (setup_use_tagged_queuing < 0) - setup_use_tagged_queuing = 0; -#endif if (setup_use_pdma < 0) setup_use_pdma = 0; @@ -440,6 +436,10 @@ static int __init mac_scsi_probe(struct platform_device *pdev) mac_scsi_reset_boot(instance); #endif +#ifdef SUPPORT_TAGS + host_flags |= setup_use_tagged_queuing > 0 ? FLAG_TAGGED_QUEUING : 0; +#endif + NCR5380_init(instance, host_flags); if (instance->irq != NO_IRQ) { -- cgit v1.2.1