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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3b7cf04f87
commit
e7c8a7e350
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -34,7 +34,7 @@ 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,
|
||||
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,7 +43,7 @@ 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,
|
||||
static ssize_t impulse_volume_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
|
@ -64,11 +64,12 @@ 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,
|
||||
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,7 +78,7 @@ 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,
|
||||
static ssize_t impulse_period_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ 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,
|
||||
static ssize_t serial_number_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usb_interface *interface = to_usb_interface(dev);
|
||||
|
@ -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,7 +215,7 @@ 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,
|
||||
static ssize_t device_id_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct usb_interface *interface = to_usb_interface(dev);
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue