diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-05-18 09:42:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 19:15:04 -0400 |
commit | c74b0de1666f8b8f6c65e1e944deff71fed0769a (patch) | |
tree | d660d62478d8c6e567851fe7342b54ffcb155706 /drivers/staging | |
parent | 21b185f8d5951ebbf76d61f431fb541dce5113d1 (diff) |
staging:iio:core cleanup: squash tiny wrappers and use dev_set_name to handle creation of event interface name.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/iio/chrdev.h | 3 | ||||
-rw-r--r-- | drivers/staging/iio/industrialio-core.c | 54 |
2 files changed, 18 insertions, 39 deletions
diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h index 6523273d563..3e31ee6220e 100644 --- a/drivers/staging/iio/chrdev.h +++ b/drivers/staging/iio/chrdev.h | |||
@@ -60,8 +60,6 @@ struct iio_detected_event_list { | |||
60 | * @det_events: list of detected events | 60 | * @det_events: list of detected events |
61 | * @max_events: maximum number of events before new ones are dropped | 61 | * @max_events: maximum number of events before new ones are dropped |
62 | * @current_events: number of events in detected list | 62 | * @current_events: number of events in detected list |
63 | * @_name: used internally to store the sysfs name for minor id | ||
64 | * attribute | ||
65 | */ | 63 | */ |
66 | struct iio_event_interface { | 64 | struct iio_event_interface { |
67 | struct device dev; | 65 | struct device dev; |
@@ -71,7 +69,6 @@ struct iio_event_interface { | |||
71 | struct list_head det_events; | 69 | struct list_head det_events; |
72 | int max_events; | 70 | int max_events; |
73 | int current_events; | 71 | int current_events; |
74 | char _name[35]; | ||
75 | struct list_head dev_attr_list; | 72 | struct list_head dev_attr_list; |
76 | }; | 73 | }; |
77 | 74 | ||
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index b5b658c9b8e..9218fee8c26 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/poll.h> | 19 | #include <linux/poll.h> |
21 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
22 | #include <linux/wait.h> | 21 | #include <linux/wait.h> |
@@ -270,9 +269,10 @@ void iio_device_free_chrdev_minor(int val) | |||
270 | } | 269 | } |
271 | 270 | ||
272 | static int iio_setup_ev_int(struct iio_event_interface *ev_int, | 271 | static int iio_setup_ev_int(struct iio_event_interface *ev_int, |
273 | const char *name, | 272 | const char *dev_name, |
274 | struct module *owner, | 273 | int index, |
275 | struct device *dev) | 274 | struct module *owner, |
275 | struct device *dev) | ||
276 | { | 276 | { |
277 | int ret, minor; | 277 | int ret, minor; |
278 | 278 | ||
@@ -287,7 +287,7 @@ static int iio_setup_ev_int(struct iio_event_interface *ev_int, | |||
287 | goto error_device_put; | 287 | goto error_device_put; |
288 | } | 288 | } |
289 | ev_int->dev.devt = MKDEV(MAJOR(iio_devt), minor); | 289 | ev_int->dev.devt = MKDEV(MAJOR(iio_devt), minor); |
290 | dev_set_name(&ev_int->dev, "%s", name); | 290 | dev_set_name(&ev_int->dev, "%s:event%d", dev_name, index); |
291 | 291 | ||
292 | ret = device_add(&ev_int->dev); | 292 | ret = device_add(&ev_int->dev); |
293 | if (ret) | 293 | if (ret) |
@@ -798,20 +798,6 @@ void iio_free_ida_val(struct ida *this_ida, int id) | |||
798 | } | 798 | } |
799 | EXPORT_SYMBOL(iio_free_ida_val); | 799 | EXPORT_SYMBOL(iio_free_ida_val); |
800 | 800 | ||
801 | static int iio_device_register_id(struct iio_dev *dev_info, | ||
802 | struct ida *this_ida) | ||
803 | { | ||
804 | dev_info->id = iio_get_new_ida_val(&iio_ida); | ||
805 | if (dev_info->id < 0) | ||
806 | return dev_info->id; | ||
807 | return 0; | ||
808 | } | ||
809 | |||
810 | static void iio_device_unregister_id(struct iio_dev *dev_info) | ||
811 | { | ||
812 | iio_free_ida_val(&iio_ida, dev_info->id); | ||
813 | } | ||
814 | |||
815 | static const char * const iio_ev_type_text[] = { | 801 | static const char * const iio_ev_type_text[] = { |
816 | [IIO_EV_TYPE_THRESH] = "thresh", | 802 | [IIO_EV_TYPE_THRESH] = "thresh", |
817 | [IIO_EV_TYPE_MAG] = "mag", | 803 | [IIO_EV_TYPE_MAG] = "mag", |
@@ -832,10 +818,11 @@ static ssize_t iio_ev_state_store(struct device *dev, | |||
832 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 818 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
833 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); | 819 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
834 | int ret; | 820 | int ret; |
835 | unsigned long val; | 821 | bool val; |
836 | ret = strict_strtoul(buf, 10, &val); | 822 | |
837 | if (ret || val < 0 || val > 1) | 823 | ret = strtobool(buf, &val); |
838 | return -EINVAL; | 824 | if (ret < 0) |
825 | return ret; | ||
839 | 826 | ||
840 | ret = indio_dev->write_event_config(indio_dev, this_attr->address, | 827 | ret = indio_dev->write_event_config(indio_dev, this_attr->address, |
841 | val); | 828 | val); |
@@ -1041,13 +1028,9 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) | |||
1041 | } | 1028 | } |
1042 | 1029 | ||
1043 | for (i = 0; i < dev_info->num_interrupt_lines; i++) { | 1030 | for (i = 0; i < dev_info->num_interrupt_lines; i++) { |
1044 | snprintf(dev_info->event_interfaces[i]._name, 20, | ||
1045 | "%s:event%d", | ||
1046 | dev_name(&dev_info->dev), | ||
1047 | i); | ||
1048 | |||
1049 | ret = iio_setup_ev_int(&dev_info->event_interfaces[i], | 1031 | ret = iio_setup_ev_int(&dev_info->event_interfaces[i], |
1050 | dev_info->event_interfaces[i]._name, | 1032 | dev_name(&dev_info->dev), |
1033 | i, | ||
1051 | dev_info->driver_module, | 1034 | dev_info->driver_module, |
1052 | &dev_info->dev); | 1035 | &dev_info->dev); |
1053 | if (ret) { | 1036 | if (ret) { |
@@ -1120,10 +1103,8 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) | |||
1120 | 1103 | ||
1121 | static void iio_dev_release(struct device *device) | 1104 | static void iio_dev_release(struct device *device) |
1122 | { | 1105 | { |
1123 | struct iio_dev *dev = to_iio_dev(device); | ||
1124 | |||
1125 | iio_put(); | 1106 | iio_put(); |
1126 | kfree(dev); | 1107 | kfree(to_iio_dev(device)); |
1127 | } | 1108 | } |
1128 | 1109 | ||
1129 | static struct device_type iio_dev_type = { | 1110 | static struct device_type iio_dev_type = { |
@@ -1170,8 +1151,9 @@ int iio_device_register(struct iio_dev *dev_info) | |||
1170 | { | 1151 | { |
1171 | int ret; | 1152 | int ret; |
1172 | 1153 | ||
1173 | ret = iio_device_register_id(dev_info, &iio_ida); | 1154 | dev_info->id = iio_get_new_ida_val(&iio_ida); |
1174 | if (ret) { | 1155 | if (dev_info->id < 0) { |
1156 | ret = dev_info->id; | ||
1175 | dev_err(&dev_info->dev, "Failed to get id\n"); | 1157 | dev_err(&dev_info->dev, "Failed to get id\n"); |
1176 | goto error_ret; | 1158 | goto error_ret; |
1177 | } | 1159 | } |
@@ -1202,7 +1184,7 @@ error_free_sysfs: | |||
1202 | error_del_device: | 1184 | error_del_device: |
1203 | device_del(&dev_info->dev); | 1185 | device_del(&dev_info->dev); |
1204 | error_free_ida: | 1186 | error_free_ida: |
1205 | iio_device_unregister_id(dev_info); | 1187 | iio_free_ida_val(&iio_ida, dev_info->id); |
1206 | error_ret: | 1188 | error_ret: |
1207 | return ret; | 1189 | return ret; |
1208 | } | 1190 | } |
@@ -1214,7 +1196,7 @@ void iio_device_unregister(struct iio_dev *dev_info) | |||
1214 | iio_device_unregister_trigger_consumer(dev_info); | 1196 | iio_device_unregister_trigger_consumer(dev_info); |
1215 | iio_device_unregister_eventset(dev_info); | 1197 | iio_device_unregister_eventset(dev_info); |
1216 | iio_device_unregister_sysfs(dev_info); | 1198 | iio_device_unregister_sysfs(dev_info); |
1217 | iio_device_unregister_id(dev_info); | 1199 | iio_free_ida_val(&iio_ida, dev_info->id); |
1218 | device_unregister(&dev_info->dev); | 1200 | device_unregister(&dev_info->dev); |
1219 | } | 1201 | } |
1220 | EXPORT_SYMBOL(iio_device_unregister); | 1202 | EXPORT_SYMBOL(iio_device_unregister); |