1
0
Fork 0

USB: move many drivers to use DEVICE_ATTR_RW

Instead of "open coding" a DEVICE_ATTR() define, use the
DEVICE_ATTR_RW() macro instead, which does everything properly instead.

This does require a few static functions to be renamed to work properly,
but thanks to a script from Joe Perches, this was easily done.

Reported-by: Joe Perches <joe@perches.com>
Cc: Matthieu CASTET <castet.matthieu@free.fr>
Cc: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Peter Chen <Peter.Chen@nxp.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Greg Kroah-Hartman 2018-01-23 11:24:05 +01:00
parent 32366fc9fe
commit ed5bd7a47f
12 changed files with 56 additions and 60 deletions

View File

@ -2280,7 +2280,7 @@ static struct uea_softc *dev_to_uea(struct device *dev)
return usbatm->driver_data;
}
static ssize_t read_status(struct device *dev, struct device_attribute *attr,
static ssize_t stat_status_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
int ret = -ENODEV;
@ -2296,7 +2296,7 @@ out:
return ret;
}
static ssize_t reboot(struct device *dev, struct device_attribute *attr,
static ssize_t stat_status_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int ret = -ENODEV;
@ -2313,7 +2313,7 @@ out:
return ret;
}
static DEVICE_ATTR(stat_status, S_IWUSR | S_IRUGO, read_status, reboot);
static DEVICE_ATTR_RW(stat_status);
static ssize_t read_human_status(struct device *dev,
struct device_attribute *attr, char *buf)

View File

@ -835,7 +835,7 @@ static void ci_get_otg_capable(struct ci_hdrc *ci)
}
}
static ssize_t ci_role_show(struct device *dev, struct device_attribute *attr,
static ssize_t role_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
@ -846,7 +846,7 @@ static ssize_t ci_role_show(struct device *dev, struct device_attribute *attr,
return 0;
}
static ssize_t ci_role_store(struct device *dev,
static ssize_t role_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
@ -877,7 +877,7 @@ static ssize_t ci_role_store(struct device *dev,
return (ret == 0) ? n : ret;
}
static DEVICE_ATTR(role, 0644, ci_role_show, ci_role_store);
static DEVICE_ATTR_RW(role);
static struct attribute *ci_attrs[] = {
&dev_attr_role.attr,

View File

@ -29,7 +29,7 @@
/* Add for otg: interact with user space app */
static ssize_t
get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
a_bus_req_show(struct device *dev, struct device_attribute *attr, char *buf)
{
char *next;
unsigned size, t;
@ -45,7 +45,7 @@ get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
set_a_bus_req(struct device *dev, struct device_attribute *attr,
a_bus_req_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
@ -75,10 +75,10 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
static DEVICE_ATTR_RW(a_bus_req);
static ssize_t
get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
a_bus_drop_show(struct device *dev, struct device_attribute *attr, char *buf)
{
char *next;
unsigned size, t;
@ -94,7 +94,7 @@ get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
set_a_bus_drop(struct device *dev, struct device_attribute *attr,
a_bus_drop_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
@ -115,11 +115,10 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop,
set_a_bus_drop);
static DEVICE_ATTR_RW(a_bus_drop);
static ssize_t
get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
b_bus_req_show(struct device *dev, struct device_attribute *attr, char *buf)
{
char *next;
unsigned size, t;
@ -135,7 +134,7 @@ get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
set_b_bus_req(struct device *dev, struct device_attribute *attr,
b_bus_req_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
@ -160,7 +159,7 @@ set_b_bus_req(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
static DEVICE_ATTR_RW(b_bus_req);
static ssize_t
set_a_clr_err(struct device *dev, struct device_attribute *attr,

View File

@ -7,7 +7,7 @@
/* Display the ports dedicated to the companion controller */
static ssize_t show_companion(struct device *dev,
static ssize_t companion_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
@ -34,7 +34,7 @@ static ssize_t show_companion(struct device *dev,
* Syntax is "[-]portnum", where a leading '-' sign means
* return control of the port to the EHCI controller.
*/
static ssize_t store_companion(struct device *dev,
static ssize_t companion_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@ -59,13 +59,13 @@ static ssize_t store_companion(struct device *dev,
set_owner(ehci, portnum, new_owner);
return count;
}
static DEVICE_ATTR(companion, 0644, show_companion, store_companion);
static DEVICE_ATTR_RW(companion);
/*
* Display / Set uframe_periodic_max
*/
static ssize_t show_uframe_periodic_max(struct device *dev,
static ssize_t uframe_periodic_max_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
@ -78,7 +78,7 @@ static ssize_t show_uframe_periodic_max(struct device *dev,
}
static ssize_t store_uframe_periodic_max(struct device *dev,
static ssize_t uframe_periodic_max_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@ -143,7 +143,7 @@ out_unlock:
spin_unlock_irqrestore (&ehci->lock, flags);
return ret;
}
static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max, store_uframe_periodic_max);
static DEVICE_ATTR_RW(uframe_periodic_max);
static inline int create_sysfs_files(struct ehci_hcd *ehci)

View File

@ -4693,7 +4693,7 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
/* Display / Set uframe_periodic_max
*/
static ssize_t show_uframe_periodic_max(struct device *dev,
static ssize_t uframe_periodic_max_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct fotg210_hcd *fotg210;
@ -4705,7 +4705,7 @@ static ssize_t show_uframe_periodic_max(struct device *dev,
}
static ssize_t store_uframe_periodic_max(struct device *dev,
static ssize_t uframe_periodic_max_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct fotg210_hcd *fotg210;
@ -4772,8 +4772,7 @@ out_unlock:
return ret;
}
static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max,
store_uframe_periodic_max);
static DEVICE_ATTR_RW(uframe_periodic_max);
static inline int create_sysfs_files(struct fotg210_hcd *fotg210)
{

View File

@ -920,7 +920,7 @@ static ssize_t dbc_store(struct device *dev,
return count;
}
static DEVICE_ATTR(dbc, 0644, dbc_show, dbc_store);
static DEVICE_ATTR_RW(dbc);
int xhci_dbc_init(struct xhci_hcd *xhci)
{

View File

@ -144,7 +144,7 @@ error:
}
/* attribute callback handler (write) */
static ssize_t set_port0_handler(struct device *dev,
static ssize_t port0_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@ -152,7 +152,7 @@ static ssize_t set_port0_handler(struct device *dev,
}
/* attribute callback handler (write) */
static ssize_t set_port1_handler(struct device *dev,
static ssize_t port1_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@ -178,22 +178,22 @@ static ssize_t read_port(struct device *dev, struct device_attribute *attr,
}
/* attribute callback handler (read) */
static ssize_t get_port0_handler(struct device *dev,
static ssize_t port0_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return read_port(dev, attr, buf, 0, CYPRESS_READ_PORT_ID0);
}
/* attribute callback handler (read) */
static ssize_t get_port1_handler(struct device *dev,
static ssize_t port1_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1);
}
static DEVICE_ATTR(port0, S_IRUGO | S_IWUSR, get_port0_handler, set_port0_handler);
static DEVICE_ATTR_RW(port0);
static DEVICE_ATTR(port1, S_IRUGO | S_IWUSR, get_port1_handler, set_port1_handler);
static DEVICE_ATTR_RW(port1);
static int cypress_probe(struct usb_interface *interface,

View File

@ -30,7 +30,7 @@ struct trancevibrator {
unsigned int speed;
};
static ssize_t show_speed(struct device *dev, struct device_attribute *attr,
static ssize_t speed_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -39,7 +39,7 @@ static ssize_t show_speed(struct device *dev, struct device_attribute *attr,
return sprintf(buf, "%d\n", tv->speed);
}
static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -70,7 +70,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR, show_speed, set_speed);
static DEVICE_ATTR_RW(speed);
static int tv_probe(struct usb_interface *interface,
const struct usb_device_id *id)

View File

@ -187,7 +187,7 @@ static ssize_t set_attr_##name(struct device *dev, \
} \
static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_attr_##name, set_attr_##name);
static ssize_t show_attr_text(struct device *dev,
static ssize_t text_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -196,7 +196,7 @@ static ssize_t show_attr_text(struct device *dev,
return snprintf(buf, mydev->textlength, "%s\n", mydev->text);
}
static ssize_t set_attr_text(struct device *dev,
static ssize_t text_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -216,9 +216,9 @@ static ssize_t set_attr_text(struct device *dev,
return count;
}
static DEVICE_ATTR(text, S_IRUGO | S_IWUSR, show_attr_text, set_attr_text);
static DEVICE_ATTR_RW(text);
static ssize_t show_attr_decimals(struct device *dev,
static ssize_t decimals_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -240,7 +240,7 @@ static ssize_t show_attr_decimals(struct device *dev,
return sizeof(mydev->decimals) + 1;
}
static ssize_t set_attr_decimals(struct device *dev,
static ssize_t decimals_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -265,9 +265,9 @@ static ssize_t set_attr_decimals(struct device *dev,
return count;
}
static DEVICE_ATTR(decimals, S_IRUGO | S_IWUSR, show_attr_decimals, set_attr_decimals);
static DEVICE_ATTR_RW(decimals);
static ssize_t show_attr_textmode(struct device *dev,
static ssize_t textmode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -293,7 +293,7 @@ static ssize_t show_attr_textmode(struct device *dev,
return strlen(buf);
}
static ssize_t set_attr_textmode(struct device *dev,
static ssize_t textmode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct usb_interface *intf = to_usb_interface(dev);
@ -309,7 +309,7 @@ static ssize_t set_attr_textmode(struct device *dev,
return count;
}
static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode);
static DEVICE_ATTR_RW(textmode);
MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered);

View File

@ -1687,7 +1687,7 @@ EXPORT_SYMBOL_GPL(musb_mailbox);
/*-------------------------------------------------------------------------*/
static ssize_t
musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct musb *musb = dev_to_musb(dev);
unsigned long flags;
@ -1701,7 +1701,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
musb_mode_store(struct device *dev, struct device_attribute *attr,
mode_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t n)
{
struct musb *musb = dev_to_musb(dev);
@ -1721,10 +1721,10 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
return (status == 0) ? n : status;
}
static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
static DEVICE_ATTR_RW(mode);
static ssize_t
musb_vbus_store(struct device *dev, struct device_attribute *attr,
vbus_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t n)
{
struct musb *musb = dev_to_musb(dev);
@ -1748,7 +1748,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
}
static ssize_t
musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct musb *musb = dev_to_musb(dev);
unsigned long flags;
@ -1773,7 +1773,7 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "Vbus %s, timeout %lu msec\n",
vbus ? "on" : "off", val);
}
static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
static DEVICE_ATTR_RW(vbus);
/* Gadget drivers can't know that a host is connected so they might want
* to start SRP, but users can. This allows userspace to trigger SRP.

View File

@ -519,7 +519,7 @@ static irqreturn_t mv_otg_inputs_irq(int irq, void *dev)
}
static ssize_t
get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
a_bus_req_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct mv_otg *mvotg = dev_get_drvdata(dev);
return scnprintf(buf, PAGE_SIZE, "%d\n",
@ -527,7 +527,7 @@ get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
set_a_bus_req(struct device *dev, struct device_attribute *attr,
a_bus_req_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct mv_otg *mvotg = dev_get_drvdata(dev);
@ -559,8 +559,7 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req,
set_a_bus_req);
static DEVICE_ATTR_RW(a_bus_req);
static ssize_t
set_a_clr_err(struct device *dev, struct device_attribute *attr,
@ -590,7 +589,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err);
static ssize_t
get_a_bus_drop(struct device *dev, struct device_attribute *attr,
a_bus_drop_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct mv_otg *mvotg = dev_get_drvdata(dev);
@ -599,7 +598,7 @@ get_a_bus_drop(struct device *dev, struct device_attribute *attr,
}
static ssize_t
set_a_bus_drop(struct device *dev, struct device_attribute *attr,
a_bus_drop_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct mv_otg *mvotg = dev_get_drvdata(dev);
@ -630,8 +629,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
return count;
}
static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR,
get_a_bus_drop, set_a_bus_drop);
static DEVICE_ATTR_RW(a_bus_drop);
static struct attribute *inputs_attrs[] = {
&dev_attr_a_bus_req.attr,

View File

@ -310,7 +310,7 @@ static ssize_t otg_mode_store(struct device *device,
return r;
}
static DEVICE_ATTR(otg_mode, 0644, otg_mode_show, otg_mode_store);
static DEVICE_ATTR_RW(otg_mode);
static struct attribute *tahvo_attributes[] = {
&dev_attr_vbus.attr,