Skip to content

Commit 7726d4c

Browse files
committed
Merge tag 'gpio-fixes-for-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "A a set of fixes from the GPIO subsystem. Most are small driver fixes except the realtek-otto driver patch which is pretty big but addresses a significant flaw that can cause the CPU to stay infinitely busy on uncleared ISR on some platforms. Summary: - MAINTAINERS update - fix resource leaks in gpio-mockup and gpio-pxa - add missing locking in gpio-pca953x - use 32-bit I/O in gpio-realtek-otto - make irq_chip structures immutable in four more drivers" * tag 'gpio-fixes-for-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: ws16c48: Make irq_chip immutable gpio: 104-idio-16: Make irq_chip immutable gpio: 104-idi-48: Make irq_chip immutable gpio: 104-dio-48e: Make irq_chip immutable gpio: realtek-otto: switch to 32-bit I/O gpio: pca953x: Add mutex_lock for regcache sync in PM gpio: mockup: remove gpio debugfs when remove device gpio: pxa: use devres for the clock struct MAINTAINERS: rectify entry for XILINX GPIO DRIVER
2 parents 65eea2c + 6890381 commit 7726d4c

File tree

9 files changed

+135
-109
lines changed

9 files changed

+135
-109
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22307,7 +22307,7 @@ M: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
2230722307
R: Srinivas Neeli <srinivas.neeli@xilinx.com>
2230822308
R: Michal Simek <michal.simek@xilinx.com>
2230922309
S: Maintained
22310-
F: Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
22310+
F: Documentation/devicetree/bindings/gpio/xlnx,gpio-xilinx.yaml
2231122311
F: Documentation/devicetree/bindings/gpio/gpio-zynq.yaml
2231222312
F: drivers/gpio/gpio-xilinx.c
2231322313
F: drivers/gpio/gpio-zynq.c

drivers/gpio/gpio-104-dio-48e.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static void dio48e_irq_mask(struct irq_data *data)
164164
dio48egpio->irq_mask &= ~BIT(0);
165165
else
166166
dio48egpio->irq_mask &= ~BIT(1);
167+
gpiochip_disable_irq(chip, offset);
167168

168169
if (!dio48egpio->irq_mask)
169170
/* disable interrupts */
@@ -191,6 +192,7 @@ static void dio48e_irq_unmask(struct irq_data *data)
191192
iowrite8(0x00, &dio48egpio->reg->enable_interrupt);
192193
}
193194

195+
gpiochip_enable_irq(chip, offset);
194196
if (offset == 19)
195197
dio48egpio->irq_mask |= BIT(0);
196198
else
@@ -213,12 +215,14 @@ static int dio48e_irq_set_type(struct irq_data *data, unsigned int flow_type)
213215
return 0;
214216
}
215217

216-
static struct irq_chip dio48e_irqchip = {
218+
static const struct irq_chip dio48e_irqchip = {
217219
.name = "104-dio-48e",
218220
.irq_ack = dio48e_irq_ack,
219221
.irq_mask = dio48e_irq_mask,
220222
.irq_unmask = dio48e_irq_unmask,
221-
.irq_set_type = dio48e_irq_set_type
223+
.irq_set_type = dio48e_irq_set_type,
224+
.flags = IRQCHIP_IMMUTABLE,
225+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
222226
};
223227

224228
static irqreturn_t dio48e_irq_handler(int irq, void *dev_id)
@@ -322,7 +326,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
322326
dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
323327

324328
girq = &dio48egpio->chip.irq;
325-
girq->chip = &dio48e_irqchip;
329+
gpio_irq_chip_set_chip(girq, &dio48e_irqchip);
326330
/* This will let us handle the parent IRQ in the driver */
327331
girq->parent_handler = NULL;
328332
girq->num_parents = 0;

drivers/gpio/gpio-104-idi-48.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static void idi_48_irq_mask(struct irq_data *data)
113113
spin_lock_irqsave(&idi48gpio->lock, flags);
114114

115115
idi48gpio->irq_mask[boundary] &= ~mask;
116+
gpiochip_disable_irq(chip, offset);
116117

117118
/* Exit early if there are still input lines with IRQ unmasked */
118119
if (idi48gpio->irq_mask[boundary])
@@ -140,6 +141,7 @@ static void idi_48_irq_unmask(struct irq_data *data)
140141

141142
prev_irq_mask = idi48gpio->irq_mask[boundary];
142143

144+
gpiochip_enable_irq(chip, offset);
143145
idi48gpio->irq_mask[boundary] |= mask;
144146

145147
/* Exit early if IRQ was already unmasked for this boundary */
@@ -164,12 +166,14 @@ static int idi_48_irq_set_type(struct irq_data *data, unsigned int flow_type)
164166
return 0;
165167
}
166168

167-
static struct irq_chip idi_48_irqchip = {
169+
static const struct irq_chip idi_48_irqchip = {
168170
.name = "104-idi-48",
169171
.irq_ack = idi_48_irq_ack,
170172
.irq_mask = idi_48_irq_mask,
171173
.irq_unmask = idi_48_irq_unmask,
172-
.irq_set_type = idi_48_irq_set_type
174+
.irq_set_type = idi_48_irq_set_type,
175+
.flags = IRQCHIP_IMMUTABLE,
176+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
173177
};
174178

175179
static irqreturn_t idi_48_irq_handler(int irq, void *dev_id)
@@ -267,7 +271,7 @@ static int idi_48_probe(struct device *dev, unsigned int id)
267271
idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
268272

269273
girq = &idi48gpio->chip.irq;
270-
girq->chip = &idi_48_irqchip;
274+
gpio_irq_chip_set_chip(girq, &idi_48_irqchip);
271275
/* This will let us handle the parent IRQ in the driver */
272276
girq->parent_handler = NULL;
273277
girq->num_parents = 0;

drivers/gpio/gpio-104-idio-16.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ static void idio_16_irq_mask(struct irq_data *data)
174174
{
175175
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
176176
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
177-
const unsigned long mask = BIT(irqd_to_hwirq(data));
177+
const unsigned long offset = irqd_to_hwirq(data);
178178
unsigned long flags;
179179

180-
idio16gpio->irq_mask &= ~mask;
180+
idio16gpio->irq_mask &= ~BIT(offset);
181+
gpiochip_disable_irq(chip, offset);
181182

182183
if (!idio16gpio->irq_mask) {
183184
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -192,11 +193,12 @@ static void idio_16_irq_unmask(struct irq_data *data)
192193
{
193194
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
194195
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
195-
const unsigned long mask = BIT(irqd_to_hwirq(data));
196+
const unsigned long offset = irqd_to_hwirq(data);
196197
const unsigned long prev_irq_mask = idio16gpio->irq_mask;
197198
unsigned long flags;
198199

199-
idio16gpio->irq_mask |= mask;
200+
gpiochip_enable_irq(chip, offset);
201+
idio16gpio->irq_mask |= BIT(offset);
200202

201203
if (!prev_irq_mask) {
202204
raw_spin_lock_irqsave(&idio16gpio->lock, flags);
@@ -217,12 +219,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
217219
return 0;
218220
}
219221

220-
static struct irq_chip idio_16_irqchip = {
222+
static const struct irq_chip idio_16_irqchip = {
221223
.name = "104-idio-16",
222224
.irq_ack = idio_16_irq_ack,
223225
.irq_mask = idio_16_irq_mask,
224226
.irq_unmask = idio_16_irq_unmask,
225-
.irq_set_type = idio_16_irq_set_type
227+
.irq_set_type = idio_16_irq_set_type,
228+
.flags = IRQCHIP_IMMUTABLE,
229+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
226230
};
227231

228232
static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
@@ -299,7 +303,7 @@ static int idio_16_probe(struct device *dev, unsigned int id)
299303
idio16gpio->out_state = 0xFFFF;
300304

301305
girq = &idio16gpio->chip.irq;
302-
girq->chip = &idio_16_irqchip;
306+
gpio_irq_chip_set_chip(girq, &idio_16_irqchip);
303307
/* This will let us handle the parent IRQ in the driver */
304308
girq->parent_handler = NULL;
305309
girq->num_parents = 0;

drivers/gpio/gpio-mockup.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,13 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
373373
}
374374
}
375375

376+
static void gpio_mockup_debugfs_cleanup(void *data)
377+
{
378+
struct gpio_mockup_chip *chip = data;
379+
380+
debugfs_remove_recursive(chip->dbg_dir);
381+
}
382+
376383
static void gpio_mockup_dispose_mappings(void *data)
377384
{
378385
struct gpio_mockup_chip *chip = data;
@@ -455,7 +462,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
455462

456463
gpio_mockup_debugfs_setup(dev, chip);
457464

458-
return 0;
465+
return devm_add_action_or_reset(dev, gpio_mockup_debugfs_cleanup, chip);
459466
}
460467

461468
static const struct of_device_id gpio_mockup_of_match[] = {

drivers/gpio/gpio-pca953x.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,9 @@ static int pca953x_suspend(struct device *dev)
11751175
{
11761176
struct pca953x_chip *chip = dev_get_drvdata(dev);
11771177

1178+
mutex_lock(&chip->i2c_lock);
11781179
regcache_cache_only(chip->regmap, true);
1180+
mutex_unlock(&chip->i2c_lock);
11791181

11801182
if (atomic_read(&chip->wakeup_path))
11811183
device_set_wakeup_path(dev);
@@ -1198,13 +1200,17 @@ static int pca953x_resume(struct device *dev)
11981200
}
11991201
}
12001202

1203+
mutex_lock(&chip->i2c_lock);
12011204
regcache_cache_only(chip->regmap, false);
12021205
regcache_mark_dirty(chip->regmap);
12031206
ret = pca953x_regcache_sync(dev);
1204-
if (ret)
1207+
if (ret) {
1208+
mutex_unlock(&chip->i2c_lock);
12051209
return ret;
1210+
}
12061211

12071212
ret = regcache_sync(chip->regmap);
1213+
mutex_unlock(&chip->i2c_lock);
12081214
if (ret) {
12091215
dev_err(dev, "Failed to restore register map: %d\n", ret);
12101216
return ret;

drivers/gpio/gpio-pxa.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,24 +661,17 @@ static int pxa_gpio_probe(struct platform_device *pdev)
661661
if (IS_ERR(gpio_reg_base))
662662
return PTR_ERR(gpio_reg_base);
663663

664-
clk = clk_get(&pdev->dev, NULL);
664+
clk = devm_clk_get_enabled(&pdev->dev, NULL);
665665
if (IS_ERR(clk)) {
666666
dev_err(&pdev->dev, "Error %ld to get gpio clock\n",
667667
PTR_ERR(clk));
668668
return PTR_ERR(clk);
669669
}
670-
ret = clk_prepare_enable(clk);
671-
if (ret) {
672-
clk_put(clk);
673-
return ret;
674-
}
675670

676671
/* Initialize GPIO chips */
677672
ret = pxa_init_gpio_chip(pchip, pxa_last_gpio + 1, gpio_reg_base);
678-
if (ret) {
679-
clk_put(clk);
673+
if (ret)
680674
return ret;
681-
}
682675

683676
/* clear all GPIO edge detects */
684677
for_each_gpio_bank(gpio, c, pchip) {

0 commit comments

Comments
 (0)