2017-06-19 10:09:17

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 00/13] NFC: clean up for ACPI GPIO usage

This clean up series to NFC drivers that are using GPIOs on ACPI enabled
platforms. Since GPIO ACPI library goes stricter about requesting
resources we need to amend drivers for that. Here we are for NFC
subsystem.

While doing above, get rid of legacy and unused platform data as well as
some artificial IDs.

Changelog v3:
- incorporate Samuel's fixes
- fix the bug kbuild bot complains about
- add MAINTAINERS patch

Changelog v2:
- add patches 1,4-12

Andy Shevchenko (13):
NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()
NFC: st21nfca: Add GPIO ACPI mapping table
NFC: st21nfca: Get rid of code duplication in ->probe()
NFC: fdp: Convert I2C driver to ->probe_new()
NFC: fdp: Convert to use devres API
NFC: fdp: Add GPIO ACPI mapping table
NFC: st-nci: Get rid of platform data
NFC: st-nci: Get rid of "interesting" use of interrupt polarity
NFC: st-nci: Covert to use GPIO descriptor
NFC: st-nci: Use unified device properties API meaningfully
NFC: st-nci: Add GPIO ACPI mapping table
NFC: st-nci: Get rid of code duplication in ->probe()
MAINTAINERS: Remove non-existing NFC platform data files

MAINTAINERS | 3 -
drivers/nfc/fdp/fdp.c | 15 +---
drivers/nfc/fdp/i2c.c | 38 ++++----
drivers/nfc/pn544/i2c.c | 3 +-
drivers/nfc/st-nci/i2c.c | 164 ++++++-----------------------------
drivers/nfc/st-nci/spi.c | 162 ++++++----------------------------
drivers/nfc/st21nfca/i2c.c | 62 ++++---------
include/linux/platform_data/st-nci.h | 31 -------
8 files changed, 90 insertions(+), 388 deletions(-)
delete mode 100644 include/linux/platform_data/st-nci.h

--
2.11.0


2017-06-19 10:09:10

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 06/13] NFC: fdp: Add GPIO ACPI mapping table

In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/fdp/i2c.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index c955f1f5139d..c4da50e07bbc 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -27,7 +27,6 @@

#define FDP_I2C_DRIVER_NAME "fdp_nci_i2c"

-#define FDP_DP_POWER_GPIO_NAME "power"
#define FDP_DP_CLOCK_TYPE_NAME "clock-type"
#define FDP_DP_CLOCK_FREQ_NAME "clock-freq"
#define FDP_DP_FW_VSC_CFG_NAME "fw-vsc-cfg"
@@ -281,6 +280,13 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
}

+static const struct acpi_gpio_params power_gpios = { 0, 0, false };
+
+static const struct acpi_gpio_mapping acpi_fdp_gpios[] = {
+ { "power-gpios", &power_gpios, 1 },
+ {},
+};
+
static int fdp_nci_i2c_probe(struct i2c_client *client)
{
struct fdp_i2c_phy *phy;
@@ -321,10 +327,12 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return r;
}

- /* Requesting the power gpio */
- phy->power_gpio = devm_gpiod_get(dev, FDP_DP_POWER_GPIO_NAME,
- GPIOD_OUT_LOW);
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_fdp_gpios);
+ if (r)
+ dev_dbg(dev, "Unable to add GPIO mapping table\n");

+ /* Requesting the power gpio */
+ phy->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW);
if (IS_ERR(phy->power_gpio)) {
nfc_err(dev, "Power GPIO request failed\n");
return PTR_ERR(phy->power_gpio);
--
2.11.0

2017-06-19 10:09:34

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 04/13] NFC: fdp: Convert I2C driver to ->probe_new()

There is no platform code that uses i2c module table.
Remove it altogether and adjust ->probe() to be ->probe_new().

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/fdp/i2c.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index e0baec848ff2..8a66b1845f27 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -281,8 +281,7 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
*clock_type, *clock_freq, *fw_vsc_cfg != NULL ? "yes" : "no");
}

-static int fdp_nci_i2c_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int fdp_nci_i2c_probe(struct i2c_client *client)
{
struct fdp_i2c_phy *phy;
struct device *dev = &client->dev;
@@ -360,12 +359,6 @@ static int fdp_nci_i2c_remove(struct i2c_client *client)
return 0;
}

-static struct i2c_device_id fdp_nci_i2c_id_table[] = {
- {"int339a", 0},
- {}
-};
-MODULE_DEVICE_TABLE(i2c, fdp_nci_i2c_id_table);
-
static const struct acpi_device_id fdp_nci_i2c_acpi_match[] = {
{"INT339A", 0},
{}
@@ -377,8 +370,7 @@ static struct i2c_driver fdp_nci_i2c_driver = {
.name = FDP_I2C_DRIVER_NAME,
.acpi_match_table = ACPI_PTR(fdp_nci_i2c_acpi_match),
},
- .id_table = fdp_nci_i2c_id_table,
- .probe = fdp_nci_i2c_probe,
+ .probe_new = fdp_nci_i2c_probe,
.remove = fdp_nci_i2c_remove,
};
module_i2c_driver(fdp_nci_i2c_driver);
--
2.11.0

2017-06-19 10:09:17

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 03/13] NFC: st21nfca: 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: Andy Shevchenko <[email protected]>
---
drivers/nfc/st21nfca/i2c.c | 62 ++++++++--------------------------------------
1 file changed, 10 insertions(+), 52 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 3621290807f6..cd1f7bfa75eb 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -61,8 +61,6 @@
#define ST21NFCA_HCI_DRIVER_NAME "st21nfca_hci"
#define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c"

-#define ST21NFCA_GPIO_NAME_EN "enable"
-
struct st21nfca_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;
@@ -508,44 +506,10 @@ static const struct acpi_gpio_mapping acpi_st21nfca_gpios[] = {
{},
};

-static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
-{
- struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
- int ret;
-
- ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
- if (ret)
- return ret;
-
- /* Get EN GPIO from ACPI */
- phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, GPIOD_OUT_LOW);
- if (IS_ERR(phy->gpiod_ena)) {
- nfc_err(dev, "Unable to get ENABLE GPIO\n");
- return PTR_ERR(phy->gpiod_ena);
- }
-
- return 0;
-}
-
-static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
-{
- struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
-
- /* Get GPIO from device tree */
- phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, GPIOD_OUT_HIGH);
- if (IS_ERR(phy->gpiod_ena)) {
- nfc_err(dev, "Failed to request enable pin\n");
- return PTR_ERR(phy->gpiod_ena);
- }
-
- return 0;
-}
-
static int st21nfca_hci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device *dev = &client->dev;
struct st21nfca_i2c_phy *phy;
int r;

@@ -572,21 +536,15 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
mutex_init(&phy->phy_lock);
i2c_set_clientdata(client, phy);

- if (client->dev.of_node) {
- r = st21nfca_hci_i2c_of_request_resources(client);
- if (r) {
- nfc_err(&client->dev, "No platform data\n");
- return r;
- }
- } else if (ACPI_HANDLE(&client->dev)) {
- r = st21nfca_hci_i2c_acpi_request_resources(client);
- if (r) {
- nfc_err(&client->dev, "Cannot get ACPI data\n");
- return r;
- }
- } else {
- nfc_err(&client->dev, "st21nfca platform resources not available\n");
- return -ENODEV;
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+ if (r)
+ dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+ /* Get EN GPIO from resource provider */
+ phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_ena)) {
+ nfc_err(dev, "Unable to get ENABLE GPIO\n");
+ return PTR_ERR(phy->gpiod_ena);
}

phy->se_status.is_ese_present =
--
2.11.0

2017-06-19 10:09:16

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 11/13] NFC: st-nci: Add GPIO ACPI mapping table

In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/st-nci/i2c.c | 17 +++++++++++++----
drivers/nfc/st-nci/spi.c | 17 +++++++++++++----
2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 2ee381586f14..edda253b07fe 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -40,8 +40,6 @@
#define ST_NCI_DRIVER_NAME "st_nci"
#define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"

-#define ST_NCI_GPIO_NAME_RESET "reset"
-
struct st_nci_i2c_phy {
struct i2c_client *i2c_dev;
struct llt_ndlc *ndlc;
@@ -205,14 +203,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st_nci_i2c_disable,
};

+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+ { "reset-gpios", &reset_gpios, 1 },
+ {},
+};
+
static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+ int r;
+
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+ if (r)
+ return r;

/* Get RESET GPIO from ACPI */
- phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
- 1, GPIOD_OUT_HIGH);
+ phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 383bf69163ef..99ecf92edc8c 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -41,8 +41,6 @@
#define ST_NCI_DRIVER_NAME "st_nci"
#define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"

-#define ST_NCI_GPIO_NAME_RESET "reset"
-
struct st_nci_spi_phy {
struct spi_device *spi_dev;
struct llt_ndlc *ndlc;
@@ -220,14 +218,25 @@ static struct nfc_phy_ops spi_phy_ops = {
.disable = st_nci_spi_disable,
};

+static const struct acpi_gpio_params reset_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
+ { "reset-gpios", &reset_gpios, 1 },
+ {},
+};
+
static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
{
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
+ int r;
+
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+ if (r)
+ return r;

/* Get RESET GPIO from ACPI */
- phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
- 1, GPIOD_OUT_HIGH);
+ phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return PTR_ERR(phy->gpiod_reset);
--
2.11.0

2017-06-19 10:09:10

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 05/13] 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 <[email protected]>
---
drivers/nfc/fdp/fdp.c | 15 ++++-----------
drivers/nfc/fdp/i2c.c | 10 +++++-----
2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
index badd8167ac73..ec50027b0d8b 100644
--- a/drivers/nfc/fdp/fdp.c
+++ b/drivers/nfc/fdp/fdp.c
@@ -749,11 +749,9 @@ int fdp_nci_probe(struct fdp_i2c_phy *phy, struct nfc_phy_ops *phy_ops,
u32 protocols;
int r;

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

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

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

err_regdev:
nci_free_device(ndev);
-err_alloc_ndev:
- kfree(info);
-err_info_alloc:
return r;
}
EXPORT_SYMBOL(fdp_nci_probe);
@@ -808,7 +802,6 @@ void fdp_nci_remove(struct nci_dev *ndev)

nci_unregister_device(ndev);
nci_free_device(ndev);
- kfree(info);
}
EXPORT_SYMBOL(fdp_nci_remove);

diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 8a66b1845f27..c955f1f5139d 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -303,8 +303,7 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
return -ENODEV;
}

- phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy),
- GFP_KERNEL);
+ phy = devm_kzalloc(dev, sizeof(struct fdp_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;

@@ -312,9 +311,10 @@ static int fdp_nci_i2c_probe(struct i2c_client *client)
phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
i2c_set_clientdata(client, phy);

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

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

2017-06-19 10:09:37

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 02/13] NFC: st21nfca: Add GPIO ACPI mapping table

In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/st21nfca/i2c.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 4bff76baa341..3621290807f6 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -501,14 +501,25 @@ static struct nfc_phy_ops i2c_phy_ops = {
.disable = st21nfca_hci_i2c_disable,
};

+static const struct acpi_gpio_params enable_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_st21nfca_gpios[] = {
+ { "enable-gpios", &enable_gpios, 1 },
+ {},
+};
+
static int st21nfca_hci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+ int ret;
+
+ ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st21nfca_gpios);
+ if (ret)
+ return ret;

/* Get EN GPIO from ACPI */
- phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 1,
- GPIOD_OUT_LOW);
+ phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Unable to get ENABLE GPIO\n");
return PTR_ERR(phy->gpiod_ena);
@@ -523,8 +534,7 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
struct device *dev = &client->dev;

/* Get GPIO from device tree */
- phy->gpiod_ena = devm_gpiod_get_index(dev, ST21NFCA_GPIO_NAME_EN, 0,
- GPIOD_OUT_HIGH);
+ phy->gpiod_ena = devm_gpiod_get(dev, ST21NFCA_GPIO_NAME_EN, GPIOD_OUT_HIGH);
if (IS_ERR(phy->gpiod_ena)) {
nfc_err(dev, "Failed to request enable pin\n");
return PTR_ERR(phy->gpiod_ena);
--
2.11.0

2017-06-19 10:09:50

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 10/13] NFC: st-nci: Use unified device properties API meaningfully

Use unified device properties API in meaningful way.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/st-nci/i2c.c | 30 ++++++------------------------
drivers/nfc/st-nci/spi.c | 29 +++++------------------------
2 files changed, 11 insertions(+), 48 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 93a621e27d4e..2ee381586f14 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -209,7 +209,6 @@ static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
- u8 tmp;

/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
@@ -219,19 +218,6 @@ static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
return -ENODEV;
}

- phy->se_status.is_ese_present = false;
- phy->se_status.is_uicc_present = false;
-
- if (device_property_present(dev, "ese-present")) {
- device_property_read_u8(dev, "ese-present", &tmp);
- phy->se_status.is_ese_present = tmp;
- }
-
- if (device_property_present(dev, "uicc-present")) {
- device_property_read_u8(dev, "uicc-present", &tmp);
- phy->se_status.is_uicc_present = tmp;
- }
-
return 0;
}

@@ -239,11 +225,6 @@ static int st_nci_i2c_of_request_resources(struct i2c_client *client)
{
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
- struct device_node *pp;
-
- pp = client->dev.of_node;
- if (!pp)
- return -ENODEV;

/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -252,17 +233,13 @@ static int st_nci_i2c_of_request_resources(struct i2c_client *client)
return PTR_ERR(phy->gpiod_reset);
}

- phy->se_status.is_ese_present =
- of_property_read_bool(pp, "ese-present");
- phy->se_status.is_uicc_present =
- of_property_read_bool(pp, "uicc-present");
-
return 0;
}

static int st_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device *dev = &client->dev;
struct st_nci_i2c_phy *phy;
int r;

@@ -301,6 +278,11 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}

+ phy->se_status.is_ese_present =
+ device_property_read_bool(dev, "ese-present");
+ phy->se_status.is_uicc_present =
+ device_property_read_bool(dev, "uicc-present");
+
r = ndlc_probe(phy, &i2c_phy_ops, &client->dev,
ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
&phy->ndlc, &phy->se_status);
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 2834f6984608..383bf69163ef 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -224,7 +224,6 @@ static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
{
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
struct device *dev = &spi_dev->dev;
- u8 tmp;

/* Get RESET GPIO from ACPI */
phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
@@ -234,19 +233,6 @@ static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
return PTR_ERR(phy->gpiod_reset);
}

- phy->se_status.is_ese_present = false;
- phy->se_status.is_uicc_present = false;
-
- if (device_property_present(dev, "ese-present")) {
- device_property_read_u8(dev, "ese-present", &tmp);
- tmp = phy->se_status.is_ese_present;
- }
-
- if (device_property_present(dev, "uicc-present")) {
- device_property_read_u8(dev, "uicc-present", &tmp);
- tmp = phy->se_status.is_uicc_present;
- }
-
return 0;
}

@@ -254,11 +240,6 @@ static int st_nci_spi_of_request_resources(struct spi_device *spi)
{
struct st_nci_spi_phy *phy = spi_get_drvdata(spi);
struct device *dev = &spi->dev;
- struct device_node *pp;
-
- pp = spi->dev.of_node;
- if (!pp)
- return -ENODEV;

/* Get GPIO from device tree */
phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
@@ -267,11 +248,6 @@ static int st_nci_spi_of_request_resources(struct spi_device *spi)
return PTR_ERR(phy->gpiod_reset);
}

- phy->se_status.is_ese_present =
- of_property_read_bool(pp, "ese-present");
- phy->se_status.is_uicc_present =
- of_property_read_bool(pp, "uicc-present");
-
return 0;
}

@@ -317,6 +293,11 @@ static int st_nci_spi_probe(struct spi_device *dev)
return -ENODEV;
}

+ phy->se_status.is_ese_present =
+ device_property_read_bool(&dev->dev, "ese-present");
+ phy->se_status.is_uicc_present =
+ device_property_read_bool(&dev->dev, "uicc-present");
+
r = ndlc_probe(phy, &spi_phy_ops, &dev->dev,
ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
&phy->ndlc, &phy->se_status);
--
2.11.0

2017-06-22 21:55:11

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH v3 00/13] NFC: clean up for ACPI GPIO usage

Hi Andy,

On Mon, Jun 19, 2017 at 01:08:45PM +0300, Andy Shevchenko wrote:
> This clean up series to NFC drivers that are using GPIOs on ACPI enabled
> platforms. Since GPIO ACPI library goes stricter about requesting
> resources we need to amend drivers for that. Here we are for NFC
> subsystem.
>
> While doing above, get rid of legacy and unused platform data as well as
> some artificial IDs.
>
> Changelog v3:
> - incorporate Samuel's fixes
> - fix the bug kbuild bot complains about
> - add MAINTAINERS patch
>
> Changelog v2:
> - add patches 1,4-12
>
> Andy Shevchenko (13):
> NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()
> NFC: st21nfca: Add GPIO ACPI mapping table
> NFC: st21nfca: Get rid of code duplication in ->probe()
> NFC: fdp: Convert I2C driver to ->probe_new()
> NFC: fdp: Convert to use devres API
> NFC: fdp: Add GPIO ACPI mapping table
> NFC: st-nci: Get rid of platform data
> NFC: st-nci: Get rid of "interesting" use of interrupt polarity
> NFC: st-nci: Covert to use GPIO descriptor
> NFC: st-nci: Use unified device properties API meaningfully
> NFC: st-nci: Add GPIO ACPI mapping table
> NFC: st-nci: Get rid of code duplication in ->probe()
> MAINTAINERS: Remove non-existing NFC platform data files
All patches applied, thanks.

Cheers,
Samuel.

2017-06-19 10:09:28

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 08/13] NFC: st-nci: Get rid of "interesting" use of interrupt polarity

I2C and SPI frameworks followed by IRQ framework do set
interrupt polarity correctly if it's properly specified in firmware
(ACPI or DT).

Get rid of the redundant trick when requesting interrupt.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/st-nci/i2c.c | 8 +-------
drivers/nfc/st-nci/spi.c | 8 +-------
2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 6d3d8e43fa50..bdfbd543e671 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -21,7 +21,6 @@
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
@@ -51,7 +50,6 @@ struct st_nci_i2c_phy {
bool irq_active;

unsigned int gpio_reset;
- unsigned int irq_polarity;

struct st_nci_se_status se_status;
};
@@ -225,8 +223,6 @@ static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)

phy->gpio_reset = desc_to_gpio(gpiod_reset);

- phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;

@@ -271,8 +267,6 @@ static int st_nci_i2c_of_request_resources(struct i2c_client *client)
}
phy->gpio_reset = gpio;

- phy->irq_polarity = irq_get_trigger_type(client->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -333,7 +327,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
phy->irq_active = true;
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
st_nci_irq_thread_fn,
- phy->irq_polarity | IRQF_ONESHOT,
+ IRQF_ONESHOT,
ST_NCI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&client->dev, "Unable to register IRQ handler\n");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index ee8ea708d5b7..4585e205778b 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -21,7 +21,6 @@
#include <linux/spi/spi.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
@@ -52,7 +51,6 @@ struct st_nci_spi_phy {
bool irq_active;

unsigned int gpio_reset;
- unsigned int irq_polarity;

struct st_nci_se_status se_status;
};
@@ -240,8 +238,6 @@ static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)

phy->gpio_reset = desc_to_gpio(gpiod_reset);

- phy->irq_polarity = irq_get_trigger_type(spi_dev->irq);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;

@@ -286,8 +282,6 @@ static int st_nci_spi_of_request_resources(struct spi_device *dev)
}
phy->gpio_reset = gpio;

- phy->irq_polarity = irq_get_trigger_type(dev->irq);
-
phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
phy->se_status.is_uicc_present =
@@ -349,7 +343,7 @@ static int st_nci_spi_probe(struct spi_device *dev)
phy->irq_active = true;
r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL,
st_nci_irq_thread_fn,
- phy->irq_polarity | IRQF_ONESHOT,
+ IRQF_ONESHOT,
ST_NCI_SPI_DRIVER_NAME, phy);
if (r < 0)
nfc_err(&dev->dev, "Unable to register IRQ handler\n");
--
2.11.0

2017-06-19 10:10:35

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 09/13] NFC: st-nci: Covert to use GPIO descriptor

Since we got rid of platform data, the driver may use GPIO descriptor
directly.

Looking deeply to the use of the GPIO pin it looks like it should be
a GPIO based reset control rather than custom GPIO handling. But this
is out of scope of the change.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/st-nci/i2c.c | 39 ++++++++++++---------------------------
drivers/nfc/st-nci/spi.c | 47 ++++++++++++++++-------------------------------
2 files changed, 28 insertions(+), 58 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index bdfbd543e671..93a621e27d4e 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -19,13 +19,12 @@

#include <linux/module.h>
#include <linux/i2c.h>
-#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_gpio.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/nfc.h>
+#include <linux/of.h>

#include "st-nci.h"

@@ -49,7 +48,7 @@ struct st_nci_i2c_phy {

bool irq_active;

- unsigned int gpio_reset;
+ struct gpio_desc *gpiod_reset;

struct st_nci_se_status se_status;
};
@@ -58,9 +57,9 @@ static int st_nci_i2c_enable(void *phy_id)
{
struct st_nci_i2c_phy *phy = phy_id;

- gpio_set_value(phy->gpio_reset, 0);
+ gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(10000, 15000);
- gpio_set_value(phy->gpio_reset, 1);
+ gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(80000, 85000);

if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -209,20 +208,17 @@ static struct nfc_phy_ops i2c_phy_ops = {
static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
- struct gpio_desc *gpiod_reset;
struct device *dev = &client->dev;
u8 tmp;

/* Get RESET GPIO from ACPI */
- gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1,
- GPIOD_OUT_HIGH);
- if (IS_ERR(gpiod_reset)) {
+ phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
+ 1, GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}

- phy->gpio_reset = desc_to_gpio(gpiod_reset);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;

@@ -242,30 +238,19 @@ static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
static int st_nci_i2c_of_request_resources(struct i2c_client *client)
{
struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
struct device_node *pp;
- int gpio;
- int r;

pp = client->dev.of_node;
if (!pp)
return -ENODEV;

/* Get GPIO from device tree */
- gpio = of_get_named_gpio(pp, "reset-gpios", 0);
- if (gpio < 0) {
- nfc_err(&client->dev,
- "Failed to retrieve reset-gpios from device tree\n");
- return gpio;
- }
-
- /* GPIO request and configuration */
- r = devm_gpio_request_one(&client->dev, gpio,
- GPIOF_OUT_INIT_HIGH, ST_NCI_GPIO_NAME_RESET);
- if (r) {
- nfc_err(&client->dev, "Failed to request reset pin\n");
- return r;
+ phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
+ nfc_err(dev, "Unable to get RESET GPIO\n");
+ return PTR_ERR(phy->gpiod_reset);
}
- phy->gpio_reset = gpio;

phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 4585e205778b..2834f6984608 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -19,13 +19,12 @@

#include <linux/module.h>
#include <linux/spi/spi.h>
-#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_gpio.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/nfc.h>
+#include <linux/of.h>
#include <net/nfc/nci.h>

#include "st-nci.h"
@@ -50,7 +49,7 @@ struct st_nci_spi_phy {

bool irq_active;

- unsigned int gpio_reset;
+ struct gpio_desc *gpiod_reset;

struct st_nci_se_status se_status;
};
@@ -59,9 +58,9 @@ static int st_nci_spi_enable(void *phy_id)
{
struct st_nci_spi_phy *phy = phy_id;

- gpio_set_value(phy->gpio_reset, 0);
+ gpiod_set_value(phy->gpiod_reset, 0);
usleep_range(10000, 15000);
- gpio_set_value(phy->gpio_reset, 1);
+ gpiod_set_value(phy->gpiod_reset, 1);
usleep_range(80000, 85000);

if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
@@ -224,20 +223,17 @@ static struct nfc_phy_ops spi_phy_ops = {
static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
{
struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
- struct gpio_desc *gpiod_reset;
struct device *dev = &spi_dev->dev;
u8 tmp;

/* Get RESET GPIO from ACPI */
- gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET, 1,
- GPIOD_OUT_HIGH);
- if (IS_ERR(gpiod_reset)) {
+ phy->gpiod_reset = devm_gpiod_get_index(dev, ST_NCI_GPIO_NAME_RESET,
+ 1, GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
nfc_err(dev, "Unable to get RESET GPIO\n");
- return -ENODEV;
+ return PTR_ERR(phy->gpiod_reset);
}

- phy->gpio_reset = desc_to_gpio(gpiod_reset);
-
phy->se_status.is_ese_present = false;
phy->se_status.is_uicc_present = false;

@@ -254,33 +250,22 @@ static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
return 0;
}

-static int st_nci_spi_of_request_resources(struct spi_device *dev)
+static int st_nci_spi_of_request_resources(struct spi_device *spi)
{
- struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
+ struct st_nci_spi_phy *phy = spi_get_drvdata(spi);
+ struct device *dev = &spi->dev;
struct device_node *pp;
- int gpio;
- int r;

- pp = dev->dev.of_node;
+ pp = spi->dev.of_node;
if (!pp)
return -ENODEV;

/* Get GPIO from device tree */
- gpio = of_get_named_gpio(pp, "reset-gpios", 0);
- if (gpio < 0) {
- nfc_err(&dev->dev,
- "Failed to retrieve reset-gpios from device tree\n");
- return gpio;
- }
-
- /* GPIO request and configuration */
- r = devm_gpio_request_one(&dev->dev, gpio,
- GPIOF_OUT_INIT_HIGH, ST_NCI_GPIO_NAME_RESET);
- if (r) {
- nfc_err(&dev->dev, "Failed to request reset pin\n");
- return r;
+ phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
+ nfc_err(dev, "Unable to get RESET GPIO\n");
+ return PTR_ERR(phy->gpiod_reset);
}
- phy->gpio_reset = gpio;

phy->se_status.is_ese_present =
of_property_read_bool(pp, "ese-present");
--
2.11.0

2017-06-19 10:09:22

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 01/13] NFC: pn544: Switch to devm_acpi_dev_add_driver_gpios()

Switch to use managed variant of acpi_dev_add_driver_gpios() to simplify
error path and fix potentially wrong assignment if ->probe() fails.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/nfc/pn544/i2c.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index fedde9d46ab6..4b14740edb67 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -904,7 +904,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);

- r = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_pn544_gpios);
if (r)
dev_dbg(dev, "Unable to add GPIO mapping table\n");

@@ -958,7 +958,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
if (phy->powered)
pn544_hci_i2c_disable(phy);

- acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
return 0;
}

--
2.11.0

2017-06-19 10:09:11

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 12/13] NFC: st-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: Andy Shevchenko <[email protected]>
---
drivers/nfc/st-nci/i2c.c | 61 +++++++-----------------------------------------
drivers/nfc/st-nci/spi.c | 60 +++++++----------------------------------------
2 files changed, 18 insertions(+), 103 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index edda253b07fe..515f08d037fb 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -210,41 +210,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
{},
};

-static int st_nci_i2c_acpi_request_resources(struct i2c_client *client)
-{
- struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
- int r;
-
- r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
- if (r)
- return r;
-
- /* Get RESET GPIO from ACPI */
- phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(phy->gpiod_reset)) {
- nfc_err(dev, "Unable to get RESET GPIO\n");
- return -ENODEV;
- }
-
- return 0;
-}
-
-static int st_nci_i2c_of_request_resources(struct i2c_client *client)
-{
- struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
-
- /* Get GPIO from device tree */
- phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(phy->gpiod_reset)) {
- nfc_err(dev, "Unable to get RESET GPIO\n");
- return PTR_ERR(phy->gpiod_reset);
- }
-
- return 0;
-}
-
static int st_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -260,8 +225,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}

- phy = devm_kzalloc(&client->dev, sizeof(struct st_nci_i2c_phy),
- GFP_KERNEL);
+ phy = devm_kzalloc(dev, sizeof(struct st_nci_i2c_phy), GFP_KERNEL);
if (!phy)
return -ENOMEM;

@@ -269,21 +233,14 @@ static int st_nci_i2c_probe(struct i2c_client *client,

i2c_set_clientdata(client, phy);

- if (client->dev.of_node) {
- r = st_nci_i2c_of_request_resources(client);
- if (r) {
- nfc_err(&client->dev, "No platform data\n");
- return r;
- }
- } else if (ACPI_HANDLE(&client->dev)) {
- r = st_nci_i2c_acpi_request_resources(client);
- if (r) {
- nfc_err(&client->dev, "Cannot get ACPI data\n");
- return r;
- }
- } else {
- nfc_err(&client->dev,
- "st_nci platform resources not available\n");
+ r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
+ if (r)
+ dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+ /* Get RESET GPIO */
+ phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
+ nfc_err(dev, "Unable to get RESET GPIO\n");
return -ENODEV;
}

diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 99ecf92edc8c..14705591b0fb 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -225,41 +225,6 @@ static const struct acpi_gpio_mapping acpi_st_nci_gpios[] = {
{},
};

-static int st_nci_spi_acpi_request_resources(struct spi_device *spi_dev)
-{
- struct st_nci_spi_phy *phy = spi_get_drvdata(spi_dev);
- struct device *dev = &spi_dev->dev;
- int r;
-
- r = devm_acpi_dev_add_driver_gpios(dev, acpi_st_nci_gpios);
- if (r)
- return r;
-
- /* Get RESET GPIO from ACPI */
- phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(phy->gpiod_reset)) {
- nfc_err(dev, "Unable to get RESET GPIO\n");
- return PTR_ERR(phy->gpiod_reset);
- }
-
- return 0;
-}
-
-static int st_nci_spi_of_request_resources(struct spi_device *spi)
-{
- struct st_nci_spi_phy *phy = spi_get_drvdata(spi);
- struct device *dev = &spi->dev;
-
- /* Get GPIO from device tree */
- phy->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(phy->gpiod_reset)) {
- nfc_err(dev, "Unable to get RESET GPIO\n");
- return PTR_ERR(phy->gpiod_reset);
- }
-
- return 0;
-}
-
static int st_nci_spi_probe(struct spi_device *dev)
{
struct st_nci_spi_phy *phy;
@@ -284,22 +249,15 @@ static int st_nci_spi_probe(struct spi_device *dev)

spi_set_drvdata(dev, phy);

- if (dev->dev.of_node) {
- r = st_nci_spi_of_request_resources(dev);
- if (r) {
- nfc_err(&dev->dev, "No platform data\n");
- return r;
- }
- } else if (ACPI_HANDLE(&dev->dev)) {
- r = st_nci_spi_acpi_request_resources(dev);
- if (r) {
- nfc_err(&dev->dev, "Cannot get ACPI data\n");
- return r;
- }
- } else {
- nfc_err(&dev->dev,
- "st_nci platform resources not available\n");
- return -ENODEV;
+ r = devm_acpi_dev_add_driver_gpios(&dev->dev, acpi_st_nci_gpios);
+ if (r)
+ dev_dbg(&dev->dev, "Unable to add GPIO mapping table\n");
+
+ /* Get RESET GPIO */
+ phy->gpiod_reset = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(phy->gpiod_reset)) {
+ nfc_err(&dev->dev, "Unable to get RESET GPIO\n");
+ return PTR_ERR(phy->gpiod_reset);
}

phy->se_status.is_ese_present =
--
2.11.0

2017-06-19 10:09:24

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 13/13] MAINTAINERS: Remove non-existing NFC platform data files

There are no longer platform data files for NFC drivers.
Remove it from MAINTAINERS data base.

Signed-off-by: Andy Shevchenko <[email protected]>
---
MAINTAINERS | 2 --
1 file changed, 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6f2d96313230..6b6079ad91f4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9175,8 +9175,6 @@ F: include/uapi/linux/nfc.h
F: drivers/nfc/
F: include/linux/platform_data/nfcmrvl.h
F: include/linux/platform_data/nxp-nci.h
-F: include/linux/platform_data/pn544.h
-F: include/linux/platform_data/st21nfca.h
F: Documentation/devicetree/bindings/net/nfc/

NFS, SUNRPC, AND LOCKD CLIENTS
--
2.11.0

2017-06-19 10:09:13

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v3 07/13] NFC: st-nci: Get rid of platform data

Legacy platform data must go away. We are on the safe side here since
there are no users of it in the kernel.

If anyone by any odd reason needs it the GPIO lookup tables and
built-in device properties at your service.

Signed-off-by: Andy Shevchenko <[email protected]>
---
MAINTAINERS | 1 -
drivers/nfc/st-nci/i2c.c | 43 ++----------------------------------
drivers/nfc/st-nci/spi.c | 43 ++----------------------------------
include/linux/platform_data/st-nci.h | 31 --------------------------
4 files changed, 4 insertions(+), 114 deletions(-)
delete mode 100644 include/linux/platform_data/st-nci.h

diff --git a/MAINTAINERS b/MAINTAINERS
index e3d41ceaf20d..6f2d96313230 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9177,7 +9177,6 @@ F: include/linux/platform_data/nfcmrvl.h
F: include/linux/platform_data/nxp-nci.h
F: include/linux/platform_data/pn544.h
F: include/linux/platform_data/st21nfca.h
-F: include/linux/platform_data/st-nci.h
F: Documentation/devicetree/bindings/net/nfc/

NFS, SUNRPC, AND LOCKD CLIENTS
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 9dfae0efa922..6d3d8e43fa50 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -27,7 +27,6 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/nfc.h>
-#include <linux/platform_data/st-nci.h>

#include "st-nci.h"

@@ -40,6 +39,7 @@
#define ST_NCI_I2C_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
#define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */

+#define ST_NCI_DRIVER_NAME "st_nci"
#define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"

#define ST_NCI_GPIO_NAME_RESET "reset"
@@ -281,41 +281,10 @@ static int st_nci_i2c_of_request_resources(struct i2c_client *client)
return 0;
}

-static int st_nci_i2c_request_resources(struct i2c_client *client)
-{
- struct st_nci_nfc_platform_data *pdata;
- struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
- int r;
-
- pdata = client->dev.platform_data;
- if (pdata == NULL) {
- nfc_err(&client->dev, "No platform data\n");
- return -EINVAL;
- }
-
- /* store for later use */
- phy->gpio_reset = pdata->gpio_reset;
- phy->irq_polarity = pdata->irq_polarity;
-
- r = devm_gpio_request_one(&client->dev,
- phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
- ST_NCI_GPIO_NAME_RESET);
- if (r) {
- pr_err("%s : reset gpio_request failed\n", __FILE__);
- return r;
- }
-
- phy->se_status.is_ese_present = pdata->is_ese_present;
- phy->se_status.is_uicc_present = pdata->is_uicc_present;
-
- return 0;
-}
-
static int st_nci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct st_nci_i2c_phy *phy;
- struct st_nci_nfc_platform_data *pdata;
int r;

dev_dbg(&client->dev, "%s\n", __func__);
@@ -335,20 +304,12 @@ static int st_nci_i2c_probe(struct i2c_client *client,

i2c_set_clientdata(client, phy);

- pdata = client->dev.platform_data;
- if (!pdata && client->dev.of_node) {
+ if (client->dev.of_node) {
r = st_nci_i2c_of_request_resources(client);
if (r) {
nfc_err(&client->dev, "No platform data\n");
return r;
}
- } else if (pdata) {
- r = st_nci_i2c_request_resources(client);
- if (r) {
- nfc_err(&client->dev,
- "Cannot get platform resources\n");
- return r;
- }
} else if (ACPI_HANDLE(&client->dev)) {
r = st_nci_i2c_acpi_request_resources(client);
if (r) {
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 89e341eba3eb..ee8ea708d5b7 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -28,7 +28,6 @@
#include <linux/delay.h>
#include <linux/nfc.h>
#include <net/nfc/nci.h>
-#include <linux/platform_data/st-nci.h>

#include "st-nci.h"

@@ -41,6 +40,7 @@
#define ST_NCI_SPI_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
#define ST_NCI_SPI_MAX_SIZE 250 /* req 4.2.1 */

+#define ST_NCI_DRIVER_NAME "st_nci"
#define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"

#define ST_NCI_GPIO_NAME_RESET "reset"
@@ -296,40 +296,9 @@ static int st_nci_spi_of_request_resources(struct spi_device *dev)
return 0;
}

-static int st_nci_spi_request_resources(struct spi_device *dev)
-{
- struct st_nci_nfc_platform_data *pdata;
- struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
- int r;
-
- pdata = dev->dev.platform_data;
- if (pdata == NULL) {
- nfc_err(&dev->dev, "No platform data\n");
- return -EINVAL;
- }
-
- /* store for later use */
- phy->gpio_reset = pdata->gpio_reset;
- phy->irq_polarity = pdata->irq_polarity;
-
- r = devm_gpio_request_one(&dev->dev,
- phy->gpio_reset, GPIOF_OUT_INIT_HIGH,
- ST_NCI_GPIO_NAME_RESET);
- if (r) {
- pr_err("%s : reset gpio_request failed\n", __FILE__);
- return r;
- }
-
- phy->se_status.is_ese_present = pdata->is_ese_present;
- phy->se_status.is_uicc_present = pdata->is_uicc_present;
-
- return 0;
-}
-
static int st_nci_spi_probe(struct spi_device *dev)
{
struct st_nci_spi_phy *phy;
- struct st_nci_nfc_platform_data *pdata;
int r;

dev_dbg(&dev->dev, "%s\n", __func__);
@@ -351,20 +320,12 @@ static int st_nci_spi_probe(struct spi_device *dev)

spi_set_drvdata(dev, phy);

- pdata = dev->dev.platform_data;
- if (!pdata && dev->dev.of_node) {
+ if (dev->dev.of_node) {
r = st_nci_spi_of_request_resources(dev);
if (r) {
nfc_err(&dev->dev, "No platform data\n");
return r;
}
- } else if (pdata) {
- r = st_nci_spi_request_resources(dev);
- if (r) {
- nfc_err(&dev->dev,
- "Cannot get platform resources\n");
- return r;
- }
} else if (ACPI_HANDLE(&dev->dev)) {
r = st_nci_spi_acpi_request_resources(dev);
if (r) {
diff --git a/include/linux/platform_data/st-nci.h b/include/linux/platform_data/st-nci.h
deleted file mode 100644
index f6494b347c06..000000000000
--- a/include/linux/platform_data/st-nci.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Driver include for ST NCI NFC chip family.
- *
- * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _ST_NCI_H_
-#define _ST_NCI_H_
-
-#define ST_NCI_DRIVER_NAME "st_nci"
-
-struct st_nci_nfc_platform_data {
- unsigned int gpio_reset;
- unsigned int irq_polarity;
- bool is_ese_present;
- bool is_uicc_present;
-};
-
-#endif /* _ST_NCI_H_ */
--
2.11.0