NFC: pn544: Use devm_kzalloc API
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
234d4d6b10
commit
a0f36536ac
1 changed files with 6 additions and 14 deletions
|
@ -376,12 +376,12 @@ static int __devinit pn544_hci_i2c_probe(struct i2c_client *client,
|
||||||
return -ENODEV;
|
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) {
|
if (!phy) {
|
||||||
dev_err(&client->dev,
|
dev_err(&client->dev,
|
||||||
"Cannot allocate memory for pn544 i2c phy.\n");
|
"Cannot allocate memory for pn544 i2c phy.\n");
|
||||||
r = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_phy_alloc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
phy->i2c_dev = client;
|
phy->i2c_dev = client;
|
||||||
|
@ -390,20 +390,18 @@ static int __devinit pn544_hci_i2c_probe(struct i2c_client *client,
|
||||||
pdata = client->dev.platform_data;
|
pdata = client->dev.platform_data;
|
||||||
if (pdata == NULL) {
|
if (pdata == NULL) {
|
||||||
dev_err(&client->dev, "No platform data\n");
|
dev_err(&client->dev, "No platform data\n");
|
||||||
r = -EINVAL;
|
return -EINVAL;
|
||||||
goto err_pdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdata->request_resources == NULL) {
|
if (pdata->request_resources == NULL) {
|
||||||
dev_err(&client->dev, "request_resources() missing\n");
|
dev_err(&client->dev, "request_resources() missing\n");
|
||||||
r = -EINVAL;
|
return -EINVAL;
|
||||||
goto err_pdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = pdata->request_resources(client);
|
r = pdata->request_resources(client);
|
||||||
if (r) {
|
if (r) {
|
||||||
dev_err(&client->dev, "Cannot get platform resources\n");
|
dev_err(&client->dev, "Cannot get platform resources\n");
|
||||||
goto err_pdata;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
|
phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
|
||||||
|
@ -435,10 +433,6 @@ err_rti:
|
||||||
if (pdata->free_resources != NULL)
|
if (pdata->free_resources != NULL)
|
||||||
pdata->free_resources();
|
pdata->free_resources();
|
||||||
|
|
||||||
err_pdata:
|
|
||||||
kfree(phy);
|
|
||||||
|
|
||||||
err_phy_alloc:
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,8 +452,6 @@ static __devexit int pn544_hci_i2c_remove(struct i2c_client *client)
|
||||||
if (pdata->free_resources)
|
if (pdata->free_resources)
|
||||||
pdata->free_resources();
|
pdata->free_resources();
|
||||||
|
|
||||||
kfree(phy);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue