diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-10-07 07:50:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-10-12 07:17:34 -0400 |
commit | 84088ebd14aebf1b8499409a037094b9b88e2796 (patch) | |
tree | a239085ff20650319449d811f5e55207ea890df3 /drivers/iio/industrialio-event.c | |
parent | a95194569f697a6cc10d00f9b9b3d21b0b820520 (diff) |
iio: Add a helper to free a list of IIO device attributes
We have the same code to free a IIO device attribute list in multiple place.
This patch adds a new helper function to take care of this and replaces the
custom instances with a call to the helper function. Note that we do not need to
call list_del() for each of the list items since we will never look at any of
the list items nor the list itself again.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-event.c')
-rw-r--r-- | drivers/iio/industrialio-event.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index d251f30fb739..4a3fd5acda94 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c | |||
@@ -350,17 +350,6 @@ error_ret: | |||
350 | return ret; | 350 | return ret; |
351 | } | 351 | } |
352 | 352 | ||
353 | static inline void __iio_remove_event_config_attrs(struct iio_dev *indio_dev) | ||
354 | { | ||
355 | struct iio_dev_attr *p, *n; | ||
356 | list_for_each_entry_safe(p, n, | ||
357 | &indio_dev->event_interface-> | ||
358 | dev_attr_list, l) { | ||
359 | kfree(p->dev_attr.attr.name); | ||
360 | kfree(p); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev) | 353 | static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev) |
365 | { | 354 | { |
366 | int j, ret, attrcount = 0; | 355 | int j, ret, attrcount = 0; |
@@ -452,7 +441,7 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) | |||
452 | return 0; | 441 | return 0; |
453 | 442 | ||
454 | error_free_setup_event_lines: | 443 | error_free_setup_event_lines: |
455 | __iio_remove_event_config_attrs(indio_dev); | 444 | iio_free_chan_devattr_list(&indio_dev->event_interface->dev_attr_list); |
456 | kfree(indio_dev->event_interface); | 445 | kfree(indio_dev->event_interface); |
457 | error_ret: | 446 | error_ret: |
458 | 447 | ||
@@ -477,7 +466,7 @@ void iio_device_unregister_eventset(struct iio_dev *indio_dev) | |||
477 | { | 466 | { |
478 | if (indio_dev->event_interface == NULL) | 467 | if (indio_dev->event_interface == NULL) |
479 | return; | 468 | return; |
480 | __iio_remove_event_config_attrs(indio_dev); | 469 | iio_free_chan_devattr_list(&indio_dev->event_interface->dev_attr_list); |
481 | kfree(indio_dev->event_interface->group.attrs); | 470 | kfree(indio_dev->event_interface->group.attrs); |
482 | kfree(indio_dev->event_interface); | 471 | kfree(indio_dev->event_interface); |
483 | } | 472 | } |