Skip to content

Commit 7b9fcda

Browse files
andy-shevSamuel Ortiz
authored andcommitted
NFC: fdp: Convert to use devres API
It looks like there are two leftovers, at least one of which can leak the resource (IRQ). Convert both places to use managed variants of the functions. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 8597c09 commit 7b9fcda

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

‎drivers/nfc/fdp/fdp.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,9 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
749749
u32 protocols;
750750
int r;
751751

752-
info = kzalloc(sizeof(struct fdp_nci_info), GFP_KERNEL);
753-
if (!info) {
754-
r = -ENOMEM;
755-
goto err_info_alloc;
756-
}
752+
info = devm_kzalloc(dev, sizeof(struct fdp_nci_info), GFP_KERNEL);
753+
if (!info)
754+
return -ENOMEM;
757755

758756
info->phy = phy;
759757
info->phy_ops = phy_ops;
@@ -775,8 +773,7 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
775773
tx_tailroom);
776774
if (!ndev) {
777775
nfc_err(dev, "Cannot allocate nfc ndev\n");
778-
r = -ENOMEM;
779-
goto err_alloc_ndev;
776+
return -ENOMEM;
780777
}
781778

782779
r = nci_register_device(ndev);
@@ -792,9 +789,6 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
792789

793790
err_regdev:
794791
nci_free_device(ndev);
795-
err_alloc_ndev:
796-
kfree(info);
797-
err_info_alloc:
798792
return r;
799793
}
800794
EXPORT_SYMBOL(fdp_nci_probe);
@@ -808,7 +802,6 @@ void fdp_nci_remove(struct nci_dev *ndev)
808802

809803
nci_unregister_device(ndev);
810804
nci_free_device(ndev);
811-
kfree(info);
812805
}
813806
EXPORT_SYMBOL(fdp_nci_remove);
814807

‎drivers/nfc/fdp/i2c.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,18 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
303303
return -ENODEV;
304304
}
305305

306-
phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
307-
GFP_KERNEL);
306+
phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy), GFP_KERNEL);
308307
if (!phy)
309308
return -ENOMEM;
310309

311310
phy->i2c_dev = client;
312311
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
313312
i2c_set_clientdata(client, phy);
314313

315-
r = request_threaded_irq(client->irq, NULL, fdp_nci_i2c_irq_thread_fn,
316-
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
317-
FDP_I2C_DRIVER_NAME, phy);
314+
r = devm_request_threaded_irq(dev, client->irq,
315+
NULL, fdp_nci_i2c_irq_thread_fn,
316+
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
317+
FDP_I2C_DRIVER_NAME, phy);
318318

319319
if (r < 0) {
320320
nfc_err(&client->dev, "Unable to register IRQ handler\n");

0 commit comments

Comments
 (0)