Commit e7c8a7e3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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 <stefanha@gmail.com>
Cc: Laurent Navet <laurent.navet@gmail.com>
Cc: Johannes Thumshirn <morbidrsa@googlemail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3b7cf04f
...@@ -567,15 +567,6 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, ...@@ -567,15 +567,6 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
return 0; 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. Generic destructor.
*/ */
......
...@@ -190,9 +190,6 @@ extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, ...@@ -190,9 +190,6 @@ extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
int code2, int size); int code2, int size);
extern ssize_t line6_nop_read(struct device *dev, extern ssize_t line6_nop_read(struct device *dev,
struct device_attribute *attr, char *buf); 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, extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
size_t datalen); size_t datalen);
extern int line6_read_serial_number(struct usb_line6 *line6, extern int line6_read_serial_number(struct usb_line6 *line6,
......
...@@ -34,8 +34,8 @@ static struct snd_line6_pcm *dev2pcm(struct device *dev) ...@@ -34,8 +34,8 @@ static struct snd_line6_pcm *dev2pcm(struct device *dev)
/* /*
"read" request on "impulse_volume" special file. "read" request on "impulse_volume" special file.
*/ */
static ssize_t pcm_get_impulse_volume(struct device *dev, static ssize_t impulse_volume_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume); return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume);
} }
...@@ -43,9 +43,9 @@ static ssize_t pcm_get_impulse_volume(struct device *dev, ...@@ -43,9 +43,9 @@ static ssize_t pcm_get_impulse_volume(struct device *dev,
/* /*
"write" request on "impulse_volume" special file. "write" request on "impulse_volume" special file.
*/ */
static ssize_t pcm_set_impulse_volume(struct device *dev, static ssize_t impulse_volume_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct snd_line6_pcm *line6pcm = dev2pcm(dev); struct snd_line6_pcm *line6pcm = dev2pcm(dev);
int value; int value;
...@@ -64,12 +64,13 @@ static ssize_t pcm_set_impulse_volume(struct device *dev, ...@@ -64,12 +64,13 @@ static ssize_t pcm_set_impulse_volume(struct device *dev,
return count; return count;
} }
static DEVICE_ATTR_RW(impulse_volume);
/* /*
"read" request on "impulse_period" special file. "read" request on "impulse_period" special file.
*/ */
static ssize_t pcm_get_impulse_period(struct device *dev, static ssize_t impulse_period_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period); return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period);
} }
...@@ -77,9 +78,9 @@ static ssize_t pcm_get_impulse_period(struct device *dev, ...@@ -77,9 +78,9 @@ static ssize_t pcm_get_impulse_period(struct device *dev,
/* /*
"write" request on "impulse_period" special file. "write" request on "impulse_period" special file.
*/ */
static ssize_t pcm_set_impulse_period(struct device *dev, static ssize_t impulse_period_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int value; int value;
int ret; int ret;
...@@ -91,11 +92,7 @@ static ssize_t pcm_set_impulse_period(struct device *dev, ...@@ -91,11 +92,7 @@ static ssize_t pcm_set_impulse_period(struct device *dev,
dev2pcm(dev)->impulse_period = value; dev2pcm(dev)->impulse_period = value;
return count; return count;
} }
static DEVICE_ATTR_RW(impulse_period);
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);
#endif #endif
......
...@@ -192,8 +192,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, ...@@ -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. "read" request on "serial_number" special file.
*/ */
static ssize_t pod_get_serial_number(struct device *dev, static ssize_t serial_number_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct usb_interface *interface = to_usb_interface(dev); struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface); struct usb_line6_pod *pod = usb_get_intfdata(interface);
...@@ -203,9 +203,8 @@ static ssize_t pod_get_serial_number(struct device *dev, ...@@ -203,9 +203,8 @@ static ssize_t pod_get_serial_number(struct device *dev,
/* /*
"read" request on "firmware_version" special file. "read" request on "firmware_version" special file.
*/ */
static ssize_t pod_get_firmware_version(struct device *dev, static ssize_t firmware_version_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, char *buf)
char *buf)
{ {
struct usb_interface *interface = to_usb_interface(dev); struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface); struct usb_line6_pod *pod = usb_get_intfdata(interface);
...@@ -216,8 +215,8 @@ static ssize_t pod_get_firmware_version(struct device *dev, ...@@ -216,8 +215,8 @@ static ssize_t pod_get_firmware_version(struct device *dev,
/* /*
"read" request on "device_id" special file. "read" request on "device_id" special file.
*/ */
static ssize_t pod_get_device_id(struct device *dev, static ssize_t device_id_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct usb_interface *interface = to_usb_interface(dev); struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface); struct usb_line6_pod *pod = usb_get_intfdata(interface);
...@@ -274,11 +273,9 @@ static void pod_startup4(struct work_struct *work) ...@@ -274,11 +273,9 @@ static void pod_startup4(struct work_struct *work)
} }
/* POD special files: */ /* POD special files: */
static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write); static DEVICE_ATTR_RO(device_id);
static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version, static DEVICE_ATTR_RO(firmware_version);
line6_nop_write); static DEVICE_ATTR_RO(serial_number);
static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
line6_nop_write);
/* control info callback */ /* control info callback */
static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment