Skip to content

Commit 900db15

Browse files
committed
Merge tag 'gpio-v5.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Here are some (very) late fixes for GPIO, none of them very serious except the one tagged for stable for enabling IRQ on open drain lines: - Fix probing of mvebu chips without PWM - Fix error path on ida_get_simple() on the exar driver - Notify userspace properly about line status changes when flags are changed on lines. - Fix a sleeping while holding spinlock in the mellanox driver. - Fix return value of the PXA and Kona probe calls. - Fix IRQ locking of open drain lines, it is fine to have IRQs on open drain lines flagged for output" * tag 'gpio-v5.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: fix locking open drain IRQ lines gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe() gpio: pxa: Fix return value of pxa_gpio_probe() gpio: mlxbf2: Fix sleeping while holding spinlock gpiolib: notify user-space about line status changes after flags are set gpio: exar: Fix bad handling for ida_simple_get error path gpio: mvebu: Fix probing for chips without PWM
2 parents 8685217 + e9bdf7e commit 900db15

File tree

6 files changed

+42
-18
lines changed

6 files changed

+42
-18
lines changed

drivers/gpio/gpio-bcm-kona.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
625625

626626
kona_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0);
627627
if (IS_ERR(kona_gpio->reg_base)) {
628-
ret = -ENXIO;
628+
ret = PTR_ERR(kona_gpio->reg_base);
629629
goto err_irq_domain;
630630
}
631631

drivers/gpio/gpio-exar.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
148148
mutex_init(&exar_gpio->lock);
149149

150150
index = ida_simple_get(&ida_index, 0, 0, GFP_KERNEL);
151-
if (index < 0)
152-
goto err_destroy;
151+
if (index < 0) {
152+
ret = index;
153+
goto err_mutex_destroy;
154+
}
153155

154156
sprintf(exar_gpio->name, "exar_gpio%d", index);
155157
exar_gpio->gpio_chip.label = exar_gpio->name;
@@ -176,6 +178,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
176178

177179
err_destroy:
178180
ida_simple_remove(&ida_index, index);
181+
err_mutex_destroy:
179182
mutex_destroy(&exar_gpio->lock);
180183
return ret;
181184
}

drivers/gpio/gpio-mlxbf2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ static int mlxbf2_gpio_lock_acquire(struct mlxbf2_gpio_context *gs)
127127
{
128128
u32 arm_gpio_lock_val;
129129

130-
spin_lock(&gs->gc.bgpio_lock);
131130
mutex_lock(yu_arm_gpio_lock_param.lock);
131+
spin_lock(&gs->gc.bgpio_lock);
132132

133133
arm_gpio_lock_val = readl(yu_arm_gpio_lock_param.io);
134134

135135
/*
136136
* When lock active bit[31] is set, ModeX is write enabled
137137
*/
138138
if (YU_LOCK_ACTIVE_BIT(arm_gpio_lock_val)) {
139-
mutex_unlock(yu_arm_gpio_lock_param.lock);
140139
spin_unlock(&gs->gc.bgpio_lock);
140+
mutex_unlock(yu_arm_gpio_lock_param.lock);
141141
return -EINVAL;
142142
}
143143

@@ -152,8 +152,8 @@ static int mlxbf2_gpio_lock_acquire(struct mlxbf2_gpio_context *gs)
152152
static void mlxbf2_gpio_lock_release(struct mlxbf2_gpio_context *gs)
153153
{
154154
writel(YU_ARM_GPIO_LOCK_RELEASE, yu_arm_gpio_lock_param.io);
155-
mutex_unlock(yu_arm_gpio_lock_param.lock);
156155
spin_unlock(&gs->gc.bgpio_lock);
156+
mutex_unlock(yu_arm_gpio_lock_param.lock);
157157
}
158158

159159
/*

drivers/gpio/gpio-mvebu.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,15 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
782782
"marvell,armada-370-gpio"))
783783
return 0;
784784

785+
/*
786+
* There are only two sets of PWM configuration registers for
787+
* all the GPIO lines on those SoCs which this driver reserves
788+
* for the first two GPIO chips. So if the resource is missing
789+
* we can't treat it as an error.
790+
*/
791+
if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
792+
return 0;
793+
785794
if (IS_ERR(mvchip->clk))
786795
return PTR_ERR(mvchip->clk);
787796

@@ -804,12 +813,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
804813
mvchip->mvpwm = mvpwm;
805814
mvpwm->mvchip = mvchip;
806815

807-
/*
808-
* There are only two sets of PWM configuration registers for
809-
* all the GPIO lines on those SoCs which this driver reserves
810-
* for the first two GPIO chips. So if the resource is missing
811-
* we can't treat it as an error.
812-
*/
813816
mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm");
814817
if (IS_ERR(mvpwm->membase))
815818
return PTR_ERR(mvpwm->membase);

drivers/gpio/gpio-pxa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ static int pxa_gpio_probe(struct platform_device *pdev)
660660
pchip->irq1 = irq1;
661661

662662
gpio_reg_base = devm_platform_ioremap_resource(pdev, 0);
663-
if (!gpio_reg_base)
664-
return -EINVAL;
663+
if (IS_ERR(gpio_reg_base))
664+
return PTR_ERR(gpio_reg_base);
665665

666666
clk = clk_get(&pdev->dev, NULL);
667667
if (IS_ERR(clk)) {

drivers/gpio/gpiolib.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
729729
if (ret)
730730
goto out_free_descs;
731731
}
732+
733+
atomic_notifier_call_chain(&desc->gdev->notifier,
734+
GPIOLINE_CHANGED_REQUESTED, desc);
735+
732736
dev_dbg(&gdev->dev, "registered chardev handle for line %d\n",
733737
offset);
734738
}
@@ -1083,6 +1087,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
10831087
if (ret)
10841088
goto out_free_desc;
10851089

1090+
atomic_notifier_call_chain(&desc->gdev->notifier,
1091+
GPIOLINE_CHANGED_REQUESTED, desc);
1092+
10861093
le->irq = gpiod_to_irq(desc);
10871094
if (le->irq <= 0) {
10881095
ret = -ENODEV;
@@ -2998,8 +3005,6 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
29983005
}
29993006
done:
30003007
spin_unlock_irqrestore(&gpio_lock, flags);
3001-
atomic_notifier_call_chain(&desc->gdev->notifier,
3002-
GPIOLINE_CHANGED_REQUESTED, desc);
30033008
return ret;
30043009
}
30053010

@@ -4215,7 +4220,9 @@ int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset)
42154220
}
42164221
}
42174222

4218-
if (test_bit(FLAG_IS_OUT, &desc->flags)) {
4223+
/* To be valid for IRQ the line needs to be input or open drain */
4224+
if (test_bit(FLAG_IS_OUT, &desc->flags) &&
4225+
!test_bit(FLAG_OPEN_DRAIN, &desc->flags)) {
42194226
chip_err(gc,
42204227
"%s: tried to flag a GPIO set as output for IRQ\n",
42214228
__func__);
@@ -4278,7 +4285,12 @@ void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset)
42784285

42794286
if (!IS_ERR(desc) &&
42804287
!WARN_ON(!test_bit(FLAG_USED_AS_IRQ, &desc->flags))) {
4281-
WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags));
4288+
/*
4289+
* We must not be output when using IRQ UNLESS we are
4290+
* open drain.
4291+
*/
4292+
WARN_ON(test_bit(FLAG_IS_OUT, &desc->flags) &&
4293+
!test_bit(FLAG_OPEN_DRAIN, &desc->flags));
42824294
set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags);
42834295
}
42844296
}
@@ -4961,6 +4973,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
49614973
return ERR_PTR(ret);
49624974
}
49634975

4976+
atomic_notifier_call_chain(&desc->gdev->notifier,
4977+
GPIOLINE_CHANGED_REQUESTED, desc);
4978+
49644979
return desc;
49654980
}
49664981
EXPORT_SYMBOL_GPL(gpiod_get_index);
@@ -5026,6 +5041,9 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
50265041
return ERR_PTR(ret);
50275042
}
50285043

5044+
atomic_notifier_call_chain(&desc->gdev->notifier,
5045+
GPIOLINE_CHANGED_REQUESTED, desc);
5046+
50295047
return desc;
50305048
}
50315049
EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);

0 commit comments

Comments
 (0)