Lines Matching +full:hog +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
74 guard(mutex)(&chip->lock); in gpio_sim_apply_pull()
76 if (test_bit(offset, chip->request_map) && in gpio_sim_apply_pull()
77 test_bit(offset, chip->direction_map)) { in gpio_sim_apply_pull()
78 if (value == !!test_bit(offset, chip->value_map)) in gpio_sim_apply_pull()
82 * This is fine - it just means, nobody is listening in gpio_sim_apply_pull()
87 irq = irq_find_mapping(chip->irq_sim, offset); in gpio_sim_apply_pull()
104 if (!test_bit(offset, chip->request_map) || in gpio_sim_apply_pull()
105 test_bit(offset, chip->direction_map)) in gpio_sim_apply_pull()
106 __assign_bit(offset, chip->value_map, value); in gpio_sim_apply_pull()
109 __assign_bit(offset, chip->pull_map, value); in gpio_sim_apply_pull()
117 guard(mutex)(&chip->lock); in gpio_sim_get()
119 return !!test_bit(offset, chip->value_map); in gpio_sim_get()
126 scoped_guard(mutex, &chip->lock) in gpio_sim_set()
127 __assign_bit(offset, chip->value_map, value); in gpio_sim_set()
135 scoped_guard(mutex, &chip->lock) in gpio_sim_get_multiple()
136 bitmap_replace(bits, bits, chip->value_map, mask, gc->ngpio); in gpio_sim_get_multiple()
146 scoped_guard(mutex, &chip->lock) in gpio_sim_set_multiple()
147 bitmap_replace(chip->value_map, chip->value_map, bits, mask, in gpio_sim_set_multiple()
148 gc->ngpio); in gpio_sim_set_multiple()
156 scoped_guard(mutex, &chip->lock) { in gpio_sim_direction_output()
157 __clear_bit(offset, chip->direction_map); in gpio_sim_direction_output()
158 __assign_bit(offset, chip->value_map, value); in gpio_sim_direction_output()
168 scoped_guard(mutex, &chip->lock) in gpio_sim_direction_input()
169 __set_bit(offset, chip->direction_map); in gpio_sim_direction_input()
179 scoped_guard(mutex, &chip->lock) in gpio_sim_get_direction()
180 direction = !!test_bit(offset, chip->direction_map); in gpio_sim_get_direction()
199 return -ENOTSUPP; in gpio_sim_set_config()
206 return irq_create_mapping(chip->irq_sim, offset); in gpio_sim_to_irq()
213 scoped_guard(mutex, &chip->lock) in gpio_sim_request()
214 __set_bit(offset, chip->request_map); in gpio_sim_request()
223 scoped_guard(mutex, &chip->lock) { in gpio_sim_free()
224 __assign_bit(offset, chip->value_map, in gpio_sim_free()
225 !!test_bit(offset, chip->pull_map)); in gpio_sim_free()
226 __clear_bit(offset, chip->request_map); in gpio_sim_free()
235 return gpiochip_lock_as_irq(&chip->gc, hwirq); in gpio_sim_irq_requested()
243 gpiochip_unlock_as_irq(&chip->gc, hwirq); in gpio_sim_irq_released()
257 guard(mutex)(&chip->lock); in gpio_sim_dbg_show()
260 seq_printf(seq, " gpio-%-3d (%s) %s,%s\n", in gpio_sim_dbg_show()
261 gc->base + i, in gpio_sim_dbg_show()
263 test_bit(i, chip->direction_map) ? "input" : in gpio_sim_dbg_show()
264 test_bit(i, chip->value_map) ? "output-high" : in gpio_sim_dbg_show()
265 "output-low", in gpio_sim_dbg_show()
266 test_bit(i, chip->pull_map) ? "pull-up" : in gpio_sim_dbg_show()
267 "pull-down"); in gpio_sim_dbg_show()
277 scoped_guard(mutex, &chip->lock) in gpio_sim_sysfs_val_show()
278 val = !!test_bit(line_attr->offset, chip->value_map); in gpio_sim_sysfs_val_show()
288 * Not assigning this function will result in write() returning -EIO in gpio_sim_sysfs_val_store()
289 * which is confusing. Return -EPERM explicitly. in gpio_sim_sysfs_val_store()
291 return -EPERM; in gpio_sim_sysfs_val_store()
295 [0] = "pull-down",
296 [1] = "pull-up",
307 scoped_guard(mutex, &chip->lock) in gpio_sim_sysfs_pull_show()
308 pull = !!test_bit(line_attr->offset, chip->pull_map); in gpio_sim_sysfs_pull_show()
325 ret = gpio_sim_apply_pull(chip, line_attr->offset, pull); in gpio_sim_sysfs_pull_store()
344 for (i = 0; i < chip->gc.ngpio; i++) in gpio_sim_dispose_mappings()
345 irq_dispose_mapping(irq_find_mapping(chip->irq_sim, i)); in gpio_sim_dispose_mappings()
352 sysfs_remove_groups(&chip->dev->kobj, chip->attr_groups); in gpio_sim_sysfs_remove()
359 unsigned int num_lines = chip->gc.ngpio; in gpio_sim_setup_sysfs()
360 struct device *dev = chip->gc.parent; in gpio_sim_setup_sysfs()
365 chip->attr_groups = devm_kcalloc(dev, sizeof(*chip->attr_groups), in gpio_sim_setup_sysfs()
367 if (!chip->attr_groups) in gpio_sim_setup_sysfs()
368 return -ENOMEM; in gpio_sim_setup_sysfs()
377 return -ENOMEM; in gpio_sim_setup_sysfs()
379 attr_group->name = devm_kasprintf(dev, GFP_KERNEL, in gpio_sim_setup_sysfs()
381 if (!attr_group->name) in gpio_sim_setup_sysfs()
382 return -ENOMEM; in gpio_sim_setup_sysfs()
384 val_attr->offset = pull_attr->offset = i; in gpio_sim_setup_sysfs()
386 val_dev_attr = &val_attr->dev_attr; in gpio_sim_setup_sysfs()
387 pull_dev_attr = &pull_attr->dev_attr; in gpio_sim_setup_sysfs()
389 sysfs_attr_init(&val_dev_attr->attr); in gpio_sim_setup_sysfs()
390 sysfs_attr_init(&pull_dev_attr->attr); in gpio_sim_setup_sysfs()
392 val_dev_attr->attr.name = "value"; in gpio_sim_setup_sysfs()
393 pull_dev_attr->attr.name = "pull"; in gpio_sim_setup_sysfs()
395 val_dev_attr->attr.mode = pull_dev_attr->attr.mode = 0644; in gpio_sim_setup_sysfs()
397 val_dev_attr->show = gpio_sim_sysfs_val_show; in gpio_sim_setup_sysfs()
398 val_dev_attr->store = gpio_sim_sysfs_val_store; in gpio_sim_setup_sysfs()
399 pull_dev_attr->show = gpio_sim_sysfs_pull_show; in gpio_sim_setup_sysfs()
400 pull_dev_attr->store = gpio_sim_sysfs_pull_store; in gpio_sim_setup_sysfs()
402 attrs[0] = &val_dev_attr->attr; in gpio_sim_setup_sysfs()
403 attrs[1] = &pull_dev_attr->attr; in gpio_sim_setup_sysfs()
405 attr_group->attrs = attrs; in gpio_sim_setup_sysfs()
406 chip->attr_groups[i] = attr_group; in gpio_sim_setup_sysfs()
409 ret = sysfs_create_groups(&chip->dev->kobj, chip->attr_groups); in gpio_sim_setup_sysfs()
434 return -ERANGE; in gpio_sim_add_bank()
436 ret = fwnode_property_read_string(swnode, "gpio-sim,label", &label); in gpio_sim_add_bank()
441 return -ENOMEM; in gpio_sim_add_bank()
446 return -ENOMEM; in gpio_sim_add_bank()
448 chip->request_map = devm_bitmap_zalloc(dev, num_lines, GFP_KERNEL); in gpio_sim_add_bank()
449 if (!chip->request_map) in gpio_sim_add_bank()
450 return -ENOMEM; in gpio_sim_add_bank()
452 chip->direction_map = devm_bitmap_alloc(dev, num_lines, GFP_KERNEL); in gpio_sim_add_bank()
453 if (!chip->direction_map) in gpio_sim_add_bank()
454 return -ENOMEM; in gpio_sim_add_bank()
457 bitmap_fill(chip->direction_map, num_lines); in gpio_sim_add_bank()
459 chip->value_map = devm_bitmap_zalloc(dev, num_lines, GFP_KERNEL); in gpio_sim_add_bank()
460 if (!chip->value_map) in gpio_sim_add_bank()
461 return -ENOMEM; in gpio_sim_add_bank()
463 chip->pull_map = devm_bitmap_zalloc(dev, num_lines, GFP_KERNEL); in gpio_sim_add_bank()
464 if (!chip->pull_map) in gpio_sim_add_bank()
465 return -ENOMEM; in gpio_sim_add_bank()
467 chip->irq_sim = devm_irq_domain_create_sim_full(dev, swnode, num_lines, in gpio_sim_add_bank()
470 if (IS_ERR(chip->irq_sim)) in gpio_sim_add_bank()
471 return PTR_ERR(chip->irq_sim); in gpio_sim_add_bank()
477 ret = devm_mutex_init(dev, &chip->lock); in gpio_sim_add_bank()
481 gc = &chip->gc; in gpio_sim_add_bank()
482 gc->base = -1; in gpio_sim_add_bank()
483 gc->ngpio = num_lines; in gpio_sim_add_bank()
484 gc->label = label; in gpio_sim_add_bank()
485 gc->owner = THIS_MODULE; in gpio_sim_add_bank()
486 gc->parent = dev; in gpio_sim_add_bank()
487 gc->fwnode = swnode; in gpio_sim_add_bank()
488 gc->get = gpio_sim_get; in gpio_sim_add_bank()
489 gc->set = gpio_sim_set; in gpio_sim_add_bank()
490 gc->get_multiple = gpio_sim_get_multiple; in gpio_sim_add_bank()
491 gc->set_multiple = gpio_sim_set_multiple; in gpio_sim_add_bank()
492 gc->direction_output = gpio_sim_direction_output; in gpio_sim_add_bank()
493 gc->direction_input = gpio_sim_direction_input; in gpio_sim_add_bank()
494 gc->get_direction = gpio_sim_get_direction; in gpio_sim_add_bank()
495 gc->set_config = gpio_sim_set_config; in gpio_sim_add_bank()
496 gc->to_irq = gpio_sim_to_irq; in gpio_sim_add_bank()
497 gc->request = gpio_sim_request; in gpio_sim_add_bank()
498 gc->free = gpio_sim_free; in gpio_sim_add_bank()
499 gc->dbg_show = PTR_IF(IS_ENABLED(CONFIG_DEBUG_FS), gpio_sim_dbg_show); in gpio_sim_add_bank()
500 gc->can_sleep = true; in gpio_sim_add_bank()
506 chip->dev = device_find_child(dev, swnode, gpio_sim_dev_match_fwnode); in gpio_sim_add_bank()
507 if (!chip->dev) in gpio_sim_add_bank()
508 return -ENODEV; in gpio_sim_add_bank()
510 ret = devm_add_action_or_reset(dev, gpio_sim_put_device, chip->dev); in gpio_sim_add_bank()
515 dev_set_drvdata(chip->dev, chip); in gpio_sim_add_bank()
522 struct device *dev = &pdev->dev; in gpio_sim_probe()
538 { .compatible = "gpio-simulator" },
545 .name = "gpio-sim",
575 * and notify the user-space about any errors.
586 /* This is called with dev->lock already taken. */
596 snprintf(devname, sizeof(devname), "gpio-sim.%u", simdev->id); in gpio_sim_bus_notifier_call()
602 simdev->driver_bound = true; in gpio_sim_bus_notifier_call()
604 simdev->driver_bound = false; in gpio_sim_bus_notifier_call()
608 complete(&simdev->probe_completion); in gpio_sim_bus_notifier_call()
656 return bank->label && *bank->label; in gpio_sim_bank_has_label()
662 return bank->parent; in gpio_sim_bank_get_device()
676 /* There can only be one hog per line. */
677 struct gpio_sim_hog *hog; member
690 struct gpio_sim_bank *bank = line->parent; in gpio_sim_line_get_device()
708 static struct gpio_sim_device *gpio_sim_hog_get_device(struct gpio_sim_hog *hog) in gpio_sim_hog_get_device() argument
710 struct gpio_sim_line *line = hog->parent; in gpio_sim_hog_get_device()
717 lockdep_assert_held(&dev->lock); in gpio_sim_device_is_live()
719 return !!dev->pdev; in gpio_sim_device_is_live()
739 guard(mutex)(&dev->lock); in gpio_sim_device_config_dev_name_show()
741 pdev = dev->pdev; in gpio_sim_device_config_dev_name_show()
743 return sprintf(page, "%s\n", dev_name(&pdev->dev)); in gpio_sim_device_config_dev_name_show()
745 return sprintf(page, "gpio-sim.%d\n", dev->id); in gpio_sim_device_config_dev_name_show()
756 scoped_guard(mutex, &dev->lock) in gpio_sim_device_config_live_show()
767 list_for_each_entry(line, &bank->line_list, siblings) { in gpio_sim_get_line_names_size()
768 if (!line->name || (line->offset >= bank->num_lines)) in gpio_sim_get_line_names_size()
771 size = max(size, line->offset + 1); in gpio_sim_get_line_names_size()
782 list_for_each_entry(line, &bank->line_list, siblings) { in gpio_sim_set_line_names()
783 if (!line->name || (line->offset >= bank->num_lines)) in gpio_sim_set_line_names()
786 line_names[line->offset] = line->name; in gpio_sim_set_line_names()
792 struct gpiod_hog *hog; in gpio_sim_remove_hogs() local
794 if (!dev->hogs) in gpio_sim_remove_hogs()
797 gpiod_remove_hogs(dev->hogs); in gpio_sim_remove_hogs()
799 for (hog = dev->hogs; hog->chip_label; hog++) { in gpio_sim_remove_hogs()
800 kfree(hog->chip_label); in gpio_sim_remove_hogs()
801 kfree(hog->line_name); in gpio_sim_remove_hogs()
804 kfree(dev->hogs); in gpio_sim_remove_hogs()
805 dev->hogs = NULL; in gpio_sim_remove_hogs()
813 struct gpiod_hog *hog; in gpio_sim_add_hogs() local
815 list_for_each_entry(bank, &dev->bank_list, siblings) { in gpio_sim_add_hogs()
816 list_for_each_entry(line, &bank->line_list, siblings) { in gpio_sim_add_hogs()
817 if (line->offset >= bank->num_lines) in gpio_sim_add_hogs()
820 if (line->hog) in gpio_sim_add_hogs()
829 dev->hogs = kcalloc(num_hogs + 1, sizeof(*dev->hogs), GFP_KERNEL); in gpio_sim_add_hogs()
830 if (!dev->hogs) in gpio_sim_add_hogs()
831 return -ENOMEM; in gpio_sim_add_hogs()
833 list_for_each_entry(bank, &dev->bank_list, siblings) { in gpio_sim_add_hogs()
834 list_for_each_entry(line, &bank->line_list, siblings) { in gpio_sim_add_hogs()
835 if (line->offset >= bank->num_lines) in gpio_sim_add_hogs()
838 if (!line->hog) in gpio_sim_add_hogs()
841 hog = &dev->hogs[idx++]; in gpio_sim_add_hogs()
849 hog->chip_label = kstrdup(bank->label, in gpio_sim_add_hogs()
852 hog->chip_label = kasprintf(GFP_KERNEL, in gpio_sim_add_hogs()
853 "gpio-sim.%u:%pfwP", in gpio_sim_add_hogs()
854 dev->id, in gpio_sim_add_hogs()
855 bank->swnode); in gpio_sim_add_hogs()
856 if (!hog->chip_label) { in gpio_sim_add_hogs()
858 return -ENOMEM; in gpio_sim_add_hogs()
862 * We need to duplicate this because the hog config in gpio_sim_add_hogs()
864 * it) and gpiolib doesn't make a deep copy of the hog in gpio_sim_add_hogs()
867 if (line->hog->name) { in gpio_sim_add_hogs()
868 hog->line_name = kstrdup(line->hog->name, in gpio_sim_add_hogs()
870 if (!hog->line_name) { in gpio_sim_add_hogs()
872 return -ENOMEM; in gpio_sim_add_hogs()
876 hog->chip_hwnum = line->offset; in gpio_sim_add_hogs()
877 hog->dflags = line->hog->dir; in gpio_sim_add_hogs()
881 gpiod_add_hogs(dev->hogs); in gpio_sim_add_hogs()
896 properties[prop_idx++] = PROPERTY_ENTRY_U32("ngpios", bank->num_lines); in gpio_sim_make_bank_swnode()
899 properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label", in gpio_sim_make_bank_swnode()
900 bank->label); in gpio_sim_make_bank_swnode()
907 return ERR_PTR(-ENOMEM); in gpio_sim_make_bank_swnode()
912 "gpio-line-names", in gpio_sim_make_bank_swnode()
933 list_for_each_entry(this, &dev->bank_list, siblings) { in gpio_sim_bank_labels_non_unique()
934 list_for_each_entry(pos, &dev->bank_list, siblings) { in gpio_sim_bank_labels_non_unique()
935 if (this == pos || (!this->label || !pos->label)) in gpio_sim_bank_labels_non_unique()
938 if (strcmp(this->label, pos->label) == 0) in gpio_sim_bank_labels_non_unique()
954 lockdep_assert_held(&dev->lock); in gpio_sim_device_activate()
956 if (list_empty(&dev->bank_list)) in gpio_sim_device_activate()
957 return -ENODATA; in gpio_sim_device_activate()
960 * Non-unique GPIO device labels are a corner-case we don't support in gpio_sim_device_activate()
965 return -EINVAL; in gpio_sim_device_activate()
973 list_for_each_entry(bank, &dev->bank_list, siblings) { in gpio_sim_device_activate()
974 bank->swnode = gpio_sim_make_bank_swnode(bank, swnode); in gpio_sim_device_activate()
975 if (IS_ERR(bank->swnode)) { in gpio_sim_device_activate()
976 ret = PTR_ERR(bank->swnode); in gpio_sim_device_activate()
988 pdevinfo.name = "gpio-sim"; in gpio_sim_device_activate()
990 pdevinfo.id = dev->id; in gpio_sim_device_activate()
992 reinit_completion(&dev->probe_completion); in gpio_sim_device_activate()
993 dev->driver_bound = false; in gpio_sim_device_activate()
994 bus_register_notifier(&platform_bus_type, &dev->bus_notifier); in gpio_sim_device_activate()
998 bus_unregister_notifier(&platform_bus_type, &dev->bus_notifier); in gpio_sim_device_activate()
1004 wait_for_completion(&dev->probe_completion); in gpio_sim_device_activate()
1005 bus_unregister_notifier(&platform_bus_type, &dev->bus_notifier); in gpio_sim_device_activate()
1007 if (!dev->driver_bound) { in gpio_sim_device_activate()
1012 return -ENXIO; in gpio_sim_device_activate()
1015 dev->pdev = pdev; in gpio_sim_device_activate()
1024 lockdep_assert_held(&dev->lock); in gpio_sim_device_deactivate()
1026 swnode = dev_fwnode(&dev->pdev->dev); in gpio_sim_device_deactivate()
1027 platform_device_unregister(dev->pdev); in gpio_sim_device_deactivate()
1030 dev->pdev = NULL; in gpio_sim_device_deactivate()
1045 guard(mutex)(&dev->lock); in gpio_sim_device_config_live_store()
1048 ret = -EPERM; in gpio_sim_device_config_live_store()
1075 if (dev->class) in gpio_sim_emit_chip_name()
1078 if (device_match_fwnode(dev, ctx->swnode)) in gpio_sim_emit_chip_name()
1079 return sprintf(ctx->page, "%s\n", dev_name(dev)); in gpio_sim_emit_chip_name()
1089 struct gpio_sim_chip_name_ctx ctx = { bank->swnode, page }; in gpio_sim_bank_config_chip_name_show()
1091 guard(mutex)(&dev->lock); in gpio_sim_bank_config_chip_name_show()
1094 return device_for_each_child(&dev->pdev->dev, &ctx, in gpio_sim_bank_config_chip_name_show()
1108 guard(mutex)(&dev->lock); in gpio_sim_bank_config_label_show()
1110 return sprintf(page, "%s\n", bank->label ?: ""); in gpio_sim_bank_config_label_show()
1120 guard(mutex)(&dev->lock); in gpio_sim_bank_config_label_store()
1123 return -EBUSY; in gpio_sim_bank_config_label_store()
1127 return -ENOMEM; in gpio_sim_bank_config_label_store()
1129 kfree(bank->label); in gpio_sim_bank_config_label_store()
1130 bank->label = trimmed; in gpio_sim_bank_config_label_store()
1143 guard(mutex)(&dev->lock); in gpio_sim_bank_config_num_lines_show()
1145 return sprintf(page, "%u\n", bank->num_lines); in gpio_sim_bank_config_num_lines_show()
1162 return -EINVAL; in gpio_sim_bank_config_num_lines_store()
1164 guard(mutex)(&dev->lock); in gpio_sim_bank_config_num_lines_store()
1167 return -EBUSY; in gpio_sim_bank_config_num_lines_store()
1169 bank->num_lines = num_lines; in gpio_sim_bank_config_num_lines_store()
1189 guard(mutex)(&dev->lock); in gpio_sim_line_config_name_show()
1191 return sprintf(page, "%s\n", line->name ?: ""); in gpio_sim_line_config_name_show()
1201 guard(mutex)(&dev->lock); in gpio_sim_line_config_name_store()
1204 return -EBUSY; in gpio_sim_line_config_name_store()
1208 return -ENOMEM; in gpio_sim_line_config_name_store()
1210 kfree(line->name); in gpio_sim_line_config_name_store()
1211 line->name = trimmed; in gpio_sim_line_config_name_store()
1226 struct gpio_sim_hog *hog = to_gpio_sim_hog(item); in gpio_sim_hog_config_name_show() local
1227 struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); in gpio_sim_hog_config_name_show()
1229 guard(mutex)(&dev->lock); in gpio_sim_hog_config_name_show()
1231 return sprintf(page, "%s\n", hog->name ?: ""); in gpio_sim_hog_config_name_show()
1237 struct gpio_sim_hog *hog = to_gpio_sim_hog(item); in gpio_sim_hog_config_name_store() local
1238 struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); in gpio_sim_hog_config_name_store()
1241 guard(mutex)(&dev->lock); in gpio_sim_hog_config_name_store()
1244 return -EBUSY; in gpio_sim_hog_config_name_store()
1248 return -ENOMEM; in gpio_sim_hog_config_name_store()
1250 kfree(hog->name); in gpio_sim_hog_config_name_store()
1251 hog->name = trimmed; in gpio_sim_hog_config_name_store()
1261 struct gpio_sim_hog *hog = to_gpio_sim_hog(item); in gpio_sim_hog_config_direction_show() local
1262 struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); in gpio_sim_hog_config_direction_show()
1266 scoped_guard(mutex, &dev->lock) in gpio_sim_hog_config_direction_show()
1267 dir = hog->dir; in gpio_sim_hog_config_direction_show()
1274 repr = "output-high"; in gpio_sim_hog_config_direction_show()
1277 repr = "output-low"; in gpio_sim_hog_config_direction_show()
1281 WARN(1, "Unexpected hog direction value: %d", dir); in gpio_sim_hog_config_direction_show()
1282 return -EINVAL; in gpio_sim_hog_config_direction_show()
1292 struct gpio_sim_hog *hog = to_gpio_sim_hog(item); in gpio_sim_hog_config_direction_store() local
1293 struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); in gpio_sim_hog_config_direction_store()
1296 guard(mutex)(&dev->lock); in gpio_sim_hog_config_direction_store()
1299 return -EBUSY; in gpio_sim_hog_config_direction_store()
1303 else if (sysfs_streq(page, "output-high")) in gpio_sim_hog_config_direction_store()
1305 else if (sysfs_streq(page, "output-low")) in gpio_sim_hog_config_direction_store()
1308 return -EINVAL; in gpio_sim_hog_config_direction_store()
1310 hog->dir = dir; in gpio_sim_hog_config_direction_store()
1325 struct gpio_sim_hog *hog = to_gpio_sim_hog(item); in gpio_sim_hog_config_item_release() local
1326 struct gpio_sim_line *line = hog->parent; in gpio_sim_hog_config_item_release()
1327 struct gpio_sim_device *dev = gpio_sim_hog_get_device(hog); in gpio_sim_hog_config_item_release()
1329 scoped_guard(mutex, &dev->lock) in gpio_sim_hog_config_item_release()
1330 line->hog = NULL; in gpio_sim_hog_config_item_release()
1332 kfree(hog->name); in gpio_sim_hog_config_item_release()
1333 kfree(hog); in gpio_sim_hog_config_item_release()
1349 struct gpio_sim_line *line = to_gpio_sim_line(&group->cg_item); in gpio_sim_line_config_make_hog_item()
1351 struct gpio_sim_hog *hog; in gpio_sim_line_config_make_hog_item() local
1353 if (strcmp(name, "hog") != 0) in gpio_sim_line_config_make_hog_item()
1354 return ERR_PTR(-EINVAL); in gpio_sim_line_config_make_hog_item()
1356 guard(mutex)(&dev->lock); in gpio_sim_line_config_make_hog_item()
1358 hog = kzalloc(sizeof(*hog), GFP_KERNEL); in gpio_sim_line_config_make_hog_item()
1359 if (!hog) in gpio_sim_line_config_make_hog_item()
1360 return ERR_PTR(-ENOMEM); in gpio_sim_line_config_make_hog_item()
1362 config_item_init_type_name(&hog->item, name, in gpio_sim_line_config_make_hog_item()
1365 hog->dir = GPIOD_IN; in gpio_sim_line_config_make_hog_item()
1366 hog->name = NULL; in gpio_sim_line_config_make_hog_item()
1367 hog->parent = line; in gpio_sim_line_config_make_hog_item()
1368 line->hog = hog; in gpio_sim_line_config_make_hog_item()
1370 return &hog->item; in gpio_sim_line_config_make_hog_item()
1378 scoped_guard(mutex, &dev->lock) in gpio_sim_line_config_group_release()
1379 list_del(&line->siblings); in gpio_sim_line_config_group_release()
1381 kfree(line->name); in gpio_sim_line_config_group_release()
1404 struct gpio_sim_bank *bank = to_gpio_sim_bank(&group->cg_item); in gpio_sim_bank_config_make_line_group()
1412 return ERR_PTR(-EINVAL); in gpio_sim_bank_config_make_line_group()
1414 guard(mutex)(&dev->lock); in gpio_sim_bank_config_make_line_group()
1417 return ERR_PTR(-EBUSY); in gpio_sim_bank_config_make_line_group()
1421 return ERR_PTR(-ENOMEM); in gpio_sim_bank_config_make_line_group()
1423 config_group_init_type_name(&line->group, name, in gpio_sim_bank_config_make_line_group()
1426 line->parent = bank; in gpio_sim_bank_config_make_line_group()
1427 line->offset = offset; in gpio_sim_bank_config_make_line_group()
1428 list_add_tail(&line->siblings, &bank->line_list); in gpio_sim_bank_config_make_line_group()
1430 return &line->group; in gpio_sim_bank_config_make_line_group()
1438 scoped_guard(mutex, &dev->lock) in gpio_sim_bank_config_group_release()
1439 list_del(&bank->siblings); in gpio_sim_bank_config_group_release()
1441 kfree(bank->label); in gpio_sim_bank_config_group_release()
1464 struct gpio_sim_device *dev = to_gpio_sim_device(&group->cg_item); in gpio_sim_device_config_make_bank_group()
1467 guard(mutex)(&dev->lock); in gpio_sim_device_config_make_bank_group()
1470 return ERR_PTR(-EBUSY); in gpio_sim_device_config_make_bank_group()
1474 return ERR_PTR(-ENOMEM); in gpio_sim_device_config_make_bank_group()
1476 config_group_init_type_name(&bank->group, name, in gpio_sim_device_config_make_bank_group()
1478 bank->num_lines = 1; in gpio_sim_device_config_make_bank_group()
1479 bank->parent = dev; in gpio_sim_device_config_make_bank_group()
1480 INIT_LIST_HEAD(&bank->line_list); in gpio_sim_device_config_make_bank_group()
1481 list_add_tail(&bank->siblings, &dev->bank_list); in gpio_sim_device_config_make_bank_group()
1483 return &bank->group; in gpio_sim_device_config_make_bank_group()
1490 scoped_guard(mutex, &dev->lock) { in gpio_sim_device_config_group_release()
1495 mutex_destroy(&dev->lock); in gpio_sim_device_config_group_release()
1496 ida_free(&gpio_sim_ida, dev->id); in gpio_sim_device_config_group_release()
1523 return ERR_PTR(-ENOMEM); in gpio_sim_config_make_device_group()
1529 config_group_init_type_name(&dev->group, name, in gpio_sim_config_make_device_group()
1531 dev->id = id; in gpio_sim_config_make_device_group()
1532 mutex_init(&dev->lock); in gpio_sim_config_make_device_group()
1533 INIT_LIST_HEAD(&dev->bank_list); in gpio_sim_config_make_device_group()
1535 dev->bus_notifier.notifier_call = gpio_sim_bus_notifier_call; in gpio_sim_config_make_device_group()
1536 init_completion(&dev->probe_completion); in gpio_sim_config_make_device_group()
1538 return &no_free_ptr(dev)->group; in gpio_sim_config_make_device_group()
1553 .ci_namebuf = "gpio-sim",