Skip to content

Commit

Permalink
Merge branch 'pnp'
Browse files Browse the repository at this point in the history
* pnp:
  PNP: Avoid leaving unregistered device objects in lists
  PNP: Convert pnp_lock into a mutex
  PNP: tty/serial/8250/8250_fintek: Use module_pnp_driver to register driver
  PNP: platform/x86/apple-gmux: Use module_pnp_driver to register driver
  PNP: net/sb1000: Use module_pnp_driver to register driver
  PNP: media/rc: Use module_pnp_driver to register driver
  PNP: ide/ide-pnp: Use module_pnp_driver to register driver
  PNP: ata/pata_isapnp: Use module_pnp_driver to register driver
  PNP: tpm/tpm_infineon: Use module_pnp_driver to register driver
  PNP: Add helper macro for pnp_register_driver boilerplate
  PNP / ACPI: Use ACPI_COMPANION_SET() during initialization
  • Loading branch information
Rafael J. Wysocki committed Apr 12, 2015
2 parents 9a9ca16 + 71150d2 commit 17528b3
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 164 deletions.
14 changes: 1 addition & 13 deletions drivers/ata/pata_isapnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,8 @@ static struct pnp_driver isapnp_driver = {
.remove = isapnp_remove_one,
};

static int __init isapnp_init(void)
{
return pnp_register_driver(&isapnp_driver);
}

static void __exit isapnp_exit(void)
{
pnp_unregister_driver(&isapnp_driver);
}

module_pnp_driver(isapnp_driver);
MODULE_AUTHOR("Alan Cox");
MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);

module_init(isapnp_init);
module_exit(isapnp_exit);
13 changes: 1 addition & 12 deletions drivers/char/tpm/tpm_infineon.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,7 @@ static struct pnp_driver tpm_inf_pnp_driver = {
.remove = tpm_inf_pnp_remove
};

static int __init init_inf(void)
{
return pnp_register_driver(&tpm_inf_pnp_driver);
}

static void __exit cleanup_inf(void)
{
pnp_unregister_driver(&tpm_inf_pnp_driver);
}

module_init(init_inf);
module_exit(cleanup_inf);
module_pnp_driver(tpm_inf_pnp_driver);

MODULE_AUTHOR("Marcel Selhorst <tpmdd@sirrix.com>");
MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
Expand Down
14 changes: 1 addition & 13 deletions drivers/ide/ide-pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,5 @@ static struct pnp_driver idepnp_driver = {
.remove = idepnp_remove,
};

static int __init pnpide_init(void)
{
return pnp_register_driver(&idepnp_driver);
}

static void __exit pnpide_exit(void)
{
pnp_unregister_driver(&idepnp_driver);
}

module_init(pnpide_init);
module_exit(pnpide_exit);

module_pnp_driver(idepnp_driver);
MODULE_LICENSE("GPL");
13 changes: 1 addition & 12 deletions drivers/media/rc/ene_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,16 +1195,6 @@ static struct pnp_driver ene_driver = {
.shutdown = ene_shutdown,
};

static int __init ene_init(void)
{
return pnp_register_driver(&ene_driver);
}

static void ene_exit(void)
{
pnp_unregister_driver(&ene_driver);
}

module_param(sample_period, int, S_IRUGO);
MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)");

Expand All @@ -1226,5 +1216,4 @@ MODULE_DESCRIPTION
MODULE_AUTHOR("Maxim Levitsky");
MODULE_LICENSE("GPL");

module_init(ene_init);
module_exit(ene_exit);
module_pnp_driver(ene_driver);
13 changes: 1 addition & 12 deletions drivers/media/rc/fintek-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,6 @@ static struct pnp_driver fintek_driver = {
.shutdown = fintek_shutdown,
};

static int __init fintek_init(void)
{
return pnp_register_driver(&fintek_driver);
}

static void __exit fintek_exit(void)
{
pnp_unregister_driver(&fintek_driver);
}

module_param(debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Enable debugging output");

Expand All @@ -703,5 +693,4 @@ MODULE_DESCRIPTION(FINTEK_DESCRIPTION " driver");
MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
MODULE_LICENSE("GPL");

module_init(fintek_init);
module_exit(fintek_exit);
module_pnp_driver(fintek_driver);
13 changes: 1 addition & 12 deletions drivers/media/rc/ite-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,21 +1708,10 @@ static struct pnp_driver ite_driver = {
.shutdown = ite_shutdown,
};

static int __init ite_init(void)
{
return pnp_register_driver(&ite_driver);
}

static void __exit ite_exit(void)
{
pnp_unregister_driver(&ite_driver);
}

MODULE_DEVICE_TABLE(pnp, ite_ids);
MODULE_DESCRIPTION("ITE Tech Inc. IT8712F/ITE8512F CIR driver");

MODULE_AUTHOR("Juan J. Garcia de Soria <skandalfo@gmail.com>");
MODULE_LICENSE("GPL");

module_init(ite_init);
module_exit(ite_exit);
module_pnp_driver(ite_driver);
13 changes: 1 addition & 12 deletions drivers/media/rc/nuvoton-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,16 +1219,6 @@ static struct pnp_driver nvt_driver = {
.shutdown = nvt_shutdown,
};

static int __init nvt_init(void)
{
return pnp_register_driver(&nvt_driver);
}

static void __exit nvt_exit(void)
{
pnp_unregister_driver(&nvt_driver);
}

module_param(debug, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Enable debugging output");

Expand All @@ -1238,5 +1228,4 @@ MODULE_DESCRIPTION("Nuvoton W83667HG-A & W83677HG-I CIR driver");
MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
MODULE_LICENSE("GPL");

module_init(nvt_init);
module_exit(nvt_exit);
module_pnp_driver(nvt_driver);
15 changes: 1 addition & 14 deletions drivers/net/sb1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,17 +1175,4 @@ MODULE_AUTHOR("Franco Venturi <fventuri@mediaone.net>");
MODULE_DESCRIPTION("General Instruments SB1000 driver");
MODULE_LICENSE("GPL");

static int __init
sb1000_init(void)
{
return pnp_register_driver(&sb1000_driver);
}

static void __exit
sb1000_exit(void)
{
pnp_unregister_driver(&sb1000_driver);
}

module_init(sb1000_init);
module_exit(sb1000_exit);
module_pnp_driver(sb1000_driver);
14 changes: 1 addition & 13 deletions drivers/platform/x86/apple-gmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,7 @@ static struct pnp_driver gmux_pnp_driver = {
},
};

static int __init apple_gmux_init(void)
{
return pnp_register_driver(&gmux_pnp_driver);
}

static void __exit apple_gmux_exit(void)
{
pnp_unregister_driver(&gmux_pnp_driver);
}

module_init(apple_gmux_init);
module_exit(apple_gmux_exit);

module_pnp_driver(gmux_pnp_driver);
MODULE_AUTHOR("Seth Forshee <seth.forshee@canonical.com>");
MODULE_DESCRIPTION("Apple Gmux Driver");
MODULE_LICENSE("GPL");
Expand Down
2 changes: 1 addition & 1 deletion drivers/pnp/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Bjorn Helgaas <bjorn.helgaas@hp.com>
*/

extern spinlock_t pnp_lock;
extern struct mutex pnp_lock;
extern const struct attribute_group *pnp_dev_groups[];
void *pnp_alloc(long size);

Expand Down
25 changes: 13 additions & 12 deletions drivers/pnp/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/ctype.h>
#include <linux/slab.h>
#include <linux/pnp.h>
Expand Down Expand Up @@ -244,10 +245,10 @@ int pnp_add_card(struct pnp_card *card)
}

pnp_interface_attach_card(card);
spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
list_add_tail(&card->global_list, &pnp_cards);
list_add_tail(&card->protocol_list, &card->protocol->cards);
spin_unlock(&pnp_lock);
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
Expand Down Expand Up @@ -276,10 +277,10 @@ void pnp_remove_card(struct pnp_card *card)
struct list_head *pos, *temp;

device_unregister(&card->dev);
spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
list_del(&card->global_list);
list_del(&card->protocol_list);
spin_unlock(&pnp_lock);
mutex_unlock(&pnp_lock);
list_for_each_safe(pos, temp, &card->devices) {
struct pnp_dev *dev = card_to_pnp_dev(pos);
pnp_remove_card_device(dev);
Expand All @@ -297,10 +298,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
dev->card_link = NULL;
dev_set_name(&dev->dev, "%02x:%02x.%02x",
dev->protocol->number, card->number, dev->number);
spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
dev->card = card;
list_add_tail(&dev->card_list, &card->devices);
spin_unlock(&pnp_lock);
mutex_unlock(&pnp_lock);
return 0;
}

Expand All @@ -310,10 +311,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
*/
void pnp_remove_card_device(struct pnp_dev *dev)
{
spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
dev->card = NULL;
list_del(&dev->card_list);
spin_unlock(&pnp_lock);
mutex_unlock(&pnp_lock);
__pnp_remove_device(dev);
}

Expand Down Expand Up @@ -426,9 +427,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
if (error < 0)
return error;

spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
list_add_tail(&drv->global_list, &pnp_card_drivers);
spin_unlock(&pnp_lock);
mutex_unlock(&pnp_lock);

list_for_each_safe(pos, temp, &pnp_cards) {
struct pnp_card *card =
Expand All @@ -444,9 +445,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
*/
void pnp_unregister_card_driver(struct pnp_card_driver *drv)
{
spin_lock(&pnp_lock);
mutex_lock(&pnp_lock);
list_del(&drv->global_list);
spin_unlock(&pnp_lock);
mutex_unlock(&pnp_lock);
pnp_unregister_driver(&drv->link);
}

Expand Down
Loading

0 comments on commit 17528b3

Please sign in to comment.