staging: line6: use default sysfs attribute macros
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Aug 2013 17:36:49 +0000 (10:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Aug 2013 17:36:49 +0000 (10:36 -0700)
Move to use the DEVICE_ATTR_RW/RO macros, making it easier to audit the
sysfs file permissions, and get rid of the "empty" callback for
read-only files, saving lines of code.

Cc: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Laurent Navet <laurent.navet@gmail.com>
Cc: Johannes Thumshirn <morbidrsa@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/line6/driver.c
drivers/staging/line6/driver.h
drivers/staging/line6/pcm.c
drivers/staging/line6/pod.c

index 6252aca828662101a835e6945208323c7e54ef71..471c10c116ec823d54587c5426d79881cfc0db46 100644 (file)
@@ -567,15 +567,6 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
        return 0;
 }
 
-/*
-       No operation (i.e., unsupported).
-*/
-ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
-                       const char *buf, size_t count)
-{
-       return count;
-}
-
 /*
        Generic destructor.
 */
index a8341f9fdb981926d7c6132e2ebf11c2a9a552c2..34ae95e7e512871a74e9e9cd427ce28b3fb916f9 100644 (file)
@@ -190,9 +190,6 @@ extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
                                      int code2, int size);
 extern ssize_t line6_nop_read(struct device *dev,
                              struct device_attribute *attr, char *buf);
-extern ssize_t line6_nop_write(struct device *dev,
-                              struct device_attribute *attr,
-                              const char *buf, size_t count);
 extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
                           size_t datalen);
 extern int line6_read_serial_number(struct usb_line6 *line6,
index 0dd08ef51398cabe6164cb90f4280ca401fb996f..6a0648cd03a7012b42abf518f1807a3da97dcec8 100644 (file)
@@ -34,8 +34,8 @@ static struct snd_line6_pcm *dev2pcm(struct device *dev)
 /*
        "read" request on "impulse_volume" special file.
 */
-static ssize_t pcm_get_impulse_volume(struct device *dev,
-                                     struct device_attribute *attr, char *buf)
+static ssize_t impulse_volume_show(struct device *dev,
+                                  struct device_attribute *attr, char *buf)
 {
        return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume);
 }
@@ -43,9 +43,9 @@ static ssize_t pcm_get_impulse_volume(struct device *dev,
 /*
        "write" request on "impulse_volume" special file.
 */
-static ssize_t pcm_set_impulse_volume(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf, size_t count)
+static ssize_t impulse_volume_store(struct device *dev,
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t count)
 {
        struct snd_line6_pcm *line6pcm = dev2pcm(dev);
        int value;
@@ -64,12 +64,13 @@ static ssize_t pcm_set_impulse_volume(struct device *dev,
 
        return count;
 }
+static DEVICE_ATTR_RW(impulse_volume);
 
 /*
        "read" request on "impulse_period" special file.
 */
-static ssize_t pcm_get_impulse_period(struct device *dev,
-                                     struct device_attribute *attr, char *buf)
+static ssize_t impulse_period_show(struct device *dev,
+                                  struct device_attribute *attr, char *buf)
 {
        return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period);
 }
@@ -77,9 +78,9 @@ static ssize_t pcm_get_impulse_period(struct device *dev,
 /*
        "write" request on "impulse_period" special file.
 */
-static ssize_t pcm_set_impulse_period(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf, size_t count)
+static ssize_t impulse_period_store(struct device *dev,
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t count)
 {
        int value;
        int ret;
@@ -91,11 +92,7 @@ static ssize_t pcm_set_impulse_period(struct device *dev,
        dev2pcm(dev)->impulse_period = value;
        return count;
 }
-
-static DEVICE_ATTR(impulse_volume, S_IWUSR | S_IRUGO, pcm_get_impulse_volume,
-                  pcm_set_impulse_volume);
-static DEVICE_ATTR(impulse_period, S_IWUSR | S_IRUGO, pcm_get_impulse_period,
-                  pcm_set_impulse_period);
+static DEVICE_ATTR_RW(impulse_period);
 
 #endif
 
index 699b21725062284ca081ba71ddba0bb978427bb9..f4e95a614e3fd807e38512cde9e881a7b6ae92fd 100644 (file)
@@ -192,8 +192,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value,
 /*
        "read" request on "serial_number" special file.
 */
-static ssize_t pod_get_serial_number(struct device *dev,
-                                    struct device_attribute *attr, char *buf)
+static ssize_t serial_number_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
 {
        struct usb_interface *interface = to_usb_interface(dev);
        struct usb_line6_pod *pod = usb_get_intfdata(interface);
@@ -203,9 +203,8 @@ static ssize_t pod_get_serial_number(struct device *dev,
 /*
        "read" request on "firmware_version" special file.
 */
-static ssize_t pod_get_firmware_version(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
+static ssize_t firmware_version_show(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
 {
        struct usb_interface *interface = to_usb_interface(dev);
        struct usb_line6_pod *pod = usb_get_intfdata(interface);
@@ -216,8 +215,8 @@ static ssize_t pod_get_firmware_version(struct device *dev,
 /*
        "read" request on "device_id" special file.
 */
-static ssize_t pod_get_device_id(struct device *dev,
-                                struct device_attribute *attr, char *buf)
+static ssize_t device_id_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
 {
        struct usb_interface *interface = to_usb_interface(dev);
        struct usb_line6_pod *pod = usb_get_intfdata(interface);
@@ -274,11 +273,9 @@ static void pod_startup4(struct work_struct *work)
 }
 
 /* POD special files: */
-static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write);
-static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version,
-                  line6_nop_write);
-static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
-                  line6_nop_write);
+static DEVICE_ATTR_RO(device_id);
+static DEVICE_ATTR_RO(firmware_version);
+static DEVICE_ATTR_RO(serial_number);
 
 /* control info callback */
 static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,