* [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API
@ 2017-07-20 2:44 Fabio Estevam
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
0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2017-07-20 2:44 UTC (permalink / raw)
To: gregkh; +Cc: cory.tusar, linux-kernel, Fabio Estevam
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] misc: eeprom_93xx46: Include <linux/gpio/consumer.h>
2017-07-20 2:44 [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API Fabio Estevam
@ 2017-07-20 2:44 ` Fabio Estevam
2017-07-28 16:48 ` [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API Fabio Estevam
1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2017-07-20 2:44 UTC (permalink / raw)
To: gregkh; +Cc: cory.tusar, linux-kernel, Fabio Estevam
From: Fabio Estevam <fabio.estevam@nxp.com>
eeprom_93xx46_platform_data struct has a 'struct gpio_desc'
type member, so it is better to include <linux/gpio/consumer.h>,
which provides 'struct gpio_desc' type.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v1:
- None
include/linux/eeprom_93xx46.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h
index 885f587..9158987 100644
--- a/include/linux/eeprom_93xx46.h
+++ b/include/linux/eeprom_93xx46.h
@@ -2,8 +2,7 @@
* Module: eeprom_93xx46
* platform description for 93xx46 EEPROMs.
*/
-
-struct gpio_desc;
+#include <linux/gpio/consumer.h>
struct eeprom_93xx46_platform_data {
unsigned char flags;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API
2017-07-20 2:44 [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API Fabio Estevam
2017-07-20 2:44 ` [PATCH v2 2/2] misc: eeprom_93xx46: Include <linux/gpio/consumer.h> Fabio Estevam
@ 2017-07-28 16:48 ` Fabio Estevam
1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2017-07-28 16:48 UTC (permalink / raw)
To: Greg Kroah-Hartman, Cory Tusar; +Cc: linux-kernel, Fabio Estevam
Hi Cory,
On Wed, Jul 19, 2017 at 11:44 PM, Fabio Estevam <festevam@gmail.com> wrote:
> 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>
Could you please test this patch when you have a chance, please?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-28 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-20 2:44 [PATCH v2 1/2] misc: eeprom_93xx46: Simplify the usage of gpiod API Fabio Estevam
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox