Commit ed36188d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] aha152x pcmcia updates

(1) use new pcmcia_register_driver() & co API
(2) use scsi_add_host & co.  This needed some restructuring in aha152x.c
(3) add a bunch of missing statics to aha152x.c
(4) move prototypes for functions used by aha152x_stub.c to aha152x.h
parent a80bc2d3
This diff is collapsed.
...@@ -313,4 +313,24 @@ enum { ...@@ -313,4 +313,24 @@ enum {
}; };
#endif #endif
/* for the pcmcia stub */
struct aha152x_setup {
int io_port;
int irq;
int scsiid;
int reconnect;
int parity;
int synchronous;
int delay;
int ext_trans;
int tc1550;
#if defined(AHA152X_DEBUG)
int debug;
#endif
char *conf;
};
struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *);
int aha152x_host_reset(struct scsi_cmnd *);
#endif /* _AHA152X_H */ #endif /* _AHA152X_H */
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "scsi.h" #include "scsi.h"
#include "hosts.h" #include "hosts.h"
#include "aha152x.h"
#include <pcmcia/version.h> #include <pcmcia/version.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
...@@ -102,8 +103,6 @@ typedef struct scsi_info_t { ...@@ -102,8 +103,6 @@ typedef struct scsi_info_t {
dev_node_t node[8]; dev_node_t node[8];
} scsi_info_t; } scsi_info_t;
extern void aha152x_setup(char *str, int *ints);
static void aha152x_release_cs(u_long arg); static void aha152x_release_cs(u_long arg);
static int aha152x_event(event_t event, int priority, static int aha152x_event(event_t event, int priority,
event_callback_args_t *args); event_callback_args_t *args);
...@@ -111,11 +110,7 @@ static int aha152x_event(event_t event, int priority, ...@@ -111,11 +110,7 @@ static int aha152x_event(event_t event, int priority,
static dev_link_t *aha152x_attach(void); static dev_link_t *aha152x_attach(void);
static void aha152x_detach(dev_link_t *); static void aha152x_detach(dev_link_t *);
#define driver_template aha152x_driver_template static dev_link_t *dev_list;
extern Scsi_Host_Template aha152x_driver_template;
static dev_link_t *dev_list = NULL;
static dev_info_t dev_info = "aha152x_cs"; static dev_info_t dev_info = "aha152x_cs";
/*====================================================================*/ /*====================================================================*/
...@@ -227,11 +222,12 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -227,11 +222,12 @@ static void aha152x_config_cs(dev_link_t *link)
{ {
client_handle_t handle = link->handle; client_handle_t handle = link->handle;
scsi_info_t *info = link->priv; scsi_info_t *info = link->priv;
struct aha152x_setup s;
tuple_t tuple; tuple_t tuple;
cisparse_t parse; cisparse_t parse;
int i, last_ret, last_fn, ints[8]; int i, last_ret, last_fn;
u_char tuple_data[64]; u_char tuple_data[64];
Scsi_Device *dev; struct scsi_device *dev;
dev_node_t *node, **tail; dev_node_t *node, **tail;
struct Scsi_Host *host; struct Scsi_Host *host;
...@@ -247,7 +243,6 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -247,7 +243,6 @@ static void aha152x_config_cs(dev_link_t *link)
link->conf.ConfigBase = parse.config.base; link->conf.ConfigBase = parse.config.base;
/* Configure card */ /* Configure card */
driver_template.module = &__this_module;
link->state |= DEV_CONFIG; link->state |= DEV_CONFIG;
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
...@@ -276,29 +271,32 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -276,29 +271,32 @@ static void aha152x_config_cs(dev_link_t *link)
/* A bad hack... */ /* A bad hack... */
release_region(link->io.BasePort1, link->io.NumPorts1); release_region(link->io.BasePort1, link->io.NumPorts1);
/* Set configuration options for the aha152x driver */ /* Set configuration options for the aha152x driver */
ints[0] = 7; memset(&s, 0, sizeof(s));
ints[1] = link->io.BasePort1; s.conf = "PCMCIA setup";
ints[2] = link->irq.AssignedIRQ; s.io_port = link->io.BasePort1;
ints[3] = host_id; s.irq = link->irq.AssignedIRQ;
ints[4] = reconnect; s.scsiid = host_id;
ints[5] = parity; s.reconnect = reconnect;
ints[6] = synchronous; s.parity = parity;
ints[7] = reset_delay; s.synchronous = synchronous;
if (ext_trans) { s.delay = reset_delay;
ints[8] = ext_trans; ints[0] = 8; if (ext_trans)
} s.ext_trans = ext_trans;
aha152x_setup("PCMCIA setup", ints);
scsi_register_host(&driver_template);
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host)) host = aha152x_probe_one(&s);
if (host->hostt == &driver_template) if (host == NULL) {
list_for_each_entry (dev, &host->my_devices, siblings) { printk(KERN_INFO "aha152x_cs: no SCSI devices found\n");
goto cs_failed;
}
scsi_add_host(host, NULL);
list_for_each_entry(dev, &host->my_devices, siblings) {
u_long arg[2], id; u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg); kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) + id = (arg[0]&0x0f) + ((arg[0]>>4)&0xf0) +
...@@ -328,11 +326,9 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -328,11 +326,9 @@ static void aha152x_config_cs(dev_link_t *link)
*tail = node; tail = &node->next; *tail = node; tail = &node->next;
info->ndev++; info->ndev++;
info->host = dev->host; info->host = dev->host;
} }
*tail = NULL; *tail = NULL;
if (info->ndev == 0)
printk(KERN_INFO "aha152x_cs: no SCSI devices found\n");
link->state &= ~DEV_CONFIG_PENDING; link->state &= ~DEV_CONFIG_PENDING;
return; return;
...@@ -340,41 +336,26 @@ static void aha152x_config_cs(dev_link_t *link) ...@@ -340,41 +336,26 @@ static void aha152x_config_cs(dev_link_t *link)
cs_error(link->handle, last_fn, last_ret); cs_error(link->handle, last_fn, last_ret);
aha152x_release_cs((u_long)link); aha152x_release_cs((u_long)link);
return; return;
}
} /* aha152x_config_cs */
/*====================================================================*/
static void aha152x_release_cs(u_long arg) static void aha152x_release_cs(u_long arg)
{ {
dev_link_t *link = (dev_link_t *)arg; dev_link_t *link = (dev_link_t *)arg;
scsi_info_t *info = link->priv;
DEBUG(0, "aha152x_release_cs(0x%p)\n", link);
#warning This does not protect you. You need some real fix for your races. scsi_remove_host(info->host);
#if 0 link->dev = NULL;
if (GET_USE_COUNT(driver_template.module) != 0) {
DEBUG(1, "aha152x_cs: release postponed, "
"device still open\n");
link->state |= DEV_STALE_CONFIG;
return;
}
#endif
scsi_unregister_host(&driver_template);
link->dev = NULL;
CardServices(ReleaseConfiguration, link->handle); CardServices(ReleaseConfiguration, link->handle);
CardServices(ReleaseIO, link->handle, &link->io); CardServices(ReleaseIO, link->handle, &link->io);
CardServices(ReleaseIRQ, link->handle, &link->irq); CardServices(ReleaseIRQ, link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
if (link->state & DEV_STALE_LINK)
aha152x_detach(link);
} /* aha152x_release_cs */ link->state &= ~DEV_CONFIG;
scsi_unregister(info->host);
/*====================================================================*/ if (link->state & DEV_STALE_LINK)
aha152x_detach(link);
}
static int aha152x_event(event_t event, int priority, static int aha152x_event(event_t event, int priority,
event_callback_args_t *args) event_callback_args_t *args)
...@@ -414,28 +395,29 @@ static int aha152x_event(event_t event, int priority, ...@@ -414,28 +395,29 @@ static int aha152x_event(event_t event, int priority,
break; break;
} }
return 0; return 0;
} /* aha152x_event */ }
/*====================================================================*/ static struct pcmcia_driver aha152x_cs_driver = {
.owner = THIS_MODULE,
.drv = {
.name = "aha152x_cs",
},
.attach = aha152x_attach,
.detach = aha152x_detach,
};
static int __init init_aha152x_cs(void) { static int __init init_aha152x_cs(void)
servinfo_t serv; {
DEBUG(0, "%s\n", version); return pcmcia_register_driver(&aha152x_cs_driver);
CardServices(GetCardServicesInfo, &serv);
if (serv.Revision != CS_RELEASE_CODE) {
printk(KERN_NOTICE "aha152x_cs: Card Services release "
"does not match!\n");
return -1;
}
register_pccard_driver(&dev_info, &aha152x_attach, &aha152x_detach);
return 0;
} }
static void __exit exit_aha152x_cs(void) { static void __exit exit_aha152x_cs(void)
DEBUG(0, "aha152x_cs: unloading\n"); {
unregister_pccard_driver(&dev_info); pcmcia_unregister_driver(&aha152x_cs_driver);
while (dev_list != NULL)
aha152x_detach(dev_list); /* XXX: this really needs to move into generic code.. */
while (dev_list != NULL)
aha152x_detach(dev_list);
} }
module_init(init_aha152x_cs); module_init(init_aha152x_cs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment