From 86d3f367686852cde028cf6c12cb0e944f28a784 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 9 Mar 2016 20:39:57 +0800 Subject: gpio: menz127: Drop *mdev field from struct men_z127_gpio No need to store *medv in struct men_z127_gpio. Signed-off-by: Axel Lin Signed-off-by: Linus Walleij --- drivers/gpio/gpio-menz127.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/gpio/gpio-menz127.c') diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c index a68e199d579d..8c1ab8e1974f 100644 --- a/drivers/gpio/gpio-menz127.c +++ b/drivers/gpio/gpio-menz127.c @@ -35,7 +35,6 @@ struct men_z127_gpio { struct gpio_chip gc; void __iomem *reg_base; - struct mcb_device *mdev; struct resource *mem; spinlock_t lock; }; @@ -44,7 +43,7 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio, unsigned debounce) { struct men_z127_gpio *priv = gpiochip_get_data(gc); - struct device *dev = &priv->mdev->dev; + struct device *dev = gc->parent; unsigned int rnd; u32 db_en, db_cnt; @@ -136,7 +135,6 @@ static int men_z127_probe(struct mcb_device *mdev, goto err_release; } - men_z127_gpio->mdev = mdev; mcb_set_drvdata(mdev, men_z127_gpio); ret = bgpio_init(&men_z127_gpio->gc, &mdev->dev, 4, -- cgit v1.2.3 From 811a1882b12bbbcbd447ad8c4d16d170e196c58f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 9 Apr 2016 21:53:39 +0200 Subject: gpio: menz127: use the new open drain callback The menz127 driver tries to support open drain by detecting it at request time. However: without the new callbacks from the gpiolib it is not really working: the core will still just emulate the open drain mode by switching the line to an input. By adding a hook into the new .set_single_ended() call rather than trying to autodetect at request() time, proper open drain can be supported. Cc: Andreas Werner Signed-off-by: Linus Walleij --- drivers/gpio/gpio-menz127.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/gpio/gpio-menz127.c') diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c index 8c1ab8e1974f..334fe270dcf1 100644 --- a/drivers/gpio/gpio-menz127.c +++ b/drivers/gpio/gpio-menz127.c @@ -88,21 +88,25 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio, return 0; } -static int men_z127_request(struct gpio_chip *gc, unsigned gpio_pin) +static int men_z127_set_single_ended(struct gpio_chip *gc, + unsigned offset, + enum single_ended_mode mode) { struct men_z127_gpio *priv = gpiochip_get_data(gc); u32 od_en; - if (gpio_pin >= gc->ngpio) - return -EINVAL; + if (mode != LINE_MODE_OPEN_DRAIN && + mode != LINE_MODE_PUSH_PULL) + return -ENOTSUPP; spin_lock(&priv->lock); od_en = readl(priv->reg_base + MEN_Z127_ODER); - if (gpiochip_line_is_open_drain(gc, gpio_pin)) - od_en |= BIT(gpio_pin); + if (mode == LINE_MODE_OPEN_DRAIN) + od_en |= BIT(offset); else - od_en &= ~BIT(gpio_pin); + /* Implicitly LINE_MODE_PUSH_PULL */ + od_en &= ~BIT(offset); writel(od_en, priv->reg_base + MEN_Z127_ODER); spin_unlock(&priv->lock); @@ -147,7 +151,7 @@ static int men_z127_probe(struct mcb_device *mdev, goto err_unmap; men_z127_gpio->gc.set_debounce = men_z127_debounce; - men_z127_gpio->gc.request = men_z127_request; + men_z127_gpio->gc.set_single_ended = men_z127_set_single_ended; ret = gpiochip_add_data(&men_z127_gpio->gc, men_z127_gpio); if (ret) { -- cgit v1.2.3