Lines Matching refs:desc_data

731 	struct gpiod_data *desc_data;  in gpiod_export()  local
764 desc_data = kzalloc(sizeof(*desc_data), GFP_KERNEL); in gpiod_export()
765 if (!desc_data) { in gpiod_export()
770 desc_data->desc = desc; in gpiod_export()
771 mutex_init(&desc_data->mutex); in gpiod_export()
773 desc_data->direction_can_change = direction_may_change; in gpiod_export()
775 desc_data->direction_can_change = false; in gpiod_export()
777 gpiod_attr_init(&desc_data->dir_attr, "direction", in gpiod_export()
779 gpiod_attr_init(&desc_data->val_attr, "value", value_show, value_store); in gpiod_export()
782 gpiod_attr_init(&desc_data->edge_attr, "edge", edge_show, edge_store); in gpiod_export()
783 gpiod_attr_init(&desc_data->active_low_attr, "active_low", in gpiod_export()
786 attrs = desc_data->class_attrs; in gpiod_export()
787 desc_data->class_attr_group.is_visible = gpio_is_visible; in gpiod_export()
788 attrs[GPIO_SYSFS_LINE_CLASS_ATTR_DIRECTION] = &desc_data->dir_attr.attr; in gpiod_export()
789 attrs[GPIO_SYSFS_LINE_CLASS_ATTR_VALUE] = &desc_data->val_attr.attr; in gpiod_export()
790 attrs[GPIO_SYSFS_LINE_CLASS_ATTR_EDGE] = &desc_data->edge_attr.attr; in gpiod_export()
791 attrs[GPIO_SYSFS_LINE_CLASS_ATTR_ACTIVE_LOW] = &desc_data->active_low_attr.attr; in gpiod_export()
793 desc_data->class_attr_group.attrs = desc_data->class_attrs; in gpiod_export()
794 desc_data->class_attr_groups[0] = &desc_data->class_attr_group; in gpiod_export()
801 desc_data->dev = device_create_with_groups(&gpio_class, &gdev->dev, in gpiod_export()
802 MKDEV(0, 0), desc_data, in gpiod_export()
803 desc_data->class_attr_groups, in gpiod_export()
806 if (IS_ERR(desc_data->dev)) { in gpiod_export()
807 status = PTR_ERR(desc_data->dev); in gpiod_export()
811 desc_data->value_kn = sysfs_get_dirent(desc_data->dev->kobj.sd, in gpiod_export()
813 if (!desc_data->value_kn) { in gpiod_export()
825 desc_data->chip_attr_group.name = kasprintf(GFP_KERNEL, "gpio%u", in gpiod_export()
827 if (!desc_data->chip_attr_group.name) { in gpiod_export()
832 attrs = desc_data->chip_attrs; in gpiod_export()
833 desc_data->chip_attr_group.is_visible = gpio_is_visible; in gpiod_export()
834 attrs[GPIO_SYSFS_LINE_CHIP_ATTR_DIRECTION] = &desc_data->dir_attr.attr; in gpiod_export()
835 attrs[GPIO_SYSFS_LINE_CHIP_ATTR_VALUE] = &desc_data->val_attr.attr; in gpiod_export()
837 desc_data->chip_attr_group.attrs = attrs; in gpiod_export()
838 desc_data->chip_attr_groups[0] = &desc_data->chip_attr_group; in gpiod_export()
840 desc_data->parent = &gdev_data->cdev_id->kobj; in gpiod_export()
841 status = sysfs_create_groups(desc_data->parent, in gpiod_export()
842 desc_data->chip_attr_groups); in gpiod_export()
852 list_add(&desc_data->list, &gdev_data->exported_lines); in gpiod_export()
857 sysfs_remove_groups(desc_data->parent, desc_data->chip_attr_groups); in gpiod_export()
859 kfree(desc_data->chip_attr_group.name); in gpiod_export()
862 sysfs_put(desc_data->value_kn); in gpiod_export()
864 device_unregister(desc_data->dev); in gpiod_export()
867 kfree(desc_data); in gpiod_export()
930 struct gpiod_data *tmp, *desc_data = NULL; in gpiod_unexport() local
950 desc_data = tmp; in gpiod_unexport()
955 if (!desc_data) in gpiod_unexport()
958 list_del(&desc_data->list); in gpiod_unexport()
961 sysfs_put(desc_data->value_kn); in gpiod_unexport()
962 device_unregister(desc_data->dev); in gpiod_unexport()
968 if (desc_data->irq_flags) in gpiod_unexport()
969 gpio_sysfs_free_irq(desc_data); in gpiod_unexport()
972 sysfs_remove_groups(desc_data->parent, in gpiod_unexport()
973 desc_data->chip_attr_groups); in gpiod_unexport()
976 mutex_destroy(&desc_data->mutex); in gpiod_unexport()
977 kfree(desc_data); in gpiod_unexport()