From: "Paul A. Tessier" <phern...@gmail.com> add reasonable default permission defines for attributes RW : ug=rw,o=r RO : ugo=r WO : ug=w
enabled reading relavent attributes changed to scnprintf(buf, PAGE_SIZE, ... ) as suggested in sysfs.txt for show functions Signed-off-by: Paul A. Tessier <phern...@gmail.com> --- 3.7/wacom_sys.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/3.7/wacom_sys.c b/3.7/wacom_sys.c index 8de1cc3..255a398 100644 --- a/3.7/wacom_sys.c +++ b/3.7/wacom_sys.c @@ -60,6 +60,10 @@ struct hid_descriptor { #define WAC_CMD_ICON_XFER 0x23 #define WAC_CMD_RETRIES 10 +#define DEV_ATTR_RW_PERM (S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH) +#define DEV_ATTR_RO_PERM (S_IRUSR | S_IRGRP | S_IROTH) +#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP) + static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id, void *buf, size_t size, unsigned int retries) { @@ -825,9 +829,10 @@ static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ struct wacom *wacom = dev_get_drvdata(dev); \ - return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \ + return scnprintf(buf, PAGE_SIZE, "%d\n", \ + wacom->led.select[SET_ID]); \ } \ -static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \ +static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \ wacom_led##SET_ID##_select_show, \ wacom_led##SET_ID##_select_store) @@ -863,8 +868,15 @@ static ssize_t wacom_##name##_luminance_store(struct device *dev, \ return wacom_luminance_store(wacom, &wacom->led.field, \ buf, count); \ } \ -static DEVICE_ATTR(name##_luminance, S_IWUSR, \ - NULL, wacom_##name##_luminance_store) +static ssize_t wacom_##name##_luminance_show(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ \ + struct wacom *wacom = dev_get_drvdata(dev); \ + return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \ +} \ +static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \ + wacom_##name##_luminance_show, \ + wacom_##name##_luminance_store) DEVICE_LUMINANCE_ATTR(status0, llv); DEVICE_LUMINANCE_ATTR(status1, hlv); @@ -894,7 +906,7 @@ static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \ { \ return wacom_button_image_store(dev, BUTTON_ID, buf, count); \ } \ -static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \ +static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \ NULL, wacom_btnimg##BUTTON_ID##_store) DEVICE_BTNIMG_ATTR(0); -- 1.8.3.2 ------------------------------------------------------------------------------ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel