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

gpio: dwapb: convert device node to fwnode

This patch converts device node to fwnode for dwapb driver, so
as to provide a unified fwnode for DT and ACPI bindings.

Tested-by: Alan Tull <delicious.quinoa@gmail.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jiang Qiu <qiujiang@huawei.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Jiang Qiu and committed by
Linus Walleij
4ba8cfa7 e8159181

+19 -21
+17 -19
drivers/gpio/gpio-dwapb.c
··· 22 22 #include <linux/of_address.h> 23 23 #include <linux/of_irq.h> 24 24 #include <linux/platform_device.h> 25 + #include <linux/property.h> 25 26 #include <linux/spinlock.h> 26 27 #include <linux/platform_data/gpio-dwapb.h> 27 28 #include <linux/slab.h> ··· 291 290 struct dwapb_port_property *pp) 292 291 { 293 292 struct gpio_chip *gc = &port->gc; 294 - struct device_node *node = pp->node; 293 + struct fwnode_handle *fwnode = pp->fwnode; 295 294 struct irq_chip_generic *irq_gc = NULL; 296 295 unsigned int hwirq, ngpio = gc->ngpio; 297 296 struct irq_chip_type *ct; 298 297 int err, i; 299 298 300 - gpio->domain = irq_domain_add_linear(node, ngpio, 301 - &irq_generic_chip_ops, gpio); 299 + gpio->domain = irq_domain_create_linear(fwnode, ngpio, 300 + &irq_generic_chip_ops, gpio); 302 301 if (!gpio->domain) 303 302 return; 304 303 ··· 416 415 } 417 416 418 417 #ifdef CONFIG_OF_GPIO 419 - port->gc.of_node = pp->node; 418 + port->gc.of_node = to_of_node(pp->fwnode); 420 419 #endif 421 420 port->gc.ngpio = pp->ngpio; 422 421 port->gc.base = pp->gpio_base; ··· 448 447 } 449 448 450 449 static struct dwapb_platform_data * 451 - dwapb_gpio_get_pdata_of(struct device *dev) 450 + dwapb_gpio_get_pdata(struct device *dev) 452 451 { 453 - struct device_node *node, *port_np; 452 + struct fwnode_handle *fwnode; 454 453 struct dwapb_platform_data *pdata; 455 454 struct dwapb_port_property *pp; 456 455 int nports; 457 456 int i; 458 457 459 - node = dev->of_node; 460 - if (!IS_ENABLED(CONFIG_OF_GPIO) || !node) 461 - return ERR_PTR(-ENODEV); 462 - 463 - nports = of_get_child_count(node); 458 + nports = device_get_child_node_count(dev); 464 459 if (nports == 0) 465 460 return ERR_PTR(-ENODEV); 466 461 ··· 471 474 pdata->nports = nports; 472 475 473 476 i = 0; 474 - for_each_child_of_node(node, port_np) { 477 + device_for_each_child_node(dev, fwnode) { 475 478 pp = &pdata->properties[i++]; 476 - pp->node = port_np; 479 + pp->fwnode = fwnode; 477 480 478 - if (of_property_read_u32(port_np, "reg", &pp->idx) || 481 + if (fwnode_property_read_u32(fwnode, "reg", &pp->idx) || 479 482 pp->idx >= DWAPB_MAX_PORTS) { 480 483 dev_err(dev, 481 484 "missing/invalid port index for port%d\n", i); 482 485 return ERR_PTR(-EINVAL); 483 486 } 484 487 485 - if (of_property_read_u32(port_np, "snps,nr-gpios", 488 + if (fwnode_property_read_u32(fwnode, "snps,nr-gpios", 486 489 &pp->ngpio)) { 487 490 dev_info(dev, 488 491 "failed to get number of gpios for port%d\n", ··· 494 497 * Only port A can provide interrupts in all configurations of 495 498 * the IP. 496 499 */ 497 - if (pp->idx == 0 && 498 - of_property_read_bool(port_np, "interrupt-controller")) { 499 - pp->irq = irq_of_parse_and_map(port_np, 0); 500 + if (dev->of_node && pp->idx == 0 && 501 + fwnode_property_read_bool(fwnode, 502 + "interrupt-controller")) { 503 + pp->irq = irq_of_parse_and_map(to_of_node(fwnode), 0); 500 504 if (!pp->irq) 501 505 dev_warn(dev, "no irq for port%d\n", pp->idx); 502 506 } ··· 519 521 struct dwapb_platform_data *pdata = dev_get_platdata(dev); 520 522 521 523 if (!pdata) { 522 - pdata = dwapb_gpio_get_pdata_of(dev); 524 + pdata = dwapb_gpio_get_pdata(dev); 523 525 if (IS_ERR(pdata)) 524 526 return PTR_ERR(pdata); 525 527 }
+1 -1
drivers/mfd/intel_quark_i2c_gpio.c
··· 219 219 return -ENOMEM; 220 220 221 221 /* Set the properties for portA */ 222 - pdata->properties->node = NULL; 222 + pdata->properties->fwnode = NULL; 223 223 pdata->properties->idx = 0; 224 224 pdata->properties->ngpio = INTEL_QUARK_MFD_NGPIO; 225 225 pdata->properties->gpio_base = INTEL_QUARK_MFD_GPIO_BASE;
+1 -1
include/linux/platform_data/gpio-dwapb.h
··· 15 15 #define GPIO_DW_APB_H 16 16 17 17 struct dwapb_port_property { 18 - struct device_node *node; 18 + struct fwnode_handle *fwnode; 19 19 unsigned int idx; 20 20 unsigned int ngpio; 21 21 unsigned int gpio_base;