From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Clément Perrochaud" <clement.perrochaud@effinnov.com>,
"Charles Gorand" <charles.gorand@effinnov.com>,
linux-nfc@lists.01.org, "Samuel Ortiz" <sameo@linux.intel.com>,
linux-wireless@vger.kernel.org,
"Sedat Dilek" <sedat.dilek@gmail.com>,
"Oleg Zhurakivskyy" <oleg.zhurakivskyy@intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 03/12] NFC: nxp-nci: Convert to use GPIO descriptor
Date: Mon, 13 May 2019 13:43:49 +0300 [thread overview]
Message-ID: <20190513104358.59716-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20190513104358.59716-1-andriy.shevchenko@linux.intel.com>
Since we got rid of platform data, the driver may use
GPIO descriptor directly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/nfc/nxp-nci/core.c | 1 -
drivers/nfc/nxp-nci/i2c.c | 60 ++++++++++----------------------------
2 files changed, 15 insertions(+), 46 deletions(-)
diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index 1907b1fd57a7..b0b6db81a5e8 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -22,7 +22,6 @@
*/
#include <linux/delay.h>
-#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/nfc.h>
diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index 549e09deb92f..6f61368ae065 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -32,8 +32,6 @@
#include <linux/module.h>
#include <linux/nfc.h>
#include <linux/gpio/consumer.h>
-#include <linux/of_gpio.h>
-#include <linux/of_irq.h>
#include <asm/unaligned.h>
#include <net/nfc/nfc.h>
@@ -48,8 +46,8 @@ struct nxp_nci_i2c_phy {
struct i2c_client *i2c_dev;
struct nci_dev *ndev;
- unsigned int gpio_en;
- unsigned int gpio_fw;
+ struct gpio_desc *gpiod_en;
+ struct gpio_desc *gpiod_fw;
int hard_fault; /*
* < 0 if hardware error occurred (e.g. i2c err)
@@ -62,8 +60,8 @@ static int nxp_nci_i2c_set_mode(void *phy_id,
{
struct nxp_nci_i2c_phy *phy = (struct nxp_nci_i2c_phy *) phy_id;
- gpio_set_value(phy->gpio_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
- gpio_set_value(phy->gpio_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
+ gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
+ gpiod_set_value(phy->gpiod_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
usleep_range(10000, 15000);
if (mode == NXP_NCI_MODE_COLD)
@@ -263,30 +261,18 @@ static irqreturn_t nxp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
{
struct nxp_nci_i2c_phy *phy = i2c_get_clientdata(client);
- struct device_node *pp;
- int r;
-
- pp = client->dev.of_node;
- if (!pp)
- return -ENODEV;
- r = of_get_named_gpio(pp, "enable-gpios", 0);
- if (r == -EPROBE_DEFER)
- r = of_get_named_gpio(pp, "enable-gpios", 0);
- if (r < 0) {
- nfc_err(&client->dev, "Failed to get EN gpio, error: %d\n", r);
- return r;
+ 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->gpio_en = r;
- r = of_get_named_gpio(pp, "firmware-gpios", 0);
- if (r == -EPROBE_DEFER)
- r = of_get_named_gpio(pp, "firmware-gpios", 0);
- if (r < 0) {
- nfc_err(&client->dev, "Failed to get FW gpio, error: %d\n", r);
- return r;
+ 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);
}
- phy->gpio_fw = r;
return 0;
}
@@ -294,19 +280,15 @@ static int nxp_nci_i2c_parse_devtree(struct i2c_client *client)
static int nxp_nci_i2c_acpi_config(struct nxp_nci_i2c_phy *phy)
{
struct i2c_client *client = phy->i2c_dev;
- struct gpio_desc *gpiod_en, *gpiod_fw;
- gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
- gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
+ phy->gpiod_en = devm_gpiod_get_index(&client->dev, NULL, 2, GPIOD_OUT_LOW);
+ phy->gpiod_fw = devm_gpiod_get_index(&client->dev, NULL, 1, GPIOD_OUT_LOW);
- if (IS_ERR(gpiod_en) || IS_ERR(gpiod_fw)) {
+ if (IS_ERR(phy->gpiod_en) || IS_ERR(phy->gpiod_fw)) {
nfc_err(&client->dev, "No GPIOs\n");
return -EINVAL;
}
- phy->gpio_en = desc_to_gpio(gpiod_en);
- phy->gpio_fw = desc_to_gpio(gpiod_fw);
-
return 0;
}
@@ -342,24 +324,12 @@ static int nxp_nci_i2c_probe(struct i2c_client *client,
r = nxp_nci_i2c_acpi_config(phy);
if (r < 0)
goto probe_exit;
- goto nci_probe;
} else {
nfc_err(&client->dev, "No platform data\n");
r = -EINVAL;
goto probe_exit;
}
- r = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_en,
- GPIOF_OUT_INIT_LOW, "nxp_nci_en");
- if (r < 0)
- goto probe_exit;
-
- r = devm_gpio_request_one(&phy->i2c_dev->dev, phy->gpio_fw,
- GPIOF_OUT_INIT_LOW, "nxp_nci_fw");
- if (r < 0)
- goto probe_exit;
-
-nci_probe:
r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops,
NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev);
if (r < 0)
--
2.20.1
next prev parent reply other threads:[~2019-05-13 10:44 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-13 10:43 [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 01/12] NFC: nxp-nci: Add NXP1001 to the ACPI ID table Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 02/12] NFC: nxp-nci: Get rid of platform data Andy Shevchenko
2019-05-13 10:43 ` Andy Shevchenko [this message]
2019-05-13 10:43 ` [PATCH v2 04/12] NFC: nxp-nci: Add GPIO ACPI mapping table Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 05/12] NFC: nxp-nci: Get rid of code duplication in ->probe() Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 06/12] NFC: nxp-nci: Get rid of useless label Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 07/12] NFC: nxp-nci: Constify acpi_device_id Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 08/12] NFC: nxp-nci: Drop of_match_ptr() use Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 09/12] NFC: nxp-nci: Drop comma in terminator lines Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 10/12] NFC: nxp-nci: Remove unused macro pr_fmt() Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 11/12] NFC: nxp-nci: Remove 'default n' for tests Andy Shevchenko
2019-05-13 10:43 ` [PATCH v2 12/12] NFC: nxp-nci: Convert to SPDX license tags Andy Shevchenko
2019-05-13 11:43 ` [PATCH v2 00/12] NFC: nxp-nci: clean up and support new ID Sedat Dilek
2019-05-13 11:46 ` Sedat Dilek
2019-05-13 12:49 ` Oleg Zhurakivskyy
2019-05-13 12:56 ` Andy Shevchenko
2019-05-13 12:18 ` Sedat Dilek
2019-05-13 12:37 ` Andy Shevchenko
2019-05-14 8:34 ` Sedat Dilek
2019-05-14 11:44 ` Oleg Zhurakivskyy
2019-05-14 12:03 ` Sedat Dilek
2019-05-14 13:30 ` Oleg Zhurakivskyy
2019-05-14 13:44 ` Sedat Dilek
2019-05-14 13:56 ` Oleg Zhurakivskyy
2019-05-14 14:53 ` Sedat Dilek
2019-05-14 17:01 ` Andy Shevchenko
2019-05-15 8:32 ` Sedat Dilek
2019-05-15 10:09 ` Andy Shevchenko
2019-05-15 10:22 ` Sedat Dilek
2019-05-13 19:48 ` Sedat Dilek
2019-05-14 10:03 ` Andy Shevchenko
2019-05-14 12:12 ` Sedat Dilek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190513104358.59716-4-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=charles.gorand@effinnov.com \
--cc=clement.perrochaud@effinnov.com \
--cc=linux-nfc@lists.01.org \
--cc=linux-wireless@vger.kernel.org \
--cc=oleg.zhurakivskyy@intel.com \
--cc=sameo@linux.intel.com \
--cc=sedat.dilek@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.