Lines Matching refs:gdev

127 	struct gpio_device *gdev;  in gpio_to_desc()  local
132 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_to_desc()
133 if (gdev->base <= gpio && in gpio_to_desc()
134 gdev->base + gdev->ngpio > gpio) { in gpio_to_desc()
136 return &gdev->descs[gpio - gdev->base]; in gpio_to_desc()
162 struct gpio_device *gdev = gc->gpiodev; in gpiochip_get_desc() local
164 if (hwnum >= gdev->ngpio) in gpiochip_get_desc()
167 return &gdev->descs[hwnum]; in gpiochip_get_desc()
183 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
194 if (!desc || !desc->gdev) in gpiod_to_chip()
196 return desc->gdev->chip; in gpiod_to_chip()
203 struct gpio_device *gdev; in gpiochip_find_base() local
206 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_find_base()
208 if (gdev->base >= base + ngpio) in gpiochip_find_base()
211 base = gdev->base + gdev->ngpio; in gpiochip_find_base()
274 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
280 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
285 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
287 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
292 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
294 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
304 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
305 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
306 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
322 struct gpio_device *gdev; in gpio_name_to_desc() local
330 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
333 for_each_gpio_desc(gdev->chip, desc) { in gpio_name_to_desc()
356 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
365 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
372 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
388 struct gpio_device *gdev = chip->gpiodev; in gpiochip_set_names() local
389 struct device *dev = &gdev->dev; in gpiochip_set_names()
446 gdev->descs[i].name = names[chip->offset + i]; in gpiochip_set_names()
579 struct gpio_device *gdev = to_gpio_device(dev); in gpiodev_release() local
583 list_del(&gdev->list); in gpiodev_release()
586 ida_free(&gpio_ida, gdev->id); in gpiodev_release()
587 kfree_const(gdev->label); in gpiodev_release()
588 kfree(gdev->descs); in gpiodev_release()
589 kfree(gdev); in gpiodev_release()
593 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
594 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
600 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
601 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
604 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
606 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in gpiochip_setup_dev()
616 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
621 gdev->dev.release = gpiodev_release; in gpiochip_setup_dev()
623 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
627 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
628 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
633 gcdev_unregister(gdev); in gpiochip_setup_dev()
674 struct gpio_device *gdev; in gpiochip_setup_devs() local
677 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
678 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
680 dev_err(&gdev->dev, in gpiochip_setup_devs()
741 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
751 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
752 if (!gdev) in gpiochip_add_data_with_key()
754 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
755 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
756 gdev->chip = gc; in gpiochip_add_data_with_key()
758 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
766 device_set_node(&gdev->dev, gc->fwnode); in gpiochip_add_data_with_key()
768 device_set_node(&gdev->dev, dev_fwnode(gc->parent)); in gpiochip_add_data_with_key()
770 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
771 if (gdev->id < 0) { in gpiochip_add_data_with_key()
772 ret = gdev->id; in gpiochip_add_data_with_key()
776 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
780 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
782 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
785 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
787 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
789 ret = gpiochip_get_ngpios(gc, &gdev->dev); in gpiochip_add_data_with_key()
793 gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); in gpiochip_add_data_with_key()
794 if (!gdev->descs) { in gpiochip_add_data_with_key()
799 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
800 if (!gdev->label) { in gpiochip_add_data_with_key()
805 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
833 dev_warn(&gdev->dev, in gpiochip_add_data_with_key()
836 gdev->base = base; in gpiochip_add_data_with_key()
838 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
846 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
850 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier); in gpiochip_add_data_with_key()
851 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier); in gpiochip_add_data_with_key()
852 init_rwsem(&gdev->sem); in gpiochip_add_data_with_key()
855 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
876 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
916 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
934 if (gdev->dev.release) { in gpiochip_add_data_with_key()
936 gpio_device_put(gdev); in gpiochip_add_data_with_key()
941 list_del(&gdev->list); in gpiochip_add_data_with_key()
944 kfree_const(gdev->label); in gpiochip_add_data_with_key()
946 kfree(gdev->descs); in gpiochip_add_data_with_key()
948 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
950 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
952 kfree(gdev); in gpiochip_add_data_with_key()
972 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
976 down_write(&gdev->sem); in gpiochip_remove()
979 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
982 gdev->chip = NULL; in gpiochip_remove()
995 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
1001 if (i != gdev->ngpio) in gpiochip_remove()
1002 dev_crit(&gdev->dev, in gpiochip_remove()
1011 gcdev_unregister(gdev); in gpiochip_remove()
1012 up_write(&gdev->sem); in gpiochip_remove()
1013 gpio_device_put(gdev); in gpiochip_remove()
1032 struct gpio_device *gdev; in gpiochip_find() local
1037 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
1038 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
1039 gc = gdev->chip; in gpiochip_find()
1909 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1922 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1939 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1967 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1980 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1996 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
2009 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
2011 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
2028 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2097 if (!desc->gdev) { in validate_desc()
2101 if (!desc->gdev->chip) { in validate_desc()
2102 dev_warn(&desc->gdev->dev, in validate_desc()
2127 if (try_module_get(desc->gdev->owner)) { in gpiod_request()
2130 module_put(desc->gdev->owner); in gpiod_request()
2132 gpio_device_get(desc->gdev); in gpiod_request()
2151 gc = desc->gdev->chip; in gpiod_free_commit()
2198 module_put(desc->gdev->owner); in gpiod_free()
2199 gpio_device_put(desc->gdev); in gpiod_free()
2316 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config_with_argument()
2327 struct device *dev = &desc->gdev->dev; in gpio_set_config_with_argument_optional()
2411 gc = desc->gdev->chip; in gpiod_direction_input()
2453 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2600 gc = desc->gdev->chip; in gpiod_enable_hw_timestamp_ns()
2629 gc = desc->gdev->chip; in gpiod_disable_hw_timestamp_ns()
2657 gc = desc->gdev->chip; in gpiod_set_config()
2761 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2824 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2865 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2914 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2935 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
3009 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
3034 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
3055 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
3118 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3180 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3208 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3249 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3313 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3355 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3358 gc = desc->gdev->chip; in gpiod_to_irq()
3751 blocking_notifier_call_chain(&desc->gdev->line_state_notifier, in gpiod_line_state_notify()
4537 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4539 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4541 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4571 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4577 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4580 return gdev; in gpiolib_seq_start()
4590 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4594 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4597 ret = list_first_entry(&gdev->list, struct gpio_device, list); in gpiolib_seq_next()
4612 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4613 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4618 dev_name(&gdev->dev)); in gpiolib_seq_show()
4623 dev_name(&gdev->dev), in gpiolib_seq_show()
4624 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4639 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()