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: sim: allow to define the active-low setting of a simulated hog

Add a new configfs attribute to the hog group allowing to configure the
active-low lookup flag for hogged lines. This will allow us to extend
tests to also cover the line config of hogs set up using software nodes.

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-6-4e61f3dbf06a@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

+39 -1
+39 -1
drivers/gpio/gpio-sim.c
··· 654 654 655 655 char *name; 656 656 int dir; 657 + bool active_low; 657 658 }; 658 659 659 660 static struct gpio_sim_hog *to_gpio_sim_hog(struct config_item *item) ··· 837 836 hog = line->hog; 838 837 839 838 gpios[0] = line->offset; 840 - gpios[1] = 0; 839 + gpios[1] = hog->active_low ? 1 : 0; 841 840 842 841 memset(properties, 0, sizeof(properties)); 843 842 ··· 1316 1315 1317 1316 CONFIGFS_ATTR(gpio_sim_hog_config_, direction); 1318 1317 1318 + static ssize_t gpio_sim_hog_config_active_low_show(struct config_item *item, 1319 + char *page) 1320 + { 1321 + struct gpio_sim_hog *hog = to_gpio_sim_hog(item); 1322 + struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); 1323 + 1324 + guard(mutex)(&dev->lock); 1325 + 1326 + return sprintf(page, "%c\n", hog->active_low ? '1' : '0'); 1327 + } 1328 + 1329 + static ssize_t 1330 + gpio_sim_hog_config_active_low_store(struct config_item *item, 1331 + const char *page, size_t count) 1332 + { 1333 + struct gpio_sim_hog *hog = to_gpio_sim_hog(item); 1334 + struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); 1335 + bool active_low; 1336 + int ret; 1337 + 1338 + guard(mutex)(&dev->lock); 1339 + 1340 + if (gpio_sim_device_is_live(dev)) 1341 + return -EBUSY; 1342 + 1343 + ret = kstrtobool(page, &active_low); 1344 + if (ret) 1345 + return ret; 1346 + 1347 + hog->active_low = active_low; 1348 + 1349 + return count; 1350 + } 1351 + 1352 + CONFIGFS_ATTR(gpio_sim_hog_config_, active_low); 1353 + 1319 1354 static struct configfs_attribute *gpio_sim_hog_config_attrs[] = { 1320 1355 &gpio_sim_hog_config_attr_name, 1321 1356 &gpio_sim_hog_config_attr_direction, 1357 + &gpio_sim_hog_config_attr_active_low, 1322 1358 NULL 1323 1359 }; 1324 1360