From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 17:36:49 +0000 (-0700) Subject: staging: line6: use default sysfs attribute macros X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e7c8a7e350e22bf60d94d5e9361cee29058684c1;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git staging: line6: use default sysfs attribute macros 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 Cc: Laurent Navet Cc: Johannes Thumshirn Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 6252aca82866..471c10c116ec 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -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. */ diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h index a8341f9fdb98..34ae95e7e512 100644 --- a/drivers/staging/line6/driver.h +++ b/drivers/staging/line6/driver.h @@ -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, diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 0dd08ef51398..6a0648cd03a7 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -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 diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index 699b21725062..f4e95a614e3f 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -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,