[PATCH] pcmcia: add return value to _config() functions

Most of the driver initialization isn't done in the .probe function, but in
the internal _config() functions. Make them return a value, so that .probe
can properly report whether the probing of the device succeeded or not.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Dominik Brodowski
2006-03-31 17:26:06 +02:00
parent fba395eee7
commit 15b99ac172
45 changed files with 375 additions and 400 deletions

View File

@ -80,7 +80,7 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
event handler.
*/
static void airo_config(struct pcmcia_device *link);
static int airo_config(struct pcmcia_device *link);
static void airo_release(struct pcmcia_device *link);
/*
@ -141,7 +141,7 @@ typedef struct local_info_t {
======================================================================*/
static int airo_attach(struct pcmcia_device *p_dev)
static int airo_probe(struct pcmcia_device *p_dev)
{
local_info_t *local;
@ -171,9 +171,7 @@ static int airo_attach(struct pcmcia_device *p_dev)
p_dev->priv = local;
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
airo_config(p_dev);
return 0;
return airo_config(p_dev);
} /* airo_attach */
/*======================================================================
@ -211,7 +209,7 @@ static void airo_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static void airo_config(struct pcmcia_device *link)
static int airo_config(struct pcmcia_device *link)
{
tuple_t tuple;
cisparse_t parse;
@ -386,12 +384,12 @@ static void airo_config(struct pcmcia_device *link)
printk("\n");
link->state &= ~DEV_CONFIG_PENDING;
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
airo_release(link);
return -ENODEV;
} /* airo_config */
/*======================================================================
@ -444,7 +442,7 @@ static struct pcmcia_driver airo_driver = {
.drv = {
.name = "airo_cs",
},
.probe = airo_attach,
.probe = airo_probe,
.remove = airo_detach,
.id_table = airo_ids,
.suspend = airo_suspend,

View File

@ -91,7 +91,7 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
event handler.
*/
static void atmel_config(struct pcmcia_device *link);
static int atmel_config(struct pcmcia_device *link);
static void atmel_release(struct pcmcia_device *link);
/*
@ -152,7 +152,7 @@ typedef struct local_info_t {
======================================================================*/
static int atmel_attach(struct pcmcia_device *p_dev)
static int atmel_probe(struct pcmcia_device *p_dev)
{
local_info_t *local;
@ -182,9 +182,7 @@ static int atmel_attach(struct pcmcia_device *p_dev)
p_dev->priv = local;
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
atmel_config(p_dev);
return 0;
return atmel_config(p_dev);
} /* atmel_attach */
/*======================================================================
@ -230,7 +228,7 @@ static int card_present(void *arg)
return 0;
}
static void atmel_config(struct pcmcia_device *link)
static int atmel_config(struct pcmcia_device *link)
{
tuple_t tuple;
cisparse_t parse;
@ -377,11 +375,12 @@ static void atmel_config(struct pcmcia_device *link)
link->dev_node = &dev->node;
link->state &= ~DEV_CONFIG_PENDING;
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
atmel_release(link);
return -ENODEV;
}
/*======================================================================
@ -476,7 +475,7 @@ static struct pcmcia_driver atmel_driver = {
.drv = {
.name = "atmel_cs",
},
.probe = atmel_attach,
.probe = atmel_probe,
.remove = atmel_detach,
.id_table = atmel_ids,
.suspend = atmel_suspend,

View File

@ -501,16 +501,20 @@ static struct prism2_helper_functions prism2_pccard_funcs =
/* allocate local data and register with CardServices
* initialize dev_link structure, but do not configure the card yet */
static int prism2_attach(struct pcmcia_device *p_dev)
static int hostap_cs_probe(struct pcmcia_device *p_dev)
{
int ret;
PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
p_dev->conf.IntType = INT_MEMORY_AND_IO;
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
if (prism2_config(p_dev))
ret = prism2_config(p_dev);
if (ret) {
PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
}
return 0;
return ret;
}
@ -894,7 +898,7 @@ static struct pcmcia_driver hostap_driver = {
.drv = {
.name = "hostap_cs",
},
.probe = prism2_attach,
.probe = hostap_cs_probe,
.remove = prism2_detach,
.owner = THIS_MODULE,
.id_table = hostap_cs_ids,

View File

@ -191,7 +191,7 @@ module_param(mem_speed, int, 0);
/* PCMCIA (Card Services) related functions */
static void netwave_release(struct pcmcia_device *link); /* Card removal */
static void netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card
static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card
insertion */
static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
@ -376,7 +376,7 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
* configure the card at this point -- we wait until we receive a
* card insertion event.
*/
static int netwave_attach(struct pcmcia_device *link)
static int netwave_probe(struct pcmcia_device *link)
{
struct net_device *dev;
netwave_private *priv;
@ -429,9 +429,7 @@ static int netwave_attach(struct pcmcia_device *link)
link->irq.Instance = dev;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
netwave_pcmcia_config( link);
return 0;
return netwave_pcmcia_config( link);
} /* netwave_attach */
/*
@ -737,7 +735,7 @@ static const struct iw_handler_def netwave_handler_def =
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
static void netwave_pcmcia_config(struct pcmcia_device *link) {
static int netwave_pcmcia_config(struct pcmcia_device *link) {
struct net_device *dev = link->priv;
netwave_private *priv = netdev_priv(dev);
tuple_t tuple;
@ -845,12 +843,13 @@ static void netwave_pcmcia_config(struct pcmcia_device *link) {
printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n",
get_uint16(ramBase + NETWAVE_EREG_ARW),
get_uint16(ramBase + NETWAVE_EREG_ARW+2));
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
netwave_release(link);
return -ENODEV;
} /* netwave_pcmcia_config */
/*
@ -1387,7 +1386,7 @@ static struct pcmcia_driver netwave_driver = {
.drv = {
.name = "netwave_cs",
},
.probe = netwave_attach,
.probe = netwave_probe,
.remove = netwave_detach,
.id_table = netwave_ids,
.suspend = netwave_suspend,

View File

@ -63,7 +63,7 @@ struct orinoco_pccard {
/* Function prototypes */
/********************************************************************/
static void orinoco_cs_config(struct pcmcia_device *link);
static int orinoco_cs_config(struct pcmcia_device *link);
static void orinoco_cs_release(struct pcmcia_device *link);
static void orinoco_cs_detach(struct pcmcia_device *p_dev);
@ -104,7 +104,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
* configure the card at this point -- we wait until we receive a card
* insertion event. */
static int
orinoco_cs_attach(struct pcmcia_device *link)
orinoco_cs_probe(struct pcmcia_device *link)
{
struct net_device *dev;
struct orinoco_private *priv;
@ -135,9 +135,7 @@ orinoco_cs_attach(struct pcmcia_device *link)
link->conf.IntType = INT_MEMORY_AND_IO;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
orinoco_cs_config(link);
return 0;
return orinoco_cs_config(link);
} /* orinoco_cs_attach */
/*
@ -172,7 +170,7 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \
} while (0)
static void
static int
orinoco_cs_config(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
@ -377,13 +375,14 @@ orinoco_cs_config(struct pcmcia_device *link)
link->io.BasePort2 + link->io.NumPorts2 - 1);
printk("\n");
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
orinoco_cs_release(link);
return -ENODEV;
} /* orinoco_cs_config */
/*
@ -576,7 +575,7 @@ static struct pcmcia_driver orinoco_driver = {
.drv = {
.name = DRIVER_NAME,
},
.probe = orinoco_cs_attach,
.probe = orinoco_cs_probe,
.remove = orinoco_cs_detach,
.id_table = orinoco_cs_ids,
.suspend = orinoco_cs_suspend,

View File

@ -90,7 +90,7 @@ module_param(pc_debug, int, 0);
#define DEBUG(n, args...)
#endif
/** Prototypes based on PCMCIA skeleton driver *******************************/
static void ray_config(struct pcmcia_device *link);
static int ray_config(struct pcmcia_device *link);
static void ray_release(struct pcmcia_device *link);
static void ray_detach(struct pcmcia_device *p_dev);
@ -303,7 +303,7 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
configure the card at this point -- we wait until we receive a
card insertion event.
=============================================================================*/
static int ray_attach(struct pcmcia_device *p_dev)
static int ray_probe(struct pcmcia_device *p_dev)
{
ray_dev_t *local;
struct net_device *dev;
@ -368,9 +368,7 @@ static int ray_attach(struct pcmcia_device *p_dev)
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
this_device = p_dev;
ray_config(p_dev);
return 0;
return ray_config(p_dev);
fail_alloc_dev:
return -ENOMEM;
@ -412,7 +410,7 @@ static void ray_detach(struct pcmcia_device *link)
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
#define MAX_TUPLE_SIZE 128
static void ray_config(struct pcmcia_device *link)
static int ray_config(struct pcmcia_device *link)
{
tuple_t tuple;
cisparse_t parse;
@ -499,7 +497,7 @@ static void ray_config(struct pcmcia_device *link)
DEBUG(3,"ray_config amem=%p\n",local->amem);
if (ray_init(dev) < 0) {
ray_release(link);
return;
return -ENODEV;
}
SET_NETDEV_DEV(dev, &handle_to_dev(link));
@ -507,7 +505,7 @@ static void ray_config(struct pcmcia_device *link)
if (i != 0) {
printk("ray_config register_netdev() failed\n");
ray_release(link);
return;
return i;
}
strcpy(local->node.dev_name, dev->name);
@ -519,12 +517,13 @@ static void ray_config(struct pcmcia_device *link)
for (i = 0; i < 6; i++)
printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n"));
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
ray_release(link);
return -ENODEV;
} /* ray_config */
static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
@ -2846,7 +2845,7 @@ static struct pcmcia_driver ray_driver = {
.drv = {
.name = "ray_cs",
},
.probe = ray_attach,
.probe = ray_probe,
.remove = ray_detach,
.id_table = ray_ids,
.suspend = ray_suspend,

View File

@ -71,7 +71,7 @@ struct orinoco_pccard {
/* Function prototypes */
/********************************************************************/
static void spectrum_cs_config(struct pcmcia_device *link);
static int spectrum_cs_config(struct pcmcia_device *link);
static void spectrum_cs_release(struct pcmcia_device *link);
/********************************************************************/
@ -583,7 +583,7 @@ spectrum_cs_hard_reset(struct orinoco_private *priv)
* configure the card at this point -- we wait until we receive a card
* insertion event. */
static int
spectrum_cs_attach(struct pcmcia_device *link)
spectrum_cs_probe(struct pcmcia_device *link)
{
struct net_device *dev;
struct orinoco_private *priv;
@ -614,9 +614,7 @@ spectrum_cs_attach(struct pcmcia_device *link)
link->conf.IntType = INT_MEMORY_AND_IO;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
spectrum_cs_config(link);
return 0;
return spectrum_cs_config(link);
} /* spectrum_cs_attach */
/*
@ -647,7 +645,7 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
* device available to the system.
*/
static void
static int
spectrum_cs_config(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
@ -857,13 +855,14 @@ spectrum_cs_config(struct pcmcia_device *link)
link->io.BasePort2 + link->io.NumPorts2 - 1);
printk("\n");
return;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
spectrum_cs_release(link);
return -ENODEV;
} /* spectrum_cs_config */
/*
@ -954,7 +953,7 @@ static struct pcmcia_driver orinoco_driver = {
.drv = {
.name = DRIVER_NAME,
},
.probe = spectrum_cs_attach,
.probe = spectrum_cs_probe,
.remove = spectrum_cs_detach,
.suspend = spectrum_cs_suspend,
.resume = spectrum_cs_resume,

View File

@ -4580,10 +4580,11 @@ wavelan_close(struct net_device * dev)
* card insertion event.
*/
static int
wavelan_attach(struct pcmcia_device *p_dev)
wavelan_probe(struct pcmcia_device *p_dev)
{
struct net_device * dev; /* Interface generic data */
net_local * lp; /* Interface specific data */
int ret;
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG "-> wavelan_attach()\n");
@ -4651,11 +4652,18 @@ wavelan_attach(struct pcmcia_device *p_dev)
dev->mtu = WAVELAN_MTU;
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
if(wv_pcmcia_config(p_dev) &&
wv_hw_config(dev))
wv_init_info(dev);
else
ret = wv_pcmcia_config(p_dev);
if (ret)
return ret;
ret = wv_hw_config(dev);
if (ret) {
dev->irq = 0;
pcmcia_disable_device(p_dev);
return ret;
}
wv_init_info(dev);
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG "<- wavelan_attach()\n");
@ -4760,7 +4768,7 @@ static struct pcmcia_driver wavelan_driver = {
.drv = {
.name = "wavelan_cs",
},
.probe = wavelan_attach,
.probe = wavelan_probe,
.remove = wavelan_detach,
.id_table = wavelan_ids,
.suspend = wavelan_suspend,

View File

@ -103,7 +103,7 @@ module_param(pc_debug, int, 0);
* release a socket, in response to card insertion and ejection events. They
* are invoked from the wl24 event handler.
*/
static void wl3501_config(struct pcmcia_device *link);
static int wl3501_config(struct pcmcia_device *link);
static void wl3501_release(struct pcmcia_device *link);
/*
@ -1920,7 +1920,7 @@ static const struct iw_handler_def wl3501_handler_def = {
* The dev_link structure is initialized, but we don't actually configure the
* card at this point -- we wait until we receive a card insertion event.
*/
static int wl3501_attach(struct pcmcia_device *p_dev)
static int wl3501_probe(struct pcmcia_device *p_dev)
{
struct net_device *dev;
struct wl3501_card *this;
@ -1960,9 +1960,7 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
p_dev->priv = p_dev->irq.Instance = dev;
p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
wl3501_config(p_dev);
return 0;
return wl3501_config(p_dev);
out_link:
return -ENOMEM;
}
@ -1978,7 +1976,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
* received, to configure the PCMCIA socket, and to make the ethernet device
* available to the system.
*/
static void wl3501_config(struct pcmcia_device *link)
static int wl3501_config(struct pcmcia_device *link)
{
tuple_t tuple;
cisparse_t parse;
@ -2082,13 +2080,13 @@ static void wl3501_config(struct pcmcia_device *link)
spin_lock_init(&this->lock);
init_waitqueue_head(&this->wait);
netif_start_queue(dev);
goto out;
return 0;
cs_failed:
cs_error(link, last_fn, last_ret);
failed:
wl3501_release(link);
out:
return;
return -ENODEV;
}
/**
@ -2146,7 +2144,7 @@ static struct pcmcia_driver wl3501_driver = {
.drv = {
.name = "wl3501_cs",
},
.probe = wl3501_attach,
.probe = wl3501_probe,
.remove = wl3501_detach,
.id_table = wl3501_ids,
.suspend = wl3501_suspend,