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: remove machine hogs

With no more users, remove legacy machine hog API from the kernel.

Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260309-gpio-hog-fwnode-v2-5-4e61f3dbf06a@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

-120
-16
Documentation/driver-api/gpio/board.rst
··· 239 239 A set of functions such as gpiod_set_value() is available to work with 240 240 the new descriptor-oriented interface. 241 241 242 - Boards using platform data can also hog GPIO lines by defining GPIO hog tables. 243 - 244 - .. code-block:: c 245 - 246 - struct gpiod_hog gpio_hog_table[] = { 247 - GPIO_HOG("gpio.0", 10, "foo", GPIO_ACTIVE_LOW, GPIOD_OUT_HIGH), 248 - { } 249 - }; 250 - 251 - And the table can be added to the board code as follows:: 252 - 253 - gpiod_add_hogs(gpio_hog_table); 254 - 255 - The line will be hogged as soon as the gpiochip is created or - in case the 256 - chip was created earlier - when the hog table is registered. 257 - 258 242 Arrays of pins 259 243 -------------- 260 244 In addition to requesting pins belonging to a function one by one, a device may
-71
drivers/gpio/gpiolib.c
··· 103 103 /* Ensures coherence during read-only accesses to the list of GPIO devices. */ 104 104 DEFINE_STATIC_SRCU(gpio_devices_srcu); 105 105 106 - static DEFINE_MUTEX(gpio_machine_hogs_mutex); 107 - static LIST_HEAD(gpio_machine_hogs); 108 - 109 106 const char *const gpio_suffixes[] = { "gpios", "gpio", NULL }; 110 107 111 108 static void gpiochip_free_hogs(struct gpio_chip *gc); ··· 927 930 return ret; 928 931 } 929 932 930 - static void gpiochip_machine_hog(struct gpio_chip *gc, struct gpiod_hog *hog) 931 - { 932 - struct gpio_desc *desc; 933 - int rv; 934 - 935 - desc = gpiochip_get_desc(gc, hog->chip_hwnum); 936 - if (IS_ERR(desc)) { 937 - gpiochip_err(gc, "%s: unable to get GPIO desc: %ld\n", 938 - __func__, PTR_ERR(desc)); 939 - return; 940 - } 941 - 942 - rv = gpiod_hog(desc, hog->line_name, hog->lflags, hog->dflags); 943 - if (rv) 944 - gpiod_err(desc, "%s: unable to hog GPIO line (%s:%u): %d\n", 945 - __func__, gc->label, hog->chip_hwnum, rv); 946 - } 947 - 948 - static void gpiochip_machine_hog_lines(struct gpio_chip *gc) 949 - { 950 - struct gpiod_hog *hog; 951 - 952 - guard(mutex)(&gpio_machine_hogs_mutex); 953 - 954 - list_for_each_entry(hog, &gpio_machine_hogs, list) { 955 - if (!strcmp(gc->label, hog->chip_label)) 956 - gpiochip_machine_hog(gc, hog); 957 - } 958 - } 959 - 960 933 int gpiochip_add_hog(struct gpio_chip *gc, struct fwnode_handle *fwnode) 961 934 { 962 935 struct fwnode_handle *gc_node = dev_fwnode(&gc->gpiodev->dev); ··· 1013 1046 if (ret) 1014 1047 return ret; 1015 1048 } 1016 - 1017 - gpiochip_machine_hog_lines(gc); 1018 1049 1019 1050 return 0; 1020 1051 } ··· 4542 4577 list_del(&table->list); 4543 4578 } 4544 4579 EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); 4545 - 4546 - /** 4547 - * gpiod_add_hogs() - register a set of GPIO hogs from machine code 4548 - * @hogs: table of gpio hog entries with a zeroed sentinel at the end 4549 - */ 4550 - void gpiod_add_hogs(struct gpiod_hog *hogs) 4551 - { 4552 - struct gpiod_hog *hog; 4553 - 4554 - guard(mutex)(&gpio_machine_hogs_mutex); 4555 - 4556 - for (hog = &hogs[0]; hog->chip_label; hog++) { 4557 - list_add_tail(&hog->list, &gpio_machine_hogs); 4558 - 4559 - /* 4560 - * The chip may have been registered earlier, so check if it 4561 - * exists and, if so, try to hog the line now. 4562 - */ 4563 - struct gpio_device *gdev __free(gpio_device_put) = 4564 - gpio_device_find_by_label(hog->chip_label); 4565 - if (gdev) 4566 - gpiochip_machine_hog(gpio_device_get_chip(gdev), hog); 4567 - } 4568 - } 4569 - EXPORT_SYMBOL_GPL(gpiod_add_hogs); 4570 - 4571 - void gpiod_remove_hogs(struct gpiod_hog *hogs) 4572 - { 4573 - struct gpiod_hog *hog; 4574 - 4575 - guard(mutex)(&gpio_machine_hogs_mutex); 4576 - 4577 - for (hog = &hogs[0]; hog->chip_label; hog++) 4578 - list_del(&hog->list); 4579 - } 4580 - EXPORT_SYMBOL_GPL(gpiod_remove_hogs); 4581 4580 4582 4581 static bool gpiod_match_lookup_table(struct device *dev, 4583 4582 const struct gpiod_lookup_table *table)
-33
include/linux/gpio/machine.h
··· 46 46 struct gpiod_lookup table[]; 47 47 }; 48 48 49 - /** 50 - * struct gpiod_hog - GPIO line hog table 51 - * @chip_label: name of the chip the GPIO belongs to 52 - * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO 53 - * @line_name: consumer name for the hogged line 54 - * @lflags: bitmask of gpio_lookup_flags GPIO_* values 55 - * @dflags: GPIO flags used to specify the direction and value 56 - */ 57 - struct gpiod_hog { 58 - struct list_head list; 59 - const char *chip_label; 60 - u16 chip_hwnum; 61 - const char *line_name; 62 - unsigned long lflags; 63 - int dflags; 64 - }; 65 - 66 49 /* 67 50 * Helper for lookup tables with just one single lookup for a device. 68 51 */ ··· 78 95 .flags = _flags, \ 79 96 } 80 97 81 - /* 82 - * Simple definition of a single GPIO hog in an array. 83 - */ 84 - #define GPIO_HOG(_chip_label, _chip_hwnum, _line_name, _lflags, _dflags) \ 85 - (struct gpiod_hog) { \ 86 - .chip_label = _chip_label, \ 87 - .chip_hwnum = _chip_hwnum, \ 88 - .line_name = _line_name, \ 89 - .lflags = _lflags, \ 90 - .dflags = _dflags, \ 91 - } 92 - 93 98 #ifdef CONFIG_GPIOLIB 94 99 void gpiod_add_lookup_table(struct gpiod_lookup_table *table); 95 100 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); 96 101 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); 97 - void gpiod_add_hogs(struct gpiod_hog *hogs); 98 - void gpiod_remove_hogs(struct gpiod_hog *hogs); 99 102 #else /* ! CONFIG_GPIOLIB */ 100 103 static inline 101 104 void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} ··· 89 120 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {} 90 121 static inline 91 122 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} 92 - static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} 93 - static inline void gpiod_remove_hogs(struct gpiod_hog *hogs) {} 94 123 #endif /* CONFIG_GPIOLIB */ 95 124 96 125 #endif /* __LINUX_GPIO_MACHINE_H */