wusbcore: add sysfs attribute for DNTS count and interval
authorThomas Pugliese <thomas.pugliese@gmail.com>
Tue, 18 Jun 2013 18:31:25 +0000 (13:31 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Jun 2013 23:19:02 +0000 (16:19 -0700)
This patch adds a sysfs attribute for the wireless USB host controller
device notification transmit slot(DNTS) count and interval.  It also
changes the defaults from 16 slots in every MMC to a more reasonable 4
slots every 2ms.

Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/wusbcore/mmc.c
drivers/usb/wusbcore/wusbhc.c
drivers/usb/wusbcore/wusbhc.h

index b8c7258..021467f 100644 (file)
@@ -214,9 +214,9 @@ int wusbhc_start(struct wusbhc *wusbhc)
                dev_err(dev, "error starting security in the HC: %d\n", result);
                goto error_sec_start;
        }
-       /* FIXME: the choice of the DNTS parameters is somewhat
-        * arbitrary */
-       result = wusbhc->set_num_dnts(wusbhc, 0, 15);
+
+       result = wusbhc->set_num_dnts(wusbhc, wusbhc->dnts_interval,
+               wusbhc->dnts_num_slots);
        if (result < 0) {
                dev_err(dev, "Cannot set DNTS parameters: %d\n", result);
                goto error_set_num_dnts;
index c35ee43..8759aa6 100644 (file)
@@ -175,11 +175,42 @@ static ssize_t wusb_phy_rate_store(struct device *dev,
 }
 static DEVICE_ATTR(wusb_phy_rate, 0644, wusb_phy_rate_show, wusb_phy_rate_store);
 
+static ssize_t wusb_dnts_show(struct device *dev,
+                                 struct device_attribute *attr,
+                                 char *buf)
+{
+       struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
+
+       return sprintf(buf, "num slots: %d\ninterval: %dms\n",
+                       wusbhc->dnts_num_slots, wusbhc->dnts_interval);
+}
+
+static ssize_t wusb_dnts_store(struct device *dev,
+                                  struct device_attribute *attr,
+                                  const char *buf, size_t size)
+{
+       struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
+       uint8_t num_slots, interval;
+       ssize_t result;
+
+       result = sscanf(buf, "%hhu %hhu", &num_slots, &interval);
+
+       if (result != 2)
+               return -EINVAL;
+
+       wusbhc->dnts_num_slots = num_slots;
+       wusbhc->dnts_interval = interval;
+
+       return size;
+}
+static DEVICE_ATTR(wusb_dnts, 0644, wusb_dnts_show, wusb_dnts_store);
+
 /* Group all the WUSBHC attributes */
 static struct attribute *wusbhc_attrs[] = {
                &dev_attr_wusb_trust_timeout.attr,
                &dev_attr_wusb_chid.attr,
                &dev_attr_wusb_phy_rate.attr,
+               &dev_attr_wusb_dnts.attr,
                NULL,
 };
 
@@ -205,8 +236,11 @@ int wusbhc_create(struct wusbhc *wusbhc)
 {
        int result = 0;
 
+       /* set defaults.  These can be overwritten using sysfs attributes. */
        wusbhc->trust_timeout = WUSB_TRUST_TIMEOUT_MS;
        wusbhc->phy_rate = UWB_PHY_RATE_INVALID - 1;
+       wusbhc->dnts_num_slots = 4;
+       wusbhc->dnts_interval = 2;
 
        mutex_init(&wusbhc->mutex);
        result = wusbhc_mmcie_create(wusbhc);
index b4a4fa7..a7069f4 100644 (file)
@@ -252,6 +252,8 @@ struct wusbhc {
        unsigned trust_timeout;                 /* in jiffies */
        struct wusb_ckhdid chid;
        uint8_t phy_rate;
+       uint8_t dnts_num_slots;
+       uint8_t dnts_interval;
        struct wuie_host_info *wuie_host_info;
 
        struct mutex mutex;                     /* locks everything else */