Commit ad0acfd6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller

NFC: nxp-nci: Get rid of code duplication in ->probe()

Since OF and ACPI case almost the same get rid of code duplication
by moving gpiod_get() calls directly to ->probe().
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 099d03f0
...@@ -256,48 +256,10 @@ static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = { ...@@ -256,48 +256,10 @@ static const struct acpi_gpio_mapping acpi_nxp_nci_gpios[] = {
{ } { }
}; };
static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
{
struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_en)) {
nfc_err(&client->dev, "Failed to get EN gpio\n");
return PTR_ERR(phy->gpiod_en);
}
phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_fw)) {
nfc_err(&client->dev, "Failed to get FW gpio\n");
return PTR_ERR(phy->gpiod_fw);
}
return 0;
}
static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
{
struct i2c_client *client = phy->i2c_dev;
int r;
r = devm_acpi_dev_add_driver_gpios(&client->dev, acpi_nxp_nci_gpios);
if (r)
return r;
phy->gpiod_en = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
phy->gpiod_fw = devm_gpiod_get(&client->dev, "firmware", GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
nfc_err(&client->dev, "No GPIOs\n");
return -EINVAL;
}
return 0;
}
static int nxp_nci_i2c_probe(struct i2c_client *client, static int nxp_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct nxp_nci_i2c_phy *phy; struct nxp_nci_i2c_phy *phy;
int r; int r;
...@@ -317,20 +279,20 @@ static int nxp_nci_i2c_probe(struct i2c_client *client, ...@@ -317,20 +279,20 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client; phy->i2c_dev = client;
i2c_set_clientdata(client, phy); i2c_set_clientdata(client, phy);
if (client->dev.of_node) { r = devm_acpi_dev_add_driver_gpios(dev, acpi_nxp_nci_gpios);
r = nxp_nci_i2c_parse_devtree(client); if (r)
if (r < 0) { return r;
nfc_err(&client->dev, "Failed to get DT data\n");
goto probe_exit; phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
} if (IS_ERR(phy->gpiod_en)) {
} else if (ACPI_HANDLE(&client->dev)) { nfc_err(dev, "Failed to get EN gpio\n");
r = nxp_nci_i2c_acpi_config(phy); return PTR_ERR(phy->gpiod_en);
if (r < 0) }
goto probe_exit;
} else { phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
nfc_err(&client->dev, "No platform data\n"); if (IS_ERR(phy->gpiod_fw)) {
r = -EINVAL; nfc_err(dev, "Failed to get FW gpio\n");
goto probe_exit; return PTR_ERR(phy->gpiod_fw);
} }
r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops, r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment