Lines Matching refs:gdev
109 struct gpio_device *gdev; in gpio_to_desc() local
114 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_to_desc()
115 if (gdev->base <= gpio && in gpio_to_desc()
116 gdev->base + gdev->ngpio > gpio) { in gpio_to_desc()
118 return &gdev->descs[gpio - gdev->base]; in gpio_to_desc()
144 struct gpio_device *gdev = gc->gpiodev; in gpiochip_get_desc() local
146 if (hwnum >= gdev->ngpio) in gpiochip_get_desc()
149 return &gdev->descs[hwnum]; in gpiochip_get_desc()
165 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
176 if (!desc || !desc->gdev) in gpiod_to_chip()
178 return desc->gdev->chip; in gpiod_to_chip()
185 struct gpio_device *gdev; in gpiochip_find_base() local
188 list_for_each_entry_reverse(gdev, &gpio_devices, list) { in gpiochip_find_base()
190 if (gdev->base + gdev->ngpio <= base) in gpiochip_find_base()
193 base = gdev->base - ngpio; in gpiochip_find_base()
254 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
260 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
265 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
267 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
272 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
274 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
284 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
285 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
286 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
302 struct gpio_device *gdev; in gpio_name_to_desc() local
310 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
313 for_each_gpio_desc(gdev->chip, desc) { in gpio_name_to_desc()
336 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
345 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
352 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
368 struct gpio_device *gdev = chip->gpiodev; in devprop_gpiochip_set_names() local
369 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in devprop_gpiochip_set_names()
387 …dev_warn(&gdev->dev, "gpio-line-names too short (length %d), cannot map names for the gpiochip at … in devprop_gpiochip_set_names()
399 dev_warn(&gdev->dev, "failed to read GPIO line names\n"); in devprop_gpiochip_set_names()
426 gdev->descs[i].name = names[chip->offset + i]; in devprop_gpiochip_set_names()
496 struct gpio_device *gdev = container_of(dev, struct gpio_device, dev); in gpiodevice_release() local
500 list_del(&gdev->list); in gpiodevice_release()
503 ida_free(&gpio_ida, gdev->id); in gpiodevice_release()
504 kfree_const(gdev->label); in gpiodevice_release()
505 kfree(gdev->descs); in gpiodevice_release()
506 kfree(gdev); in gpiodevice_release()
510 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
511 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
517 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
518 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
521 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
525 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
530 gdev->dev.release = gpiodevice_release; in gpiochip_setup_dev()
532 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
536 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
537 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
542 gcdev_unregister(gdev); in gpiochip_setup_dev()
583 struct gpio_device *gdev; in gpiochip_setup_devs() local
586 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
587 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
589 dev_err(&gdev->dev, in gpiochip_setup_devs()
599 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
615 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
616 if (!gdev) in gpiochip_add_data_with_key()
618 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
619 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
620 gdev->chip = gc; in gpiochip_add_data_with_key()
621 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
623 of_gpio_dev_init(gc, gdev); in gpiochip_add_data_with_key()
624 acpi_gpio_dev_init(gc, gdev); in gpiochip_add_data_with_key()
630 gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; in gpiochip_add_data_with_key()
632 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
633 if (gdev->id < 0) { in gpiochip_add_data_with_key()
634 ret = gdev->id; in gpiochip_add_data_with_key()
638 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
642 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
644 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
647 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
649 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
657 ret = device_property_read_u32(&gdev->dev, "ngpios", &ngpios); in gpiochip_add_data_with_key()
682 gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); in gpiochip_add_data_with_key()
683 if (!gdev->descs) { in gpiochip_add_data_with_key()
688 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
689 if (!gdev->label) { in gpiochip_add_data_with_key()
694 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
695 gdev->data = data; in gpiochip_add_data_with_key()
723 gdev->base = base; in gpiochip_add_data_with_key()
725 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
733 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
737 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier); in gpiochip_add_data_with_key()
740 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
765 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
805 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
823 if (gdev->dev.release) { in gpiochip_add_data_with_key()
825 put_device(&gdev->dev); in gpiochip_add_data_with_key()
830 list_del(&gdev->list); in gpiochip_add_data_with_key()
833 kfree_const(gdev->label); in gpiochip_add_data_with_key()
835 kfree(gdev->descs); in gpiochip_add_data_with_key()
837 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
839 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
841 kfree(gdev); in gpiochip_add_data_with_key()
874 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
879 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
882 gdev->chip = NULL; in gpiochip_remove()
892 gdev->data = NULL; in gpiochip_remove()
895 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
901 if (i != gdev->ngpio) in gpiochip_remove()
902 dev_crit(&gdev->dev, in gpiochip_remove()
911 gcdev_unregister(gdev); in gpiochip_remove()
912 put_device(&gdev->dev); in gpiochip_remove()
931 struct gpio_device *gdev; in gpiochip_find() local
936 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
937 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
938 gc = gdev->chip; in gpiochip_find()
1788 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1801 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1818 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1846 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1859 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1875 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
1888 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
1890 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
1907 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
1976 if (!desc->gdev) { in validate_desc()
1980 if (!desc->gdev->chip) { in validate_desc()
1981 dev_warn(&desc->gdev->dev, in validate_desc()
2003 struct gpio_device *gdev; in gpiod_request() local
2006 gdev = desc->gdev; in gpiod_request()
2008 if (try_module_get(gdev->owner)) { in gpiod_request()
2011 module_put(gdev->owner); in gpiod_request()
2013 get_device(&gdev->dev); in gpiod_request()
2034 gc = desc->gdev->chip; in gpiod_free_commit()
2064 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_free_commit()
2072 if (desc && desc->gdev && gpiod_free_commit(desc)) { in gpiod_free()
2073 module_put(desc->gdev->owner); in gpiod_free()
2074 put_device(&desc->gdev->dev); in gpiod_free()
2194 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config_with_argument()
2205 struct device *dev = &desc->gdev->dev; in gpio_set_config_with_argument_optional()
2289 gc = desc->gdev->chip; in gpiod_direction_input()
2331 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2478 gc = desc->gdev->chip; in gpiod_enable_hw_timestamp_ns()
2507 gc = desc->gdev->chip; in gpiod_disable_hw_timestamp_ns()
2535 gc = desc->gdev->chip; in gpiod_set_config()
2639 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2702 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2743 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2792 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2813 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2887 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
2912 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
2933 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
2996 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3058 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3086 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3127 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3191 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3233 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3236 gc = desc->gdev->chip; in gpiod_to_irq()
3871 blocking_notifier_call_chain(&desc->gdev->notifier, in fwnode_get_named_gpiod()
4135 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_get_index()
4474 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4476 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4478 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4508 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4514 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4517 return gdev; in gpiolib_seq_start()
4527 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4531 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4534 ret = list_first_entry(&gdev->list, struct gpio_device, list); in gpiolib_seq_next()
4549 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4550 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4555 dev_name(&gdev->dev)); in gpiolib_seq_show()
4560 dev_name(&gdev->dev), in gpiolib_seq_show()
4561 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4576 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()