Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+68 -94
+1
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
··· 8 8 - "renesas,gpio-r8a7745": for R8A7745 (RZ/G1E) compatible GPIO controller. 9 9 - "renesas,gpio-r8a77470": for R8A77470 (RZ/G1C) compatible GPIO controller. 10 10 - "renesas,gpio-r8a774a1": for R8A774A1 (RZ/G2M) compatible GPIO controller. 11 + - "renesas,gpio-r8a774b1": for R8A774B1 (RZ/G2N) compatible GPIO controller. 11 12 - "renesas,gpio-r8a774c0": for R8A774C0 (RZ/G2E) compatible GPIO controller. 12 13 - "renesas,gpio-r8a7778": for R8A7778 (R-Car M1) compatible GPIO controller. 13 14 - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller.
+4
Documentation/driver-api/gpio/driver.rst
··· 415 415 same time as setting up the rest of the GPIO functionality. The following 416 416 is a typical example of a cascaded interrupt handler using gpio_irq_chip: 417 417 418 + .. code-block:: c 419 + 418 420 /* Typical state container with dynamic irqchip */ 419 421 struct my_gpio { 420 422 struct gpio_chip gc; ··· 451 449 452 450 The helper support using hierarchical interrupt controllers as well. 453 451 In this case the typical set-up will look like this: 452 + 453 + .. code-block:: c 454 454 455 455 /* Typical state container with dynamic irqchip */ 456 456 struct my_gpio {
+1 -1
drivers/gpio/gpio-104-idi-48.c
··· 65 65 { 66 66 struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); 67 67 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 }; 69 69 unsigned base_offset; 70 70 unsigned mask; 71 71
+3 -7
drivers/gpio/gpio-ath79.c
··· 226 226 struct device_node *np = dev->of_node; 227 227 struct ath79_gpio_ctrl *ctrl; 228 228 struct gpio_irq_chip *girq; 229 - struct resource *res; 230 229 u32 ath79_gpio_count; 231 230 bool oe_inverted; 232 231 int err; ··· 255 256 return -EINVAL; 256 257 } 257 258 258 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 259 - if (!res) 260 - return -EINVAL; 261 - ctrl->base = devm_ioremap_nocache(dev, res->start, resource_size(res)); 262 - if (!ctrl->base) 263 - return -ENOMEM; 259 + ctrl->base = devm_platform_ioremap_resource(pdev, 0); 260 + if (IS_ERR(ctrl->base)) 261 + return PTR_ERR(ctrl->base); 264 262 265 263 raw_spin_lock_init(&ctrl->lock); 266 264 err = bgpio_init(&ctrl->gc, dev, 4,
+8 -12
drivers/gpio/gpio-em.c
··· 269 269 static int em_gio_probe(struct platform_device *pdev) 270 270 { 271 271 struct em_gio_priv *p; 272 - struct resource *io[2], *irq[2]; 272 + struct resource *irq[2]; 273 273 struct gpio_chip *gpio_chip; 274 274 struct irq_chip *irq_chip; 275 275 struct device *dev = &pdev->dev; ··· 285 285 platform_set_drvdata(pdev, p); 286 286 spin_lock_init(&p->sense_lock); 287 287 288 - io[0] = platform_get_resource(pdev, IORESOURCE_MEM, 0); 289 - io[1] = platform_get_resource(pdev, IORESOURCE_MEM, 1); 290 288 irq[0] = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 291 289 irq[1] = platform_get_resource(pdev, IORESOURCE_IRQ, 1); 292 290 293 - if (!io[0] || !io[1] || !irq[0] || !irq[1]) { 291 + if (!irq[0] || !irq[1]) { 294 292 dev_err(dev, "missing IRQ or IOMEM\n"); 295 293 return -EINVAL; 296 294 } 297 295 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); 302 299 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); 307 303 308 304 if (of_property_read_u32(dev->of_node, "ngpios", &ngpios)) { 309 305 dev_err(dev, "Missing ngpios OF property\n");
+13 -24
drivers/gpio/gpio-htc-egpio.c
··· 265 265 struct gpio_chip *chip; 266 266 unsigned int irq, irq_end; 267 267 int i; 268 - int ret; 269 268 270 269 /* Initialize ei data structure. */ 271 270 ei = devm_kzalloc(&pdev->dev, sizeof(*ei), GFP_KERNEL); ··· 274 275 spin_lock_init(&ei->lock); 275 276 276 277 /* Find chained irq */ 277 - ret = -EINVAL; 278 278 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 279 279 if (res) 280 280 ei->chained_irq = res->start; 281 281 282 282 /* Map egpio chip into virtual address space. */ 283 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 284 - if (!res) 285 - goto fail; 286 - ei->base_addr = devm_ioremap_nocache(&pdev->dev, res->start, 287 - resource_size(res)); 288 - if (!ei->base_addr) 289 - goto fail; 290 - pr_debug("EGPIO phys=%08x virt=%p\n", (u32)res->start, ei->base_addr); 283 + ei->base_addr = devm_platform_ioremap_resource(pdev, 0); 284 + if (IS_ERR(ei->base_addr)) 285 + return PTR_ERR(ei->base_addr); 291 286 292 287 if ((pdata->bus_width != 16) && (pdata->bus_width != 32)) 293 - goto fail; 288 + return -EINVAL; 289 + 294 290 ei->bus_shift = fls(pdata->bus_width - 1) - 3; 295 291 pr_debug("bus_shift = %d\n", ei->bus_shift); 296 292 297 293 if ((pdata->reg_width != 8) && (pdata->reg_width != 16)) 298 - goto fail; 294 + return -EINVAL; 295 + 299 296 ei->reg_shift = fls(pdata->reg_width - 1); 300 297 pr_debug("reg_shift = %d\n", ei->reg_shift); 301 298 ··· 303 308 ei->chip = devm_kcalloc(&pdev->dev, 304 309 ei->nchips, sizeof(struct egpio_chip), 305 310 GFP_KERNEL); 306 - if (!ei->chip) { 307 - ret = -ENOMEM; 308 - goto fail; 309 - } 311 + if (!ei->chip) 312 + return -ENOMEM; 313 + 310 314 for (i = 0; i < ei->nchips; i++) { 311 315 ei->chip[i].reg_start = pdata->chip[i].reg_start; 312 316 ei->chip[i].cached_values = pdata->chip[i].initial_values; ··· 315 321 chip->label = devm_kasprintf(&pdev->dev, GFP_KERNEL, 316 322 "htc-egpio-%d", 317 323 i); 318 - if (!chip->label) { 319 - ret = -ENOMEM; 320 - goto fail; 321 - } 324 + if (!chip->label) 325 + return -ENOMEM; 326 + 322 327 chip->parent = &pdev->dev; 323 328 chip->owner = THIS_MODULE; 324 329 chip->get = egpio_get; ··· 359 366 } 360 367 361 368 return 0; 362 - 363 - fail: 364 - printk(KERN_ERR "EGPIO failed to setup\n"); 365 - return ret; 366 369 } 367 370 368 371 #ifdef CONFIG_PM
+10 -3
drivers/gpio/gpio-mxc.c
··· 411 411 { 412 412 struct device_node *np = pdev->dev.of_node; 413 413 struct mxc_gpio_port *port; 414 + int irq_count; 414 415 int irq_base; 415 416 int err; 416 417 ··· 427 426 if (IS_ERR(port->base)) 428 427 return PTR_ERR(port->base); 429 428 430 - port->irq_high = platform_get_irq(pdev, 1); 431 - if (port->irq_high < 0) 432 - port->irq_high = 0; 429 + irq_count = platform_irq_count(pdev); 430 + if (irq_count < 0) 431 + return irq_count; 432 + 433 + if (irq_count > 1) { 434 + port->irq_high = platform_get_irq(pdev, 1); 435 + if (port->irq_high < 0) 436 + port->irq_high = 0; 437 + } 433 438 434 439 port->irq = platform_get_irq(pdev, 0); 435 440 if (port->irq < 0)
+6 -21
drivers/gpio/gpio-xgene.c
··· 155 155 156 156 static int xgene_gpio_probe(struct platform_device *pdev) 157 157 { 158 - struct resource *res; 159 158 struct xgene_gpio *gpio; 160 159 int err = 0; 161 160 162 161 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 163 - if (!gpio) { 164 - err = -ENOMEM; 165 - goto err; 166 - } 162 + if (!gpio) 163 + return -ENOMEM; 167 164 168 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 169 - if (!res) { 170 - err = -EINVAL; 171 - goto err; 172 - } 173 - 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); 180 168 181 169 gpio->chip.ngpio = XGENE_MAX_GPIOS; 182 170 ··· 184 196 if (err) { 185 197 dev_err(&pdev->dev, 186 198 "failed to register gpiochip.\n"); 187 - goto err; 199 + return err; 188 200 } 189 201 190 202 dev_info(&pdev->dev, "X-Gene GPIO driver registered.\n"); 191 203 return 0; 192 - err: 193 - dev_err(&pdev->dev, "X-Gene GPIO driver registration failed.\n"); 194 - return err; 195 204 } 196 205 197 206 static const struct of_device_id xgene_gpio_of_match[] = {
+4 -2
drivers/gpio/gpiolib-of.c
··· 135 135 (!(strcmp(propname, "enable-gpio") && 136 136 strcmp(propname, "enable-gpios")) && 137 137 of_device_is_compatible(np, "regulator-gpio")))) { 138 + bool active_low = !of_property_read_bool(np, 139 + "enable-active-high"); 138 140 /* 139 141 * The regulator GPIO handles are specified such that the 140 142 * presence or absence of "enable-active-high" solely controls 141 143 * the polarity of the GPIO line. Any phandle flags must 142 144 * be actively ignored. 143 145 */ 144 - if (*flags & OF_GPIO_ACTIVE_LOW) { 146 + if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) { 145 147 pr_warn("%s GPIO handle specifies active low - ignored\n", 146 148 of_node_full_name(np)); 147 149 *flags &= ~OF_GPIO_ACTIVE_LOW; 148 150 } 149 - if (!of_property_read_bool(np, "enable-active-high")) 151 + if (active_low) 150 152 *flags |= OF_GPIO_ACTIVE_LOW; 151 153 } 152 154 /*
+18 -24
drivers/gpio/gpiolib.c
··· 900 900 if (copy_from_user(&eventreq, ip, sizeof(eventreq))) 901 901 return -EFAULT; 902 902 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 + 903 921 le = kzalloc(sizeof(*le), GFP_KERNEL); 904 922 if (!le) 905 923 return -ENOMEM; ··· 933 915 ret = -ENOMEM; 934 916 goto out_free_le; 935 917 } 936 - } 937 - 938 - offset = eventreq.lineoffset; 939 - lflags = eventreq.handleflags; 940 - eflags = eventreq.eventflags; 941 - 942 - if (offset >= gdev->ngpio) { 943 - ret = -EINVAL; 944 - goto out_free_label; 945 - } 946 - 947 - /* Return an error if a unknown flag is set */ 948 - if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) || 949 - (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS)) { 950 - ret = -EINVAL; 951 - goto out_free_label; 952 - } 953 - 954 - /* This is just wrong: we don't look for events on output lines */ 955 - if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) || 956 - (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) || 957 - (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) { 958 - ret = -EINVAL; 959 - goto out_free_label; 960 918 } 961 919 962 920 desc = &gdev->descs[offset];