2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* sim710.c - Copyright (C) 1999 Richard Hirst <richard@sleepie.demon.co.uk>
|
|
|
|
*
|
|
|
|
*----------------------------------------------------------------------------
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*----------------------------------------------------------------------------
|
|
|
|
*
|
2012-05-17 07:33:52 +07:00
|
|
|
* MCA card detection code by Trent McNair. (now deleted)
|
2005-04-17 05:20:36 +07:00
|
|
|
* Fixes to not explicitly nul bss data from Xavier Bestel.
|
|
|
|
* Some multiboard fixes from Rolf Eike Beer.
|
|
|
|
* Auto probing of EISA config space from Trevor Hemsley.
|
|
|
|
*
|
|
|
|
* Rewritten to use 53c700.c by James.Bottomley@SteelEye.com
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/eisa.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_spi.h>
|
|
|
|
|
|
|
|
#include "53c700.h"
|
|
|
|
|
|
|
|
|
2012-05-17 07:33:52 +07:00
|
|
|
/* Must be enough for EISA */
|
2005-04-17 05:20:36 +07:00
|
|
|
#define MAX_SLOTS 8
|
|
|
|
static __u8 __initdata id_array[MAX_SLOTS] = { [0 ... MAX_SLOTS-1] = 7 };
|
|
|
|
|
|
|
|
static char *sim710; /* command line passed by insmod */
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Richard Hirst");
|
|
|
|
MODULE_DESCRIPTION("Simple NCR53C710 driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_param(sim710, charp, 0);
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
#define ARG_SEP ' '
|
|
|
|
#else
|
|
|
|
#define ARG_SEP ','
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static __init int
|
|
|
|
param_setup(char *str)
|
|
|
|
{
|
|
|
|
char *pos = str, *next;
|
|
|
|
int slot = -1;
|
|
|
|
|
|
|
|
while(pos != NULL && (next = strchr(pos, ':')) != NULL) {
|
|
|
|
int val = (int)simple_strtoul(++next, NULL, 0);
|
|
|
|
|
|
|
|
if(!strncmp(pos, "slot:", 5))
|
|
|
|
slot = val;
|
|
|
|
else if(!strncmp(pos, "id:", 3)) {
|
|
|
|
if(slot == -1) {
|
|
|
|
printk(KERN_WARNING "sim710: Must specify slot for id parameter\n");
|
2006-04-19 11:09:20 +07:00
|
|
|
} else if(slot >= MAX_SLOTS) {
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_WARNING "sim710: Illegal slot %d for id %d\n", slot, val);
|
|
|
|
} else {
|
|
|
|
id_array[slot] = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if((pos = strchr(pos, ARG_SEP)) != NULL)
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("sim710=", param_setup);
|
|
|
|
|
|
|
|
static struct scsi_host_template sim710_driver_template = {
|
2012-05-17 07:33:52 +07:00
|
|
|
.name = "LSI (Symbios) 710 EISA",
|
2005-04-17 05:20:36 +07:00
|
|
|
.proc_name = "sim710",
|
|
|
|
.this_id = 7,
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2012-12-22 04:08:55 +07:00
|
|
|
static int sim710_probe_common(struct device *dev, unsigned long base_addr,
|
|
|
|
int irq, int clock, int differential,
|
|
|
|
int scsi_id)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct Scsi_Host * host = NULL;
|
|
|
|
struct NCR_700_Host_Parameters *hostdata =
|
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing
this transformation:
@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@
x =
- kmalloc
+ kzalloc
(E1,E2)
... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);
@@
expression E1,E2,E3;
@@
- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)
[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-19 15:49:03 +07:00
|
|
|
kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-12-04 04:41:36 +07:00
|
|
|
printk(KERN_NOTICE "sim710: %s\n", dev_name(dev));
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_NOTICE "sim710: irq = %d, clock = %d, base = 0x%lx, scsi_id = %d\n",
|
|
|
|
irq, clock, base_addr, scsi_id);
|
|
|
|
|
|
|
|
if(hostdata == NULL) {
|
|
|
|
printk(KERN_ERR "sim710: Failed to allocate host data\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(request_region(base_addr, 64, "sim710") == NULL) {
|
|
|
|
printk(KERN_ERR "sim710: Failed to reserve IO region 0x%lx\n",
|
|
|
|
base_addr);
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the three required pieces of hostdata */
|
2005-04-03 16:57:48 +07:00
|
|
|
hostdata->base = ioport_map(base_addr, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
hostdata->differential = differential;
|
|
|
|
hostdata->clock = clock;
|
|
|
|
hostdata->chip710 = 1;
|
2006-12-26 03:30:08 +07:00
|
|
|
hostdata->burst_length = 8;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* and register the chip */
|
|
|
|
if((host = NCR_700_detect(&sim710_driver_template, hostdata, dev))
|
|
|
|
== NULL) {
|
|
|
|
printk(KERN_ERR "sim710: No host detected; card configuration problem?\n");
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
host->this_id = scsi_id;
|
2005-04-03 16:57:48 +07:00
|
|
|
host->base = base_addr;
|
2005-04-17 05:20:36 +07:00
|
|
|
host->irq = irq;
|
2006-07-02 09:29:42 +07:00
|
|
|
if (request_irq(irq, NCR_700_intr, IRQF_SHARED, "sim710", host)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
printk(KERN_ERR "sim710: request_irq failed\n");
|
|
|
|
goto out_put_host;
|
|
|
|
}
|
|
|
|
|
2007-07-18 02:38:03 +07:00
|
|
|
dev_set_drvdata(dev, host);
|
2005-04-17 05:20:36 +07:00
|
|
|
scsi_scan_host(host);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_put_host:
|
|
|
|
scsi_host_put(host);
|
|
|
|
out_release:
|
2006-03-11 05:25:00 +07:00
|
|
|
release_region(base_addr, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
out_free:
|
|
|
|
kfree(hostdata);
|
|
|
|
out:
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2012-12-22 04:08:55 +07:00
|
|
|
static int sim710_device_remove(struct device *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-07-18 02:38:03 +07:00
|
|
|
struct Scsi_Host *host = dev_get_drvdata(dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct NCR_700_Host_Parameters *hostdata =
|
|
|
|
(struct NCR_700_Host_Parameters *)host->hostdata[0];
|
|
|
|
|
|
|
|
scsi_remove_host(host);
|
|
|
|
NCR_700_release(host);
|
|
|
|
kfree(hostdata);
|
|
|
|
free_irq(host->irq, host);
|
2005-04-03 16:57:48 +07:00
|
|
|
release_region(host->base, 64);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_EISA
|
|
|
|
static struct eisa_device_id sim710_eisa_ids[] = {
|
|
|
|
{ "CPQ4410" },
|
|
|
|
{ "CPQ4411" },
|
|
|
|
{ "HWP0C80" },
|
|
|
|
{ "" }
|
|
|
|
};
|
2006-09-27 15:50:56 +07:00
|
|
|
MODULE_DEVICE_TABLE(eisa, sim710_eisa_ids);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-02-11 11:59:03 +07:00
|
|
|
static int sim710_eisa_probe(struct device *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct eisa_device *edev = to_eisa_device(dev);
|
|
|
|
unsigned long io_addr = edev->base_addr;
|
|
|
|
char eisa_cpq_irqs[] = { 11, 14, 15, 10, 9, 0 };
|
|
|
|
char eisa_hwp_irqs[] = { 3, 4, 5, 7, 12, 10, 11, 0};
|
|
|
|
char *eisa_irqs;
|
|
|
|
unsigned char irq_index;
|
|
|
|
unsigned char irq, differential = 0, scsi_id = 7;
|
|
|
|
|
|
|
|
if(strcmp(edev->id.sig, "HWP0C80") == 0) {
|
|
|
|
__u8 val;
|
|
|
|
eisa_irqs = eisa_hwp_irqs;
|
|
|
|
irq_index = (inb(io_addr + 0xc85) & 0x7) - 1;
|
|
|
|
|
|
|
|
val = inb(io_addr + 0x4);
|
|
|
|
scsi_id = ffs(val) - 1;
|
|
|
|
|
|
|
|
if(scsi_id > 7 || (val & ~(1<<scsi_id)) != 0) {
|
2008-12-04 04:41:36 +07:00
|
|
|
printk(KERN_ERR "sim710.c, EISA card %s has incorrect scsi_id, setting to 7\n", dev_name(dev));
|
2005-04-17 05:20:36 +07:00
|
|
|
scsi_id = 7;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
eisa_irqs = eisa_cpq_irqs;
|
|
|
|
irq_index = inb(io_addr + 0xc88) & 0x07;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(irq_index >= strlen(eisa_irqs)) {
|
|
|
|
printk("sim710.c: irq nasty\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq = eisa_irqs[irq_index];
|
|
|
|
|
|
|
|
return sim710_probe_common(dev, io_addr, irq, 50,
|
|
|
|
differential, scsi_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct eisa_driver sim710_eisa_driver = {
|
|
|
|
.id_table = sim710_eisa_ids,
|
|
|
|
.driver = {
|
|
|
|
.name = "sim710",
|
|
|
|
.probe = sim710_eisa_probe,
|
2012-12-22 04:08:55 +07:00
|
|
|
.remove = sim710_device_remove,
|
2005-04-17 05:20:36 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_EISA */
|
|
|
|
|
|
|
|
static int __init sim710_init(void)
|
|
|
|
{
|
|
|
|
int err = -ENODEV;
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
if (sim710)
|
|
|
|
param_setup(sim710);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_EISA
|
|
|
|
err = eisa_driver_register(&sim710_eisa_driver);
|
|
|
|
#endif
|
|
|
|
/* FIXME: what we'd really like to return here is -ENODEV if
|
|
|
|
* no devices have actually been found. Instead, the err
|
|
|
|
* above actually only reports problems with kobject_register,
|
|
|
|
* so for the moment return success */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit sim710_exit(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_EISA
|
|
|
|
eisa_driver_unregister(&sim710_eisa_driver);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(sim710_init);
|
|
|
|
module_exit(sim710_exit);
|