From: Fabio Estevam <festevam@gmail.com>
To: gregkh@linuxfoundation.org
Cc: cory.tusar@pid1solutions.com, linux-kernel@vger.kernel.org,
Fabio Estevam <fabio.estevam@nxp.com>
Subject: [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API
Date: Wed, 19 Jul 2017 23:44:28 -0300 [thread overview]
Message-ID: <1500518669-3680-1-git-send-email-festevam@gmail.com> (raw)
From: Fabio Estevam <fabio.estevam@nxp.com>
Commit 3ca9b1ac28398c ("misc: eeprom_93xx46: Add support for a GPIO
'select' line.") introduced the optional usage of 'select-gpios'
by using the gpiod API in a convoluted way.
Rewrite the gpiod handling to make the code simpler.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v1:
- Properly add the 1/2 notation in this patch
drivers/misc/eeprom/eeprom_93xx46.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index 94cc035..3876696 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -377,8 +377,6 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
struct device_node *np = spi->dev.of_node;
struct eeprom_93xx46_platform_data *pd;
u32 tmp;
- int gpio;
- enum of_gpio_flags of_flags;
int ret;
pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
@@ -403,22 +401,14 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
if (of_property_read_bool(np, "read-only"))
pd->flags |= EE_READONLY;
- gpio = of_get_named_gpio_flags(np, "select-gpios", 0, &of_flags);
- if (gpio_is_valid(gpio)) {
- unsigned long flags =
- of_flags == OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0;
+ pd->select = devm_gpiod_get_optional(&spi->dev, "select",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(pd->select))
+ return PTR_ERR(pd->select);
- ret = devm_gpio_request_one(&spi->dev, gpio, flags,
- "eeprom_93xx46_select");
- if (ret)
- return ret;
-
- pd->select = gpio_to_desc(gpio);
- pd->prepare = select_assert;
- pd->finish = select_deassert;
-
- gpiod_direction_output(pd->select, 0);
- }
+ pd->prepare = select_assert;
+ pd->finish = select_deassert;
+ gpiod_direction_output(pd->select, 0);
if (of_id->data) {
const struct eeprom_93xx46_devtype_data *data = of_id->data;
--
2.7.4
next reply other threads:[~2017-07-20 2:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 2:44 Fabio Estevam [this message]
2017-07-20 2:44 ` [PATCH v2 2/2] misc: eeprom_93xx46: Include <linux/gpio/consumer.h> Fabio Estevam
2017-07-28 16:48 ` [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API Fabio Estevam
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=1500518669-3680-1-git-send-email-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=cory.tusar@pid1solutions.com \
--cc=fabio.estevam@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox