Merge tag 'platform-drivers-x86-v3.20-1' of git://git.infradead.org/users/dvhart...
[cascardo/linux.git] / drivers / iio / industrialio-event.c
index 0c1e37e..a4b3970 100644 (file)
@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = {
        [IIO_EV_TYPE_ROC] = "roc",
        [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
        [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
+       [IIO_EV_TYPE_CHANGE] = "change",
 };
 
 static const char * const iio_ev_dir_text[] = {
@@ -327,9 +328,15 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
        for_each_set_bit(i, mask, sizeof(*mask)*8) {
                if (i >= ARRAY_SIZE(iio_ev_info_text))
                        return -EINVAL;
-               postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
-                               iio_ev_type_text[type], iio_ev_dir_text[dir],
-                               iio_ev_info_text[i]);
+               if (dir != IIO_EV_DIR_NONE)
+                       postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
+                                       iio_ev_type_text[type],
+                                       iio_ev_dir_text[dir],
+                                       iio_ev_info_text[i]);
+               else
+                       postfix = kasprintf(GFP_KERNEL, "%s_%s",
+                                       iio_ev_type_text[type],
+                                       iio_ev_info_text[i]);
                if (postfix == NULL)
                        return -ENOMEM;
 
@@ -404,7 +411,7 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
 {
        int j, ret, attrcount = 0;
 
-       /* Dynically created from the channels array */
+       /* Dynamically created from the channels array */
        for (j = 0; j < indio_dev->num_channels; j++) {
                ret = iio_device_add_event_sysfs(indio_dev,
                                                 &indio_dev->channels[j]);