Skip to content

Commit d763611

Browse files
andy-shevlag-linaro
authored andcommitted
mfd: lm3533: Move to new GPIO descriptor-based APIs
Legacy GPIO APIs are subject to remove. Convert the driver to new APIs. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 13c151a commit d763611

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

drivers/mfd/lm3533-core.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/kernel.h>
1313
#include <linux/err.h>
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/consumer.h>
1515
#include <linux/i2c.h>
1616
#include <linux/mfd/core.h>
1717
#include <linux/regmap.h>
@@ -225,14 +225,12 @@ static int lm3533_set_lvled_config(struct lm3533 *lm3533, u8 lvled, u8 led)
225225

226226
static void lm3533_enable(struct lm3533 *lm3533)
227227
{
228-
if (gpio_is_valid(lm3533->gpio_hwen))
229-
gpio_set_value(lm3533->gpio_hwen, 1);
228+
gpiod_set_value(lm3533->hwen, 1);
230229
}
231230

232231
static void lm3533_disable(struct lm3533 *lm3533)
233232
{
234-
if (gpio_is_valid(lm3533->gpio_hwen))
235-
gpio_set_value(lm3533->gpio_hwen, 0);
233+
gpiod_set_value(lm3533->hwen, 0);
236234
}
237235

238236
enum lm3533_attribute_type {
@@ -483,18 +481,10 @@ static int lm3533_device_init(struct lm3533 *lm3533)
483481
return -EINVAL;
484482
}
485483

486-
lm3533->gpio_hwen = pdata->gpio_hwen;
487-
488-
if (gpio_is_valid(lm3533->gpio_hwen)) {
489-
ret = devm_gpio_request_one(lm3533->dev, lm3533->gpio_hwen,
490-
GPIOF_OUT_INIT_LOW, "lm3533-hwen");
491-
if (ret < 0) {
492-
dev_err(lm3533->dev,
493-
"failed to request HWEN GPIO %d\n",
494-
lm3533->gpio_hwen);
495-
return ret;
496-
}
497-
}
484+
lm3533->hwen = devm_gpiod_get(lm3533->dev, NULL, GPIOD_OUT_LOW);
485+
if (IS_ERR(lm3533->hwen))
486+
return dev_err_probe(lm3533->dev, PTR_ERR(lm3533->hwen), "failed to request HWEN GPIO\n");
487+
gpiod_set_consumer_name(lm3533->hwen, "lm3533-hwen");
498488

499489
lm3533_enable(lm3533);
500490

include/linux/mfd/lm3533.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name)
1717

1818
struct device;
19+
struct gpio_desc;
1920
struct regmap;
2021

2122
struct lm3533 {
2223
struct device *dev;
2324

2425
struct regmap *regmap;
2526

26-
int gpio_hwen;
27+
struct gpio_desc *hwen;
2728
int irq;
2829

2930
unsigned have_als:1;
@@ -69,8 +70,6 @@ enum lm3533_boost_ovp {
6970
};
7071

7172
struct lm3533_platform_data {
72-
int gpio_hwen;
73-
7473
enum lm3533_boost_ovp boost_ovp;
7574
enum lm3533_boost_freq boost_freq;
7675

0 commit comments

Comments
 (0)