Skip to content

Commit dea046e

Browse files
author
Bartosz Golaszewski
committed
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>
1 parent e627fc9 commit dea046e

3 files changed

Lines changed: 0 additions & 120 deletions

File tree

Documentation/driver-api/gpio/board.rst

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,22 +239,6 @@ mapping and is thus transparent to GPIO consumers.
239239
A set of functions such as gpiod_set_value() is available to work with
240240
the new descriptor-oriented interface.
241241

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-
258242
Arrays of pins
259243
--------------
260244
In addition to requesting pins belonging to a function one by one, a device may

drivers/gpio/gpiolib.c

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ static DEFINE_MUTEX(gpio_devices_lock);
103103
/* Ensures coherence during read-only accesses to the list of GPIO devices. */
104104
DEFINE_STATIC_SRCU(gpio_devices_srcu);
105105

106-
static DEFINE_MUTEX(gpio_machine_hogs_mutex);
107-
static LIST_HEAD(gpio_machine_hogs);
108-
109106
const char *const gpio_suffixes[] = { "gpios", "gpio", NULL };
110107

111108
static void gpiochip_free_hogs(struct gpio_chip *gc);
@@ -930,36 +927,6 @@ static int gpiochip_setup_dev(struct gpio_chip *gc)
930927
return ret;
931928
}
932929

933-
static void gpiochip_machine_hog(struct gpio_chip *gc, struct gpiod_hog *hog)
934-
{
935-
struct gpio_desc *desc;
936-
int rv;
937-
938-
desc = gpiochip_get_desc(gc, hog->chip_hwnum);
939-
if (IS_ERR(desc)) {
940-
gpiochip_err(gc, "%s: unable to get GPIO desc: %ld\n",
941-
__func__, PTR_ERR(desc));
942-
return;
943-
}
944-
945-
rv = gpiod_hog(desc, hog->line_name, hog->lflags, hog->dflags);
946-
if (rv)
947-
gpiod_err(desc, "%s: unable to hog GPIO line (%s:%u): %d\n",
948-
__func__, gc->label, hog->chip_hwnum, rv);
949-
}
950-
951-
static void gpiochip_machine_hog_lines(struct gpio_chip *gc)
952-
{
953-
struct gpiod_hog *hog;
954-
955-
guard(mutex)(&gpio_machine_hogs_mutex);
956-
957-
list_for_each_entry(hog, &gpio_machine_hogs, list) {
958-
if (!strcmp(gc->label, hog->chip_label))
959-
gpiochip_machine_hog(gc, hog);
960-
}
961-
}
962-
963930
int gpiochip_add_hog(struct gpio_chip *gc, struct fwnode_handle *fwnode)
964931
{
965932
struct fwnode_handle *gc_node = dev_fwnode(&gc->gpiodev->dev);
@@ -1047,8 +1014,6 @@ static int gpiochip_hog_lines(struct gpio_chip *gc)
10471014
return ret;
10481015
}
10491016

1050-
gpiochip_machine_hog_lines(gc);
1051-
10521017
return 0;
10531018
}
10541019

@@ -4578,42 +4543,6 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
45784543
}
45794544
EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);
45804545

4581-
/**
4582-
* gpiod_add_hogs() - register a set of GPIO hogs from machine code
4583-
* @hogs: table of gpio hog entries with a zeroed sentinel at the end
4584-
*/
4585-
void gpiod_add_hogs(struct gpiod_hog *hogs)
4586-
{
4587-
struct gpiod_hog *hog;
4588-
4589-
guard(mutex)(&gpio_machine_hogs_mutex);
4590-
4591-
for (hog = &hogs[0]; hog->chip_label; hog++) {
4592-
list_add_tail(&hog->list, &gpio_machine_hogs);
4593-
4594-
/*
4595-
* The chip may have been registered earlier, so check if it
4596-
* exists and, if so, try to hog the line now.
4597-
*/
4598-
struct gpio_device *gdev __free(gpio_device_put) =
4599-
gpio_device_find_by_label(hog->chip_label);
4600-
if (gdev)
4601-
gpiochip_machine_hog(gpio_device_get_chip(gdev), hog);
4602-
}
4603-
}
4604-
EXPORT_SYMBOL_GPL(gpiod_add_hogs);
4605-
4606-
void gpiod_remove_hogs(struct gpiod_hog *hogs)
4607-
{
4608-
struct gpiod_hog *hog;
4609-
4610-
guard(mutex)(&gpio_machine_hogs_mutex);
4611-
4612-
for (hog = &hogs[0]; hog->chip_label; hog++)
4613-
list_del(&hog->list);
4614-
}
4615-
EXPORT_SYMBOL_GPL(gpiod_remove_hogs);
4616-
46174546
static bool gpiod_match_lookup_table(struct device *dev,
46184547
const struct gpiod_lookup_table *table)
46194548
{

include/linux/gpio/machine.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,6 @@ struct gpiod_lookup_table {
4646
struct gpiod_lookup table[];
4747
};
4848

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-
6649
/*
6750
* Helper for lookup tables with just one single lookup for a device.
6851
*/
@@ -95,33 +78,17 @@ static struct gpiod_lookup_table _name = { \
9578
.flags = _flags, \
9679
}
9780

98-
/*
99-
* Simple definition of a single GPIO hog in an array.
100-
*/
101-
#define GPIO_HOG(_chip_label, _chip_hwnum, _line_name, _lflags, _dflags) \
102-
(struct gpiod_hog) { \
103-
.chip_label = _chip_label, \
104-
.chip_hwnum = _chip_hwnum, \
105-
.line_name = _line_name, \
106-
.lflags = _lflags, \
107-
.dflags = _dflags, \
108-
}
109-
11081
#ifdef CONFIG_GPIOLIB
11182
void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
11283
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
11384
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
114-
void gpiod_add_hogs(struct gpiod_hog *hogs);
115-
void gpiod_remove_hogs(struct gpiod_hog *hogs);
11685
#else /* ! CONFIG_GPIOLIB */
11786
static inline
11887
void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
11988
static inline
12089
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
12190
static inline
12291
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
123-
static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {}
124-
static inline void gpiod_remove_hogs(struct gpiod_hog *hogs) {}
12592
#endif /* CONFIG_GPIOLIB */
12693

12794
#endif /* __LINUX_GPIO_MACHINE_H */

0 commit comments

Comments
 (0)