aboutsummaryrefslogtreecommitdiff
path: root/drivers/pnp/card.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/card.c')
-rw-r--r--drivers/pnp/card.c71
1 files changed, 28 insertions, 43 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 6c0440c20e3..da1c9909eb4 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -104,10 +104,6 @@ int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card)
{
struct pnp_id *ptr;
- if (!id)
- return -EINVAL;
- if (!card)
- return -EINVAL;
id->next = NULL;
ptr = card->id;
while (ptr && ptr->next)
@@ -124,8 +120,6 @@ static void pnp_free_card_ids(struct pnp_card *card)
struct pnp_id *id;
struct pnp_id *next;
- if (!card)
- return;
id = card->id;
while (id) {
next = id->next;
@@ -197,42 +191,39 @@ int pnp_add_card(struct pnp_card *card)
int error;
struct list_head *pos, *temp;
- if (!card || !card->protocol)
- return -EINVAL;
-
sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
card->number);
card->dev.parent = &card->protocol->dev;
card->dev.bus = NULL;
card->dev.release = &pnp_release_card;
error = device_register(&card->dev);
+ if (error) {
+ dev_err(&card->dev, "could not register (err=%d)\n", error);
+ return error;
+ }
- if (error == 0) {
- pnp_interface_attach_card(card);
- spin_lock(&pnp_lock);
- list_add_tail(&card->global_list, &pnp_cards);
- list_add_tail(&card->protocol_list, &card->protocol->cards);
- spin_unlock(&pnp_lock);
-
- /* we wait until now to add devices in order to ensure the drivers
- * will be able to use all of the related devices on the card
- * without waiting any unresonable length of time */
- list_for_each(pos, &card->devices) {
- struct pnp_dev *dev = card_to_pnp_dev(pos);
- __pnp_add_device(dev);
- }
+ pnp_interface_attach_card(card);
+ spin_lock(&pnp_lock);
+ list_add_tail(&card->global_list, &pnp_cards);
+ list_add_tail(&card->protocol_list, &card->protocol->cards);
+ spin_unlock(&pnp_lock);
- /* match with card drivers */
- list_for_each_safe(pos, temp, &pnp_card_drivers) {
- struct pnp_card_driver *drv =
- list_entry(pos, struct pnp_card_driver,
- global_list);
- card_probe(card, drv);
- }
- } else
- pnp_err("sysfs failure, card '%s' will be unavailable",
- card->dev.bus_id);
- return error;
+ /* we wait until now to add devices in order to ensure the drivers
+ * will be able to use all of the related devices on the card
+ * without waiting an unreasonable length of time */
+ list_for_each(pos, &card->devices) {
+ struct pnp_dev *dev = card_to_pnp_dev(pos);
+ __pnp_add_device(dev);
+ }
+
+ /* match with card drivers */
+ list_for_each_safe(pos, temp, &pnp_card_drivers) {
+ struct pnp_card_driver *drv =
+ list_entry(pos, struct pnp_card_driver,
+ global_list);
+ card_probe(card, drv);
+ }
+ return 0;
}
/**
@@ -243,8 +234,6 @@ void pnp_remove_card(struct pnp_card *card)
{
struct list_head *pos, *temp;
- if (!card)
- return;
device_unregister(&card->dev);
spin_lock(&pnp_lock);
list_del(&card->global_list);
@@ -263,8 +252,6 @@ void pnp_remove_card(struct pnp_card *card)
*/
int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
{
- if (!card || !dev || !dev->protocol)
- return -EINVAL;
dev->dev.parent = &card->dev;
dev->card_link = NULL;
snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x",
@@ -304,14 +291,15 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
struct pnp_card *card;
if (!clink || !id)
- goto done;
+ return NULL;
+
card = clink->card;
drv = clink->driver;
if (!from) {
pos = card->devices.next;
} else {
if (from->card != card)
- goto done;
+ return NULL;
pos = from->card_list.next;
}
while (pos != &card->devices) {
@@ -321,7 +309,6 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
pos = pos->next;
}
-done:
return NULL;
found:
@@ -348,8 +335,6 @@ void pnp_release_card_device(struct pnp_dev *dev)
{
struct pnp_card_driver *drv = dev->card_link->driver;
- if (!drv)
- return;
drv->link.remove = &card_remove;
device_release_driver(&dev->dev);
drv->link.remove = &card_remove_first;