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()
194 base = gdev->base - ngpio; in gpiochip_find_base()
255 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
261 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
266 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
268 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
273 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
275 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
285 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
286 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
287 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
292 dev_err(&gdev->dev, "GPIO integer space overlap, cannot add chip\n"); in gpiodev_add_to_list()
304 struct gpio_device *gdev; in gpio_name_to_desc() local
312 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
315 for (i = 0; i != gdev->ngpio; ++i) { in gpio_name_to_desc()
316 struct gpio_desc *desc = &gdev->descs[i]; in gpio_name_to_desc()
343 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
352 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
359 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
375 struct gpio_device *gdev = chip->gpiodev; in devprop_gpiochip_set_names() local
376 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in devprop_gpiochip_set_names()
394 …dev_warn(&gdev->dev, "gpio-line-names too short (length %d), cannot map names for the gpiochip at … in devprop_gpiochip_set_names()
406 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()
495 struct gpio_device *gdev = container_of(dev, struct gpio_device, dev); in gpiodevice_release() local
499 list_del(&gdev->list); in gpiodevice_release()
502 ida_free(&gpio_ida, gdev->id); in gpiodevice_release()
503 kfree_const(gdev->label); in gpiodevice_release()
504 kfree(gdev->descs); in gpiodevice_release()
505 kfree(gdev); in gpiodevice_release()
509 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
510 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
516 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
517 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
520 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
524 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
528 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
533 gdev->dev.release = gpiodevice_release; in gpiochip_setup_dev()
534 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
535 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
540 gcdev_unregister(gdev); in gpiochip_setup_dev()
581 struct gpio_device *gdev; in gpiochip_setup_devs() local
584 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
585 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
587 dev_err(&gdev->dev, in gpiochip_setup_devs()
601 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
607 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
608 if (!gdev) in gpiochip_add_data_with_key()
610 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
611 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
612 gdev->chip = gc; in gpiochip_add_data_with_key()
613 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
615 of_gpio_dev_init(gc, gdev); in gpiochip_add_data_with_key()
616 acpi_gpio_dev_init(gc, gdev); in gpiochip_add_data_with_key()
622 gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; in gpiochip_add_data_with_key()
624 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
625 if (gdev->id < 0) { in gpiochip_add_data_with_key()
626 ret = gdev->id; in gpiochip_add_data_with_key()
630 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
634 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
636 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
639 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
641 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
643 gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL); in gpiochip_add_data_with_key()
644 if (!gdev->descs) { in gpiochip_add_data_with_key()
659 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
660 if (!gdev->label) { in gpiochip_add_data_with_key()
665 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
666 gdev->data = data; in gpiochip_add_data_with_key()
692 gdev->base = base; in gpiochip_add_data_with_key()
694 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
701 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
705 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier); in gpiochip_add_data_with_key()
708 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
731 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
771 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
791 list_del(&gdev->list); in gpiochip_add_data_with_key()
794 kfree_const(gdev->label); in gpiochip_add_data_with_key()
796 kfree(gdev->descs); in gpiochip_add_data_with_key()
798 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
800 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
805 gdev->base, gdev->base + gdev->ngpio - 1, in gpiochip_add_data_with_key()
808 kfree(gdev); in gpiochip_add_data_with_key()
834 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
839 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
842 gdev->chip = NULL; in gpiochip_remove()
852 gdev->data = NULL; in gpiochip_remove()
855 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
861 if (i != gdev->ngpio) in gpiochip_remove()
862 dev_crit(&gdev->dev, in gpiochip_remove()
871 gcdev_unregister(gdev); in gpiochip_remove()
872 put_device(&gdev->dev); in gpiochip_remove()
891 struct gpio_device *gdev; in gpiochip_find() local
896 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
897 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
898 gc = gdev->chip; in gpiochip_find()
1720 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1733 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1750 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1778 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1791 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1807 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
1820 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
1822 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
1839 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
1908 if (!desc->gdev) { in validate_desc()
1912 if (!desc->gdev->chip) { in validate_desc()
1913 dev_warn(&desc->gdev->dev, in validate_desc()
1935 struct gpio_device *gdev; in gpiod_request() local
1938 gdev = desc->gdev; in gpiod_request()
1940 if (try_module_get(gdev->owner)) { in gpiod_request()
1943 module_put(gdev->owner); in gpiod_request()
1945 get_device(&gdev->dev); in gpiod_request()
1966 gc = desc->gdev->chip; in gpiod_free_commit()
1996 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_free_commit()
2004 if (desc && desc->gdev && gpiod_free_commit(desc)) { in gpiod_free()
2005 module_put(desc->gdev->owner); in gpiod_free()
2006 put_device(&desc->gdev->dev); in gpiod_free()
2126 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config_with_argument()
2137 struct device *dev = &desc->gdev->dev; in gpio_set_config_with_argument_optional()
2211 gc = desc->gdev->chip; in gpiod_direction_input()
2253 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2400 gc = desc->gdev->chip; in gpiod_set_config()
2500 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2564 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2605 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2654 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2675 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2749 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
2774 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
2795 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
2858 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
2920 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
2948 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
2989 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3053 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3095 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3098 gc = desc->gdev->chip; in gpiod_to_irq()
3912 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_get_index()
3978 blocking_notifier_call_chain(&desc->gdev->notifier, in fwnode_get_named_gpiod()
4319 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4322 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4323 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4324 struct gpio_desc *gdesc = &gdev->descs[0]; in gpiolib_dbg_show()
4329 for (i = 0; i < gdev->ngpio; i++, gpio++, gdesc++) { in gpiolib_dbg_show()
4355 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4361 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4364 return gdev; in gpiolib_seq_start()
4374 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4378 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4381 ret = list_entry(gdev->list.next, struct gpio_device, list); in gpiolib_seq_next()
4396 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4397 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4402 dev_name(&gdev->dev)); in gpiolib_seq_show()
4407 dev_name(&gdev->dev), in gpiolib_seq_show()
4408 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4423 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()