Skip to content

Commit fe12e94

Browse files
author
Linus Walleij
committed
Merge tag 'gpio-v5.5-updates-for-linus-part-1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel
gpio updates for v5.5 - only get the second IRQ when there is more than one IRQ in mxc - move the code around in lineevent_create() for some shrinkage - fix formatting for GPIO docs - add DT binding for r8a774b1 - convert drivers that prevously used nocache ioremap() to using regular devm_platform_ioremap_resource() - remove some redundant error messages - shrink object code in 104-idi-48e - drop an unneeded warning from gpiolib-of
2 parents 698b8ee + 228fc01 commit fe12e94

10 files changed

Lines changed: 68 additions & 94 deletions

File tree

‎Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Required Properties:
88
- "renesas,gpio-r8a7745": for R8A7745 (RZ/G1E) compatible GPIO controller.
99
- "renesas,gpio-r8a77470": for R8A77470 (RZ/G1C) compatible GPIO controller.
1010
- "renesas,gpio-r8a774a1": for R8A774A1 (RZ/G2M) compatible GPIO controller.
11+
- "renesas,gpio-r8a774b1": for R8A774B1 (RZ/G2N) compatible GPIO controller.
1112
- "renesas,gpio-r8a774c0": for R8A774C0 (RZ/G2E) compatible GPIO controller.
1213
- "renesas,gpio-r8a7778": for R8A7778 (R-Car M1) compatible GPIO controller.
1314
- "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller.

‎Documentation/driver-api/gpio/driver.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ If you do this, the additional irq_chip will be set up by gpiolib at the
415415
same time as setting up the rest of the GPIO functionality. The following
416416
is a typical example of a cascaded interrupt handler using gpio_irq_chip:
417417

418+
.. code-block:: c
419+
418420
/* Typical state container with dynamic irqchip */
419421
struct my_gpio {
420422
struct gpio_chip gc;
@@ -450,6 +452,8 @@ is a typical example of a cascaded interrupt handler using gpio_irq_chip:
450452
The helper support using hierarchical interrupt controllers as well.
451453
In this case the typical set-up will look like this:
452454

455+
.. code-block:: c
456+
453457
/* Typical state container with dynamic irqchip */
454458
struct my_gpio {
455459
struct gpio_chip gc;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset)
6565
{
6666
struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip);
6767
unsigned i;
68-
const unsigned register_offset[6] = { 0, 1, 2, 4, 5, 6 };
68+
static const unsigned int register_offset[6] = { 0, 1, 2, 4, 5, 6 };
6969
unsigned base_offset;
7070
unsigned mask;
7171

‎drivers/gpio/gpio-ath79.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ static int ath79_gpio_probe(struct platform_device *pdev)
226226
struct device_node *np = dev->of_node;
227227
struct ath79_gpio_ctrl *ctrl;
228228
struct gpio_irq_chip *girq;
229-
struct resource *res;
230229
u32 ath79_gpio_count;
231230
bool oe_inverted;
232231
int err;
@@ -256,12 +255,9 @@ static int ath79_gpio_probe(struct platform_device *pdev)
256255
return -EINVAL;
257256
}
258257

259-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
260-
if (!res)
261-
return -EINVAL;
262-
ctrl->base = devm_ioremap_nocache(dev, res->start, resource_size(res));
263-
if (!ctrl->base)
264-
return -ENOMEM;
258+
ctrl->base = devm_platform_ioremap_resource(pdev, 0);
259+
if (IS_ERR(ctrl->base))
260+
return PTR_ERR(ctrl->base);
265261

266262
raw_spin_lock_init(&ctrl->lock);
267263
err = bgpio_init(&ctrl->gc, dev, 4,

‎drivers/gpio/gpio-em.c‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static void em_gio_irq_domain_remove(void *data)
269269
static int em_gio_probe(struct platform_device *pdev)
270270
{
271271
struct em_gio_priv *p;
272-
struct resource *io[2], *irq[2];
272+
struct resource *irq[2];
273273
struct gpio_chip *gpio_chip;
274274
struct irq_chip *irq_chip;
275275
struct device *dev = &pdev->dev;
@@ -285,25 +285,21 @@ static int em_gio_probe(struct platform_device *pdev)
285285
platform_set_drvdata(pdev, p);
286286
spin_lock_init(&p->sense_lock);
287287

288-
io[0] = platform_get_resource(pdev, IORESOURCE_MEM, 0);
289-
io[1] = platform_get_resource(pdev, IORESOURCE_MEM, 1);
290288
irq[0] = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
291289
irq[1] = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
292290

293-
if (!io[0] || !io[1] || !irq[0] || !irq[1]) {
291+
if (!irq[0] || !irq[1]) {
294292
dev_err(dev, "missing IRQ or IOMEM\n");
295293
return -EINVAL;
296294
}
297295

298-
p->base0 = devm_ioremap_nocache(dev, io[0]->start,
299-
resource_size(io[0]));
300-
if (!p->base0)
301-
return -ENOMEM;
296+
p->base0 = devm_platform_ioremap_resource(pdev, 0);
297+
if (IS_ERR(p->base0))
298+
return PTR_ERR(p->base0);
302299

303-
p->base1 = devm_ioremap_nocache(dev, io[1]->start,
304-
resource_size(io[1]));
305-
if (!p->base1)
306-
return -ENOMEM;
300+
p->base1 = devm_platform_ioremap_resource(pdev, 1);
301+
if (IS_ERR(p->base1))
302+
return PTR_ERR(p->base1);
307303

308304
if (of_property_read_u32(dev->of_node, "ngpios", &ngpios)) {
309305
dev_err(dev, "Missing ngpios OF property\n");

‎drivers/gpio/gpio-htc-egpio.c‎

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ static int __init egpio_probe(struct platform_device *pdev)
265265
struct gpio_chip *chip;
266266
unsigned int irq, irq_end;
267267
int i;
268-
int ret;
269268

270269
/* Initialize ei data structure. */
271270
ei = devm_kzalloc(&pdev->dev, sizeof(*ei), GFP_KERNEL);
@@ -275,28 +274,24 @@ static int __init egpio_probe(struct platform_device *pdev)
275274
spin_lock_init(&ei->lock);
276275

277276
/* Find chained irq */
278-
ret = -EINVAL;
279277
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
280278
if (res)
281279
ei->chained_irq = res->start;
282280

283281
/* Map egpio chip into virtual address space. */
284-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
285-
if (!res)
286-
goto fail;
287-
ei->base_addr = devm_ioremap_nocache(&pdev->dev, res->start,
288-
resource_size(res));
289-
if (!ei->base_addr)
290-
goto fail;
291-
pr_debug("EGPIO phys=%08x virt=%p\n", (u32)res->start, ei->base_addr);
282+
ei->base_addr = devm_platform_ioremap_resource(pdev, 0);
283+
if (IS_ERR(ei->base_addr))
284+
return PTR_ERR(ei->base_addr);
292285

293286
if ((pdata->bus_width != 16) && (pdata->bus_width != 32))
294-
goto fail;
287+
return -EINVAL;
288+
295289
ei->bus_shift = fls(pdata->bus_width - 1) - 3;
296290
pr_debug("bus_shift = %d\n", ei->bus_shift);
297291

298292
if ((pdata->reg_width != 8) && (pdata->reg_width != 16))
299-
goto fail;
293+
return -EINVAL;
294+
300295
ei->reg_shift = fls(pdata->reg_width - 1);
301296
pr_debug("reg_shift = %d\n", ei->reg_shift);
302297

@@ -308,10 +303,9 @@ static int __init egpio_probe(struct platform_device *pdev)
308303
ei->chip = devm_kcalloc(&pdev->dev,
309304
ei->nchips, sizeof(struct egpio_chip),
310305
GFP_KERNEL);
311-
if (!ei->chip) {
312-
ret = -ENOMEM;
313-
goto fail;
314-
}
306+
if (!ei->chip)
307+
return -ENOMEM;
308+
315309
for (i = 0; i < ei->nchips; i++) {
316310
ei->chip[i].reg_start = pdata->chip[i].reg_start;
317311
ei->chip[i].cached_values = pdata->chip[i].initial_values;
@@ -321,10 +315,9 @@ static int __init egpio_probe(struct platform_device *pdev)
321315
chip->label = devm_kasprintf(&pdev->dev, GFP_KERNEL,
322316
"htc-egpio-%d",
323317
i);
324-
if (!chip->label) {
325-
ret = -ENOMEM;
326-
goto fail;
327-
}
318+
if (!chip->label)
319+
return -ENOMEM;
320+
328321
chip->parent = &pdev->dev;
329322
chip->owner = THIS_MODULE;
330323
chip->get = egpio_get;
@@ -366,10 +359,6 @@ static int __init egpio_probe(struct platform_device *pdev)
366359
}
367360

368361
return 0;
369-
370-
fail:
371-
printk(KERN_ERR "EGPIO failed to setup\n");
372-
return ret;
373362
}
374363

375364
#ifdef CONFIG_PM

‎drivers/gpio/gpio-mxc.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
411411
{
412412
struct device_node *np = pdev->dev.of_node;
413413
struct mxc_gpio_port *port;
414+
int irq_count;
414415
int irq_base;
415416
int err;
416417

@@ -426,9 +427,15 @@ static int mxc_gpio_probe(struct platform_device *pdev)
426427
if (IS_ERR(port->base))
427428
return PTR_ERR(port->base);
428429

429-
port->irq_high = platform_get_irq(pdev, 1);
430-
if (port->irq_high < 0)
431-
port->irq_high = 0;
430+
irq_count = platform_irq_count(pdev);
431+
if (irq_count < 0)
432+
return irq_count;
433+
434+
if (irq_count > 1) {
435+
port->irq_high = platform_get_irq(pdev, 1);
436+
if (port->irq_high < 0)
437+
port->irq_high = 0;
438+
}
432439

433440
port->irq = platform_get_irq(pdev, 0);
434441
if (port->irq < 0)

‎drivers/gpio/gpio-xgene.c‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,16 @@ static SIMPLE_DEV_PM_OPS(xgene_gpio_pm, xgene_gpio_suspend, xgene_gpio_resume);
155155

156156
static int xgene_gpio_probe(struct platform_device *pdev)
157157
{
158-
struct resource *res;
159158
struct xgene_gpio *gpio;
160159
int err = 0;
161160

162161
gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
163-
if (!gpio) {
164-
err = -ENOMEM;
165-
goto err;
166-
}
167-
168-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
169-
if (!res) {
170-
err = -EINVAL;
171-
goto err;
172-
}
162+
if (!gpio)
163+
return -ENOMEM;
173164

174-
gpio->base = devm_ioremap_nocache(&pdev->dev, res->start,
175-
resource_size(res));
176-
if (!gpio->base) {
177-
err = -ENOMEM;
178-
goto err;
179-
}
165+
gpio->base = devm_platform_ioremap_resource(pdev, 0);
166+
if (IS_ERR(gpio->base))
167+
return PTR_ERR(gpio->base);
180168

181169
gpio->chip.ngpio = XGENE_MAX_GPIOS;
182170

@@ -196,14 +184,11 @@ static int xgene_gpio_probe(struct platform_device *pdev)
196184
if (err) {
197185
dev_err(&pdev->dev,
198186
"failed to register gpiochip.\n");
199-
goto err;
187+
return err;
200188
}
201189

202190
dev_info(&pdev->dev, "X-Gene GPIO driver registered.\n");
203191
return 0;
204-
err:
205-
dev_err(&pdev->dev, "X-Gene GPIO driver registration failed.\n");
206-
return err;
207192
}
208193

209194
static const struct of_device_id xgene_gpio_of_match[] = {

‎drivers/gpio/gpiolib-of.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,20 @@ static void of_gpio_flags_quirks(struct device_node *np,
135135
(!(strcmp(propname, "enable-gpio") &&
136136
strcmp(propname, "enable-gpios")) &&
137137
of_device_is_compatible(np, "regulator-gpio")))) {
138+
bool active_low = !of_property_read_bool(np,
139+
"enable-active-high");
138140
/*
139141
* The regulator GPIO handles are specified such that the
140142
* presence or absence of "enable-active-high" solely controls
141143
* the polarity of the GPIO line. Any phandle flags must
142144
* be actively ignored.
143145
*/
144-
if (*flags & OF_GPIO_ACTIVE_LOW) {
146+
if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {
145147
pr_warn("%s GPIO handle specifies active low - ignored\n",
146148
of_node_full_name(np));
147149
*flags &= ~OF_GPIO_ACTIVE_LOW;
148150
}
149-
if (!of_property_read_bool(np, "enable-active-high"))
151+
if (active_low)
150152
*flags |= OF_GPIO_ACTIVE_LOW;
151153
}
152154
/*

‎drivers/gpio/gpiolib.c‎

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,24 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
900900
if (copy_from_user(&eventreq, ip, sizeof(eventreq)))
901901
return -EFAULT;
902902

903+
offset = eventreq.lineoffset;
904+
lflags = eventreq.handleflags;
905+
eflags = eventreq.eventflags;
906+
907+
if (offset >= gdev->ngpio)
908+
return -EINVAL;
909+
910+
/* Return an error if a unknown flag is set */
911+
if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
912+
(eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS))
913+
return -EINVAL;
914+
915+
/* This is just wrong: we don't look for events on output lines */
916+
if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
917+
(lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
918+
(lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE))
919+
return -EINVAL;
920+
903921
le = kzalloc(sizeof(*le), GFP_KERNEL);
904922
if (!le)
905923
return -ENOMEM;
@@ -917,30 +935,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
917935
}
918936
}
919937

920-
offset = eventreq.lineoffset;
921-
lflags = eventreq.handleflags;
922-
eflags = eventreq.eventflags;
923-
924-
if (offset >= gdev->ngpio) {
925-
ret = -EINVAL;
926-
goto out_free_label;
927-
}
928-
929-
/* Return an error if a unknown flag is set */
930-
if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
931-
(eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS)) {
932-
ret = -EINVAL;
933-
goto out_free_label;
934-
}
935-
936-
/* This is just wrong: we don't look for events on output lines */
937-
if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
938-
(lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
939-
(lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) {
940-
ret = -EINVAL;
941-
goto out_free_label;
942-
}
943-
944938
desc = &gdev->descs[offset];
945939
ret = gpiod_request(desc, le->label);
946940
if (ret)

0 commit comments

Comments
 (0)