diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-12-18 12:07:37 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-01-09 18:51:53 -0500 |
commit | a0f36536ac2ec0f7a9cfb53c72d6d8c378815fdb (patch) | |
tree | 55e068c7bc4aed729898965836add0f9cd0867eb /drivers/nfc | |
parent | 234d4d6b1038f004f233f14906ec9328bf53088b (diff) |
NFC: pn544: Use devm_kzalloc API
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/pn544/i2c.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index ec79f355edc1..7f96ca2c46bd 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c | |||
@@ -376,12 +376,12 @@ static int __devinit pn544_hci_i2c_probe(struct i2c_client *client, | |||
376 | return -ENODEV; | 376 | return -ENODEV; |
377 | } | 377 | } |
378 | 378 | ||
379 | phy = kzalloc(sizeof(struct pn544_i2c_phy), GFP_KERNEL); | 379 | phy = devm_kzalloc(&client->dev, sizeof(struct pn544_i2c_phy), |
380 | GFP_KERNEL); | ||
380 | if (!phy) { | 381 | if (!phy) { |
381 | dev_err(&client->dev, | 382 | dev_err(&client->dev, |
382 | "Cannot allocate memory for pn544 i2c phy.\n"); | 383 | "Cannot allocate memory for pn544 i2c phy.\n"); |
383 | r = -ENOMEM; | 384 | return -ENOMEM; |
384 | goto err_phy_alloc; | ||
385 | } | 385 | } |
386 | 386 | ||
387 | phy->i2c_dev = client; | 387 | phy->i2c_dev = client; |
@@ -390,20 +390,18 @@ static int __devinit pn544_hci_i2c_probe(struct i2c_client *client, | |||
390 | pdata = client->dev.platform_data; | 390 | pdata = client->dev.platform_data; |
391 | if (pdata == NULL) { | 391 | if (pdata == NULL) { |
392 | dev_err(&client->dev, "No platform data\n"); | 392 | dev_err(&client->dev, "No platform data\n"); |
393 | r = -EINVAL; | 393 | return -EINVAL; |
394 | goto err_pdata; | ||
395 | } | 394 | } |
396 | 395 | ||
397 | if (pdata->request_resources == NULL) { | 396 | if (pdata->request_resources == NULL) { |
398 | dev_err(&client->dev, "request_resources() missing\n"); | 397 | dev_err(&client->dev, "request_resources() missing\n"); |
399 | r = -EINVAL; | 398 | return -EINVAL; |
400 | goto err_pdata; | ||
401 | } | 399 | } |
402 | 400 | ||
403 | r = pdata->request_resources(client); | 401 | r = pdata->request_resources(client); |
404 | if (r) { | 402 | if (r) { |
405 | dev_err(&client->dev, "Cannot get platform resources\n"); | 403 | dev_err(&client->dev, "Cannot get platform resources\n"); |
406 | goto err_pdata; | 404 | return r; |
407 | } | 405 | } |
408 | 406 | ||
409 | phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE); | 407 | phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE); |
@@ -435,10 +433,6 @@ err_rti: | |||
435 | if (pdata->free_resources != NULL) | 433 | if (pdata->free_resources != NULL) |
436 | pdata->free_resources(); | 434 | pdata->free_resources(); |
437 | 435 | ||
438 | err_pdata: | ||
439 | kfree(phy); | ||
440 | |||
441 | err_phy_alloc: | ||
442 | return r; | 436 | return r; |
443 | } | 437 | } |
444 | 438 | ||
@@ -458,8 +452,6 @@ static __devexit int pn544_hci_i2c_remove(struct i2c_client *client) | |||
458 | if (pdata->free_resources) | 452 | if (pdata->free_resources) |
459 | pdata->free_resources(); | 453 | pdata->free_resources(); |
460 | 454 | ||
461 | kfree(phy); | ||
462 | |||
463 | return 0; | 455 | return 0; |
464 | } | 456 | } |
465 | 457 | ||