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
373 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in devprop_gpiochip_set_names()
382 if (count > gdev->ngpio) { in devprop_gpiochip_set_names()
383 dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", in devprop_gpiochip_set_names()
384 count, gdev->ngpio); in devprop_gpiochip_set_names()
385 count = gdev->ngpio; in devprop_gpiochip_set_names()
395 dev_warn(&gdev->dev, "failed to read GPIO line names\n"); in devprop_gpiochip_set_names()
401 gdev->descs[i].name = names[i]; in devprop_gpiochip_set_names()
470 struct gpio_device *gdev = dev_get_drvdata(dev); in gpiodevice_release() local
474 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()
576 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
582 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
583 if (!gdev) in gpiochip_add_data_with_key()
585 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
586 gdev->chip = gc; in gpiochip_add_data_with_key()
587 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
589 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
590 gdev->dev.of_node = gc->parent->of_node; in gpiochip_add_data_with_key()
596 gdev->dev.of_node = gc->of_node; in gpiochip_add_data_with_key()
598 gc->of_node = gdev->dev.of_node; in gpiochip_add_data_with_key()
605 gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode; in gpiochip_add_data_with_key()
607 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
608 if (gdev->id < 0) { in gpiochip_add_data_with_key()
609 ret = gdev->id; in gpiochip_add_data_with_key()
613 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
617 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
618 dev_set_drvdata(&gdev->dev, gdev); in gpiochip_add_data_with_key()
620 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
623 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
625 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
627 gdev->descs = kcalloc(gc->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL); in gpiochip_add_data_with_key()
628 if (!gdev->descs) { in gpiochip_add_data_with_key()
643 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
644 if (!gdev->label) { in gpiochip_add_data_with_key()
649 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
650 gdev->data = data; in gpiochip_add_data_with_key()
676 gdev->base = base; in gpiochip_add_data_with_key()
678 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
685 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
689 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier); in gpiochip_add_data_with_key()
692 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
715 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
755 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
775 list_del(&gdev->list); in gpiochip_add_data_with_key()
778 kfree_const(gdev->label); in gpiochip_add_data_with_key()
780 kfree(gdev->descs); in gpiochip_add_data_with_key()
782 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
784 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
788 gdev->base, gdev->base + gdev->ngpio - 1, in gpiochip_add_data_with_key()
790 kfree(gdev); in gpiochip_add_data_with_key()
816 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
821 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
824 gdev->chip = NULL; in gpiochip_remove()
834 gdev->data = NULL; in gpiochip_remove()
837 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
843 if (i != gdev->ngpio) in gpiochip_remove()
844 dev_crit(&gdev->dev, in gpiochip_remove()
853 gcdev_unregister(gdev); in gpiochip_remove()
854 put_device(&gdev->dev); in gpiochip_remove()
873 struct gpio_device *gdev; in gpiochip_find() local
878 list_for_each_entry(gdev, &gpio_devices, list) in gpiochip_find()
879 if (gdev->chip && match(gdev->chip, data)) { in gpiochip_find()
880 gc = gdev->chip; in gpiochip_find()
1864 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1877 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1894 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
1922 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
1935 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
1951 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
1964 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
1966 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
1983 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2051 if (!desc->gdev) { in validate_desc()
2055 if (!desc->gdev->chip) { in validate_desc()
2056 dev_warn(&desc->gdev->dev, in validate_desc()
2078 struct gpio_device *gdev; in gpiod_request() local
2081 gdev = desc->gdev; in gpiod_request()
2083 if (try_module_get(gdev->owner)) { in gpiod_request()
2086 module_put(gdev->owner); in gpiod_request()
2088 get_device(&gdev->dev); in gpiod_request()
2109 gc = desc->gdev->chip; in gpiod_free_commit()
2139 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_free_commit()
2147 if (desc && desc->gdev && gpiod_free_commit(desc)) { in gpiod_free()
2148 module_put(desc->gdev->owner); in gpiod_free()
2149 put_device(&desc->gdev->dev); in gpiod_free()
2270 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config()
2323 gc = desc->gdev->chip; in gpiod_direction_input()
2365 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2512 gc = desc->gdev->chip; in gpiod_set_config()
2559 gc = desc->gdev->chip; in gpiod_set_transitory()
2568 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", in gpiod_set_transitory()
2629 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2693 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2727 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2772 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2793 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
2867 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
2892 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
2913 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
2976 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3031 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3057 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3098 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3162 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3204 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3207 gc = desc->gdev->chip; in gpiod_to_irq()
4017 blocking_notifier_call_chain(&desc->gdev->notifier, in gpiod_get_index()
4085 blocking_notifier_call_chain(&desc->gdev->notifier, in fwnode_get_named_gpiod()
4383 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4386 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4387 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4388 struct gpio_desc *gdesc = &gdev->descs[0]; in gpiolib_dbg_show()
4393 for (i = 0; i < gdev->ngpio; i++, gpio++, gdesc++) { in gpiolib_dbg_show()
4419 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4425 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4428 return gdev; in gpiolib_seq_start()
4438 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4442 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4445 ret = list_entry(gdev->list.next, struct gpio_device, list); in gpiolib_seq_next()
4460 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4461 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4466 dev_name(&gdev->dev)); in gpiolib_seq_show()
4471 dev_name(&gdev->dev), in gpiolib_seq_show()
4472 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4487 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()