summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn544/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nfc/pn544/i2c.c')
-rw-r--r--drivers/nfc/pn544/i2c.c44
1 files changed, 7 insertions, 37 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 2a9c8d93d2e8..8cf64c19f022 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -376,12 +376,12 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
- phy = kzalloc(sizeof(struct pn544_i2c_phy), GFP_KERNEL);
+ phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy),
+ GFP_KERNEL);
if (!phy) {
dev_err(&client->dev,
"Cannot allocate memory for pn544 i2c phy.\n");
- r = -ENOMEM;
- goto err_phy_alloc;
+ return -ENOMEM;
}
phy->i2c_dev = client;
@@ -390,20 +390,18 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
pdata = client->dev.platform_data;
if (pdata == NULL) {
dev_err(&client->dev, "No platform data\n");
- r = -EINVAL;
- goto err_pdata;
+ return -EINVAL;
}
if (pdata->request_resources == NULL) {
dev_err(&client->dev, "request_resources() missing\n");
- r = -EINVAL;
- goto err_pdata;
+ return -EINVAL;
}
r = pdata->request_resources(client);
if (r) {
dev_err(&client->dev, "Cannot get platform resources\n");
- goto err_pdata;
+ return r;
}
phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
@@ -435,10 +433,6 @@ err_rti:
if (pdata->free_resources != NULL)
pdata->free_resources();
-err_pdata:
- kfree(phy);
-
-err_phy_alloc:
return r;
}
@@ -458,8 +452,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
if (pdata->free_resources)
pdata->free_resources();
- kfree(phy);
-
return 0;
}
@@ -472,29 +464,7 @@ static struct i2c_driver pn544_hci_i2c_driver = {
.remove = pn544_hci_i2c_remove,
};
-static int __init pn544_hci_i2c_init(void)
-{
- int r;
-
- pr_debug(DRIVER_DESC ": %s\n", __func__);
-
- r = i2c_add_driver(&pn544_hci_i2c_driver);
- if (r) {
- pr_err(PN544_HCI_I2C_DRIVER_NAME
- ": driver registration failed\n");
- return r;
- }
-
- return 0;
-}
-
-static void __exit pn544_hci_i2c_exit(void)
-{
- i2c_del_driver(&pn544_hci_i2c_driver);
-}
-
-module_init(pn544_hci_i2c_init);
-module_exit(pn544_hci_i2c_exit);
+module_i2c_driver(pn544_hci_i2c_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION(DRIVER_DESC);