Lines Matching refs:gdev
106 struct gpio_device *gdev; in gpio_to_desc() local
111 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_to_desc()
112 if (gdev->base <= gpio && in gpio_to_desc()
113 gdev->base + gdev->ngpio > gpio) { in gpio_to_desc()
115 return &gdev->descs[gpio - gdev->base]; in gpio_to_desc()
141 struct gpio_device *gdev = gc->gpiodev; in gpiochip_get_desc() local
143 if (hwnum >= gdev->ngpio) in gpiochip_get_desc()
146 return &gdev->descs[hwnum]; in gpiochip_get_desc()
162 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
173 if (!desc || !desc->gdev) in gpiod_to_chip()
175 return desc->gdev->chip; in gpiod_to_chip()
182 struct gpio_device *gdev; in gpiochip_find_base() local
185 list_for_each_entry_reverse(gdev, &gpio_devices, list) { in gpiochip_find_base()
187 if (gdev->base + gdev->ngpio <= base) in gpiochip_find_base()
191 base = gdev->base - ngpio; in gpiochip_find_base()
252 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
258 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
263 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
265 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
270 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
272 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
282 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
283 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
284 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
289 dev_err(&gdev->dev, "GPIO integer space overlap, cannot add chip\n"); in gpiodev_add_to_list()
301 struct gpio_device *gdev; in gpio_name_to_desc() local
309 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
312 for (i = 0; i != gdev->ngpio; ++i) { in gpio_name_to_desc()
313 struct gpio_desc *desc = &gdev->descs[i]; in gpio_name_to_desc()
340 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
349 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
356 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
372 struct gpio_device *gdev = chip->gpiodev; in devprop_gpiochip_set_names() local
386 if (count > gdev->ngpio) { in devprop_gpiochip_set_names()
387 dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", in devprop_gpiochip_set_names()
388 count, gdev->ngpio); in devprop_gpiochip_set_names()
389 count = gdev->ngpio; in devprop_gpiochip_set_names()
399 dev_warn(&gdev->dev, "failed to read GPIO line names\n"); in devprop_gpiochip_set_names()
405 gdev->descs[i].name = names[i]; in devprop_gpiochip_set_names()
474 struct gpio_device *gdev = dev_get_drvdata(dev); in gpiodevice_release() local
476 list_del(&gdev->list); in gpiodevice_release()
477 ida_free(&gpio_ida, gdev->id); in gpiodevice_release()
478 kfree_const(gdev->label); in gpiodevice_release()
479 kfree(gdev->descs); in gpiodevice_release()
480 kfree(gdev); in gpiodevice_release()
484 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
485 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
491 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
492 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
495 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
499 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
503 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
508 gdev->dev.release = gpiodevice_release; in gpiochip_setup_dev()
509 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
510 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
515 gcdev_unregister(gdev); in gpiochip_setup_dev()
556 struct gpio_device *gdev; in gpiochip_setup_devs() local
559 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
560 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
562 dev_err(&gdev->dev, in gpiochip_setup_devs()
575 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
581 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
582 if (!gdev) in gpiochip_add_data_with_key()
584 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
585 gdev->chip = gc; in gpiochip_add_data_with_key()
586 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
588 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
589 gdev->dev.of_node = gc->parent->of_node; in gpiochip_add_data_with_key()
595 gdev->dev.of_node = gc->of_node; in gpiochip_add_data_with_key()
597 gc->of_node = gdev->dev.of_node; in gpiochip_add_data_with_key()
600 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
601 if (gdev->id < 0) { in gpiochip_add_data_with_key()
602 ret = gdev->id; in gpiochip_add_data_with_key()
605 dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
606 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
607 dev_set_drvdata(&gdev->dev, gdev); in gpiochip_add_data_with_key()
609 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
612 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
614 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
616 gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL); in gpiochip_add_data_with_key()
617 if (!gdev->descs) { in gpiochip_add_data_with_key()
632 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
633 if (!gdev->label) { in gpiochip_add_data_with_key()
638 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
639 gdev->data = data; in gpiochip_add_data_with_key()
665 gdev->base = base; in gpiochip_add_data_with_key()
667 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
674 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
678 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier); in gpiochip_add_data_with_key()
681 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
704 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
744 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
764 list_del(&gdev->list); in gpiochip_add_data_with_key()
767 kfree_const(gdev->label); in gpiochip_add_data_with_key()
769 kfree(gdev->descs); in gpiochip_add_data_with_key()
771 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
775 gdev->base, gdev->base + gdev->ngpio - 1, in gpiochip_add_data_with_key()
777 kfree(gdev); in gpiochip_add_data_with_key()
803 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
808 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
811 gdev->chip = NULL; in gpiochip_remove()
821 gdev->data = NULL; in gpiochip_remove()
824 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
830 if (i != gdev->ngpio) in gpiochip_remove()
831 dev_crit(&gdev->dev, in gpiochip_remove()
840 gcdev_unregister(gdev); in gpiochip_remove()
841 put_device(&gdev->dev); in gpiochip_remove()
860 struct gpio_device *gdev; in gpiochip_find() local
865 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
866 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
867 gc = gdev->chip; in gpiochip_find()
1850 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1863 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1880 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1908 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1921 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1937 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
1950 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
1952 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
1969 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2037 if (!desc->gdev) { in validate_desc()
2041 if (!desc->gdev->chip) { in validate_desc()
2042 dev_warn(&desc->gdev->dev, in validate_desc()
2064 struct gpio_device *gdev; in gpiod_request() local
2067 gdev = desc->gdev; in gpiod_request()
2069 if (try_module_get(gdev->owner)) { in gpiod_request()
2072 module_put(gdev->owner); in gpiod_request()
2074 get_device(&gdev->dev); in gpiod_request()
2095 gc = desc->gdev->chip; in gpiod_free_commit()
2125 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_free_commit()
2133 if (desc && desc->gdev && gpiod_free_commit(desc)) { in gpiod_free()
2134 module_put(desc->gdev->owner); in gpiod_free()
2135 put_device(&desc->gdev->dev); in gpiod_free()
2256 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config()
2309 gc = desc->gdev->chip; in gpiod_direction_input()
2351 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2498 gc = desc->gdev->chip; in gpiod_set_config()
2545 gc = desc->gdev->chip; in gpiod_set_transitory()
2554 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", in gpiod_set_transitory()
2615 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2679 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2713 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2758 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2779 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2853 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
2878 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
2899 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
2962 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3017 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3043 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3084 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3148 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3190 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3193 gc = desc->gdev->chip; in gpiod_to_irq()
4003 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_get_index()
4071 blocking_notifier_call_chain(&desc->gdev->notifier, in fwnode_get_named_gpiod()
4369 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4372 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4373 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4374 struct gpio_desc *gdesc = &gdev->descs[0]; in gpiolib_dbg_show()
4379 for (i = 0; i < gdev->ngpio; i++, gpio++, gdesc++) { in gpiolib_dbg_show()
4405 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4411 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4414 return gdev; in gpiolib_seq_start()
4424 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4428 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4431 ret = list_entry(gdev->list.next, struct gpio_device, list); in gpiolib_seq_next()
4446 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4447 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4452 dev_name(&gdev->dev)); in gpiolib_seq_show()
4457 dev_name(&gdev->dev), in gpiolib_seq_show()
4458 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4473 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()