int pnp_add_card()

in card.c [234:270]


int pnp_add_card(struct pnp_card *card)
{
	int error;
	struct list_head *pos, *temp;

	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);
		put_device(&card->dev);
		return error;
	}

	pnp_interface_attach_card(card);
	mutex_lock(&pnp_lock);
	list_add_tail(&card->global_list, &pnp_cards);
	list_add_tail(&card->protocol_list, &card->protocol->cards);
	mutex_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 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;
}