summaryrefslogtreecommitdiff
path: root/drivers/iio/industrialio-trigger.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 23:51:35 (GMT)
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-20 23:51:35 (GMT)
commitde4fe30af1620b5117d65489621a5037913e7a92 (patch)
treea6ac7b90f8a3ac84c466d42192f521c1087bde71 /drivers/iio/industrialio-trigger.c
parentd3bad75a6d57416cf7478ca2a1e42f699bc17ec5 (diff)
parentaa3bee0daa38570b174ef6b8a77261b4473d5614 (diff)
downloadlinux-de4fe30af1620b5117d65489621a5037913e7a92.tar.xz
Merge tag 'staging-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver tree changes from Greg KH: "Here's the big drivers/staging/ update for 3.14-rc1 Lots and lots of cleanups, IIO driver updates are also mixed in here due to the subsystem still crossing staging and drivers/iio/, and the dwc2 driver is moved out of staging. There's a new driver (rts5208), which ends up making us adding more lines than removing, but overall there was lots of work toward moving code out of here, which was good All of this has been in linux-next with no reported issues" * tag 'staging-3.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1084 commits) lustre: delete linux/lustre_debug.h staging: lustre: remove some unused debug macros usb: dwc2: move device tree bindings doc to correct place staging: vt6656: sparse fixes: iwctl_giwgenie use memcpy. staging: vt6656: sparse fixes: iwctl_siwgenie use memcpy. staging: vt6656: sparse fixes ethtool_ioctl Use struct ifreq * staging: vt6656: sparse fixes: dpc.c missing dpc.h staging: lustre: libcfs_debug: small whitespace cleanups staging: lustre: libcfs_debug.h: remove extra blank lines staging: lustre: libcfs_debug.h: Align backslashes in macros staging: lustre: libcfs_debug.h: align define values staging: tidspbridge: adjust error return code (bugfix) Staging: rts5139: rts51x_card: fixed style issues staging: wlags49_h2: Fix "do not use C99 //" in wl_cs.h, wl_enc.h wl_main.h and wl_wext.h Staging: rtl8188eu: Fixed "foo * bar" related coding style issues Staging: rtl8188eu: Fixed required spaces after ',' and around '=' and '==' staging: vt6655: Fix memory leak in wpa_ioctl() imx-drm: parallel-display: honor 'native-mode' property when selecting video mode from DT staging: drm/imx: don't drop crtc offsets when doing pageflip staging: drm/imx: handle framebuffer offsets correctly ...
Diffstat (limited to 'drivers/iio/industrialio-trigger.c')
-rw-r--r--drivers/iio/industrialio-trigger.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index bf5e70a..766fab2 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -55,15 +55,7 @@ static struct attribute *iio_trig_dev_attrs[] = {
&dev_attr_name.attr,
NULL,
};
-
-static struct attribute_group iio_trig_attr_group = {
- .attrs = iio_trig_dev_attrs,
-};
-
-static const struct attribute_group *iio_trig_attr_groups[] = {
- &iio_trig_attr_group,
- NULL
-};
+ATTRIBUTE_GROUPS(iio_trig_dev);
int iio_trigger_register(struct iio_trigger *trig_info)
{
@@ -318,7 +310,7 @@ static ssize_t iio_trigger_read_current(struct device *dev,
* iio_trigger_write_current() - trigger consumer sysfs set current trigger
*
* For trigger consumers the current_trigger interface allows the trigger
- * used for this device to be specified at run time based on the triggers
+ * used for this device to be specified at run time based on the trigger's
* name.
**/
static ssize_t iio_trigger_write_current(struct device *dev,
@@ -356,7 +348,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
indio_dev->trig = trig;
- if (oldtrig && indio_dev->trig != oldtrig)
+ if (oldtrig)
iio_trigger_put(oldtrig);
if (indio_dev->trig)
iio_trigger_get(indio_dev->trig);
@@ -403,7 +395,7 @@ static void iio_trig_release(struct device *device)
static struct device_type iio_trig_type = {
.release = iio_trig_release,
- .groups = iio_trig_attr_groups,
+ .groups = iio_trig_dev_groups,
};
static void iio_trig_subirqmask(struct irq_data *d)
@@ -506,6 +498,23 @@ static int devm_iio_trigger_match(struct device *dev, void *res, void *data)
return *r == data;
}
+/**
+ * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc()
+ * @dev: Device to allocate iio_trigger for
+ * @fmt: trigger name format. If it includes format
+ * specifiers, the additional arguments following
+ * format are formatted and inserted in the resulting
+ * string replacing their respective specifiers.
+ *
+ * Managed iio_trigger_alloc. iio_trigger allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * If an iio_trigger allocated with this function needs to be freed separately,
+ * devm_iio_trigger_free() must be used.
+ *
+ * RETURNS:
+ * Pointer to allocated iio_trigger on success, NULL on failure.
+ */
struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
const char *fmt, ...)
{
@@ -532,6 +541,13 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc);
+/**
+ * devm_iio_trigger_free - Resource-managed iio_trigger_free()
+ * @dev: Device this iio_dev belongs to
+ * @iio_trig: the iio_trigger associated with the device
+ *
+ * Free iio_trigger allocated with devm_iio_trigger_alloc().
+ */
void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig)
{
int rc;