* [PATCH v3 2/5] NFC: pn544: Covert to use GPIO descriptor
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
@ 2017-03-28 9:36 ` Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 3/5] NFC: pn544: Convert to use devm_request_threaded_irq() Andy Shevchenko
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-28 9:36 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, Mika Westerberg
Cc: Andy Shevchenko
Since we got rid of platform data, the driver may use
GPIO descriptor directly.
This change fixes a potential issue of double freeing GPIOs in ACPI
case by converting to devm_gpiod_get().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3: no change
drivers/nfc/pn544/i2c.c | 126 +++++++++++++-----------------------------------
1 file changed, 33 insertions(+), 93 deletions(-)
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 41e518ee148e..b4001306aff8 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -21,9 +21,6 @@
#include <linux/crc-ccitt.h>
#include <linux/module.h>
#include <linux/i2c.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <linux/of_irq.h>
#include <linux/acpi.h>
#include <linux/miscdevice.h>
#include <linux/interrupt.h>
@@ -165,8 +162,9 @@ struct pn544_i2c_phy {
struct i2c_client *i2c_dev;
struct nfc_hci_dev *hdev;
- unsigned int gpio_en;
- unsigned int gpio_fw;
+ struct gpio_desc *gpiod_en;
+ struct gpio_desc *gpiod_fw;
+
unsigned int en_polarity;
u8 hw_variant;
@@ -208,19 +206,18 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
nfc_info(&phy->i2c_dev->dev, "Detecting nfc_en polarity\n");
/* Disable fw download */
- gpio_set_value_cansleep(phy->gpio_fw, 0);
+ gpiod_set_value_cansleep(phy->gpiod_fw, 0);
for (polarity = 0; polarity < 2; polarity++) {
phy->en_polarity = polarity;
retry = 3;
while (retry--) {
/* power off */
- gpio_set_value_cansleep(phy->gpio_en,
- !phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
usleep_range(10000, 15000);
/* power on */
- gpio_set_value_cansleep(phy->gpio_en, phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_en, phy->en_polarity);
usleep_range(10000, 15000);
/* send reset */
@@ -239,14 +236,13 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
"Could not detect nfc_en polarity, fallback to active high\n");
out:
- gpio_set_value_cansleep(phy->gpio_en, !phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
}
static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)
{
- gpio_set_value_cansleep(phy->gpio_fw,
- run_mode == PN544_FW_MODE ? 1 : 0);
- gpio_set_value_cansleep(phy->gpio_en, phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_fw, run_mode == PN544_FW_MODE ? 1 : 0);
+ gpiod_set_value_cansleep(phy->gpiod_en, phy->en_polarity);
usleep_range(10000, 15000);
phy->run_mode = run_mode;
@@ -269,14 +265,14 @@ static void pn544_hci_i2c_disable(void *phy_id)
{
struct pn544_i2c_phy *phy = phy_id;
- gpio_set_value_cansleep(phy->gpio_fw, 0);
- gpio_set_value_cansleep(phy->gpio_en, !phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_fw, 0);
+ gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
usleep_range(10000, 15000);
- gpio_set_value_cansleep(phy->gpio_en, phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_en, phy->en_polarity);
usleep_range(10000, 15000);
- gpio_set_value_cansleep(phy->gpio_en, !phy->en_polarity);
+ gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
usleep_range(10000, 15000);
phy->powered = 0;
@@ -877,96 +873,47 @@ static void pn544_hci_i2c_fw_work(struct work_struct *work)
static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
- struct gpio_desc *gpiod_en, *gpiod_fw;
struct device *dev = &client->dev;
/* Get EN GPIO from ACPI */
- gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1,
- GPIOD_OUT_LOW);
- if (IS_ERR(gpiod_en)) {
+ phy->gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_en)) {
nfc_err(dev, "Unable to get EN GPIO\n");
- return -ENODEV;
+ return PTR_ERR(phy->gpiod_en);
}
- phy->gpio_en = desc_to_gpio(gpiod_en);
-
/* Get FW GPIO from ACPI */
- gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2,
- GPIOD_OUT_LOW);
- if (IS_ERR(gpiod_fw)) {
+ phy->gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_fw)) {
nfc_err(dev, "Unable to get FW GPIO\n");
- return -ENODEV;
+ return PTR_ERR(phy->gpiod_fw);
}
- phy->gpio_fw = desc_to_gpio(gpiod_fw);
-
return 0;
}
static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
{
struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
- struct device_node *pp;
- int ret;
-
- pp = client->dev.of_node;
- if (!pp) {
- ret = -ENODEV;
- goto err_dt;
- }
-
- /* Obtention of EN GPIO from device tree */
- ret = of_get_named_gpio(pp, "enable-gpios", 0);
- if (ret < 0) {
- if (ret != -EPROBE_DEFER)
- nfc_err(&client->dev,
- "Failed to get EN gpio, error: %d\n", ret);
- goto err_dt;
- }
- phy->gpio_en = ret;
-
- /* Configuration of EN GPIO */
- ret = gpio_request(phy->gpio_en, PN544_GPIO_NAME_EN);
- if (ret) {
- nfc_err(&client->dev, "Fail EN pin\n");
- goto err_dt;
- }
- ret = gpio_direction_output(phy->gpio_en, 0);
- if (ret) {
- nfc_err(&client->dev, "Fail EN pin direction\n");
- goto err_gpio_en;
- }
+ struct device *dev = &client->dev;
- /* Obtention of FW GPIO from device tree */
- ret = of_get_named_gpio(pp, "firmware-gpios", 0);
- if (ret < 0) {
- if (ret != -EPROBE_DEFER)
- nfc_err(&client->dev,
- "Failed to get FW gpio, error: %d\n", ret);
- goto err_gpio_en;
+ /* Obtaining EN GPIO from device tree */
+ phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_en)) {
+ nfc_err(dev, "Failed to get EN gpio\n");
+ return PTR_ERR(phy->gpiod_en);
}
- phy->gpio_fw = ret;
- /* Configuration of FW GPIO */
- ret = gpio_request(phy->gpio_fw, PN544_GPIO_NAME_FW);
- if (ret) {
- nfc_err(&client->dev, "Fail FW pin\n");
- goto err_gpio_en;
- }
- ret = gpio_direction_output(phy->gpio_fw, 0);
- if (ret) {
- nfc_err(&client->dev, "Fail FW pin direction\n");
- goto err_gpio_fw;
+ /* Obtaining FW GPIO from device tree */
+ phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_fw)) {
+ nfc_err(dev, "Failed to get FW gpio\n");
+ return PTR_ERR(phy->gpiod_fw);
}
return 0;
-
-err_gpio_fw:
- gpio_free(phy->gpio_fw);
-err_gpio_en:
- gpio_free(phy->gpio_en);
-err_dt:
- return ret;
}
static int pn544_hci_i2c_probe(struct i2c_client *client,
@@ -1021,7 +968,7 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
PN544_HCI_I2C_DRIVER_NAME, phy);
if (r < 0) {
nfc_err(&client->dev, "Unable to register IRQ handler\n");
- goto err_rti;
+ return r;
}
r = pn544_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
@@ -1036,10 +983,6 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
err_hci:
free_irq(client->irq, phy);
-err_rti:
- gpio_free(phy->gpio_en);
- gpio_free(phy->gpio_fw);
-
return r;
}
@@ -1060,9 +1003,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
free_irq(client->irq, phy);
- gpio_free(phy->gpio_en);
- gpio_free(phy->gpio_fw);
-
return 0;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/5] NFC: pn544: Convert to use devm_request_threaded_irq()
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 2/5] NFC: pn544: Covert to use GPIO descriptor Andy Shevchenko
@ 2017-03-28 9:36 ` Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 4/5] NFC: pn544: Add GPIO ACPI mapping table Andy Shevchenko
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-28 9:36 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, Mika Westerberg
Cc: Andy Shevchenko
The error handling will be neat and short when using managed resources.
Convert the driver to use devm_request_threaded_irq().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3: no change
drivers/nfc/pn544/i2c.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index b4001306aff8..5e780e7a28e5 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -963,9 +963,10 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
pn544_hci_i2c_platform_init(phy);
- r = request_threaded_irq(client->irq, NULL, pn544_hci_i2c_irq_thread_fn,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- PN544_HCI_I2C_DRIVER_NAME, phy);
+ r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+ pn544_hci_i2c_irq_thread_fn,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ PN544_HCI_I2C_DRIVER_NAME, phy);
if (r < 0) {
nfc_err(&client->dev, "Unable to register IRQ handler\n");
return r;
@@ -976,14 +977,9 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
PN544_HCI_I2C_LLC_MAX_PAYLOAD,
pn544_hci_i2c_fw_download, &phy->hdev);
if (r < 0)
- goto err_hci;
+ return r;
return 0;
-
-err_hci:
- free_irq(client->irq, phy);
-
- return r;
}
static int pn544_hci_i2c_remove(struct i2c_client *client)
@@ -1001,8 +997,6 @@ static int pn544_hci_i2c_remove(struct i2c_client *client)
if (phy->powered)
pn544_hci_i2c_disable(phy);
- free_irq(client->irq, phy);
-
return 0;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/5] NFC: pn544: Add GPIO ACPI mapping table
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 2/5] NFC: pn544: Covert to use GPIO descriptor Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 3/5] NFC: pn544: Convert to use devm_request_threaded_irq() Andy Shevchenko
@ 2017-03-28 9:36 ` Andy Shevchenko
2017-03-28 9:36 ` [PATCH v3 5/5] NFC: pn544: Get rid of code duplication in ->probe() Andy Shevchenko
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-28 9:36 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, Mika Westerberg
Cc: Andy Shevchenko
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 <andriy.shevchenko@linux.intel.com>
---
v3: no change
drivers/nfc/pn544/i2c.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 5e780e7a28e5..6226d220f1d0 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -870,22 +870,34 @@ static void pn544_hci_i2c_fw_work(struct work_struct *work)
}
}
+static const struct acpi_gpio_params enable_gpios = { 1, 0, false };
+static const struct acpi_gpio_params firmware_gpios = { 2, 0, false };
+
+static const struct acpi_gpio_mapping acpi_pn544_gpios[] = {
+ { "enable-gpios", &enable_gpios, 1 },
+ { "firmware-gpios", &firmware_gpios, 1 },
+ { },
+};
+
static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
{
struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
struct device *dev = &client->dev;
+ int ret;
+
+ ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
+ if (ret)
+ return ret;
/* Get EN GPIO from ACPI */
- phy->gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1,
- GPIOD_OUT_LOW);
+ phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_en)) {
nfc_err(dev, "Unable to get EN GPIO\n");
return PTR_ERR(phy->gpiod_en);
}
/* Get FW GPIO from ACPI */
- phy->gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2,
- GPIOD_OUT_LOW);
+ phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
if (IS_ERR(phy->gpiod_fw)) {
nfc_err(dev, "Unable to get FW GPIO\n");
return PTR_ERR(phy->gpiod_fw);
@@ -997,6 +1009,7 @@ 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/5] NFC: pn544: Get rid of code duplication in ->probe()
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
` (2 preceding siblings ...)
2017-03-28 9:36 ` [PATCH v3 4/5] NFC: pn544: Add GPIO ACPI mapping table Andy Shevchenko
@ 2017-03-28 9:36 ` Andy Shevchenko
2017-04-04 16:15 ` [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
2017-04-05 8:06 ` Samuel Ortiz
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-28 9:36 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, Mika Westerberg
Cc: Andy Shevchenko
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 <andriy.shevchenko@linux.intel.com>
---
v3: use dev_dbg() instead of nfc_dbg()
drivers/nfc/pn544/i2c.c | 84 ++++++++++---------------------------------------
1 file changed, 17 insertions(+), 67 deletions(-)
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 6226d220f1d0..7a2910f12aab 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -879,58 +879,10 @@ static const struct acpi_gpio_mapping acpi_pn544_gpios[] = {
{ },
};
-static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
-{
- struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
- int ret;
-
- ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
- if (ret)
- return ret;
-
- /* Get EN GPIO from ACPI */
- phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
- if (IS_ERR(phy->gpiod_en)) {
- nfc_err(dev, "Unable to get EN GPIO\n");
- return PTR_ERR(phy->gpiod_en);
- }
-
- /* Get FW GPIO from ACPI */
- phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
- if (IS_ERR(phy->gpiod_fw)) {
- nfc_err(dev, "Unable to get FW GPIO\n");
- return PTR_ERR(phy->gpiod_fw);
- }
-
- return 0;
-}
-
-static int pn544_hci_i2c_of_request_resources(struct i2c_client *client)
-{
- struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
- struct device *dev = &client->dev;
-
- /* Obtaining EN GPIO from device tree */
- phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
- if (IS_ERR(phy->gpiod_en)) {
- nfc_err(dev, "Failed to get EN gpio\n");
- return PTR_ERR(phy->gpiod_en);
- }
-
- /* Obtaining FW GPIO from device tree */
- phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
- if (IS_ERR(phy->gpiod_fw)) {
- nfc_err(dev, "Failed to get FW gpio\n");
- return PTR_ERR(phy->gpiod_fw);
- }
-
- return 0;
-}
-
static int pn544_hci_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device *dev = &client->dev;
struct pn544_i2c_phy *phy;
int r = 0;
@@ -953,24 +905,22 @@ static int pn544_hci_i2c_probe(struct i2c_client *client,
phy->i2c_dev = client;
i2c_set_clientdata(client, phy);
- /* No platform data, using device tree. */
- if (client->dev.of_node) {
- r = pn544_hci_i2c_of_request_resources(client);
- if (r) {
- nfc_err(&client->dev, "No DT data\n");
- return r;
- }
- /* Using ACPI */
- } else if (ACPI_HANDLE(&client->dev)) {
- r = pn544_hci_i2c_acpi_request_resources(client);
- if (r) {
- nfc_err(&client->dev,
- "Cannot get ACPI data\n");
- return r;
- }
- } else {
- nfc_err(&client->dev, "No platform data\n");
- return -EINVAL;
+ r = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_pn544_gpios);
+ if (r)
+ dev_dbg(dev, "Unable to add GPIO mapping table\n");
+
+ /* Get EN GPIO */
+ phy->gpiod_en = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_en)) {
+ nfc_err(dev, "Unable to get EN GPIO\n");
+ return PTR_ERR(phy->gpiod_en);
+ }
+
+ /* Get FW GPIO */
+ phy->gpiod_fw = devm_gpiod_get(dev, "firmware", GPIOD_OUT_LOW);
+ if (IS_ERR(phy->gpiod_fw)) {
+ nfc_err(dev, "Unable to get FW GPIO\n");
+ return PTR_ERR(phy->gpiod_fw);
}
pn544_hci_i2c_platform_init(phy);
--
2.11.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/5] NFC: pn544: Get rid of platform data
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
` (3 preceding siblings ...)
2017-03-28 9:36 ` [PATCH v3 5/5] NFC: pn544: Get rid of code duplication in ->probe() Andy Shevchenko
@ 2017-04-04 16:15 ` Andy Shevchenko
2017-04-05 8:06 ` Samuel Ortiz
5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-04-04 16:15 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
linux-wireless, Mika Westerberg
On Tue, 2017-03-28 at 12:36 +0300, Andy Shevchenko wrote:
> 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.
>
Samuel, anything I need to address?
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v3: no change
>
> drivers/nfc/pn544/i2c.c | 43 ++++++--------------------
> -----------
> include/linux/platform_data/pn544.h | 43 ----------------------------
> ---------
> 2 files changed, 6 insertions(+), 80 deletions(-)
> delete mode 100644 include/linux/platform_data/pn544.h
>
> diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
> index f837c39a8017..41e518ee148e 100644
> --- a/drivers/nfc/pn544/i2c.c
> +++ b/drivers/nfc/pn544/i2c.c
> @@ -31,7 +31,7 @@
> #include <linux/nfc.h>
> #include <linux/firmware.h>
> #include <linux/gpio/consumer.h>
> -#include <linux/platform_data/pn544.h>
> +
> #include <asm/unaligned.h>
>
> #include <net/nfc/hci.h>
> @@ -973,7 +973,6 @@ static int pn544_hci_i2c_probe(struct i2c_client
> *client,
> const struct i2c_device_id *id)
> {
> struct pn544_i2c_phy *phy;
> - struct pn544_nfc_platform_data *pdata;
> int r = 0;
>
> dev_dbg(&client->dev, "%s\n", __func__);
> @@ -995,32 +994,13 @@ static int pn544_hci_i2c_probe(struct i2c_client
> *client,
> phy->i2c_dev = client;
> i2c_set_clientdata(client, phy);
>
> - pdata = client->dev.platform_data;
> -
> /* No platform data, using device tree. */
> - if (!pdata && client->dev.of_node) {
> + if (client->dev.of_node) {
> r = pn544_hci_i2c_of_request_resources(client);
> if (r) {
> nfc_err(&client->dev, "No DT data\n");
> return r;
> }
> - /* Using platform data. */
> - } else if (pdata) {
> -
> - if (pdata->request_resources == NULL) {
> - nfc_err(&client->dev, "request_resources()
> missing\n");
> - return -EINVAL;
> - }
> -
> - r = pdata->request_resources(client);
> - if (r) {
> - nfc_err(&client->dev,
> - "Cannot get platform resources\n");
> - return r;
> - }
> -
> - phy->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
> - phy->gpio_fw = pdata->get_gpio(NFC_GPIO_FW_RESET);
> /* Using ACPI */
> } else if (ACPI_HANDLE(&client->dev)) {
> r = pn544_hci_i2c_acpi_request_resources(client);
> @@ -1057,12 +1037,8 @@ static int pn544_hci_i2c_probe(struct
> i2c_client *client,
> free_irq(client->irq, phy);
>
> err_rti:
> - if (!pdata) {
> - gpio_free(phy->gpio_en);
> - gpio_free(phy->gpio_fw);
> - } else if (pdata->free_resources) {
> - pdata->free_resources();
> - }
> + gpio_free(phy->gpio_en);
> + gpio_free(phy->gpio_fw);
>
> return r;
> }
> @@ -1070,7 +1046,6 @@ static int pn544_hci_i2c_probe(struct i2c_client
> *client,
> static int pn544_hci_i2c_remove(struct i2c_client *client)
> {
> struct pn544_i2c_phy *phy = i2c_get_clientdata(client);
> - struct pn544_nfc_platform_data *pdata = client-
> >dev.platform_data;
>
> dev_dbg(&client->dev, "%s\n", __func__);
>
> @@ -1085,14 +1060,8 @@ static int pn544_hci_i2c_remove(struct
> i2c_client *client)
>
> free_irq(client->irq, phy);
>
> - /* No platform data, GPIOs have been requested by this driver
> */
> - if (!pdata) {
> - gpio_free(phy->gpio_en);
> - gpio_free(phy->gpio_fw);
> - /* Using platform data */
> - } else if (pdata->free_resources) {
> - pdata->free_resources();
> - }
> + gpio_free(phy->gpio_en);
> + gpio_free(phy->gpio_fw);
>
> return 0;
> }
> diff --git a/include/linux/platform_data/pn544.h
> b/include/linux/platform_data/pn544.h
> deleted file mode 100644
> index 5ce1ab983f44..000000000000
> --- a/include/linux/platform_data/pn544.h
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -/*
> - * Driver include for the PN544 NFC chip.
> - *
> - * Copyright (C) Nokia Corporation
> - *
> - * Author: Jari Vanhala <ext-jari.vanhala@nokia.com>
> - * Contact: Matti Aaltoenn <matti.j.aaltonen@nokia.com>
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms 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 _PN544_H_
> -#define _PN544_H_
> -
> -#include <linux/i2c.h>
> -
> -enum {
> - NFC_GPIO_ENABLE,
> - NFC_GPIO_FW_RESET,
> - NFC_GPIO_IRQ
> -};
> -
> -/* board config */
> -struct pn544_nfc_platform_data {
> - int (*request_resources) (struct i2c_client *client);
> - void (*free_resources) (void);
> - void (*enable) (int fw);
> - int (*test) (void);
> - void (*disable) (void);
> - int (*get_gpio)(int type);
> -};
> -
> -#endif /* _PN544_H_ */
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/5] NFC: pn544: Get rid of platform data
2017-03-28 9:36 [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
` (4 preceding siblings ...)
2017-04-04 16:15 ` [PATCH v3 1/5] NFC: pn544: Get rid of platform data Andy Shevchenko
@ 2017-04-05 8:06 ` Samuel Ortiz
5 siblings, 0 replies; 7+ messages in thread
From: Samuel Ortiz @ 2017-04-05 8:06 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-wireless, Mika Westerberg
Hi Andy,
On Tue, Mar 28, 2017 at 12:36:35PM +0300, Andy Shevchenko wrote:
> 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 <andriy.shevchenko@linux.intel.com>
> ---
> v3: no change
>
> drivers/nfc/pn544/i2c.c | 43 ++++++-------------------------------
> include/linux/platform_data/pn544.h | 43 -------------------------------------
> 2 files changed, 6 insertions(+), 80 deletions(-)
> delete mode 100644 include/linux/platform_data/pn544.h
All 5 patches applied to nfc-next.
Cheers,
Samuel.
^ permalink raw reply [flat|nested] 7+ messages in thread