Skip to content

Commit bc90942

Browse files
committed
Merge tag 'gpio-fixes-v3.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: - Fix a potential bit wrap issue in the Timberdale driver - Fix up the buffer allocation size in the 74x164 driver - Set the value in direction_output() right in the mvebu driver - Return proper error codes for invalid GPIOs - Fix an off-mode bug for the OMAP - Don't initialize the mask_cach on the mvebu driver * tag 'gpio-fixes-v3.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: GPIO: mvebu-gpio: Don't initialize the mask_cache gpio/omap: fix off-mode bug: clear debounce settings on free/reset gpiolib: Don't return -EPROBE_DEFER to sysfs, or for invalid gpios gpio: mvebu: correctly set the value in direction_output() gpio-74x164: Fix buffer allocation size gpio-timberdale: fix a potential wrapping issue
2 parents 8c673cb + 8fcff5f commit bc90942

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

drivers/gpio/gpio-74x164.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int __devinit gen_74x164_probe(struct spi_device *spi)
153153
}
154154

155155
chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
156-
chip->buffer = devm_kzalloc(&spi->dev, chip->gpio_chip.ngpio, GFP_KERNEL);
156+
chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
157157
if (!chip->buffer) {
158158
ret = -ENOMEM;
159159
goto exit_destroy;

drivers/gpio/gpio-mvebu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin,
244244
if (ret)
245245
return ret;
246246

247+
mvebu_gpio_set(chip, pin, value);
248+
247249
spin_lock_irqsave(&mvchip->lock, flags);
248250
u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip));
249251
u &= ~(1 << pin);
@@ -644,7 +646,7 @@ static int __devinit mvebu_gpio_probe(struct platform_device *pdev)
644646
ct->handler = handle_edge_irq;
645647
ct->chip.name = mvchip->chip.label;
646648

647-
irq_setup_generic_chip(gc, IRQ_MSK(ngpios), IRQ_GC_INIT_MASK_CACHE,
649+
irq_setup_generic_chip(gc, IRQ_MSK(ngpios), 0,
648650
IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
649651

650652
/* Setup irq domain on top of the generic chip. */

drivers/gpio/gpio-omap.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,40 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
251251
}
252252
}
253253

254+
/**
255+
* _clear_gpio_debounce - clear debounce settings for a gpio
256+
* @bank: the gpio bank we're acting upon
257+
* @gpio: the gpio number on this @gpio
258+
*
259+
* If a gpio is using debounce, then clear the debounce enable bit and if
260+
* this is the only gpio in this bank using debounce, then clear the debounce
261+
* time too. The debounce clock will also be disabled when calling this function
262+
* if this is the only gpio in the bank using debounce.
263+
*/
264+
static void _clear_gpio_debounce(struct gpio_bank *bank, unsigned gpio)
265+
{
266+
u32 gpio_bit = GPIO_BIT(bank, gpio);
267+
268+
if (!bank->dbck_flag)
269+
return;
270+
271+
if (!(bank->dbck_enable_mask & gpio_bit))
272+
return;
273+
274+
bank->dbck_enable_mask &= ~gpio_bit;
275+
bank->context.debounce_en &= ~gpio_bit;
276+
__raw_writel(bank->context.debounce_en,
277+
bank->base + bank->regs->debounce_en);
278+
279+
if (!bank->dbck_enable_mask) {
280+
bank->context.debounce = 0;
281+
__raw_writel(bank->context.debounce, bank->base +
282+
bank->regs->debounce);
283+
clk_disable(bank->dbck);
284+
bank->dbck_enabled = false;
285+
}
286+
}
287+
254288
static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
255289
unsigned trigger)
256290
{
@@ -539,6 +573,7 @@ static void _reset_gpio(struct gpio_bank *bank, int gpio)
539573
_set_gpio_irqenable(bank, gpio, 0);
540574
_clear_gpio_irqstatus(bank, gpio);
541575
_set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE);
576+
_clear_gpio_debounce(bank, gpio);
542577
}
543578

544579
/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */

drivers/gpio/gpio-timberdale.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void timbgpio_irq_disable(struct irq_data *d)
116116
unsigned long flags;
117117

118118
spin_lock_irqsave(&tgpio->lock, flags);
119-
tgpio->last_ier &= ~(1 << offset);
119+
tgpio->last_ier &= ~(1UL << offset);
120120
iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
121121
spin_unlock_irqrestore(&tgpio->lock, flags);
122122
}
@@ -128,7 +128,7 @@ static void timbgpio_irq_enable(struct irq_data *d)
128128
unsigned long flags;
129129

130130
spin_lock_irqsave(&tgpio->lock, flags);
131-
tgpio->last_ier |= 1 << offset;
131+
tgpio->last_ier |= 1UL << offset;
132132
iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
133133
spin_unlock_irqrestore(&tgpio->lock, flags);
134134
}

drivers/gpio/gpiolib.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,11 @@ static ssize_t export_store(struct class *class,
623623
*/
624624

625625
status = gpio_request(gpio, "sysfs");
626-
if (status < 0)
626+
if (status < 0) {
627+
if (status == -EPROBE_DEFER)
628+
status = -ENODEV;
627629
goto done;
628-
630+
}
629631
status = gpio_export(gpio, true);
630632
if (status < 0)
631633
gpio_free(gpio);
@@ -1191,8 +1193,10 @@ int gpio_request(unsigned gpio, const char *label)
11911193

11921194
spin_lock_irqsave(&gpio_lock, flags);
11931195

1194-
if (!gpio_is_valid(gpio))
1196+
if (!gpio_is_valid(gpio)) {
1197+
status = -EINVAL;
11951198
goto done;
1199+
}
11961200
desc = &gpio_desc[gpio];
11971201
chip = desc->chip;
11981202
if (chip == NULL)

0 commit comments

Comments
 (0)