char *name;
int dir;
+ bool active_low;
};
static struct gpio_sim_hog *to_gpio_sim_hog(struct config_item *item)
hog = line->hog;
gpios[0] = line->offset;
- gpios[1] = 0;
+ gpios[1] = hog->active_low ? 1 : 0;
memset(properties, 0, sizeof(properties));
CONFIGFS_ATTR(gpio_sim_hog_config_, direction);
+static ssize_t gpio_sim_hog_config_active_low_show(struct config_item *item,
+ char *page)
+{
+ struct gpio_sim_hog *hog = to_gpio_sim_hog(item);
+ struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog);
+
+ guard(mutex)(&dev->lock);
+
+ return sprintf(page, "%c\n", hog->active_low ? '1' : '0');
+}
+
+static ssize_t
+gpio_sim_hog_config_active_low_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct gpio_sim_hog *hog = to_gpio_sim_hog(item);
+ struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog);
+ bool active_low;
+ int ret;
+
+ guard(mutex)(&dev->lock);
+
+ if (gpio_sim_device_is_live(dev))
+ return -EBUSY;
+
+ ret = kstrtobool(page, &active_low);
+ if (ret)
+ return ret;
+
+ hog->active_low = active_low;
+
+ return count;
+}
+
+CONFIGFS_ATTR(gpio_sim_hog_config_, active_low);
+
static struct configfs_attribute *gpio_sim_hog_config_attrs[] = {
&gpio_sim_hog_config_attr_name,
&gpio_sim_hog_config_attr_direction,
+ &gpio_sim_hog_config_attr_active_low,
NULL
};