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: export symbols of the GPIO forwarder library

Export all symbols and create header file for the GPIO forwarder library.
It will be used in the next changes.

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-6-29f0cbbdfb30@bootlin.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Thomas Richard and committed by
Bartosz Golaszewski
6e986f88 b94cf35d

+233 -6
+196 -6
drivers/gpio/gpio-aggregator.c
··· 12 12 #include <linux/configfs.h> 13 13 #include <linux/ctype.h> 14 14 #include <linux/delay.h> 15 + #include <linux/export.h> 15 16 #include <linux/idr.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/list.h> ··· 29 28 30 29 #include <linux/gpio/consumer.h> 31 30 #include <linux/gpio/driver.h> 31 + #include <linux/gpio/forwarder.h> 32 32 #include <linux/gpio/machine.h> 33 33 34 34 #include "dev-sync-probe.h" ··· 477 475 } 478 476 #endif /* !CONFIG_OF_GPIO */ 479 477 480 - static struct gpiochip_fwd * 481 - devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios) 478 + /** 479 + * gpiochip_fwd_get_gpiochip - Get the GPIO chip for the GPIO forwarder 480 + * @fwd: GPIO forwarder 481 + * 482 + * Returns: The GPIO chip for the GPIO forwarder 483 + */ 484 + struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd) 485 + { 486 + return &fwd->chip; 487 + } 488 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_get_gpiochip, "GPIO_FORWARDER"); 489 + 490 + /** 491 + * gpiochip_fwd_gpio_get_direction - Return the current direction of a GPIO forwarder line 492 + * @fwd: GPIO forwarder 493 + * @offset: the offset of the line 494 + * 495 + * Returns: 0 for output, 1 for input, or an error code in case of error. 496 + */ 497 + int gpiochip_fwd_gpio_get_direction(struct gpiochip_fwd *fwd, unsigned int offset) 498 + { 499 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 500 + 501 + return gpio_fwd_get_direction(gc, offset); 502 + } 503 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get_direction, "GPIO_FORWARDER"); 504 + 505 + /** 506 + * gpiochip_fwd_gpio_direction_output - Set a GPIO forwarder line direction to 507 + * output 508 + * @fwd: GPIO forwarder 509 + * @offset: the offset of the line 510 + * @value: value to set 511 + * 512 + * Returns: 0 on success, or negative errno on failure. 513 + */ 514 + int gpiochip_fwd_gpio_direction_output(struct gpiochip_fwd *fwd, unsigned int offset, 515 + int value) 516 + { 517 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 518 + 519 + return gpio_fwd_direction_output(gc, offset, value); 520 + } 521 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_direction_output, "GPIO_FORWARDER"); 522 + 523 + /** 524 + * gpiochip_fwd_gpio_direction_input - Set a GPIO forwarder line direction to input 525 + * @fwd: GPIO forwarder 526 + * @offset: the offset of the line 527 + * 528 + * Returns: 0 on success, or negative errno on failure. 529 + */ 530 + int gpiochip_fwd_gpio_direction_input(struct gpiochip_fwd *fwd, unsigned int offset) 531 + { 532 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 533 + 534 + return gpio_fwd_direction_input(gc, offset); 535 + } 536 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_direction_input, "GPIO_FORWARDER"); 537 + 538 + /** 539 + * gpiochip_fwd_gpio_get - Return a GPIO forwarder line's value 540 + * @fwd: GPIO forwarder 541 + * @offset: the offset of the line 542 + * 543 + * Returns: The GPIO's logical value, i.e. taking the ACTIVE_LOW status into 544 + * account, or negative errno on failure. 545 + */ 546 + int gpiochip_fwd_gpio_get(struct gpiochip_fwd *fwd, unsigned int offset) 547 + { 548 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 549 + 550 + return gpio_fwd_get(gc, offset); 551 + } 552 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get, "GPIO_FORWARDER"); 553 + 554 + /** 555 + * gpiochip_fwd_gpio_get_multiple - Get values for multiple GPIO forwarder lines 556 + * @fwd: GPIO forwarder 557 + * @mask: bit mask array; one bit per line; BITS_PER_LONG bits per word defines 558 + * which lines are to be read 559 + * @bits: bit value array; one bit per line; BITS_PER_LONG bits per word will 560 + * contains the read values for the lines specified by mask 561 + * 562 + * Returns: 0 on success, or negative errno on failure. 563 + */ 564 + int gpiochip_fwd_gpio_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 565 + unsigned long *bits) 566 + { 567 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 568 + 569 + return gpio_fwd_get_multiple_locked(gc, mask, bits); 570 + } 571 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_get_multiple, "GPIO_FORWARDER"); 572 + 573 + /** 574 + * gpiochip_fwd_gpio_set - Assign value to a GPIO forwarder line. 575 + * @fwd: GPIO forwarder 576 + * @offset: the offset of the line 577 + * @value: value to set 578 + * 579 + * Returns: 0 on success, or negative errno on failure. 580 + */ 581 + int gpiochip_fwd_gpio_set(struct gpiochip_fwd *fwd, unsigned int offset, int value) 582 + { 583 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 584 + 585 + return gpio_fwd_set(gc, offset, value); 586 + } 587 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set, "GPIO_FORWARDER"); 588 + 589 + /** 590 + * gpiochip_fwd_gpio_set_multiple - Assign values to multiple GPIO forwarder lines 591 + * @fwd: GPIO forwarder 592 + * @mask: bit mask array; one bit per output; BITS_PER_LONG bits per word 593 + * defines which outputs are to be changed 594 + * @bits: bit value array; one bit per output; BITS_PER_LONG bits per word 595 + * defines the values the outputs specified by mask are to be set to 596 + * 597 + * Returns: 0 on success, or negative errno on failure. 598 + */ 599 + int gpiochip_fwd_gpio_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 600 + unsigned long *bits) 601 + { 602 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 603 + 604 + return gpio_fwd_set_multiple_locked(gc, mask, bits); 605 + } 606 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set_multiple, "GPIO_FORWARDER"); 607 + 608 + /** 609 + * gpiochip_fwd_gpio_set_config - Set @config for a GPIO forwarder line 610 + * @fwd: GPIO forwarder 611 + * @offset: the offset of the line 612 + * @config: Same packed config format as generic pinconf 613 + * 614 + * Returns: 0 on success, %-ENOTSUPP if the controller doesn't support setting 615 + * the configuration. 616 + */ 617 + int gpiochip_fwd_gpio_set_config(struct gpiochip_fwd *fwd, unsigned int offset, 618 + unsigned long config) 619 + { 620 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 621 + 622 + return gpio_fwd_set_config(gc, offset, config); 623 + } 624 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_set_config, "GPIO_FORWARDER"); 625 + 626 + /** 627 + * gpiochip_fwd_gpio_to_irq - Return the IRQ corresponding to a GPIO forwarder line 628 + * @fwd: GPIO forwarder 629 + * @offset: the offset of the line 630 + * 631 + * Returns: The Linux IRQ corresponding to the passed line, or an error code in 632 + * case of error. 633 + */ 634 + int gpiochip_fwd_gpio_to_irq(struct gpiochip_fwd *fwd, unsigned int offset) 635 + { 636 + struct gpio_chip *gc = gpiochip_fwd_get_gpiochip(fwd); 637 + 638 + return gpio_fwd_to_irq(gc, offset); 639 + } 640 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_gpio_to_irq, "GPIO_FORWARDER"); 641 + 642 + /** 643 + * devm_gpiochip_fwd_alloc - Allocate and initialize a new GPIO forwarder 644 + * @dev: Parent device pointer 645 + * @ngpios: Number of GPIOs in the forwarder 646 + * 647 + * Returns: An opaque object pointer, or an ERR_PTR()-encoded negative error 648 + * code on failure. 649 + */ 650 + struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev, 651 + unsigned int ngpios) 482 652 { 483 653 struct gpiochip_fwd *fwd; 484 654 struct gpio_chip *chip; ··· 681 507 682 508 return fwd; 683 509 } 510 + EXPORT_SYMBOL_NS_GPL(devm_gpiochip_fwd_alloc, "GPIO_FORWARDER"); 684 511 685 - static int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, 686 - struct gpio_desc *desc, 687 - unsigned int offset) 512 + /** 513 + * gpiochip_fwd_desc_add - Add a GPIO desc in the forwarder 514 + * @fwd: GPIO forwarder 515 + * @desc: GPIO descriptor to register 516 + * @offset: offset for the GPIO in the forwarder 517 + * 518 + * Returns: 0 on success, or negative errno on failure. 519 + */ 520 + int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, struct gpio_desc *desc, 521 + unsigned int offset) 688 522 { 689 523 struct gpio_chip *parent = gpiod_to_chip(desc); 690 524 struct gpio_chip *chip = &fwd->chip; ··· 719 537 720 538 return 0; 721 539 } 540 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_desc_add, "GPIO_FORWARDER"); 722 541 723 - static int gpiochip_fwd_register(struct gpiochip_fwd *fwd) 542 + /** 543 + * gpiochip_fwd_register - Register a GPIO forwarder 544 + * @fwd: GPIO forwarder 545 + * 546 + * Returns: 0 on success, or negative errno on failure. 547 + */ 548 + int gpiochip_fwd_register(struct gpiochip_fwd *fwd) 724 549 { 725 550 struct gpio_chip *chip = &fwd->chip; 726 551 ··· 738 549 739 550 return devm_gpiochip_add_data(chip->parent, chip, fwd); 740 551 } 552 + EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_register, "GPIO_FORWARDER"); 741 553 742 554 /** 743 555 * gpiochip_fwd_create() - Create a new GPIO forwarder
+37
include/linux/gpio/forwarder.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __LINUX_GPIO_FORWARDER_H 3 + #define __LINUX_GPIO_FORWARDER_H 4 + 5 + struct gpio_desc; 6 + struct gpio_chip; 7 + struct gpiochip_fwd; 8 + 9 + struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev, 10 + unsigned int ngpios); 11 + int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd, 12 + struct gpio_desc *desc, unsigned int offset); 13 + int gpiochip_fwd_register(struct gpiochip_fwd *fwd); 14 + 15 + struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd); 16 + 17 + int gpiochip_fwd_gpio_get_direction(struct gpiochip_fwd *fwd, 18 + unsigned int offset); 19 + int gpiochip_fwd_gpio_direction_input(struct gpiochip_fwd *fwd, 20 + unsigned int offset); 21 + int gpiochip_fwd_gpio_direction_output(struct gpiochip_fwd *fwd, 22 + unsigned int offset, 23 + int value); 24 + int gpiochip_fwd_gpio_get(struct gpiochip_fwd *fwd, unsigned int offset); 25 + int gpiochip_fwd_gpio_get_multiple(struct gpiochip_fwd *fwd, 26 + unsigned long *mask, 27 + unsigned long *bits); 28 + int gpiochip_fwd_gpio_set(struct gpiochip_fwd *fwd, unsigned int offset, 29 + int value); 30 + int gpiochip_fwd_gpio_set_multiple(struct gpiochip_fwd *fwd, 31 + unsigned long *mask, 32 + unsigned long *bits); 33 + int gpiochip_fwd_gpio_set_config(struct gpiochip_fwd *fwd, unsigned int offset, 34 + unsigned long config); 35 + int gpiochip_fwd_gpio_to_irq(struct gpiochip_fwd *fwd, unsigned int offset); 36 + 37 + #endif