• Home
  • Raw
  • Download

Lines Matching refs:gdev

128 	struct gpio_device *gdev;  in gpio_to_desc()  local
133 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_to_desc()
134 if (gdev->base <= gpio && in gpio_to_desc()
135 gdev->base + gdev->ngpio > gpio) { in gpio_to_desc()
137 return &gdev->descs[gpio - gdev->base]; in gpio_to_desc()
163 struct gpio_device *gdev = gc->gpiodev; in gpiochip_get_desc() local
165 if (hwnum >= gdev->ngpio) in gpiochip_get_desc()
168 return &gdev->descs[array_index_nospec(hwnum, gdev->ngpio)]; in gpiochip_get_desc()
184 return desc->gdev->base + (desc - &desc->gdev->descs[0]); in desc_to_gpio()
195 if (!desc || !desc->gdev) in gpiod_to_chip()
197 return desc->gdev->chip; in gpiod_to_chip()
204 struct gpio_device *gdev; in gpiochip_find_base() local
207 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_find_base()
209 if (gdev->base >= base + ngpio) in gpiochip_find_base()
212 base = gdev->base + gdev->ngpio; in gpiochip_find_base()
275 static int gpiodev_add_to_list(struct gpio_device *gdev) in gpiodev_add_to_list() argument
281 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
286 if (gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
288 list_add(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
293 if (prev->base + prev->ngpio <= gdev->base) { in gpiodev_add_to_list()
295 list_add_tail(&gdev->list, &gpio_devices); in gpiodev_add_to_list()
305 if (prev->base + prev->ngpio <= gdev->base in gpiodev_add_to_list()
306 && gdev->base + gdev->ngpio <= next->base) { in gpiodev_add_to_list()
307 list_add(&gdev->list, &prev->list); in gpiodev_add_to_list()
323 struct gpio_device *gdev; in gpio_name_to_desc() local
331 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_name_to_desc()
334 for_each_gpio_desc(gdev->chip, desc) { in gpio_name_to_desc()
357 struct gpio_device *gdev = gc->gpiodev; in gpiochip_set_desc_names() local
366 dev_warn(&gdev->dev, in gpiochip_set_desc_names()
373 gdev->descs[i].name = gc->names[i]; in gpiochip_set_desc_names()
389 struct gpio_device *gdev = chip->gpiodev; in gpiochip_set_names() local
390 struct device *dev = &gdev->dev; in gpiochip_set_names()
447 gdev->descs[i].name = names[chip->offset + i]; in gpiochip_set_names()
580 struct gpio_device *gdev = to_gpio_device(dev); in gpiodev_release() local
584 list_del(&gdev->list); in gpiodev_release()
587 ida_free(&gpio_ida, gdev->id); in gpiodev_release()
588 kfree_const(gdev->label); in gpiodev_release()
589 kfree(gdev->descs); in gpiodev_release()
590 kfree(gdev); in gpiodev_release()
594 #define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt)) argument
595 #define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev)) argument
601 #define gcdev_register(gdev, devt) device_add(&(gdev)->dev) argument
602 #define gcdev_unregister(gdev) device_del(&(gdev)->dev) argument
605 static int gpiochip_setup_dev(struct gpio_device *gdev) in gpiochip_setup_dev() argument
607 struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); in gpiochip_setup_dev()
617 ret = gcdev_register(gdev, gpio_devt); in gpiochip_setup_dev()
622 gdev->dev.release = gpiodev_release; in gpiochip_setup_dev()
624 ret = gpiochip_sysfs_register(gdev); in gpiochip_setup_dev()
628 dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, in gpiochip_setup_dev()
629 gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); in gpiochip_setup_dev()
634 gcdev_unregister(gdev); in gpiochip_setup_dev()
675 struct gpio_device *gdev; in gpiochip_setup_devs() local
678 list_for_each_entry(gdev, &gpio_devices, list) { in gpiochip_setup_devs()
679 ret = gpiochip_setup_dev(gdev); in gpiochip_setup_devs()
681 dev_err(&gdev->dev, in gpiochip_setup_devs()
742 struct gpio_device *gdev; in gpiochip_add_data_with_key() local
752 gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); in gpiochip_add_data_with_key()
753 if (!gdev) in gpiochip_add_data_with_key()
755 gdev->dev.bus = &gpio_bus_type; in gpiochip_add_data_with_key()
756 gdev->dev.parent = gc->parent; in gpiochip_add_data_with_key()
757 gdev->chip = gc; in gpiochip_add_data_with_key()
759 gc->gpiodev = gdev; in gpiochip_add_data_with_key()
767 device_set_node(&gdev->dev, gc->fwnode); in gpiochip_add_data_with_key()
769 device_set_node(&gdev->dev, dev_fwnode(gc->parent)); in gpiochip_add_data_with_key()
771 gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); in gpiochip_add_data_with_key()
772 if (gdev->id < 0) { in gpiochip_add_data_with_key()
773 ret = gdev->id; in gpiochip_add_data_with_key()
777 ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); in gpiochip_add_data_with_key()
781 device_initialize(&gdev->dev); in gpiochip_add_data_with_key()
783 gdev->owner = gc->parent->driver->owner; in gpiochip_add_data_with_key()
786 gdev->owner = gc->owner; in gpiochip_add_data_with_key()
788 gdev->owner = THIS_MODULE; in gpiochip_add_data_with_key()
790 ret = gpiochip_get_ngpios(gc, &gdev->dev); in gpiochip_add_data_with_key()
794 gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); in gpiochip_add_data_with_key()
795 if (!gdev->descs) { in gpiochip_add_data_with_key()
800 gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); in gpiochip_add_data_with_key()
801 if (!gdev->label) { in gpiochip_add_data_with_key()
806 gdev->ngpio = gc->ngpio; in gpiochip_add_data_with_key()
834 dev_warn(&gdev->dev, in gpiochip_add_data_with_key()
837 gdev->base = base; in gpiochip_add_data_with_key()
839 ret = gpiodev_add_to_list(gdev); in gpiochip_add_data_with_key()
847 gdev->descs[i].gdev = gdev; in gpiochip_add_data_with_key()
851 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier); in gpiochip_add_data_with_key()
852 BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier); in gpiochip_add_data_with_key()
853 init_rwsem(&gdev->sem); in gpiochip_add_data_with_key()
856 INIT_LIST_HEAD(&gdev->pin_ranges); in gpiochip_add_data_with_key()
877 struct gpio_desc *desc = &gdev->descs[i]; in gpiochip_add_data_with_key()
917 ret = gpiochip_setup_dev(gdev); in gpiochip_add_data_with_key()
935 if (gdev->dev.release) { in gpiochip_add_data_with_key()
937 gpio_device_put(gdev); in gpiochip_add_data_with_key()
942 list_del(&gdev->list); in gpiochip_add_data_with_key()
945 kfree_const(gdev->label); in gpiochip_add_data_with_key()
947 kfree(gdev->descs); in gpiochip_add_data_with_key()
949 kfree(dev_name(&gdev->dev)); in gpiochip_add_data_with_key()
951 ida_free(&gpio_ida, gdev->id); in gpiochip_add_data_with_key()
953 kfree(gdev); in gpiochip_add_data_with_key()
973 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove() local
977 down_write(&gdev->sem); in gpiochip_remove()
980 gpiochip_sysfs_unregister(gdev); in gpiochip_remove()
983 gdev->chip = NULL; in gpiochip_remove()
996 for (i = 0; i < gdev->ngpio; i++) { in gpiochip_remove()
1002 if (i != gdev->ngpio) in gpiochip_remove()
1003 dev_crit(&gdev->dev, in gpiochip_remove()
1012 gcdev_unregister(gdev); in gpiochip_remove()
1013 up_write(&gdev->sem); in gpiochip_remove()
1014 gpio_device_put(gdev); in gpiochip_remove()
1027 struct gpio_device *gdev; in gpiochip_find() local
1030 gdev = gpio_device_find(data, match); in gpiochip_find()
1031 if (gdev) { in gpiochip_find()
1032 gc = gdev->chip; in gpiochip_find()
1033 gpio_device_put(gdev); in gpiochip_find()
1065 struct gpio_device *gdev; in gpio_device_find() local
1076 list_for_each_entry(gdev, &gpio_devices, list) { in gpio_device_find()
1077 if (gdev->chip && match(gdev->chip, data)) in gpio_device_find()
1078 return gpio_device_get(gdev); in gpio_device_find()
1104 struct gpio_device *gpio_device_get(struct gpio_device *gdev) in gpio_device_get() argument
1106 return to_gpio_device(get_device(&gdev->dev)); in gpio_device_get()
1115 void gpio_device_put(struct gpio_device *gdev) in gpio_device_put() argument
1117 put_device(&gdev->dev); in gpio_device_put()
1969 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pingroup_range() local
1982 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pingroup_range()
1999 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pingroup_range()
2027 struct gpio_device *gdev = gc->gpiodev; in gpiochip_add_pin_range() local
2040 pin_range->range.base = gdev->base + gpio_offset; in gpiochip_add_pin_range()
2056 list_add_tail(&pin_range->node, &gdev->pin_ranges); in gpiochip_add_pin_range()
2069 struct gpio_device *gdev = gc->gpiodev; in gpiochip_remove_pin_ranges() local
2071 list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { in gpiochip_remove_pin_ranges()
2088 struct gpio_chip *gc = desc->gdev->chip; in gpiod_request_commit()
2157 if (!desc->gdev) { in validate_desc()
2161 if (!desc->gdev->chip) { in validate_desc()
2162 dev_warn(&desc->gdev->dev, in validate_desc()
2187 if (try_module_get(desc->gdev->owner)) { in gpiod_request()
2190 module_put(desc->gdev->owner); in gpiod_request()
2192 gpio_device_get(desc->gdev); in gpiod_request()
2211 gc = desc->gdev->chip; in gpiod_free_commit()
2258 module_put(desc->gdev->owner); in gpiod_free()
2259 gpio_device_put(desc->gdev); in gpiod_free()
2376 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_config_with_argument()
2387 struct device *dev = &desc->gdev->dev; in gpio_set_config_with_argument_optional()
2471 gc = desc->gdev->chip; in gpiod_direction_input()
2513 struct gpio_chip *gc = desc->gdev->chip; in gpiod_direction_output_raw_commit()
2660 gc = desc->gdev->chip; in gpiod_enable_hw_timestamp_ns()
2689 gc = desc->gdev->chip; in gpiod_disable_hw_timestamp_ns()
2717 gc = desc->gdev->chip; in gpiod_set_config()
2821 gc = desc->gdev->chip; in gpiod_get_raw_value_commit()
2884 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_get_array_value_complex()
2925 (desc_array[i]->gdev->chip == gc)); in gpiod_get_array_value_complex()
2974 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_raw_value()
2995 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_get_value()
3069 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_drain_value_commit()
3094 struct gpio_chip *gc = desc->gdev->chip; in gpio_set_open_source_value_commit()
3115 gc = desc->gdev->chip; in gpiod_set_raw_value_commit()
3178 struct gpio_chip *gc = desc_array[i]->gdev->chip; in gpiod_set_array_value_complex()
3240 (desc_array[i]->gdev->chip == gc)); in gpiod_set_array_value_complex()
3268 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_raw_value()
3309 WARN_ON(desc->gdev->chip->can_sleep); in gpiod_set_value()
3373 return desc->gdev->chip->can_sleep; in gpiod_cansleep()
3415 if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) in gpiod_to_irq()
3418 gc = desc->gdev->chip; in gpiod_to_irq()
3811 blocking_notifier_call_chain(&desc->gdev->line_state_notifier, in gpiod_line_state_notify()
4597 static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) in gpiolib_dbg_show() argument
4599 struct gpio_chip *gc = gdev->chip; in gpiolib_dbg_show()
4601 unsigned gpio = gdev->base; in gpiolib_dbg_show()
4631 struct gpio_device *gdev = NULL; in gpiolib_seq_start() local
4637 list_for_each_entry(gdev, &gpio_devices, list) in gpiolib_seq_start()
4640 return gdev; in gpiolib_seq_start()
4650 struct gpio_device *gdev = v; in gpiolib_seq_next() local
4654 if (list_is_last(&gdev->list, &gpio_devices)) in gpiolib_seq_next()
4657 ret = list_first_entry(&gdev->list, struct gpio_device, list); in gpiolib_seq_next()
4672 struct gpio_device *gdev = v; in gpiolib_seq_show() local
4673 struct gpio_chip *gc = gdev->chip; in gpiolib_seq_show()
4678 dev_name(&gdev->dev)); in gpiolib_seq_show()
4683 dev_name(&gdev->dev), in gpiolib_seq_show()
4684 gdev->base, gdev->base + gdev->ngpio - 1); in gpiolib_seq_show()
4699 gpiolib_dbg_show(s, gdev); in gpiolib_seq_show()