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

Configure Feed

Select the types of activity you want to include in your feed.

gpio: aggregator: move GPIO forwarder allocation in a dedicated function

Move the GPIO forwarder allocation and static initialization in a dedicated
function.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Link: https://lore.kernel.org/r/20250811-aaeon-up-board-pinctrl-support-v9-2-29f0cbbdfb30@bootlin.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Thomas Richard and committed by
Bartosz Golaszewski
871c7cd5 181fe022

+32 -18
+32 -18
drivers/gpio/gpio-aggregator.c
··· 475 475 } 476 476 #endif /* !CONFIG_OF_GPIO */ 477 477 478 + static struct gpiochip_fwd * 479 + devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios) 480 + { 481 + struct gpiochip_fwd *fwd; 482 + struct gpio_chip *chip; 483 + 484 + fwd = devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), GFP_KERNEL); 485 + if (!fwd) 486 + return ERR_PTR(-ENOMEM); 487 + 488 + chip = &fwd->chip; 489 + 490 + chip->label = dev_name(dev); 491 + chip->parent = dev; 492 + chip->owner = THIS_MODULE; 493 + chip->get_direction = gpio_fwd_get_direction; 494 + chip->direction_input = gpio_fwd_direction_input; 495 + chip->direction_output = gpio_fwd_direction_output; 496 + chip->get = gpio_fwd_get; 497 + chip->get_multiple = gpio_fwd_get_multiple_locked; 498 + chip->set = gpio_fwd_set; 499 + chip->set_multiple = gpio_fwd_set_multiple_locked; 500 + chip->to_irq = gpio_fwd_to_irq; 501 + chip->base = -1; 502 + chip->ngpio = ngpios; 503 + 504 + return fwd; 505 + } 506 + 478 507 /** 479 508 * gpiochip_fwd_create() - Create a new GPIO forwarder 480 509 * @dev: Parent device pointer ··· 524 495 struct gpio_desc *descs[], 525 496 unsigned long features) 526 497 { 527 - const char *label = dev_name(dev); 528 498 struct gpiochip_fwd *fwd; 529 499 struct gpio_chip *chip; 530 500 unsigned int i; 531 501 int error; 532 502 533 - fwd = devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), 534 - GFP_KERNEL); 535 - if (!fwd) 536 - return ERR_PTR(-ENOMEM); 503 + fwd = devm_gpiochip_fwd_alloc(dev, ngpios); 504 + if (IS_ERR(fwd)) 505 + return fwd; 537 506 538 507 chip = &fwd->chip; 539 508 ··· 553 526 chip->set_config = gpio_fwd_set_config; 554 527 } 555 528 556 - chip->label = label; 557 - chip->parent = dev; 558 - chip->owner = THIS_MODULE; 559 - chip->get_direction = gpio_fwd_get_direction; 560 - chip->direction_input = gpio_fwd_direction_input; 561 - chip->direction_output = gpio_fwd_direction_output; 562 - chip->get = gpio_fwd_get; 563 - chip->get_multiple = gpio_fwd_get_multiple_locked; 564 - chip->set = gpio_fwd_set; 565 - chip->set_multiple = gpio_fwd_set_multiple_locked; 566 - chip->to_irq = gpio_fwd_to_irq; 567 - chip->base = -1; 568 - chip->ngpio = ngpios; 569 529 fwd->descs = descs; 570 530 571 531 if (chip->can_sleep)