OSDN Git Service

wusb: Remove unnecessary static function ckhdid_printf
authorJoe Perches <joe@perches.com>
Fri, 1 Mar 2019 04:38:16 +0000 (20:38 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2019 19:53:41 +0000 (20:53 +0100)
This static inline is unnecessary and can be removed
by using the vsprintf %ph extension.

This reduces overall object size by more than 2K.

Reported-by: Louis Taylor <louis@kragniz.eu>
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Louis Taylor <louis@kragniz.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/wusbcore/cbaf.c
drivers/usb/wusbcore/dev-sysfs.c
drivers/usb/wusbcore/devconnect.c
drivers/usb/wusbcore/wusbhc.c
include/linux/usb/wusb.h

index 222228c..af77064 100644 (file)
@@ -302,10 +302,8 @@ static ssize_t cbaf_wusb_chid_show(struct device *dev,
 {
        struct usb_interface *iface = to_usb_interface(dev);
        struct cbaf *cbaf = usb_get_intfdata(iface);
-       char pr_chid[WUSB_CKHDID_STRSIZE];
 
-       ckhdid_printf(pr_chid, sizeof(pr_chid), &cbaf->chid);
-       return scnprintf(buf, PAGE_SIZE, "%s\n", pr_chid);
+       return sprintf(buf, "%16ph\n", cbaf->chid.data);
 }
 
 static ssize_t cbaf_wusb_chid_store(struct device *dev,
@@ -415,10 +413,8 @@ static ssize_t cbaf_wusb_cdid_show(struct device *dev,
 {
        struct usb_interface *iface = to_usb_interface(dev);
        struct cbaf *cbaf = usb_get_intfdata(iface);
-       char pr_cdid[WUSB_CKHDID_STRSIZE];
 
-       ckhdid_printf(pr_cdid, sizeof(pr_cdid), &cbaf->cdid);
-       return scnprintf(buf, PAGE_SIZE, "%s\n", pr_cdid);
+       return sprintf(buf, "%16ph\n", cbaf->cdid.data);
 }
 
 static ssize_t cbaf_wusb_cdid_store(struct device *dev,
@@ -503,7 +499,6 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
        int result;
        struct device *dev = &cbaf->usb_iface->dev;
        struct wusb_cbaf_cc_data *ccd;
-       char pr_cdid[WUSB_CKHDID_STRSIZE];
 
        ccd =  cbaf->buffer;
        *ccd = cbaf_cc_data_defaults;
@@ -513,10 +508,8 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
        ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups);
 
        dev_dbg(dev, "Trying to upload CC:\n");
-       ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CHID);
-       dev_dbg(dev, "  CHID       %s\n", pr_cdid);
-       ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CDID);
-       dev_dbg(dev, "  CDID       %s\n", pr_cdid);
+       dev_dbg(dev, "  CHID       %16ph\n", ccd->CHID.data);
+       dev_dbg(dev, "  CDID       %16ph\n", ccd->CDID.data);
        dev_dbg(dev, "  Bandgroups 0x%04x\n", cbaf->host_band_groups);
 
        result = usb_control_msg(
index 85a1acf..67b0a4c 100644 (file)
@@ -50,10 +50,9 @@ static ssize_t wusb_cdid_show(struct device *dev,
        wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev));
        if (wusb_dev == NULL)
                return -ENODEV;
-       result = ckhdid_printf(buf, PAGE_SIZE, &wusb_dev->cdid);
-       strcat(buf, "\n");
+       result = sprintf(buf, "%16ph\n", wusb_dev->cdid.data);
        wusb_dev_put(wusb_dev);
-       return result + 1;
+       return result;
 }
 static DEVICE_ATTR_RO(wusb_cdid);
 
index fcb06ae..a93837d 100644 (file)
@@ -532,7 +532,7 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc,
        }
 
        dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr);
-       ckhdid_printf(pr_cdid, sizeof(pr_cdid), &dnc->CDID);
+       sprintf(pr_cdid, "%16ph", dnc->CDID.data);
        dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n",
                 pr_cdid,
                 wusb_dn_connect_prev_dev_addr(dnc),
index e5ba614..d0b404d 100644 (file)
@@ -80,17 +80,13 @@ static ssize_t wusb_chid_show(struct device *dev,
 {
        struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
        const struct wusb_ckhdid *chid;
-       ssize_t result = 0;
 
        if (wusbhc->wuie_host_info != NULL)
                chid = &wusbhc->wuie_host_info->CHID;
        else
                chid = &wusb_ckhdid_zero;
 
-       result += ckhdid_printf(buf, PAGE_SIZE, chid);
-       result += sprintf(buf + result, "\n");
-
-       return result;
+       return sprintf(buf, "%16ph\n", chid->data);
 }
 
 /*
index 9e4a321..65adee6 100644 (file)
@@ -236,22 +236,6 @@ enum {
        WUSB_TRUST_TIMEOUT_MS = 4000,   /* [WUSB] section 4.15.1 */
 };
 
-static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
-                                  const struct wusb_ckhdid *ckhdid)
-{
-       return scnprintf(pr_ckhdid, size,
-                        "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
-                        "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
-                        ckhdid->data[0],  ckhdid->data[1],
-                        ckhdid->data[2],  ckhdid->data[3],
-                        ckhdid->data[4],  ckhdid->data[5],
-                        ckhdid->data[6],  ckhdid->data[7],
-                        ckhdid->data[8],  ckhdid->data[9],
-                        ckhdid->data[10], ckhdid->data[11],
-                        ckhdid->data[12], ckhdid->data[13],
-                        ckhdid->data[14], ckhdid->data[15]);
-}
-
 /*
  * WUSB Crypto stuff (WUSB1.0[6])
  */