aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2021-11-08 22:35:19 +0100
committerArnd Bergmann <arnd@arndb.de>2021-12-07 12:16:23 +0100
commit5de8ac6b8ccee6f1f892b4fa6dc16781de0c3ba8 (patch)
tree23b612378786c13df0cff3a800398a13d1608543
parent6c52c624c5baf113763014cfeda33ac6236a34d9 (diff)
downloadplayground-5de8ac6b8ccee6f1f892b4fa6dc16781de0c3ba8.tar.gz
replace most of_gpio_get
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--arch/arm/mach-mvebu/pm-board.c26
-rw-r--r--arch/mips/lantiq/xway/vmmc.c15
-rw-r--r--arch/powerpc/platforms/44x/warp.c4
-rw-r--r--arch/powerpc/platforms/85xx/sgy_cts1000.c69
-rw-r--r--drivers/input/touchscreen/auo-pixcir-ts.c33
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c76
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3.h2
-rw-r--r--drivers/media/i2c/s5k5baf.c69
-rw-r--r--drivers/media/i2c/s5k6a3.c28
-rw-r--r--drivers/mfd/stmpe.c25
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c25
-rw-r--r--drivers/net/ethernet/micrel/ks8851.h2
-rw-r--r--drivers/net/ethernet/micrel/ks8851_common.c32
-rw-r--r--drivers/net/phy/spi_ks8995.c62
-rw-r--r--drivers/pci/controller/dwc/pcie-histb.c29
-rw-r--r--drivers/pci/controller/pci-mvebu.c47
-rw-r--r--drivers/pcmcia/at91_cf.c104
-rw-r--r--drivers/remoteproc/keystone_remoteproc.c12
-rw-r--r--drivers/soc/fsl/qe/gpio.c7
-rw-r--r--drivers/spi/spi-mpc52xx.c26
-rw-r--r--drivers/usb/gadget/udc/at91_udc.c21
-rw-r--r--drivers/usb/host/fhci-hcd.c66
-rw-r--r--drivers/usb/host/fhci-hub.c14
-rw-r--r--drivers/usb/host/fhci.h3
-rw-r--r--include/linux/input/auo-pixcir-ts.h4
-rw-r--r--include/linux/platform_data/ssm2518.h1
-rw-r--r--include/media/i2c/s5c73m3.h5
-rw-r--r--include/soc/fsl/qe/qe.h5
-rw-r--r--sound/soc/codecs/ssm2518.c25
-rw-r--r--sound/soc/generic/simple-card-utils.c12
30 files changed, 259 insertions, 590 deletions
diff --git a/arch/arm/mach-mvebu/pm-board.c b/arch/arm/mach-mvebu/pm-board.c
index 0705525116996..2ae3958836025 100644
--- a/arch/arm/mach-mvebu/pm-board.c
+++ b/arch/arm/mach-mvebu/pm-board.c
@@ -16,14 +16,13 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_address.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/slab.h>
#include "common.h"
#define ARMADA_PIC_NR_GPIOS 3
static void __iomem *gpio_ctrl;
-static int pic_gpios[ARMADA_PIC_NR_GPIOS];
static int pic_raw_gpios[ARMADA_PIC_NR_GPIOS];
static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
@@ -92,12 +91,7 @@ static int __init mvebu_armada_pm_init(void)
for (i = 0; i < ARMADA_PIC_NR_GPIOS; i++) {
char *name;
struct of_phandle_args args;
-
- pic_gpios[i] = of_get_named_gpio(np, "ctrl-gpios", i);
- if (pic_gpios[i] < 0) {
- ret = -ENODEV;
- goto out;
- }
+ struct gpio_desc *desc;
name = kasprintf(GFP_KERNEL, "pic-pin%d", i);
if (!name) {
@@ -105,23 +99,19 @@ static int __init mvebu_armada_pm_init(void)
goto out;
}
- ret = gpio_request(pic_gpios[i], name);
- if (ret < 0) {
- kfree(name);
- goto out;
- }
-
- ret = gpio_direction_output(pic_gpios[i], 0);
- if (ret < 0) {
- gpio_free(pic_gpios[i]);
+ desc = fwnode_gpiod_get_index(&np->fwnode,
+ "ctrl-gpios", i,
+ GPIOD_OUT_LOW, name);
+ if (IS_ERR(desc)) {
kfree(name);
+ ret = PTR_ERR(desc);
goto out;
}
ret = of_parse_phandle_with_fixed_args(np, "ctrl-gpios", 2,
i, &args);
if (ret < 0) {
- gpio_free(pic_gpios[i]);
+ gpiod_put(desc);
kfree(name);
goto out;
}
diff --git a/arch/mips/lantiq/xway/vmmc.c b/arch/mips/lantiq/xway/vmmc.c
index 7a14da8d9d15e..151e8ef818ec8 100644
--- a/arch/mips/lantiq/xway/vmmc.c
+++ b/arch/mips/lantiq/xway/vmmc.c
@@ -27,21 +27,22 @@ static int vmmc_probe(struct platform_device *pdev)
#define CP1_SIZE (1 << 20)
int gpio_count;
dma_addr_t dma;
+ struct gpio_desc *gpio;
cp1_base =
(void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE,
&dma, GFP_KERNEL));
+
gpio_count = of_gpio_count(pdev->dev.of_node);
while (gpio_count > 0) {
enum of_gpio_flags flags;
- int gpio = of_get_gpio_flags(pdev->dev.of_node,
- --gpio_count, &flags);
- if (gpio_request(gpio, "vmmc-relay"))
- continue;
- dev_info(&pdev->dev, "requested GPIO %d\n", gpio);
- gpio_direction_output(gpio,
- (flags & OF_GPIO_ACTIVE_LOW) ? (0) : (1));
+ gpio = gpiod_get_index(&pdev->dev, NULL, --gpio_count,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(gpio))
+ dev_err(&pdev->dev, "gpio_get failed\n", gpio_count);
+ else
+ dev_info(&pdev->dev, "requested GPIO %s\n", gpio->name);
}
dev_info(&pdev->dev, "reserved %dMB at 0x%p", CP1_SIZE >> 20, cp1_base);
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 665f18e37efb2..7642bdf843da3 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -173,9 +173,9 @@ static int pika_setup_leds(void)
for_each_child_of_node(np, child)
if (of_node_name_eq(child, "green"))
- green_led = of_get_gpio(child, 0);
+ green_led = of_get_named_gpio(child, 0, NULL);
else if (of_node_name_eq(child, "red"))
- red_led = of_get_gpio(child, 0);
+ red_led = of_get_named_gpio(child, 0, NULL);
of_node_put(np);
diff --git a/arch/powerpc/platforms/85xx/sgy_cts1000.c b/arch/powerpc/platforms/85xx/sgy_cts1000.c
index 98ae640751934..455d694517b10 100644
--- a/arch/powerpc/platforms/85xx/sgy_cts1000.c
+++ b/arch/powerpc/platforms/85xx/sgy_cts1000.c
@@ -18,7 +18,7 @@
#include <asm/machdep.h>
-static struct device_node *halt_node;
+struct gpio_desc *halt_gpio;
static const struct of_device_id child_match[] = {
{
@@ -36,23 +36,13 @@ static DECLARE_WORK(gpio_halt_wq, gpio_halt_wfn);
static void __noreturn gpio_halt_cb(void)
{
- enum of_gpio_flags flags;
- int trigger, gpio;
-
- if (!halt_node)
+ if (!halt_gpio)
panic("No reset GPIO information was provided in DT\n");
- gpio = of_get_gpio_flags(halt_node, 0, &flags);
-
- if (!gpio_is_valid(gpio))
- panic("Provided GPIO is invalid\n");
-
- trigger = (flags == OF_GPIO_ACTIVE_LOW);
-
printk(KERN_INFO "gpio-halt: triggering GPIO.\n");
/* Probably wont return */
- gpio_set_value(gpio, trigger);
+ gpiod_set_value(halt_gpio, 0);
panic("Halt failed\n");
}
@@ -71,6 +61,7 @@ static int gpio_halt_probe(struct platform_device *pdev)
{
enum of_gpio_flags flags;
struct device_node *node = pdev->dev.of_node;
+ struct device_node *halt_node;
int gpio, err, irq;
int trigger;
@@ -82,37 +73,24 @@ static int gpio_halt_probe(struct platform_device *pdev)
if (!halt_node)
return 0;
- /* Technically we could just read the first one, but punish
- * DT writers for invalid form. */
- if (of_gpio_count(halt_node) != 1)
- return -EINVAL;
-
- /* Get the gpio number relative to the dynamic base. */
- gpio = of_get_gpio_flags(halt_node, 0, &flags);
- if (!gpio_is_valid(gpio))
- return -EINVAL;
-
- err = gpio_request(gpio, "gpio-halt");
- if (err) {
- printk(KERN_ERR "gpio-halt: error requesting GPIO %d.\n",
- gpio);
- halt_node = NULL;
- return err;
+ halt_gpio = devm_fwnode_gpiod_get_index(&pdev->dev,
+ of_node_to_fwnode(halt_node),
+ NULL, 0, GPIOD_OUT_HIGH,
+ "gpio-halt");
+ if (IS_ERR(halt_gpio)) {
+ printk(KERN_ERR "gpio-halt: error requesting GPIO\n");
+ halt_gpio = NULL;
+ return PTR_ERR(halt_gpio);
}
- trigger = (flags == OF_GPIO_ACTIVE_LOW);
-
- gpio_direction_output(gpio, !trigger);
-
/* Now get the IRQ which tells us when the power button is hit */
irq = irq_of_parse_and_map(halt_node, 0);
- err = request_irq(irq, gpio_halt_irq, IRQF_TRIGGER_RISING |
+ err = devm_request_irq(irq, gpio_halt_irq, IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING, "gpio-halt", halt_node);
if (err) {
printk(KERN_ERR "gpio-halt: error requesting IRQ %d for "
"GPIO %d.\n", irq, gpio);
- gpio_free(gpio);
- halt_node = NULL;
+ halt_gpio = NULL;
return err;
}
@@ -120,27 +98,16 @@ static int gpio_halt_probe(struct platform_device *pdev)
ppc_md.halt = gpio_halt_cb;
pm_power_off = gpio_halt_cb;
- printk(KERN_INFO "gpio-halt: registered GPIO %d (%d trigger, %d"
- " irq).\n", gpio, trigger, irq);
+ printk(KERN_INFO "gpio-halt: registered GPIO, %d irq).\n", irq);
return 0;
}
static int gpio_halt_remove(struct platform_device *pdev)
{
- if (halt_node) {
- int gpio = of_get_gpio(halt_node, 0);
- int irq = irq_of_parse_and_map(halt_node, 0);
-
- free_irq(irq, halt_node);
-
- ppc_md.halt = NULL;
- pm_power_off = NULL;
-
- gpio_free(gpio);
-
- halt_node = NULL;
- }
+ ppc_md.halt = NULL;
+ pm_power_off = NULL;
+ halt_gpio = NULL;
return 0;
}
diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index c33e63ca61425..86196e8e9b527 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -19,7 +19,7 @@
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/input/auo-pixcir-ts.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
@@ -182,7 +182,7 @@ static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
/* check for up event in touch touch_ind_mode */
if (ts->touch_ind_mode) {
- if (gpio_get_value(pdata->gpio_int) == 0) {
+ if (gpiod_get_value(pdata->gpio_int) == 0) {
input_mt_sync(ts->input);
input_report_key(ts->input, BTN_TOUCH, 0);
input_sync(ts->input);
@@ -478,14 +478,14 @@ static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->gpio_int = of_get_gpio(np, 0);
- if (!gpio_is_valid(pdata->gpio_int)) {
+ pdata->gpio_int = devm_gpiod_get_index(dev, NULL, 0, GPIOD_IN);
+ if (IS_ERR(pdata->gpio_int)) {
dev_err(dev, "failed to get interrupt gpio\n");
- return ERR_PTR(-EINVAL);
+ return ERR_CAST(pdata->gpio_int);
}
- pdata->gpio_rst = of_get_gpio(np, 1);
- if (!gpio_is_valid(pdata->gpio_rst)) {
+ pdata->gpio_rst = devm_gpiod_get_index(dev, NULL, 0, GPIOD_OUT_HIGH);
+ if (IS_ERR(pdata->gpio_rst)) {
dev_err(dev, "failed to get reset gpio\n");
return ERR_PTR(-EINVAL);
}
@@ -516,7 +516,7 @@ static void auo_pixcir_reset(void *data)
{
struct auo_pixcir_ts *ts = data;
- gpio_set_value(ts->pdata->gpio_rst, 0);
+ gpiod_set_value(ts->pdata->gpio_rst, 0);
}
static int auo_pixcir_probe(struct i2c_client *client,
@@ -585,23 +585,6 @@ static int auo_pixcir_probe(struct i2c_client *client,
input_set_drvdata(ts->input, ts);
- error = devm_gpio_request_one(&client->dev, pdata->gpio_int,
- GPIOF_DIR_IN, "auo_pixcir_ts_int");
- if (error) {
- dev_err(&client->dev, "request of gpio %d failed, %d\n",
- pdata->gpio_int, error);
- return error;
- }
-
- error = devm_gpio_request_one(&client->dev, pdata->gpio_rst,
- GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
- "auo_pixcir_ts_rst");
- if (error) {
- dev_err(&client->dev, "request of gpio %d failed, %d\n",
- pdata->gpio_rst, error);
- return error;
- }
-
error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts);
if (error) {
dev_err(&client->dev, "failed to register reset action, %d\n",
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index e2b88c5e4f983..66842011d6a84 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1347,24 +1347,6 @@ static int s5c73m3_oif_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
return 0;
}
-static int s5c73m3_gpio_set_value(struct s5c73m3 *priv, int id, u32 val)
-{
- if (!gpio_is_valid(priv->gpio[id].gpio))
- return 0;
- gpio_set_value(priv->gpio[id].gpio, !!val);
- return 1;
-}
-
-static int s5c73m3_gpio_assert(struct s5c73m3 *priv, int id)
-{
- return s5c73m3_gpio_set_value(priv, id, priv->gpio[id].level);
-}
-
-static int s5c73m3_gpio_deassert(struct s5c73m3 *priv, int id)
-{
- return s5c73m3_gpio_set_value(priv, id, !priv->gpio[id].level);
-}
-
static int __s5c73m3_power_on(struct s5c73m3 *state)
{
int i, ret;
@@ -1386,10 +1368,10 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)
v4l2_dbg(1, s5c73m3_dbg, &state->oif_sd, "clock frequency: %ld\n",
clk_get_rate(state->clock));
- s5c73m3_gpio_deassert(state, STBY);
+ gpiod_set_value(state->gpio[STBY], 0);
usleep_range(100, 200);
- s5c73m3_gpio_deassert(state, RSET);
+ gpiod_set_value(state->gpio[RSET], 0);
usleep_range(50, 100);
return 0;
@@ -1404,11 +1386,11 @@ static int __s5c73m3_power_off(struct s5c73m3 *state)
{
int i, ret;
- if (s5c73m3_gpio_assert(state, RSET))
- usleep_range(10, 50);
+ gpiod_set_value(state->gpio[RSET], 1);
+ usleep_range(10, 50);
- if (s5c73m3_gpio_assert(state, STBY))
- usleep_range(100, 200);
+ gpiod_set_value(state->gpio[STBY], 1);
+ usleep_range(100, 200);
clk_disable_unprepare(state->clock);
@@ -1543,51 +1525,21 @@ static const struct v4l2_subdev_ops oif_subdev_ops = {
.video = &s5c73m3_oif_video_ops,
};
-static int s5c73m3_configure_gpios(struct s5c73m3 *state)
-{
- static const char * const gpio_names[] = {
- "S5C73M3_STBY", "S5C73M3_RST"
- };
- struct i2c_client *c = state->i2c_client;
- struct s5c73m3_gpio *g = state->gpio;
- int ret, i;
-
- for (i = 0; i < GPIO_NUM; ++i) {
- unsigned int flags = GPIOF_DIR_OUT;
- if (g[i].level)
- flags |= GPIOF_INIT_HIGH;
- ret = devm_gpio_request_one(&c->dev, g[i].gpio, flags,
- gpio_names[i]);
- if (ret) {
- v4l2_err(c, "failed to request gpio %s\n",
- gpio_names[i]);
- return ret;
- }
- }
- return 0;
-}
-
static int s5c73m3_parse_gpios(struct s5c73m3 *state)
{
static const char * const prop_names[] = {
"standby-gpios", "xshutdown-gpios",
};
struct device *dev = &state->i2c_client->dev;
- struct device_node *node = dev->of_node;
- int ret, i;
+ int i;
for (i = 0; i < GPIO_NUM; ++i) {
- enum of_gpio_flags of_flags;
-
- ret = of_get_named_gpio_flags(node, prop_names[i],
- 0, &of_flags);
- if (ret < 0) {
+ state->gpio[i] = devm_gpiod_get(dev, prop_names[i], GPIOD_OUT_HIGH);
+ if (IS_ERR(state->gpio[i])) {
dev_err(dev, "failed to parse %s DT property\n",
prop_names[i]);
- return -EINVAL;
+ return PTR_ERR(state->gpio[i]);
}
- state->gpio[i].gpio = ret;
- state->gpio[i].level = !(of_flags & OF_GPIO_ACTIVE_LOW);
}
return 0;
}
@@ -1608,8 +1560,8 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
}
state->mclk_frequency = pdata->mclk_frequency;
- state->gpio[STBY] = pdata->gpio_stby;
- state->gpio[RSET] = pdata->gpio_reset;
+ state->gpio[STBY] = gpio_to_desc(pdata->gpio_stby.gpio);
+ state->gpio[RSET] = gpio_to_desc(pdata->gpio_reset.gpio);
return 0;
}
@@ -1708,10 +1660,6 @@ static int s5c73m3_probe(struct i2c_client *client)
if (ret < 0)
return ret;
- ret = s5c73m3_configure_gpios(state);
- if (ret)
- goto out_err;
-
for (i = 0; i < S5C73M3_MAX_SUPPLIES; i++)
state->supplies[i].supply = s5c73m3_supply_names[i];
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
index c3fcfdd3ea66d..bb6d4649af1b7 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3.h
+++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
@@ -383,7 +383,7 @@ struct s5c73m3 {
u32 i2c_read_address;
struct regulator_bulk_data supplies[S5C73M3_MAX_SUPPLIES];
- struct s5c73m3_gpio gpio[GPIO_NUM];
+ struct gpio_desc *gpio[GPIO_NUM];
struct clk *clock;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 6a5dceb699a88..ee4471dae9f09 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -17,7 +17,7 @@
#include <linux/i2c.h>
#include <linux/media.h>
#include <linux/module.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of_graph.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
@@ -228,11 +228,6 @@ static const char * const s5k5baf_supply_names[] = {
};
#define S5K5BAF_NUM_SUPPLIES ARRAY_SIZE(s5k5baf_supply_names)
-struct s5k5baf_gpio {
- int gpio;
- int level;
-};
-
enum s5k5baf_gpio_id {
STBY,
RSET,
@@ -284,7 +279,7 @@ struct s5k5baf_fw {
};
struct s5k5baf {
- struct s5k5baf_gpio gpios[NUM_GPIOS];
+ struct gpio_desc *gpios[NUM_GPIOS];
enum v4l2_mbus_type bus_type;
u8 nlanes;
struct regulator_bulk_data supplies[S5K5BAF_NUM_SUPPLIES];
@@ -934,20 +929,6 @@ static void s5k5baf_hw_set_test_pattern(struct s5k5baf *state, int id)
s5k5baf_i2c_write(state, REG_PATTERN_SET, id);
}
-static void s5k5baf_gpio_assert(struct s5k5baf *state, int id)
-{
- struct s5k5baf_gpio *gpio = &state->gpios[id];
-
- gpio_set_value(gpio->gpio, gpio->level);
-}
-
-static void s5k5baf_gpio_deassert(struct s5k5baf *state, int id)
-{
- struct s5k5baf_gpio *gpio = &state->gpios[id];
-
- gpio_set_value(gpio->gpio, !gpio->level);
-}
-
static int s5k5baf_power_on(struct s5k5baf *state)
{
int ret;
@@ -967,9 +948,9 @@ static int s5k5baf_power_on(struct s5k5baf *state)
v4l2_dbg(1, debug, &state->sd, "clock frequency: %ld\n",
clk_get_rate(state->clock));
- s5k5baf_gpio_deassert(state, STBY);
+ gpiod_set_value(state->gpios[STBY], 1);
usleep_range(50, 100);
- s5k5baf_gpio_deassert(state, RSET);
+ gpiod_set_value(state->gpios[RSET], 1);
return 0;
err_reg_dis:
@@ -987,8 +968,8 @@ static int s5k5baf_power_off(struct s5k5baf *state)
state->apply_cfg = 0;
state->apply_crop = 0;
- s5k5baf_gpio_assert(state, RSET);
- s5k5baf_gpio_assert(state, STBY);
+ gpiod_set_value(state->gpios[RSET], 1);
+ gpiod_set_value(state->gpios[STBY], 1);
if (!IS_ERR(state->clock))
clk_disable_unprepare(state->clock);
@@ -1797,44 +1778,20 @@ static const struct v4l2_subdev_ops s5k5baf_subdev_ops = {
.video = &s5k5baf_video_ops,
};
-static int s5k5baf_configure_gpios(struct s5k5baf *state)
-{
- static const char * const name[] = { "S5K5BAF_STBY", "S5K5BAF_RST" };
- struct i2c_client *c = v4l2_get_subdevdata(&state->sd);
- struct s5k5baf_gpio *g = state->gpios;
- int ret, i;
-
- for (i = 0; i < NUM_GPIOS; ++i) {
- int flags = GPIOF_DIR_OUT;
- if (g[i].level)
- flags |= GPIOF_INIT_HIGH;
- ret = devm_gpio_request_one(&c->dev, g[i].gpio, flags, name[i]);
- if (ret < 0) {
- v4l2_err(c, "failed to request gpio %s\n", name[i]);
- return ret;
- }
- }
- return 0;
-}
-
-static int s5k5baf_parse_gpios(struct s5k5baf_gpio *gpios, struct device *dev)
+static int s5k5baf_parse_gpios(struct gpio_desc *gpios[], struct device *dev)
{
static const char * const names[] = {
"stbyn-gpios",
"rstn-gpios",
};
- struct device_node *node = dev->of_node;
- enum of_gpio_flags flags;
- int ret, i;
+ int i;
for (i = 0; i < NUM_GPIOS; ++i) {
- ret = of_get_named_gpio_flags(node, names[i], 0, &flags);
- if (ret < 0) {
+ gpios[i] = devm_gpiod_get(dev, names[i], GPIOD_OUT_HIGH);
+ if (IS_ERR(gpios[i])) {
dev_err(dev, "no %s GPIO pin provided\n", names[i]);
- return ret;
+ return PTR_ERR(gpios[i]);
}
- gpios[i].gpio = ret;
- gpios[i].level = !(flags & OF_GPIO_ACTIVE_LOW);
}
return 0;
@@ -1974,10 +1931,6 @@ static int s5k5baf_probe(struct i2c_client *c)
if (ret < 0)
return ret;
- ret = s5k5baf_configure_gpios(state);
- if (ret < 0)
- goto err_me;
-
ret = s5k5baf_configure_regulators(state);
if (ret < 0)
goto err_me;
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index b97dd6149e90f..a229bd271800d 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -10,11 +10,10 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
-#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
@@ -59,7 +58,7 @@ struct s5k6a3 {
struct v4l2_subdev subdev;
struct media_pad pad;
struct regulator_bulk_data supplies[S5K6A3_NUM_SUPPLIES];
- int gpio_reset;
+ struct gpio_desc *gpio_reset;
struct mutex lock;
struct v4l2_mbus_framefmt format;
struct clk *clock;
@@ -216,11 +215,11 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor)
goto error_reg_dis;
}
- gpio_set_value(sensor->gpio_reset, 1);
+ gpiod_set_value(sensor->gpio_reset, 1);
usleep_range(600, 800);
- gpio_set_value(sensor->gpio_reset, 0);
+ gpiod_set_value(sensor->gpio_reset, 0);
usleep_range(600, 800);
- gpio_set_value(sensor->gpio_reset, 1);
+ gpiod_set_value(sensor->gpio_reset, 1);
/* Delay needed for the sensor initialization */
msleep(20);
@@ -238,7 +237,7 @@ static int __s5k6a3_power_off(struct s5k6a3 *sensor)
{
int i;
- gpio_set_value(sensor->gpio_reset, 0);
+ gpiod_set_value(sensor->gpio_reset, 0);
for (i = S5K6A3_NUM_SUPPLIES - 1; i >= 0; i--)
regulator_disable(sensor->supplies[i].consumer);
@@ -283,14 +282,14 @@ static int s5k6a3_probe(struct i2c_client *client)
struct device *dev = &client->dev;
struct s5k6a3 *sensor;
struct v4l2_subdev *sd;
- int gpio, i, ret;
+ int i, ret;
sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
if (!sensor)
return -ENOMEM;
mutex_init(&sensor->lock);
- sensor->gpio_reset = -EINVAL;
+ sensor->gpio_reset = NULL;
sensor->clock = ERR_PTR(-EINVAL);
sensor->dev = dev;
@@ -298,16 +297,7 @@ static int s5k6a3_probe(struct i2c_client *client)
if (IS_ERR(sensor->clock))
return PTR_ERR(sensor->clock);
- gpio = of_get_gpio_flags(dev->of_node, 0, NULL);
- if (!gpio_is_valid(gpio))
- return gpio;
-
- ret = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_LOW,
- S5K6A3_DRV_NAME);
- if (ret < 0)
- return ret;
-
- sensor->gpio_reset = gpio;
+ sensor->gpio_reset = gpiod_get(dev, NULL, GPIOD_OUT_LOW);
if (of_property_read_u32(dev->of_node, "clock-frequency",
&sensor->clock_frequency)) {
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index e928df95e3167..7bcf8a0401af2 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -15,7 +15,7 @@
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/mfd/core.h>
@@ -40,7 +40,7 @@ struct stmpe_platform_data {
unsigned int irq_trigger;
bool autosleep;
bool irq_over_gpio;
- int irq_gpio;
+ struct gpio_desc *irq_gpio;
int autosleep_timeout;
};
@@ -1341,17 +1341,18 @@ static int stmpe_devices_init(struct stmpe *stmpe)
}
static void stmpe_of_probe(struct stmpe_platform_data *pdata,
- struct device_node *np)
+ struct device *dev)
{
struct device_node *child;
+ struct device_node *np = dev->of_node;
pdata->id = of_alias_get_id(np, "stmpe-i2c");
if (pdata->id < 0)
pdata->id = -1;
- pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0,
- &pdata->irq_trigger);
- if (gpio_is_valid(pdata->irq_gpio))
+
+ pdata->irq_gpio = gpiod_get(dev, "irq-gpio", GPIOD_IN);
+ if (!IS_ERR(pdata->irq_gpio))
pdata->irq_over_gpio = 1;
else
pdata->irq_trigger = IRQF_TRIGGER_NONE;
@@ -1391,7 +1392,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
if (!pdata)
return -ENOMEM;
- stmpe_of_probe(pdata, np);
+ stmpe_of_probe(pdata, ci->dev);
if (of_find_property(np, "interrupts", NULL) == NULL)
ci->irq = -1;
@@ -1438,15 +1439,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
ci->init(stmpe);
if (pdata->irq_over_gpio) {
- ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio,
- GPIOF_DIR_IN, "stmpe");
- if (ret) {
- dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
- ret);
- return ret;
- }
-
- stmpe->irq = gpio_to_irq(pdata->irq_gpio);
+ stmpe->irq = gpiod_to_irq(pdata->irq_gpio);
} else {
stmpe->irq = ci->irq;
}
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 0985ab216566b..a6fb9966c82a1 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -28,8 +28,7 @@
#include <linux/irq.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <asm/delay.h>
#include <asm/irq.h>
@@ -1421,8 +1420,7 @@ dm9000_probe(struct platform_device *pdev)
int iosize;
int i;
u32 id_val;
- int reset_gpios;
- enum of_gpio_flags flags;
+ struct gpio_desc *reset_gpios;
struct regulator *power;
bool inv_mac_addr = false;
u8 addr[ETH_ALEN];
@@ -1442,20 +1440,17 @@ dm9000_probe(struct platform_device *pdev)
dev_dbg(dev, "regulator enabled\n");
}
- reset_gpios = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0,
- &flags);
- if (gpio_is_valid(reset_gpios)) {
- ret = devm_gpio_request_one(dev, reset_gpios, flags,
- "dm9000_reset");
- if (ret) {
- dev_err(dev, "failed to request reset gpio %d: %d\n",
- reset_gpios, ret);
- goto out_regulator_disable;
- }
+ reset_gpios = devm_gpiod_get_optional(dev, "reset-gpios", GPIOD_OUT_LOW);
+ if (IS_ERR(reset_gpios)) {
+ dev_err(dev, "failed to request reset gpio: %d\n", ret);
+ goto out_regulator_disable;
+ }
+
+ if (reset_gpios) {
/* According to manual PWRST# Low Period Min 1ms */
msleep(2);
- gpio_set_value(reset_gpios, 1);
+ gpiod_set_value(reset_gpios, 1);
/* Needs 3ms to read eeprom when PWRST is deasserted */
msleep(4);
}
diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h
index 6f34a61739b66..fecd43754cead 100644
--- a/drivers/net/ethernet/micrel/ks8851.h
+++ b/drivers/net/ethernet/micrel/ks8851.h
@@ -403,7 +403,7 @@ struct ks8851_net {
struct eeprom_93cx6 eeprom;
struct regulator *vdd_reg;
struct regulator *vdd_io;
- int gpio;
+ struct gpio_desc *gpio;
struct mii_bus *mii_bus;
void (*lock)(struct ks8851_net *ks,
diff --git a/drivers/net/ethernet/micrel/ks8851_common.c b/drivers/net/ethernet/micrel/ks8851_common.c
index 691206f19ea7b..57753cb522272 100644
--- a/drivers/net/ethernet/micrel/ks8851_common.c
+++ b/drivers/net/ethernet/micrel/ks8851_common.c
@@ -18,8 +18,7 @@
#include <linux/crc32.h>
#include <linux/mii.h>
#include <linux/regulator/consumer.h>
-
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
@@ -1117,24 +1116,17 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
{
struct ks8851_net *ks = netdev_priv(netdev);
unsigned cider;
- int gpio;
int ret;
ks->netdev = netdev;
ks->tx_space = 6144;
- gpio = of_get_named_gpio_flags(dev->of_node, "reset-gpios", 0, NULL);
- if (gpio == -EPROBE_DEFER)
- return gpio;
-
- ks->gpio = gpio;
- if (gpio_is_valid(gpio)) {
- ret = devm_gpio_request_one(dev, gpio,
- GPIOF_OUT_INIT_LOW, "ks8851_rst_n");
- if (ret) {
+ ks->gpio = gpiod_get(dev, "reset-gpios", GPIOD_OUT_LOW);
+ if (IS_ERR(ks->gpio)) {
+ ret = PTR_ERR(ks->gpio);
+ if (ret != -EPROBE_DEFER)
dev_err(dev, "reset gpio request failed\n");
- return ret;
- }
+ return ret;
}
ks->vdd_io = devm_regulator_get(dev, "vdd-io");
@@ -1161,9 +1153,9 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
goto err_reg;
}
- if (gpio_is_valid(gpio)) {
+ if (ks->gpio) {
usleep_range(10000, 11000);
- gpio_set_value(gpio, 1);
+ gpiod_set_value(ks->gpio, 1);
}
spin_lock_init(&ks->statelock);
@@ -1239,8 +1231,8 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev,
err_id:
ks8851_unregister_mdiobus(ks);
err_mdio:
- if (gpio_is_valid(gpio))
- gpio_set_value(gpio, 0);
+ if (ks->gpio)
+ gpiod_set_value(ks->gpio, 0);
regulator_disable(ks->vdd_reg);
err_reg:
regulator_disable(ks->vdd_io);
@@ -1259,8 +1251,8 @@ void ks8851_remove_common(struct device *dev)
dev_info(dev, "remove\n");
unregister_netdev(priv->netdev);
- if (gpio_is_valid(priv->gpio))
- gpio_set_value(priv->gpio, 0);
+ if (priv->gpio)
+ gpiod_set_value(priv->gpio, 0);
regulator_disable(priv->vdd_reg);
regulator_disable(priv->vdd_io);
}
diff --git a/drivers/net/phy/spi_ks8995.c b/drivers/net/phy/spi_ks8995.c
index 8b5445a724ce5..e9e0161da2fd4 100644
--- a/drivers/net/phy/spi_ks8995.c
+++ b/drivers/net/phy/spi_ks8995.c
@@ -138,8 +138,7 @@ static const struct ks8995_chip_params ks8995_chip[] = {
};
struct ks8995_pdata {
- int reset_gpio;
- enum of_gpio_flags reset_gpio_flags;
+ struct gpio_desc *reset_gpio;
};
struct ks8995_switch {
@@ -401,24 +400,6 @@ err_out:
return err;
}
-/* ks8995_parse_dt - setup platform data from devicetree
- * @ks: pointer to switch instance
- *
- * Parses supported DT properties and sets up platform data
- * accordingly.
- */
-static void ks8995_parse_dt(struct ks8995_switch *ks)
-{
- struct device_node *np = ks->spi->dev.of_node;
- struct ks8995_pdata *pdata = ks->pdata;
-
- if (!np)
- return;
-
- pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios", 0,
- &pdata->reset_gpio_flags);
-}
-
static const struct bin_attribute ks8995_registers_attr = {
.attr = {
.name = "registers",
@@ -449,38 +430,18 @@ static int ks8995_probe(struct spi_device *spi)
ks->spi = spi;
ks->chip = &ks8995_chip[variant];
- if (ks->spi->dev.of_node) {
- ks->pdata = devm_kzalloc(&spi->dev, sizeof(*ks->pdata),
- GFP_KERNEL);
- if (!ks->pdata)
- return -ENOMEM;
-
- ks->pdata->reset_gpio = -1;
-
- ks8995_parse_dt(ks);
- }
-
+ ks->pdata = devm_kzalloc(&spi->dev, sizeof(*ks->pdata),
+ GFP_KERNEL);
if (!ks->pdata)
- ks->pdata = spi->dev.platform_data;
-
- /* de-assert switch reset */
- if (ks->pdata && gpio_is_valid(ks->pdata->reset_gpio)) {
- unsigned long flags;
-
- flags = (ks->pdata->reset_gpio_flags == OF_GPIO_ACTIVE_LOW ?
- GPIOF_ACTIVE_LOW : 0);
+ return -ENOMEM;
- err = devm_gpio_request_one(&spi->dev,
- ks->pdata->reset_gpio,
- flags, "switch-reset");
- if (err) {
- dev_err(&spi->dev,
- "failed to get reset-gpios: %d\n", err);
- return -EIO;
- }
+ ks->pdata->reset_gpio = devm_gpiod_get_optional(&ks->spi->dev,
+ "reset-gpios", 0);
+ if (IS_ERR(ks->pdata->reset_gpio))
+ return PTR_ERR(ks->pdata->reset_gpio);
- gpiod_set_value(gpio_to_desc(ks->pdata->reset_gpio), 0);
- }
+ /* de-assert switch reset */
+ gpiod_set_value(ks->pdata->reset_gpio, 0);
spi_set_drvdata(spi, ks);
@@ -524,8 +485,7 @@ static int ks8995_remove(struct spi_device *spi)
sysfs_remove_bin_file(&spi->dev.kobj, &ks->regs_attr);
/* assert reset */
- if (ks->pdata && gpio_is_valid(ks->pdata->reset_gpio))
- gpiod_set_value(gpio_to_desc(ks->pdata->reset_gpio), 1);
+ gpiod_set_value(ks->pdata->reset_gpio, 1);
return 0;
}
diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c
index 410555dccb6d9..60bcb15a95301 100644
--- a/drivers/pci/controller/dwc/pcie-histb.c
+++ b/drivers/pci/controller/dwc/pcie-histb.c
@@ -60,7 +60,7 @@ struct histb_pcie {
struct reset_control *sys_reset;
struct reset_control *bus_reset;
void __iomem *ctrl;
- int reset_gpio;
+ struct gpio_desc *reset_gpio;
struct regulator *vpcie;
};
@@ -212,8 +212,8 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie)
clk_disable_unprepare(hipcie->sys_clk);
clk_disable_unprepare(hipcie->bus_clk);
- if (gpio_is_valid(hipcie->reset_gpio))
- gpio_set_value_cansleep(hipcie->reset_gpio, 0);
+ if (hipcie->reset_gpio)
+ gpiod_set_value_cansleep(hipcie->reset_gpio, 0);
if (hipcie->vpcie)
regulator_disable(hipcie->vpcie);
@@ -235,8 +235,8 @@ static int histb_pcie_host_enable(struct pcie_port *pp)
}
}
- if (gpio_is_valid(hipcie->reset_gpio))
- gpio_set_value_cansleep(hipcie->reset_gpio, 1);
+ if (hipcie->reset_gpio)
+ gpiod_set_value_cansleep(hipcie->reset_gpio, 1);
ret = clk_prepare_enable(hipcie->bus_clk);
if (ret) {
@@ -298,10 +298,7 @@ static int histb_pcie_probe(struct platform_device *pdev)
struct histb_pcie *hipcie;
struct dw_pcie *pci;
struct pcie_port *pp;
- struct device_node *np = pdev->dev.of_node;
struct device *dev = &pdev->dev;
- enum of_gpio_flags of_flags;
- unsigned long flag = GPIOF_DIR_OUT;
int ret;
hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL);
@@ -336,17 +333,11 @@ static int histb_pcie_probe(struct platform_device *pdev)
hipcie->vpcie = NULL;
}
- hipcie->reset_gpio = of_get_named_gpio_flags(np,
- "reset-gpios", 0, &of_flags);
- if (of_flags & OF_GPIO_ACTIVE_LOW)
- flag |= GPIOF_ACTIVE_LOW;
- if (gpio_is_valid(hipcie->reset_gpio)) {
- ret = devm_gpio_request_one(dev, hipcie->reset_gpio,
- flag, "PCIe device power control");
- if (ret) {
- dev_err(dev, "unable to request gpio\n");
- return ret;
- }
+ hipcie->reset_gpio = devm_gpiod_get_optional(dev, "reset-gpios",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(hipcie->reset_gpio)) {
+ dev_err(dev, "unable to request gpio\n");
+ return PTR_ERR(hipcie->reset_gpio);
}
hipcie->aux_clk = devm_clk_get(dev, "aux");
diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
index 4e3dafce1e2ac..8ef5fd93d56ba 100644
--- a/drivers/pci/controller/pci-mvebu.c
+++ b/drivers/pci/controller/pci-mvebu.c
@@ -810,8 +810,7 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
struct mvebu_pcie_port *port, struct device_node *child)
{
struct device *dev = &pcie->pdev->dev;
- enum of_gpio_flags flags;
- int reset_gpio, ret;
+ int ret;
port->pcie = pcie;
@@ -851,40 +850,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
port->io_attr = -1;
}
- reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
- if (reset_gpio == -EPROBE_DEFER) {
- ret = reset_gpio;
+ port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
+ port->name);
+ if (!port->reset_name) {
+ ret = -ENOMEM;
goto err;
}
- if (gpio_is_valid(reset_gpio)) {
- unsigned long gpio_flags;
-
- port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
- port->name);
- if (!port->reset_name) {
- ret = -ENOMEM;
- goto err;
- }
-
- if (flags & OF_GPIO_ACTIVE_LOW) {
- dev_info(dev, "%pOF: reset gpio is active low\n",
- child);
- gpio_flags = GPIOF_ACTIVE_LOW |
- GPIOF_OUT_INIT_LOW;
- } else {
- gpio_flags = GPIOF_OUT_INIT_HIGH;
- }
-
- ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
- port->reset_name);
- if (ret) {
- if (ret == -EPROBE_DEFER)
- goto err;
- goto skip;
- }
+ port->reset_gpio = fwnode_get_named_gpiod(of_node_to_fwnode(child),
+ "reset-gpios", 0,
+ GPIOD_OUT_HIGH,
+ port->reset_name);
+ if (port->reset_gpio == ERR_PTR(-EPROBE_DEFER)) {
+ ret = -EPROBE_DEFER;
+ goto err;
+ }
- port->reset_gpio = gpio_to_desc(reset_gpio);
+ if (IS_ERR(port->reset_gpio)) {
+ port->reset_gpio = NULL;
}
port->clk = of_clk_get_by_name(child, NULL);
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 92df2c2c5d076..45d34fcb35db1 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -36,10 +36,10 @@
#define CF_MEM_PHYS (0x017ff800)
struct at91_cf_data {
- int irq_pin; /* I/O IRQ */
- int det_pin; /* Card detect */
- int vcc_pin; /* power switching */
- int rst_pin; /* card reset */
+ struct gpio_desc *irq_pin; /* I/O IRQ */
+ struct gpio_desc *det_pin; /* Card detect */
+ struct gpio_desc *vcc_pin; /* power switching */
+ struct gpio_desc *rst_pin; /* card reset */
u8 chipselect; /* EBI Chip Select number */
u8 flags;
#define AT91_CF_TRUE_IDE 0x01
@@ -63,7 +63,7 @@ struct at91_cf_socket {
static inline int at91_cf_present(struct at91_cf_socket *cf)
{
- return !gpio_get_value(cf->board->det_pin);
+ return !gpiod_get_value(cf->board->det_pin);
}
/*--------------------------------------------------------------------------*/
@@ -77,7 +77,7 @@ static irqreturn_t at91_cf_irq(int irq, void *_cf)
{
struct at91_cf_socket *cf = _cf;
- if (irq == gpio_to_irq(cf->board->det_pin)) {
+ if (irq == gpiod_to_irq(cf->board->det_pin)) {
unsigned present = at91_cf_present(cf);
/* kick pccard as needed */
@@ -103,13 +103,13 @@ static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp)
/* NOTE: CF is always 3VCARD */
if (at91_cf_present(cf)) {
- int rdy = gpio_is_valid(cf->board->irq_pin); /* RDY/nIRQ */
- int vcc = gpio_is_valid(cf->board->vcc_pin);
+ int rdy = !!cf->board->irq_pin; /* RDY/nIRQ */
+ int vcc = !!cf->board->vcc_pin;
*sp = SS_DETECT | SS_3VCARD;
- if (!rdy || gpio_get_value(cf->board->irq_pin))
+ if (!rdy || gpiod_get_value(cf->board->irq_pin))
*sp |= SS_READY;
- if (!vcc || gpio_get_value(cf->board->vcc_pin))
+ if (!vcc || gpiod_get_value(cf->board->vcc_pin))
*sp |= SS_POWERON;
} else
*sp = 0;
@@ -125,21 +125,19 @@ at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
cf = container_of(sock, struct at91_cf_socket, socket);
/* switch Vcc if needed and possible */
- if (gpio_is_valid(cf->board->vcc_pin)) {
- switch (s->Vcc) {
- case 0:
- gpio_set_value(cf->board->vcc_pin, 0);
- break;
- case 33:
- gpio_set_value(cf->board->vcc_pin, 1);
- break;
- default:
- return -EINVAL;
- }
+ switch (s->Vcc) {
+ case 0:
+ gpiod_set_value(cf->board->vcc_pin, 0);
+ break;
+ case 33:
+ gpiod_set_value(cf->board->vcc_pin, 1);
+ break;
+ default:
+ return -EINVAL;
}
/* toggle reset if needed */
- gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET);
+ gpiod_set_value(cf->board->rst_pin, s->flags & SS_RESET);
dev_dbg(&cf->pdev->dev, "Vcc %d, io_irq %d, flags %04x csc %04x\n",
s->Vcc, s->io_irq, s->flags, s->csc_mask);
@@ -238,18 +236,26 @@ static int at91_cf_probe(struct platform_device *pdev)
if (!board)
return -ENOMEM;
- board->irq_pin = of_get_gpio(pdev->dev.of_node, 0);
- board->det_pin = of_get_gpio(pdev->dev.of_node, 1);
- board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2);
- board->rst_pin = of_get_gpio(pdev->dev.of_node, 3);
+ board->irq_pin = devm_gpiod_get_index_optional(&pdev->dev, NULL, 0, GPIOD_IN);
+ if (IS_ERR(board->irq_pin))
+ return PTR_ERR(board->irq_pin);
+
+ board->det_pin = devm_gpiod_get_index(&pdev->dev, NULL, 1, GPIOD_IN);
+ if (IS_ERR(board->det_pin))
+ return PTR_ERR(board->det_pin);
+
+ board->vcc_pin = devm_gpiod_get_index(&pdev->dev, NULL, 2, GPIOD_IN);
+ if (IS_ERR(board->vcc_pin))
+ return PTR_ERR(board->vcc_pin);
+
+ board->rst_pin = devm_gpiod_get_index(&pdev->dev, NULL, 3, GPIOD_OUT_LOW);
+ if (IS_ERR(board->rst_pin))
+ return PTR_ERR(board->rst_pin);
mc = syscon_regmap_lookup_by_compatible("atmel,at91rm9200-sdramc");
if (IS_ERR(mc))
return PTR_ERR(mc);
- if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin))
- return -ENODEV;
-
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!io)
return -ENODEV;
@@ -263,27 +269,13 @@ static int at91_cf_probe(struct platform_device *pdev)
cf->phys_baseaddr = io->start;
platform_set_drvdata(pdev, cf);
- /* must be a GPIO; ergo must trigger on both edges */
- status = devm_gpio_request(&pdev->dev, board->det_pin, "cf_det");
- if (status < 0)
- return status;
-
- status = devm_request_irq(&pdev->dev, gpio_to_irq(board->det_pin),
+ status = devm_request_irq(&pdev->dev, gpiod_to_irq(board->det_pin),
at91_cf_irq, 0, "at91_cf detect", cf);
if (status < 0)
return status;
device_init_wakeup(&pdev->dev, 1);
- status = devm_gpio_request(&pdev->dev, board->rst_pin, "cf_rst");
- if (status < 0)
- goto fail0a;
-
- if (gpio_is_valid(board->vcc_pin)) {
- status = devm_gpio_request(&pdev->dev, board->vcc_pin, "cf_vcc");
- if (status < 0)
- goto fail0a;
- }
/*
* The card driver will request this irq later as needed.
@@ -291,16 +283,12 @@ static int at91_cf_probe(struct platform_device *pdev)
* unless we report that we handle everything (sigh).
* (Note: DK board doesn't wire the IRQ pin...)
*/
- if (gpio_is_valid(board->irq_pin)) {
- status = devm_gpio_request(&pdev->dev, board->irq_pin, "cf_irq");
- if (status < 0)
- goto fail0a;
-
- status = devm_request_irq(&pdev->dev, gpio_to_irq(board->irq_pin),
+ if (!IS_ERR(board->irq_pin)) {
+ status = devm_request_irq(&pdev->dev, gpiod_to_irq(board->irq_pin),
at91_cf_irq, IRQF_SHARED, "at91_cf", cf);
if (status < 0)
goto fail0a;
- cf->socket.pci_irq = gpio_to_irq(board->irq_pin);
+ cf->socket.pci_irq = gpiod_to_irq(board->irq_pin);
} else
cf->socket.pci_irq = nr_irqs + 1;
@@ -322,7 +310,7 @@ static int at91_cf_probe(struct platform_device *pdev)
}
dev_info(&pdev->dev, "irqs det #%d, io #%d\n",
- gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin));
+ gpiod_to_irq(board->det_pin), gpiod_to_irq(board->irq_pin));
cf->socket.owner = THIS_MODULE;
cf->socket.dev.parent = &pdev->dev;
@@ -362,9 +350,9 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
struct at91_cf_data *board = cf->board;
if (device_may_wakeup(&pdev->dev)) {
- enable_irq_wake(gpio_to_irq(board->det_pin));
- if (gpio_is_valid(board->irq_pin))
- enable_irq_wake(gpio_to_irq(board->irq_pin));
+ enable_irq_wake(gpiod_to_irq(board->det_pin));
+ if (board->irq_pin)
+ enable_irq_wake(gpiod_to_irq(board->irq_pin));
}
return 0;
}
@@ -375,9 +363,9 @@ static int at91_cf_resume(struct platform_device *pdev)
struct at91_cf_data *board = cf->board;
if (device_may_wakeup(&pdev->dev)) {
- disable_irq_wake(gpio_to_irq(board->det_pin));
- if (gpio_is_valid(board->irq_pin))
- disable_irq_wake(gpio_to_irq(board->irq_pin));
+ disable_irq_wake(gpiod_to_irq(board->det_pin));
+ if (board->irq_pin)
+ disable_irq_wake(gpiod_to_irq(board->irq_pin));
}
return 0;
diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
index 54781f553f4e5..2351ab14fefbb 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -62,7 +62,7 @@ struct keystone_rproc {
u32 boot_offset;
int irq_ring;
int irq_fault;
- int kick_gpio;
+ struct gpio_desc *kick_gpio;
struct work_struct workqueue;
};
@@ -232,10 +232,10 @@ static void keystone_rproc_kick(struct rproc *rproc, int vqid)
{
struct keystone_rproc *ksproc = rproc->priv;
- if (WARN_ON(ksproc->kick_gpio < 0))
+ if (WARN_ON(IS_ERR(ksproc->kick_gpio)))
return;
- gpio_set_value(ksproc->kick_gpio, 1);
+ gpiod_set_value(ksproc->kick_gpio, 1);
}
/*
@@ -433,9 +433,9 @@ static int keystone_rproc_probe(struct platform_device *pdev)
goto disable_clk;
}
- ksproc->kick_gpio = of_get_named_gpio_flags(np, "kick-gpios", 0, NULL);
- if (ksproc->kick_gpio < 0) {
- ret = ksproc->kick_gpio;
+ ksproc->kick_gpio = gpiod_get(dev, "kick-gpios", 0);
+ if (IS_ERR(ksproc->kick_gpio)) {
+ ret = PTR_ERR(ksproc->kick_gpio);
dev_err(dev, "failed to get gpio for virtio kicks, status = %d\n",
ret);
goto disable_clk;
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 9cdace9f96dab..3215191d21211 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -154,7 +154,7 @@ struct qe_pin {
* This function return qe_pin so that you could use it with the rest of
* the QE Pin Multiplexing API.
*/
-struct qe_pin *qe_pin_request(struct device_node *np, int index)
+struct qe_pin *qe_pin_request(struct gpio_desc *desc)
{
struct qe_pin *qe_pin;
struct gpio_chip *gc;
@@ -168,10 +168,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
return ERR_PTR(-ENOMEM);
}
- err = of_get_gpio(np, index);
- if (err < 0)
- goto err0;
- gc = gpiod_to_chip(gpio_to_desc(err));
+ gc = gpiod_to_chip(desc);
if (WARN_ON(!gc)) {
err = -ENODEV;
goto err0;
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index 51041526546dd..b07ca0f49b77c 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -86,7 +86,7 @@ struct mpc52xx_spi {
const u8 *tx_buf;
int cs_change;
int gpio_cs_count;
- unsigned int *gpio_cs;
+ struct gpio_desc *gpio_cs[];
};
/*
@@ -98,7 +98,7 @@ static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms, int value)
if (ms->gpio_cs_count > 0) {
cs = ms->message->spi->chip_select;
- gpio_set_value(ms->gpio_cs[cs], value ? 0 : 1);
+ gpiod_set_value(ms->gpio_cs[cs], value ? 0 : 1);
} else
out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08);
}
@@ -385,7 +385,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
void __iomem *regs;
u8 ctrl1;
int rc, i = 0;
- int gpio_cs;
+ struct gpio_desc *gpio_cs;
/* MMIO registers */
dev_dbg(&op->dev, "probing mpc5200 SPI device\n");
@@ -447,23 +447,13 @@ static int mpc52xx_spi_probe(struct platform_device *op)
}
for (i = 0; i < ms->gpio_cs_count; i++) {
- gpio_cs = of_get_gpio(op->dev.of_node, i);
- if (!gpio_is_valid(gpio_cs)) {
+ gpio_cs = gpiod_get_index(&op->dev, NULL, i, GPIOD_OUT_LOW);
+ if (IS_ERR(gpio_cs)) {
dev_err(&op->dev,
- "could not parse the gpio field in oftree\n");
- rc = -ENODEV;
+ "can't request spi cs gpio #%d on gpio line\n", i);
goto err_gpio;
}
- rc = gpio_request(gpio_cs, dev_name(&op->dev));
- if (rc) {
- dev_err(&op->dev,
- "can't request spi cs gpio #%d on gpio line %d\n",
- i, gpio_cs);
- goto err_gpio;
- }
-
- gpio_direction_output(gpio_cs, 1);
ms->gpio_cs[i] = gpio_cs;
}
}
@@ -504,7 +494,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
dev_err(&ms->master->dev, "initialization failed\n");
err_gpio:
while (i-- > 0)
- gpio_free(ms->gpio_cs[i]);
+ gpio_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs);
err_alloc_gpio:
@@ -525,7 +515,7 @@ static int mpc52xx_spi_remove(struct platform_device *op)
free_irq(ms->irq1, ms);
for (i = 0; i < ms->gpio_cs_count; i++)
- gpio_free(ms->gpio_cs[i]);
+ gpio_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs);
spi_unregister_master(master);
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index dd0819df096e1..1fa5d66ad60ab 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1618,9 +1618,6 @@ static int at91rm9200_udc_init(struct at91_udc *udc)
return -ENODEV;
}
- gpiod_direction_output(udc->board.pullup_pin,
- gpiod_is_active_low(udc->board.pullup_pin));
-
return 0;
}
@@ -1768,26 +1765,24 @@ static const struct of_device_id at91_udc_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
-static void at91udc_of_init(struct at91_udc *udc, struct device_node *np)
+static void at91udc_of_init(struct at91_udc *udc, struct device *dev)
{
struct at91_udc_data *board = &udc->board;
const struct of_device_id *match;
u32 val;
- if (of_property_read_u32(np, "atmel,vbus-polled", &val) == 0)
+ if (of_property_read_u32(dev->of_node, "atmel,vbus-polled", &val) == 0)
board->vbus_polled = 1;
- board->vbus_pin = gpiod_get_from_of_node(np, "atmel,vbus-gpio", 0,
- GPIOD_IN, "udc_vbus");
+ board->vbus_pin = devm_gpiod_get_optional(dev, "atmel,vbus-gpio", GPIOD_IN);
if (IS_ERR(board->vbus_pin))
board->vbus_pin = NULL;
- board->pullup_pin = gpiod_get_from_of_node(np, "atmel,pullup-gpio", 0,
- GPIOD_ASIS, "udc_pullup");
+ board->pullup_pin = devm_gpiod_get_optional(dev, "atmel,pullup-gpio", GPIOD_ASIS);
if (IS_ERR(board->pullup_pin))
board->pullup_pin = NULL;
- match = of_match_node(at91_udc_dt_ids, np);
+ match = of_match_node(at91_udc_dt_ids, dev->of_node);
if (match)
udc->caps = match->data;
}
@@ -1806,7 +1801,7 @@ static int at91udc_probe(struct platform_device *pdev)
/* init software state */
udc->gadget.dev.parent = dev;
- at91udc_of_init(udc, pdev->dev.of_node);
+ at91udc_of_init(udc, dev);
udc->pdev = pdev;
udc->enabled = 0;
spin_lock_init(&udc->lock);
@@ -1876,8 +1871,6 @@ static int at91udc_probe(struct platform_device *pdev)
}
if (udc->board.vbus_pin) {
- gpiod_direction_input(udc->board.vbus_pin);
-
/*
* Get the initial state of VBUS - we cannot expect
* a pending interrupt.
@@ -1895,7 +1888,7 @@ static int at91udc_probe(struct platform_device *pdev)
at91_vbus_irq, 0, driver_name, udc);
if (retval) {
DBG("request vbus irq %d failed\n",
- udc->board.vbus_pin);
+ gpiod_to_irq(udc->board.vbus_pin));
goto err_unprepare_iclk;
}
}
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index a8e1048278d0c..7dcd05c2bff7d 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -150,15 +150,15 @@ int fhci_ioports_check_bus_state(struct fhci_hcd *fhci)
u8 bits = 0;
/* check USBOE,if transmitting,exit */
- if (!gpio_get_value(fhci->gpios[GPIO_USBOE]))
+ if (!gpiod_get_value(fhci->gpios[GPIO_USBOE]))
return -1;
/* check USBRP */
- if (gpio_get_value(fhci->gpios[GPIO_USBRP]))
+ if (gpiod_get_value(fhci->gpios[GPIO_USBRP]))
bits |= 0x2;
/* check USBRN */
- if (gpio_get_value(fhci->gpios[GPIO_USBRN]))
+ if (gpiod_get_value(fhci->gpios[GPIO_USBRN]))
bits |= 0x1;
return bits;
@@ -630,46 +630,31 @@ static int of_fhci_probe(struct platform_device *ofdev)
fhci->pram = cpm_muram_addr(pram_addr);
/* GPIOs and pins */
- for (i = 0; i < NUM_GPIOS; i++) {
- int gpio;
- enum of_gpio_flags flags;
-
- gpio = of_get_gpio_flags(node, i, &flags);
- fhci->gpios[i] = gpio;
- fhci->alow_gpios[i] = flags & OF_GPIO_ACTIVE_LOW;
-
- if (!gpio_is_valid(gpio)) {
- if (i < GPIO_SPEED) {
- dev_err(dev, "incorrect GPIO%d: %d\n",
- i, gpio);
- goto err_gpios;
- } else {
- dev_info(dev, "assuming board doesn't have "
- "%s gpio\n", i == GPIO_SPEED ?
- "speed" : "power");
- continue;
- }
+ for (i = 0; i < GPIO_SPEED; i++) {
+ fhci->gpios[i] = gpiod_get_index(dev, NULL, i, 0);
+ if (IS_ERR(fhci->gpios[i])) {
+ dev_err(dev, "incorrect GPIO%d: %d\n", i, gpio);
+ goto err_gpios;
}
+ }
- ret = gpio_request(gpio, dev_name(dev));
- if (ret) {
- dev_err(dev, "failed to request gpio %d", i);
+ for (i = GPIO_SPEED; i < NUM_GPIOS; i++) {
+ fhci->gpios[i] = gpiod_get_index_optional(dev, NULL, i,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(fhci->gpios[i])) {
+ dev_err(dev, "incorrect GPIO%d: %d\n", i, gpio);
goto err_gpios;
}
-
- if (i >= GPIO_SPEED) {
- ret = gpio_direction_output(gpio, 0);
- if (ret) {
- dev_err(dev, "failed to set gpio %d as "
- "an output\n", i);
- i++;
- goto err_gpios;
- }
+ if (!fhci->gpios[i]) {
+ dev_info(dev, "assuming board doesn't have "
+ "%s gpio\n", i == GPIO_SPEED ?
+ "speed" : "power");
+ continue;
}
}
for (j = 0; j < NUM_PINS; j++) {
- fhci->pins[j] = qe_pin_request(node, j);
+ fhci->pins[j] = qe_pin_request(fhci->gpios[i]);
if (IS_ERR(fhci->pins[j])) {
ret = PTR_ERR(fhci->pins[j]);
dev_err(dev, "can't get pin %d: %d\n", j, ret);
@@ -768,8 +753,7 @@ err_pins:
qe_pin_free(fhci->pins[j]);
err_gpios:
while (--i >= 0) {
- if (gpio_is_valid(fhci->gpios[i]))
- gpio_free(fhci->gpios[i]);
+ gpiod_put(fhci->gpios[i]);
}
cpm_muram_free(pram_addr);
err_pram:
@@ -790,11 +774,9 @@ static int fhci_remove(struct device *dev)
free_irq(fhci->timer->irq, hcd);
gtm_put_timer16(fhci->timer);
cpm_muram_free(cpm_muram_offset(fhci->pram));
- for (i = 0; i < NUM_GPIOS; i++) {
- if (!gpio_is_valid(fhci->gpios[i]))
- continue;
- gpio_free(fhci->gpios[i]);
- }
+ for (i = 0; i < NUM_GPIOS; i++)
+ gpiod_put(fhci->gpios[i]);
+
for (j = 0; j < NUM_PINS; j++)
qe_pin_free(fhci->pins[j]);
fhci_dfs_destroy(fhci);
diff --git a/drivers/usb/host/fhci-hub.c b/drivers/usb/host/fhci-hub.c
index c359dcdb9b137..8ed2416cee160 100644
--- a/drivers/usb/host/fhci-hub.c
+++ b/drivers/usb/host/fhci-hub.c
@@ -38,13 +38,7 @@ static u8 root_hub_des[] = {
static void fhci_gpio_set_value(struct fhci_hcd *fhci, int gpio_nr, bool on)
{
- int gpio = fhci->gpios[gpio_nr];
- bool alow = fhci->alow_gpios[gpio_nr];
-
- if (!gpio_is_valid(gpio))
- return;
-
- gpio_set_value(gpio, on ^ alow);
+ gpiod_set_value(fhci->gpios[gpio_nr], on);
mdelay(5);
}
@@ -129,9 +123,9 @@ void fhci_io_port_generate_reset(struct fhci_hcd *fhci)
{
fhci_dbg(fhci, "-> %s\n", __func__);
- gpio_direction_output(fhci->gpios[GPIO_USBOE], 0);
- gpio_direction_output(fhci->gpios[GPIO_USBTP], 0);
- gpio_direction_output(fhci->gpios[GPIO_USBTN], 0);
+ gpiod_direction_output(fhci->gpios[GPIO_USBOE], 0);
+ gpiod_direction_output(fhci->gpios[GPIO_USBTP], 0);
+ gpiod_direction_output(fhci->gpios[GPIO_USBTN], 0);
mdelay(5);
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 81fbc019a9b3e..f729446f837c8 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -242,8 +242,7 @@ struct fhci_hcd {
enum qe_clock fullspeed_clk;
enum qe_clock lowspeed_clk;
struct qe_pin *pins[NUM_PINS];
- int gpios[NUM_GPIOS];
- bool alow_gpios[NUM_GPIOS];
+ struct gpio_desc *gpios[NUM_GPIOS];
struct qe_usb_ctlr __iomem *regs; /* I/O memory used to communicate */
struct fhci_pram __iomem *pram; /* Parameter RAM */
diff --git a/include/linux/input/auo-pixcir-ts.h b/include/linux/input/auo-pixcir-ts.h
index ed0776997a7a5..7d53c4930fbd7 100644
--- a/include/linux/input/auo-pixcir-ts.h
+++ b/include/linux/input/auo-pixcir-ts.h
@@ -32,8 +32,8 @@
* @y_max y-resolution
*/
struct auo_pixcir_ts_platdata {
- int gpio_int;
- int gpio_rst;
+ struct gpio_desc *gpio_int;
+ struct gpio_desc *gpio_rst;
int int_setting;
diff --git a/include/linux/platform_data/ssm2518.h b/include/linux/platform_data/ssm2518.h
index 3f9e632d6f633..a279b1d9dc086 100644
--- a/include/linux/platform_data/ssm2518.h
+++ b/include/linux/platform_data/ssm2518.h
@@ -15,7 +15,6 @@
* hardwired.
*/
struct ssm2518_platform_data {
- int enable_gpio;
};
#endif
diff --git a/include/media/i2c/s5c73m3.h b/include/media/i2c/s5c73m3.h
index a51f1025ba1c6..fd4fbe7099ba1 100644
--- a/include/media/i2c/s5c73m3.h
+++ b/include/media/i2c/s5c73m3.h
@@ -20,11 +20,6 @@
#include <linux/videodev2.h>
#include <media/v4l2-mediabus.h>
-/**
- * struct s5c73m3_gpio - data structure describing a GPIO
- * @gpio: GPIO number
- * @level: indicates active state of the @gpio
- */
struct s5c73m3_gpio {
int gpio;
int level;
diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
index b02e9fe69146a..fc2c390252d0c 100644
--- a/include/soc/fsl/qe/qe.h
+++ b/include/soc/fsl/qe/qe.h
@@ -173,13 +173,14 @@ static inline int par_io_data_set(u8 port, u8 pin, u8 val) { return -ENOSYS; }
* Pin multiplexing functions.
*/
struct qe_pin;
+struct gpio_desc;
#ifdef CONFIG_QE_GPIO
-extern struct qe_pin *qe_pin_request(struct device_node *np, int index);
+extern struct qe_pin *qe_pin_request(struct gpio_desc *desc);
extern void qe_pin_free(struct qe_pin *qe_pin);
extern void qe_pin_set_gpio(struct qe_pin *qe_pin);
extern void qe_pin_set_dedicated(struct qe_pin *pin);
#else
-static inline struct qe_pin *qe_pin_request(struct device_node *np, int index)
+static inline struct qe_pin *qe_pin_request(struct gpio_desc *desc)
{
return ERR_PTR(-ENOSYS);
}
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c
index 09449c6c4024d..bc101de97eb65 100644
--- a/sound/soc/codecs/ssm2518.c
+++ b/sound/soc/codecs/ssm2518.c
@@ -114,7 +114,7 @@ struct ssm2518 {
unsigned int sysclk;
const struct snd_pcm_hw_constraint_list *constraints;
- int enable_gpio;
+ struct gpio_desc *enable_gpio;
};
static const struct reg_default ssm2518_reg_defaults[] = {
@@ -483,8 +483,7 @@ static int ssm2518_set_power(struct ssm2518 *ssm2518, bool enable)
regcache_mark_dirty(ssm2518->regmap);
}
- if (gpio_is_valid(ssm2518->enable_gpio))
- gpio_set_value(ssm2518->enable_gpio, enable);
+ gpiod_set_value(ssm2518->enable_gpio, enable);
regcache_cache_only(ssm2518->regmap, !enable);
@@ -738,7 +737,6 @@ static const struct regmap_config ssm2518_regmap_config = {
static int ssm2518_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
- struct ssm2518_platform_data *pdata = i2c->dev.platform_data;
struct ssm2518 *ssm2518;
int ret;
@@ -746,22 +744,11 @@ static int ssm2518_i2c_probe(struct i2c_client *i2c,
if (ssm2518 == NULL)
return -ENOMEM;
- if (pdata) {
- ssm2518->enable_gpio = pdata->enable_gpio;
- } else if (i2c->dev.of_node) {
- ssm2518->enable_gpio = of_get_gpio(i2c->dev.of_node, 0);
- if (ssm2518->enable_gpio < 0 && ssm2518->enable_gpio != -ENOENT)
- return ssm2518->enable_gpio;
- } else {
- ssm2518->enable_gpio = -1;
- }
- if (gpio_is_valid(ssm2518->enable_gpio)) {
- ret = devm_gpio_request_one(&i2c->dev, ssm2518->enable_gpio,
- GPIOF_OUT_INIT_HIGH, "SSM2518 nSD");
- if (ret)
- return ret;
- }
+ ssm2518->enable_gpio = devm_gpiod_get_optional(&i2c->dev, NULL,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(ssm2518->enable_gpio))
+ return PTR_ERR(ssm2518->enable_gpio);
i2c_set_clientdata(i2c, ssm2518);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 850e968677f10..60a25a86ab3f6 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -559,12 +559,11 @@ int asoc_simple_init_jack(struct snd_soc_card *card,
char *pin)
{
struct device *dev = card->dev;
- enum of_gpio_flags flags;
char prop[128];
char *pin_name;
char *gpio_name;
int mask;
- int det;
+ struct gpio_desc *det;
if (!prefix)
prefix = "";
@@ -583,18 +582,17 @@ int asoc_simple_init_jack(struct snd_soc_card *card,
mask = SND_JACK_MICROPHONE;
}
- det = of_get_named_gpio_flags(dev->of_node, prop, 0, &flags);
- if (det == -EPROBE_DEFER)
+ det = gpiod_get(dev, prop, GPIOD_IN);
+ if (det == ERR_PTR(-EPROBE_DEFER))
return -EPROBE_DEFER;
- if (gpio_is_valid(det)) {
+ if (!IS_ERR(det)) {
sjack->pin.pin = pin_name;
sjack->pin.mask = mask;
sjack->gpio.name = gpio_name;
sjack->gpio.report = mask;
- sjack->gpio.gpio = det;
- sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW);
+ sjack->gpio.desc = det;
sjack->gpio.debounce_time = 150;
snd_soc_card_jack_new(card, pin_name, mask,