misc: eeprom_93xx46: Simplify the usage of gpiod API
Commit 3ca9b1ac28
("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
75e5bae6dd
commit
54ec602370
@ -377,8 +377,6 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
|
|||||||
struct device_node *np = spi->dev.of_node;
|
struct device_node *np = spi->dev.of_node;
|
||||||
struct eeprom_93xx46_platform_data *pd;
|
struct eeprom_93xx46_platform_data *pd;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
int gpio;
|
|
||||||
enum of_gpio_flags of_flags;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
|
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"))
|
if (of_property_read_bool(np, "read-only"))
|
||||||
pd->flags |= EE_READONLY;
|
pd->flags |= EE_READONLY;
|
||||||
|
|
||||||
gpio = of_get_named_gpio_flags(np, "select-gpios", 0, &of_flags);
|
pd->select = devm_gpiod_get_optional(&spi->dev, "select",
|
||||||
if (gpio_is_valid(gpio)) {
|
GPIOD_OUT_LOW);
|
||||||
unsigned long flags =
|
if (IS_ERR(pd->select))
|
||||||
of_flags == OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0;
|
return PTR_ERR(pd->select);
|
||||||
|
|
||||||
ret = devm_gpio_request_one(&spi->dev, gpio, flags,
|
pd->prepare = select_assert;
|
||||||
"eeprom_93xx46_select");
|
pd->finish = select_deassert;
|
||||||
if (ret)
|
gpiod_direction_output(pd->select, 0);
|
||||||
return ret;
|
|
||||||
|
|
||||||
pd->select = gpio_to_desc(gpio);
|
|
||||||
pd->prepare = select_assert;
|
|
||||||
pd->finish = select_deassert;
|
|
||||||
|
|
||||||
gpiod_direction_output(pd->select, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (of_id->data) {
|
if (of_id->data) {
|
||||||
const struct eeprom_93xx46_devtype_data *data = of_id->data;
|
const struct eeprom_93xx46_devtype_data *data = of_id->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user