Re: [PATCH] staging: comedi: comedi_fops: coding style fixes

2016-09-09 Thread Ian Abbott

On 08/09/16 19:27, Matias Mucciolo wrote:


- Fixed coding style in comedi_fops.c Symbolic to octal permission.

Signed-off-by: Matias Mucciolo 
---
 drivers/staging/comedi/comedi_fops.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 1999eed..bf922ea 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -81,20 +81,20 @@ struct comedi_file {
(COMEDI_NUM_MINORS - COMEDI_NUM_BOARD_MINORS)

 static int comedi_num_legacy_minors;
-module_param(comedi_num_legacy_minors, int, S_IRUGO);
+module_param(comedi_num_legacy_minors, int, 0444);
 MODULE_PARM_DESC(comedi_num_legacy_minors,
 "number of comedi minor devices to reserve for non-auto-configured 
devices (default 0)"
);

 unsigned int comedi_default_buf_size_kb = CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB;
-module_param(comedi_default_buf_size_kb, uint, S_IRUGO | S_IWUSR);
+module_param(comedi_default_buf_size_kb, uint, 0644);
 MODULE_PARM_DESC(comedi_default_buf_size_kb,
 "default asynchronous buffer size in KiB (default "
 __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB) ")");

 unsigned int comedi_default_buf_maxsize_kb
= CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB;
-module_param(comedi_default_buf_maxsize_kb, uint, S_IRUGO | S_IWUSR);
+module_param(comedi_default_buf_maxsize_kb, uint, 0644);
 MODULE_PARM_DESC(comedi_default_buf_maxsize_kb,
 "default maximum size of asynchronous buffer in KiB (default "
 __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")");



Thanks.  It looks fine.  Personally, I find the octal constants more 
readable, as POSIX octal file permissions have been burned into my brain 
for >30 years now!


Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/9] staging: most: hdm-usb: extend DCI access

2016-09-09 Thread Christian Gromm
This patch extends the direct communication interface ABI of the USB
network interface controller. It is needed to provide applications
arbitrary access to DCI registers and the ability to synchronize the
internal endpoint logic of the controller.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 38 +-
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index 08c4a3b..da47253 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -79,10 +79,12 @@ struct buf_anchor {
  * struct most_dci_obj - Direct Communication Interface
  * @kobj:position in sysfs
  * @usb_device: pointer to the usb device
+ * @reg_addr: register address for arbitrary DCI access
  */
 struct most_dci_obj {
struct kobject kobj;
struct usb_device *usb_device;
+   u16 reg_addr;
 };
 
 #define to_dci_obj(p) container_of(p, struct most_dci_obj, kobj)
@@ -948,6 +950,10 @@ static struct usb_device_id usbid[] = {
struct most_dci_attribute most_dci_attr_##_name = \
__ATTR(_name, S_IRUGO | S_IWUSR, show_value, store_value)
 
+#define MOST_DCI_WO_ATTR(_name) \
+   struct most_dci_attribute most_dci_attr_##_name = \
+   __ATTR(_name, S_IWUSR, show_value, store_value)
+
 /**
  * struct most_dci_attribute - to access the attributes of a dci object
  * @attr: attributes of a dci object
@@ -1031,6 +1037,9 @@ static ssize_t show_value(struct most_dci_obj *dci_obj,
u16 reg_addr;
int err;
 
+   if (!strcmp(attr->attr.name, "arb_address"))
+   return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
+
if (!strcmp(attr->attr.name, "ni_state"))
reg_addr = DRCI_REG_NI_STATE;
else if (!strcmp(attr->attr.name, "packet_bandwidth"))
@@ -1055,6 +1064,8 @@ static ssize_t show_value(struct most_dci_obj *dci_obj,
reg_addr = DRCI_REG_HW_ADDR_MI;
else if (!strcmp(attr->attr.name, "mep_eui48_lo"))
reg_addr = DRCI_REG_HW_ADDR_LO;
+   else if (!strcmp(attr->attr.name, "arb_value"))
+   reg_addr = dci_obj->reg_addr;
else
return -EIO;
 
@@ -1073,6 +1084,14 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
u16 reg_addr;
int err;
 
+   err = kstrtou16(buf, 16, &val);
+   if (err)
+   return err;
+
+   if (!strcmp(attr->attr.name, "arb_address")) {
+   dci_obj->reg_addr = val;
+   return count;
+   }
if (!strcmp(attr->attr.name, "mep_filter"))
reg_addr = DRCI_REG_MEP_FILTER;
else if (!strcmp(attr->attr.name, "mep_hash0"))
@@ -1089,13 +1108,16 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
reg_addr = DRCI_REG_HW_ADDR_MI;
else if (!strcmp(attr->attr.name, "mep_eui48_lo"))
reg_addr = DRCI_REG_HW_ADDR_LO;
-   else
+   else if (!strcmp(attr->attr.name, "arb_value"))
+   reg_addr = dci_obj->reg_addr;
+   else if (!strcmp(attr->attr.name, "sync_ep")) {
+   u16 ep = val;
+
+   reg_addr = DRCI_REG_BASE + DRCI_COMMAND + ep * 16;
+   val = 1;
+   } else
return -EIO;
 
-   err = kstrtou16(buf, 16, &val);
-   if (err)
-   return err;
-
err = drci_wr_reg(dci_obj->usb_device, reg_addr, val);
if (err < 0)
return err;
@@ -1107,6 +1129,7 @@ static MOST_DCI_RO_ATTR(ni_state);
 static MOST_DCI_RO_ATTR(packet_bandwidth);
 static MOST_DCI_RO_ATTR(node_address);
 static MOST_DCI_RO_ATTR(node_position);
+static MOST_DCI_WO_ATTR(sync_ep);
 static MOST_DCI_ATTR(mep_filter);
 static MOST_DCI_ATTR(mep_hash0);
 static MOST_DCI_ATTR(mep_hash1);
@@ -1115,6 +1138,8 @@ static MOST_DCI_ATTR(mep_hash3);
 static MOST_DCI_ATTR(mep_eui48_hi);
 static MOST_DCI_ATTR(mep_eui48_mi);
 static MOST_DCI_ATTR(mep_eui48_lo);
+static MOST_DCI_ATTR(arb_address);
+static MOST_DCI_ATTR(arb_value);
 
 /**
  * most_dci_def_attrs - array of default attribute files of the dci object
@@ -1124,6 +1149,7 @@ static struct attribute *most_dci_def_attrs[] = {
&most_dci_attr_packet_bandwidth.attr,
&most_dci_attr_node_address.attr,
&most_dci_attr_node_position.attr,
+   &most_dci_attr_sync_ep.attr,
&most_dci_attr_mep_filter.attr,
&most_dci_attr_mep_hash0.attr,
&most_dci_attr_mep_hash1.attr,
@@ -1132,6 +1158,8 @@ static struct attribute *most_dci_def_attrs[] = {
&most_dci_attr_mep_eui48_hi.attr,
&most_dci_attr_mep_eui48_mi.attr,
&most_dci_attr_mep_eui48_lo.attr,
+   &most_dci_attr_arb_address.attr,
+   &most_dci_attr_arb_value.attr,
NULL,
 };
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://drive

[PATCH 2/9] staging: most: hdm-usb: use defined error codes

2016-09-09 Thread Christian Gromm
This patch replaces return values with defined error codes to indicate
an exception.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index da47253..5d62d1b 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -801,17 +801,17 @@ static int hdm_update_netinfo(struct most_dev *mdev)
if (!is_valid_ether_addr(mdev->hw_addr)) {
if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) {
dev_err(dev, "Vendor request \"hw_addr_hi\" failed\n");
-   return -1;
+   return -EFAULT;
}
 
if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) {
dev_err(dev, "Vendor request \"hw_addr_mid\" failed\n");
-   return -1;
+   return -EFAULT;
}
 
if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) {
dev_err(dev, "Vendor request \"hw_addr_low\" failed\n");
-   return -1;
+   return -EFAULT;
}
 
mutex_lock(&mdev->io_mutex);
@@ -826,7 +826,7 @@ static int hdm_update_netinfo(struct most_dev *mdev)
 
if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) {
dev_err(dev, "Vendor request \"link status\" failed\n");
-   return -1;
+   return -EFAULT;
}
 
mutex_lock(&mdev->io_mutex);
@@ -1116,7 +1116,7 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
reg_addr = DRCI_REG_BASE + DRCI_COMMAND + ep * 16;
val = 1;
} else
-   return -EIO;
+   return -EFAULT;
 
err = drci_wr_reg(dci_obj->usb_device, reg_addr, val);
if (err < 0)
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/9] staging: most: fix issues of hdm-usb

2016-09-09 Thread Christian Gromm
This patchset is needed to fix issues of hdm-usb module.

Andrey Shvetsov (3):
  staging: most: hdm-usb: unify returned errors
  staging: most: hdm-usb: initialize variables by declaration
  staging: most: hdm-usb: remove reference to read function in write
only macro

Christian Gromm (6):
  staging: most: hdm-usb: extend DCI access
  staging: most: hdm-usb: use defined error codes
  staging: most: Documentation: update ABI description
  staging: most: hdm-usb: replace if-else branches with lookup table
  staging: most: hdm-usb: unify variable names
  staging: most: hdm-usb: remove repeated access to structure

 .../most/Documentation/ABI/sysfs-class-most.txt| 134 +++
 drivers/staging/most/hdm-usb/hdm_usb.c | 148 +
 2 files changed, 224 insertions(+), 58 deletions(-)

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/9] staging: most: hdm-usb: unify returned errors

2016-09-09 Thread Christian Gromm
From: Andrey Shvetsov 

This patch is needed to return the same error codes for the same error
cases in the functions show_value() and store_value().

Signed-off-by: Andrey Shvetsov 
Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index 203c4a4..b3abab6 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -1083,7 +1083,7 @@ static ssize_t show_value(struct most_dci_obj *dci_obj,
reg_addr = dci_obj->reg_addr;
else if (get_static_reg_addr(ro_regs, attr->attr.name, ®_addr) &&
 get_static_reg_addr(rw_regs, attr->attr.name, ®_addr))
-   return -EIO;
+   return -EFAULT;
 
err = drci_rd_reg(dci_obj->usb_device, reg_addr, &tmp_val);
if (err < 0)
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/9] staging: most: hdm-usb: replace if-else branches with lookup table

2016-09-09 Thread Christian Gromm
This patch removes a series of if-else-if conditions with a lookup table.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 93 +-
 1 file changed, 47 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index 5d62d1b..203c4a4 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -1030,6 +1030,46 @@ static void most_dci_release(struct kobject *kobj)
kfree(dci_obj);
 }
 
+struct regs {
+   const char *name;
+   u16 reg;
+};
+
+static const struct regs ro_regs[] = {
+   { "ni_state", DRCI_REG_NI_STATE },
+   { "packet_bandwidth", DRCI_REG_PACKET_BW },
+   { "node_address", DRCI_REG_NODE_ADDR },
+   { "node_position", DRCI_REG_NODE_POS },
+};
+
+static const struct regs rw_regs[] = {
+   { "mep_filter", DRCI_REG_MEP_FILTER },
+   { "mep_hash0", DRCI_REG_HASH_TBL0 },
+   { "mep_hash1", DRCI_REG_HASH_TBL1 },
+   { "mep_hash2", DRCI_REG_HASH_TBL2 },
+   { "mep_hash3", DRCI_REG_HASH_TBL3 },
+   { "mep_eui48_hi", DRCI_REG_HW_ADDR_HI },
+   { "mep_eui48_mi", DRCI_REG_HW_ADDR_MI },
+   { "mep_eui48_lo", DRCI_REG_HW_ADDR_LO },
+};
+
+static int get_stat_reg_addr(const struct regs *regs, int size,
+const char *name, u16 *reg_addr)
+{
+   int i;
+
+   for (i = 0; i < size; i++) {
+   if (!strcmp(name, regs[i].name)) {
+   *reg_addr = regs[i].reg;
+   return 0;
+   }
+   }
+   return -EFAULT;
+}
+
+#define get_static_reg_addr(regs, name, reg_addr) \
+   get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr)
+
 static ssize_t show_value(struct most_dci_obj *dci_obj,
  struct most_dci_attribute *attr, char *buf)
 {
@@ -1039,34 +1079,10 @@ static ssize_t show_value(struct most_dci_obj *dci_obj,
 
if (!strcmp(attr->attr.name, "arb_address"))
return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
-
-   if (!strcmp(attr->attr.name, "ni_state"))
-   reg_addr = DRCI_REG_NI_STATE;
-   else if (!strcmp(attr->attr.name, "packet_bandwidth"))
-   reg_addr = DRCI_REG_PACKET_BW;
-   else if (!strcmp(attr->attr.name, "node_address"))
-   reg_addr = DRCI_REG_NODE_ADDR;
-   else if (!strcmp(attr->attr.name, "node_position"))
-   reg_addr = DRCI_REG_NODE_POS;
-   else if (!strcmp(attr->attr.name, "mep_filter"))
-   reg_addr = DRCI_REG_MEP_FILTER;
-   else if (!strcmp(attr->attr.name, "mep_hash0"))
-   reg_addr = DRCI_REG_HASH_TBL0;
-   else if (!strcmp(attr->attr.name, "mep_hash1"))
-   reg_addr = DRCI_REG_HASH_TBL1;
-   else if (!strcmp(attr->attr.name, "mep_hash2"))
-   reg_addr = DRCI_REG_HASH_TBL2;
-   else if (!strcmp(attr->attr.name, "mep_hash3"))
-   reg_addr = DRCI_REG_HASH_TBL3;
-   else if (!strcmp(attr->attr.name, "mep_eui48_hi"))
-   reg_addr = DRCI_REG_HW_ADDR_HI;
-   else if (!strcmp(attr->attr.name, "mep_eui48_mi"))
-   reg_addr = DRCI_REG_HW_ADDR_MI;
-   else if (!strcmp(attr->attr.name, "mep_eui48_lo"))
-   reg_addr = DRCI_REG_HW_ADDR_LO;
-   else if (!strcmp(attr->attr.name, "arb_value"))
+   if (!strcmp(attr->attr.name, "arb_value"))
reg_addr = dci_obj->reg_addr;
-   else
+   else if (get_static_reg_addr(ro_regs, attr->attr.name, ®_addr) &&
+get_static_reg_addr(rw_regs, attr->attr.name, ®_addr))
return -EIO;
 
err = drci_rd_reg(dci_obj->usb_device, reg_addr, &tmp_val);
@@ -1092,31 +1108,16 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
dci_obj->reg_addr = val;
return count;
}
-   if (!strcmp(attr->attr.name, "mep_filter"))
-   reg_addr = DRCI_REG_MEP_FILTER;
-   else if (!strcmp(attr->attr.name, "mep_hash0"))
-   reg_addr = DRCI_REG_HASH_TBL0;
-   else if (!strcmp(attr->attr.name, "mep_hash1"))
-   reg_addr = DRCI_REG_HASH_TBL1;
-   else if (!strcmp(attr->attr.name, "mep_hash2"))
-   reg_addr = DRCI_REG_HASH_TBL2;
-   else if (!strcmp(attr->attr.name, "mep_hash3"))
-   reg_addr = DRCI_REG_HASH_TBL3;
-   else if (!strcmp(attr->attr.name, "mep_eui48_hi"))
-   reg_addr = DRCI_REG_HW_ADDR_HI;
-   else if (!strcmp(attr->attr.name, "mep_eui48_mi"))
-   reg_addr = DRCI_REG_HW_ADDR_MI;
-   else if (!strcmp(attr->attr.name, "mep_eui48_lo"))
-   reg_addr = DRCI_REG_HW_ADDR_LO;
-   else if (!strcmp(attr->attr.name, "arb_value"))
+   if (!strcmp(attr->attr.name, "arb_value")) {
reg_addr = dci_obj->reg_addr;
-   else if (!strcmp(attr->attr.name, "sync_ep")) {
+   

[PATCH 9/9] staging: most: hdm-usb: remove repeated access to structure

2016-09-09 Thread Christian Gromm
This patch removes the repeated access to a struct member by assigning
its value to a local variable once.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index a01b0e6..2ea1488 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -1073,16 +1073,18 @@ static int get_stat_reg_addr(const struct regs *regs, 
int size,
 static ssize_t show_value(struct most_dci_obj *dci_obj,
  struct most_dci_attribute *attr, char *buf)
 {
+   const char *name = attr->attr.name;
u16 val;
u16 reg_addr;
int err;
 
-   if (!strcmp(attr->attr.name, "arb_address"))
+   if (!strcmp(name, "arb_address"))
return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
-   if (!strcmp(attr->attr.name, "arb_value"))
+
+   if (!strcmp(name, "arb_value"))
reg_addr = dci_obj->reg_addr;
-   else if (get_static_reg_addr(ro_regs, attr->attr.name, ®_addr) &&
-get_static_reg_addr(rw_regs, attr->attr.name, ®_addr))
+   else if (get_static_reg_addr(ro_regs, name, ®_addr) &&
+get_static_reg_addr(rw_regs, name, ®_addr))
return -EFAULT;
 
err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
@@ -1098,23 +1100,25 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
 {
u16 val;
u16 reg_addr;
+   const char *name = attr->attr.name;
int err = kstrtou16(buf, 16, &val);
 
if (err)
return err;
 
-   if (!strcmp(attr->attr.name, "arb_address")) {
+   if (!strcmp(name, "arb_address")) {
dci_obj->reg_addr = val;
return count;
}
-   if (!strcmp(attr->attr.name, "arb_value")) {
+
+   if (!strcmp(name, "arb_value")) {
reg_addr = dci_obj->reg_addr;
-   } else if (!strcmp(attr->attr.name, "sync_ep")) {
+   } else if (!strcmp(name, "sync_ep")) {
u16 ep = val;
 
reg_addr = DRCI_REG_BASE + DRCI_COMMAND + ep * 16;
val = 1;
-   } else if (get_static_reg_addr(ro_regs, attr->attr.name, ®_addr)) {
+   } else if (get_static_reg_addr(ro_regs, name, ®_addr)) {
return -EFAULT;
}
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/9] staging: most: Documentation: update ABI description

2016-09-09 Thread Christian Gromm
This patch updates the ABI description file to reflect the latest changes
of the interface.

Signed-off-by: Christian Gromm 
---
 .../most/Documentation/ABI/sysfs-class-most.txt| 134 +
 1 file changed, 134 insertions(+)

diff --git a/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt 
b/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
index 42ff0d8..48aa45a 100644
--- a/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
+++ b/drivers/staging/most/Documentation/ABI/sysfs-class-most.txt
@@ -51,6 +51,140 @@ Description:
uses.
 Users:
 
+What:  /sys/class/most/mostcore/devices//dci
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   If the network interface controller is attached via USB, a dci
+   directory is created that allows applications to use the
+   controller's direct communication interface (DCI) to exchange
+   information.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/arb_address
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to set an arbitrary DCI register address an
+   application wants to read from or write to.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/arb_value
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to read from or write to the arbitrary DCI register
+   whose address is stored in arb_address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_eui48_hi
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_eui48_lo
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_eui48_mi
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MAC address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_filter
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP filter address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_hash0
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_hash1
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_hash2
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/mep_hash3
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   This is used to check and configure the MEP hash table.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/ni_state
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   Indicates the current network interface state.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/node_address
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   Indicates the current node address.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/node_position
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   Indicates the current node position.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/packet_bandwidth
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   Indicates the configured packet bandwidth.
+Users:
+
+What:  /sys/class/most/mostcore/devices//dci/sync_ep
+Date:  June 2016
+KernelVersion: 4.9
+Contact:   Christian Gromm 
+Description:
+   Triggers the controller's synchronization process for a certain
+   endpoint.
+Users:
+
 What:  /sys/class/most/mostcore/devices///
 Date:  June 2015
 KernelVersion: 4.3
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-d

[PATCH 8/9] staging: most: hdm-usb: remove reference to read function in write only macro

2016-09-09 Thread Christian Gromm
From: Andrey Shvetsov 

This patch replaces the reference to the function show_value() with
NULL in the macro MOST_DCI_WO_ATTR used for the write only attributes.

Signed-off-by: Andrey Shvetsov 
Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index 990a03e..a01b0e6 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -952,7 +952,7 @@ static struct usb_device_id usbid[] = {
 
 #define MOST_DCI_WO_ATTR(_name) \
struct most_dci_attribute most_dci_attr_##_name = \
-   __ATTR(_name, S_IWUSR, show_value, store_value)
+   __ATTR(_name, S_IWUSR, NULL, store_value)
 
 /**
  * struct most_dci_attribute - to access the attributes of a dci object
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 7/9] staging: most: hdm-usb: initialize variables by declaration

2016-09-09 Thread Christian Gromm
From: Andrey Shvetsov 

This patch moves initialization of the variables to the declaration
where possible.

Signed-off-by: Andrey Shvetsov 
Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index 744c8d5..990a03e 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -326,10 +326,10 @@ static int hdm_poison_channel(struct most_interface 
*iface, int channel)
 static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
 {
struct most_channel_config *conf = &mdev->conf[channel];
-   unsigned int j, num_frames, frame_size;
+   unsigned int frame_size = get_stream_frame_size(conf);
+   unsigned int j, num_frames;
u16 rd_addr, wr_addr;
 
-   frame_size = get_stream_frame_size(conf);
if (!frame_size)
return -EIO;
num_frames = mbo->buffer_length / frame_size;
@@ -363,10 +363,10 @@ static int hdm_add_padding(struct most_dev *mdev, int 
channel, struct mbo *mbo)
 static int hdm_remove_padding(struct most_dev *mdev, int channel,
  struct mbo *mbo)
 {
-   unsigned int j, num_frames, frame_size;
struct most_channel_config *const conf = &mdev->conf[channel];
+   unsigned int frame_size = get_stream_frame_size(conf);
+   unsigned int j, num_frames;
 
-   frame_size = get_stream_frame_size(conf);
if (!frame_size)
return -EIO;
num_frames = mbo->processed_length / USB_MTU;
@@ -1098,9 +1098,8 @@ static ssize_t store_value(struct most_dci_obj *dci_obj,
 {
u16 val;
u16 reg_addr;
-   int err;
+   int err = kstrtou16(buf, 16, &val);
 
-   err = kstrtou16(buf, 16, &val);
if (err)
return err;
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/9] staging: most: hdm-usb: unify variable names

2016-09-09 Thread Christian Gromm
This patch is needed to have the same variable name for the same quantity
in the functions show_value() and store_value().

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
b/drivers/staging/most/hdm-usb/hdm_usb.c
index b3abab6..744c8d5 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -1073,7 +1073,7 @@ static int get_stat_reg_addr(const struct regs *regs, int 
size,
 static ssize_t show_value(struct most_dci_obj *dci_obj,
  struct most_dci_attribute *attr, char *buf)
 {
-   u16 tmp_val;
+   u16 val;
u16 reg_addr;
int err;
 
@@ -1085,11 +1085,11 @@ static ssize_t show_value(struct most_dci_obj *dci_obj,
 get_static_reg_addr(rw_regs, attr->attr.name, ®_addr))
return -EFAULT;
 
-   err = drci_rd_reg(dci_obj->usb_device, reg_addr, &tmp_val);
+   err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
if (err < 0)
return err;
 
-   return snprintf(buf, PAGE_SIZE, "%04x\n", tmp_val);
+   return snprintf(buf, PAGE_SIZE, "%04x\n", val);
 }
 
 static ssize_t store_value(struct most_dci_obj *dci_obj,
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: lustre: lustre: obdclass: Modify return statement

2016-09-09 Thread Anchal Jain
Modify the return statement.
The Coccinelle semantic patch used to make this change is as follows:

@@
expression e, ret;
@@

-ret =
+return
 e;
-return ret;

Delete the declaration of the return variable rc, as it is no longer used.

Signed-off-by: Anchal Jain 
---
 drivers/staging/lustre/lustre/obdclass/llog_cat.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c 
b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index c27d4ec..55f625f 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -127,7 +127,6 @@ out:
 int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle)
 {
struct llog_handle  *loghandle, *n;
-   int  rc;
 
list_for_each_entry_safe(loghandle, n, &cathandle->u.chd.chd_head,
 u.phd.phd_entry) {
@@ -138,8 +137,7 @@ int llog_cat_close(const struct lu_env *env, struct 
llog_handle *cathandle)
/* if handle was stored in ctxt, remove it too */
if (cathandle->lgh_ctxt->loc_handle == cathandle)
cathandle->lgh_ctxt->loc_handle = NULL;
-   rc = llog_close(env, cathandle);
-   return rc;
+   return llog_close(env, cathandle);
 }
 EXPORT_SYMBOL(llog_cat_close);
 
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] rtlbt: Add RTL8822BE Bluetooth device

2016-09-09 Thread Larry Finger
The RTL8822BE is a new Realtek wifi and BT device. Support for the BT
part is hereby added.

As this device is similar to most of the other Realtek BT devices, the
changes are minimal. The main difference is that the 8822BE needs a
configuration file for enabling and disabling features. Thus code is
added to select and load this configuration file. Although not needed
at the moment, hooks are added for the other devices that might need
such configuration files.

One additional change is to the routine that tests that the project
ID contained in the firmware matches the hardware. As the project IDs
are not sequential, continuing to use the position in the array as the
expected value of the ID would require adding extra unused entries in
the table, and any subsequant rearrangment of the array would break the
code. To fix these problems, the array elements now contain both the
hardware ID and the expected value for the project ID.

Signed-off-by: 陆朱伟 
Signed-off-by: Larry Finger 
---
 drivers/bluetooth/btrtl.c | 104 --
 drivers/bluetooth/btrtl.h |   5 +++
 2 files changed, 97 insertions(+), 12 deletions(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 8428893..cb73863 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -33,6 +33,7 @@
 #define RTL_ROM_LMP_8723B  0x8723
 #define RTL_ROM_LMP_8821A  0x8821
 #define RTL_ROM_LMP_8761A  0x8761
+#define RTL_ROM_LMP_8822B  0x8822
 
 static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version)
 {
@@ -78,11 +79,12 @@ static int rtl8723b_parse_firmware(struct hci_dev *hdev, 
u16 lmp_subver,
const unsigned char *patch_length_base, *patch_offset_base;
u32 patch_offset = 0;
u16 patch_length, num_patches;
-   const u16 project_id_to_lmp_subver[] = {
-   RTL_ROM_LMP_8723A,
-   RTL_ROM_LMP_8723B,
-   RTL_ROM_LMP_8821A,
-   RTL_ROM_LMP_8761A
+   const struct lmp_subver project_id_to_lmp_subver[] = {
+   {RTL_ROM_LMP_8723A, 0},
+   {RTL_ROM_LMP_8723B, 1},
+   {RTL_ROM_LMP_8821A, 2},
+   {RTL_ROM_LMP_8761A, 3},
+   {RTL_ROM_LMP_8822B, 8},
};
 
ret = rtl_read_rom_version(hdev, &rom_version);
@@ -134,14 +136,20 @@ static int rtl8723b_parse_firmware(struct hci_dev *hdev, 
u16 lmp_subver,
return -EINVAL;
}
 
-   if (project_id >= ARRAY_SIZE(project_id_to_lmp_subver)) {
+   /* Find project_id in table */
+   for (i = 0; i < ARRAY_SIZE(project_id_to_lmp_subver); i++) {
+   if (project_id == project_id_to_lmp_subver[i].id)
+   break;
+   }
+
+   if (i >= ARRAY_SIZE(project_id_to_lmp_subver)) {
BT_ERR("%s: unknown project id %d", hdev->name, project_id);
return -EINVAL;
}
 
-   if (lmp_subver != project_id_to_lmp_subver[project_id]) {
+   if (lmp_subver != project_id_to_lmp_subver[i].lmp_subver) {
BT_ERR("%s: firmware is for %x but this is a %x", hdev->name,
-  project_id_to_lmp_subver[project_id], lmp_subver);
+  project_id_to_lmp_subver[i].lmp_subver, lmp_subver);
return -EINVAL;
}
 
@@ -257,6 +265,26 @@ out:
return ret;
 }
 
+static int rtl_load_config(struct hci_dev *hdev, const char *name, u8 **buff)
+{
+   const struct firmware *fw;
+   int ret;
+
+   BT_INFO("%s: rtl: loading %s", hdev->name, name);
+   ret = request_firmware(&fw, name, &hdev->dev);
+   if (ret < 0) {
+   BT_ERR("%s: Failed to load %s", hdev->name, name);
+   return ret;
+   }
+
+   ret = fw->size;
+   *buff = kmemdup(fw->data, ret, GFP_KERNEL);
+
+   release_firmware(fw);
+
+   return ret;
+}
+
 static int btrtl_setup_rtl8723a(struct hci_dev *hdev)
 {
const struct firmware *fw;
@@ -296,25 +324,74 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, u16 
lmp_subver,
unsigned char *fw_data = NULL;
const struct firmware *fw;
int ret;
+   int cfg_sz;
+   u8 *cfg_buff = NULL;
+   u8 *tbuff;
+   char *cfg_name = NULL;
+
+   switch (lmp_subver) {
+   case RTL_ROM_LMP_8723B:
+   cfg_name = "rtl_bt/rtl8723b_config.bin";
+   break;
+   case RTL_ROM_LMP_8821A:
+   cfg_name = "rtl_bt/rtl8821a_config.bin";
+   break;
+   case RTL_ROM_LMP_8761A:
+   cfg_name = "rtl_bt/rtl8761a_config.bin";
+   break;
+   case RTL_ROM_LMP_8822B:
+   cfg_name = "rtl_bt/rtl8822b_config.bin";
+   break;
+   default:
+   BT_ERR("%s: rtl: no config according to lmp_subver %04x",
+  hdev->name, lmp_subver);
+   break;
+   }
+
+   if (cfg_name) {
+   cfg_sz = rtl_load_config(hdev, c

[PATCH] staging: lustre: lustre/ldlm: Fixed sparse warnings

2016-09-09 Thread Nayeemahmed Badebade
Added __acquires / __releases sparse locking annotations
to lock_res_and_lock and unlock_res_and_lock functions in
l_lock.c, to fix below sparse warnings:

 l_lock.c:47:22: warning: context imbalance in 'lock_res_and_lock' - wrong 
count at exit
 l_lock.c:62:6: warning: context imbalance in 'unlock_res_and_lock' - 
unexpected unlock

Signed-off-by: Nayeemahmed Badebade 
---
 drivers/staging/lustre/lustre/ldlm/l_lock.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c 
b/drivers/staging/lustre/lustre/ldlm/l_lock.c
index ea8840c..c4b9612 100644
--- a/drivers/staging/lustre/lustre/ldlm/l_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c
@@ -45,6 +45,8 @@
  * being an atomic operation.
  */
 struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock)
+   __acquires(&lock->l_lock)
+   __acquires(lock->l_resource)
 {
spin_lock(&lock->l_lock);

@@ -59,6 +61,8 @@ EXPORT_SYMBOL(lock_res_and_lock);
  * Unlock a lock and its resource previously locked with lock_res_and_lock
  */
 void unlock_res_and_lock(struct ldlm_lock *lock)
+   __releases(lock->l_resource)
+   __releases(&lock->l_lock)
 {
/* on server-side resource of lock doesn't change */
ldlm_clear_res_locked(lock);
--
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-09 Thread Todd Kjos
From: Todd Kjos 

In Android systems, the display pipeline relies on low
latency binder transactions and is therefore sensitive to
delays caused by contention for the global binder lock.
Jank is significantly reduced by disabling preemption
while the global binder lock is held.

This patch was originated by Riley Andrews 
with tweaks and forward-porting by me.

Originally-from: Riley Andrews 
Signed-off-by: Todd Kjos 
---
 drivers/android/binder.c | 194 +++
 1 file changed, 146 insertions(+), 48 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 16288e7..c36e420 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -379,6 +379,7 @@ static int task_get_unused_fd_flags(struct binder_proc 
*proc, int flags)
struct files_struct *files = proc->files;
unsigned long rlim_cur;
unsigned long irqs;
+   int ret;
 
if (files == NULL)
return -ESRCH;
@@ -389,7 +390,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
*proc, int flags)
rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
unlock_task_sighand(proc->tsk, &irqs);
 
-   return __alloc_fd(files, 0, rlim_cur, flags);
+   preempt_enable_no_resched();
+   ret = __alloc_fd(files, 0, rlim_cur, flags);
+   preempt_disable();
+
+   return ret;
 }
 
 /*
@@ -398,8 +403,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
*proc, int flags)
 static void task_fd_install(
struct binder_proc *proc, unsigned int fd, struct file *file)
 {
-   if (proc->files)
+   if (proc->files) {
+   preempt_enable_no_resched();
__fd_install(proc->files, fd, file);
+   preempt_disable();
+   }
 }
 
 /*
@@ -427,6 +435,7 @@ static inline void binder_lock(const char *tag)
 {
trace_binder_lock(tag);
mutex_lock(&binder_main_lock);
+   preempt_disable();
trace_binder_locked(tag);
 }
 
@@ -434,8 +443,65 @@ static inline void binder_unlock(const char *tag)
 {
trace_binder_unlock(tag);
mutex_unlock(&binder_main_lock);
+   preempt_enable();
+}
+
+static inline void *kzalloc_nopreempt(size_t size)
+{
+   void *ptr;
+
+   ptr = kzalloc(size, GFP_NOWAIT);
+   if (ptr)
+   return ptr;
+
+   preempt_enable_no_resched();
+   ptr = kzalloc(size, GFP_KERNEL);
+   preempt_disable();
+
+   return ptr;
+}
+
+static inline long copy_to_user_nopreempt(void __user *to,
+ const void *from, long n)
+{
+   long ret;
+
+   preempt_enable_no_resched();
+   ret = copy_to_user(to, from, n);
+   preempt_disable();
+   return ret;
+}
+
+static inline long copy_from_user_nopreempt(void *to,
+   const void __user *from,
+   long n)
+{
+   long ret;
+
+   preempt_enable_no_resched();
+   ret = copy_from_user(to, from, n);
+   preempt_disable();
+   return ret;
 }
 
+#define get_user_nopreempt(x, ptr) \
+({ \
+   int __ret;  \
+   preempt_enable_no_resched();\
+   __ret = get_user(x, ptr);   \
+   preempt_disable();  \
+   __ret;  \
+})
+
+#define put_user_nopreempt(x, ptr) \
+({ \
+   int __ret;  \
+   preempt_enable_no_resched();\
+   __ret = put_user(x, ptr);   \
+   preempt_disable();  \
+   __ret;  \
+})
+
 static void binder_set_nice(long nice)
 {
long min_nice;
@@ -568,6 +634,8 @@ static int binder_update_page_range(struct binder_proc 
*proc, int allocate,
else
mm = get_task_mm(proc->tsk);
 
+   preempt_enable_no_resched();
+
if (mm) {
down_write(&mm->mmap_sem);
vma = proc->vma;
@@ -622,6 +690,9 @@ static int binder_update_page_range(struct binder_proc 
*proc, int allocate,
up_write(&mm->mmap_sem);
mmput(mm);
}
+
+   preempt_disable();
+
return 0;
 
 free_range:
@@ -644,6 +715,9 @@ err_no_vma:
up_write(&mm->mmap_sem);
mmput(mm);
}
+
+   preempt_disable();
+
return -ENOMEM;
 }
 
@@ -903,7 +977,7 @@ static struct binder_node *binder_new_node(struct 
binder_proc *proc,
return NULL;
}
 
-   node = kzalloc(sizeof(*node), GFP_KERNEL);
+   node = kzalloc_nopreempt(sizeof(*node));
if (node == NULL)
return NULL;
binder_stats_created(BINDER_STAT_NODE);
@@ -1040,7 +1114,7 @@ static struct binder_ref *binder_get_ref_for_node(struct 
binder_proc *proc

[PATCH staging/rtl8712] staging: rtl8712: checkpatch cleanup: block comments using a trailing */

2016-09-09 Thread Raphaël Beamonte
Fix checkpatch.pl warning "Block comments use a trailing */ on
a separate line" on multiple files of the driver by editing the
affected comments.

Signed-off-by: Raphaël Beamonte 
---
 drivers/staging/rtl8712/rtl8712_led.c   | 12 --
 drivers/staging/rtl8712/rtl8712_recv.c  | 54 -
 drivers/staging/rtl8712/rtl8712_recv.h  |  3 +-
 drivers/staging/rtl8712/rtl8712_spec.h  |  3 +-
 drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h | 27 -
 drivers/staging/rtl8712/rtl8712_xmit.c  |  9 +++--
 drivers/staging/rtl8712/rtl871x_cmd.h   |  9 +++--
 drivers/staging/rtl8712/rtl871x_ht.h|  3 +-
 drivers/staging/rtl8712/rtl871x_ioctl.h |  3 +-
 drivers/staging/rtl8712/rtl871x_ioctl_set.c | 12 --
 drivers/staging/rtl8712/rtl871x_led.h   | 15 ---
 drivers/staging/rtl8712/rtl871x_mlme.c  | 30 +-
 drivers/staging/rtl8712/rtl871x_mlme.h  | 12 --
 drivers/staging/rtl8712/rtl871x_mp.c|  3 +-
 drivers/staging/rtl8712/rtl871x_mp.h|  3 +-
 drivers/staging/rtl8712/rtl871x_mp_ioctl.h  | 39 --
 drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h | 33 ++-
 drivers/staging/rtl8712/rtl871x_pwrctrl.c   |  3 +-
 drivers/staging/rtl8712/rtl871x_pwrctrl.h   |  3 +-
 drivers/staging/rtl8712/rtl871x_recv.c  | 24 +++
 drivers/staging/rtl8712/rtl871x_recv.h  |  9 +++--
 drivers/staging/rtl8712/rtl871x_security.h  | 24 +++
 drivers/staging/rtl8712/rtl871x_sta_mgt.c   |  3 +-
 drivers/staging/rtl8712/rtl871x_xmit.c  | 18 ++---
 drivers/staging/rtl8712/rtl871x_xmit.h  | 12 --
 drivers/staging/rtl8712/usb_halinit.c   |  3 +-
 drivers/staging/rtl8712/usb_intf.c  | 12 --
 drivers/staging/rtl8712/wifi.h  | 15 ---
 drivers/staging/rtl8712/wlan_bssdef.h   |  6 ++-
 29 files changed, 268 insertions(+), 134 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_led.c 
b/drivers/staging/rtl8712/rtl8712_led.c
index 9055827..76d0535 100644
--- a/drivers/staging/rtl8712/rtl8712_led.c
+++ b/drivers/staging/rtl8712/rtl8712_led.c
@@ -58,10 +58,12 @@ enum _LED_STATE_871x {
LED_POWER_ON_BLINK = 5,
LED_SCAN_BLINK = 6, /* LED is blinking during scanning period,
 * the # of times to blink is depend on time
-* for scanning. */
+* for scanning.
+*/
LED_NO_LINK_BLINK = 7, /* LED is blinking during no link state. */
LED_BLINK_StartToBlink = 8,/* Customized for Sercomm Printer
-   * Server case */
+   * Server case
+   */
LED_BLINK_WPS = 9,  /* LED is blinkg during WPS communication */
LED_TXRX_BLINK = 10,
LED_BLINK_WPS_STOP = 11,/*for ALPHA */
@@ -110,7 +112,8 @@ static void DeInitLed871x(struct LED_871x *pLed)
 {
del_timer_sync(&pLed->BlinkTimer);
/* We should reset bLedBlinkInProgress if we cancel
-* the LedControlTimer, */
+* the LedControlTimer,
+*/
pLed->bLedBlinkInProgress = false;
 }
 
@@ -827,7 +830,8 @@ static void BlinkTimerCallback(unsigned long data)
struct LED_871x  *pLed = (struct LED_871x *)data;
 
/* This fixed the crash problem on Fedora 12 when trying to do the
-* insmod;ifconfig up;rmmod commands. */
+* insmod;ifconfig up;rmmod commands.
+*/
if (pLed->padapter->bSurpriseRemoved || pLed->padapter->bDriverStopped)
return;
schedule_work(&pLed->BlinkWorkItem);
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c 
b/drivers/staging/rtl8712/rtl8712_recv.c
index f25b34c..4027d1a 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -163,7 +163,8 @@ static void update_recvframe_attrib_from_recvstat(struct 
rx_pkt_attrib *pattrib,
drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f) >> 16;
drvinfo_sz <<= 3;
/*TODO:
-* Offset 0 */
+* Offset 0
+*/
pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27)
 ? 0 : 1;
pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14;
@@ -210,7 +211,8 @@ static union recv_frame *recvframe_defrag(struct _adapter 
*adapter,
curfragnum = 0;
if (curfragnum != pfhdr->attrib.frag_num) {
/*the first fragment number must be 0
-*free the whole queue*/
+*free the whole queue
+*/
r8712_free_recvframe(prframe, pfree_recv_queue);
r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
return NULL;
@@ -224,18 +226,21 @@ static union rec

[PATCH] staging: dgnc: dgnc_sysfs *_ATTR() macros convert

2016-09-09 Thread Matias Mucciolo

Convert DRIVER_ATTR() macro with DRIVER_ATTR_RO/RW and
DEVICE_ATTR() macro with DEVICE_ATTR_RO()

Signed-off-by: Matias Mucciolo 
---
 drivers/staging/dgnc/dgnc_sysfs.c | 183 +++---
 1 file changed, 90 insertions(+), 93 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_sysfs.c 
b/drivers/staging/dgnc/dgnc_sysfs.c
index b8d41c5..a83e0e4 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -25,31 +25,31 @@
 #include "dgnc_driver.h"
 #include "dgnc_mgmt.h"
 
-static ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf)
+static ssize_t version_show(struct device_driver *ddp, char *buf)
 {
return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART);
 }
-static DRIVER_ATTR(version, S_IRUSR, dgnc_driver_version_show, NULL);
+static DRIVER_ATTR_RO(version);
 
-static ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf)
+static ssize_t boards_show(struct device_driver *ddp, char *buf)
 {
return snprintf(buf, PAGE_SIZE, "%d\n", dgnc_num_boards);
 }
-static DRIVER_ATTR(boards, S_IRUSR, dgnc_driver_boards_show, NULL);
+static DRIVER_ATTR_RO(boards);
 
-static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf)
+static ssize_t maxboards_show(struct device_driver *ddp, char *buf)
 {
return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS);
 }
-static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL);
+static DRIVER_ATTR_RO(maxboards);
 
-static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf)
+static ssize_t pollrate_show(struct device_driver *ddp, char *buf)
 {
return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick);
 }
 
-static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp,
- const char *buf, size_t count)
+static ssize_t pollrate_store(struct device_driver *ddp,
+ const char *buf, size_t count)
 {
unsigned long flags;
int tick;
@@ -65,8 +65,7 @@ static ssize_t dgnc_driver_pollrate_store(struct 
device_driver *ddp,
 
return count;
 }
-static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show,
-  dgnc_driver_pollrate_store);
+static DRIVER_ATTR_RW(pollrate);
 
 void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver)
 {
@@ -103,8 +102,8 @@ void dgnc_remove_driver_sysfiles(struct pci_driver 
*dgnc_driver)
return 0;   \
} while (0)
 
-static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr,
-char *buf)
+static ssize_t vpd_show(struct device *p, struct device_attribute *attr,
+   char *buf)
 {
struct dgnc_board *bd;
int count = 0;
@@ -123,10 +122,10 @@ static ssize_t dgnc_vpd_show(struct device *p, struct 
device_attribute *attr,
 
return count;
 }
-static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL);
+static DEVICE_ATTR_RO(vpd);
 
-static ssize_t dgnc_serial_number_show(struct device *p,
-  struct device_attribute *attr, char *buf)
+static ssize_t serial_number_show(struct device *p,
+ struct device_attribute *attr, char *buf)
 {
struct dgnc_board *bd;
int count = 0;
@@ -140,10 +139,10 @@ static ssize_t dgnc_serial_number_show(struct device *p,
 
return count;
 }
-static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL);
+static DEVICE_ATTR_RO(serial_number);
 
-static ssize_t dgnc_ports_state_show(struct device *p,
-struct device_attribute *attr, char *buf)
+static ssize_t ports_state_show(struct device *p,
+   struct device_attribute *attr, char *buf)
 {
struct dgnc_board *bd;
int count = 0;
@@ -158,10 +157,10 @@ static ssize_t dgnc_ports_state_show(struct device *p,
}
return count;
 }
-static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL);
+static DEVICE_ATTR_RO(ports_state);
 
-static ssize_t dgnc_ports_baud_show(struct device *p,
-   struct device_attribute *attr, char *buf)
+static ssize_t ports_baud_show(struct device *p,
+  struct device_attribute *attr, char *buf)
 {
struct dgnc_board *bd;
int count = 0;
@@ -176,11 +175,10 @@ static ssize_t dgnc_ports_baud_show(struct device *p,
}
return count;
 }
-static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL);
+static DEVICE_ATTR_RO(ports_baud);
 
-static ssize_t dgnc_ports_msignals_show(struct device *p,
-   struct device_attribute *attr,
-   char *buf)
+static ssize_t ports_msignals_show(struct device *p,
+  struct device_attribute *attr, char *buf)
 {
struc

Re: [PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-09 Thread Greg KH
On Fri, Sep 09, 2016 at 08:17:44AM -0700, Todd Kjos wrote:
> From: Todd Kjos 
> 
> In Android systems, the display pipeline relies on low
> latency binder transactions and is therefore sensitive to
> delays caused by contention for the global binder lock.
> Jank is significantly reduced by disabling preemption
> while the global binder lock is held.

What is the technical definition of "Jank"?  :)

> 
> This patch was originated by Riley Andrews 
> with tweaks and forward-porting by me.
> 
> Originally-from: Riley Andrews 
> Signed-off-by: Todd Kjos 
> ---
>  drivers/android/binder.c | 194 
> +++
>  1 file changed, 146 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 16288e7..c36e420 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -379,6 +379,7 @@ static int task_get_unused_fd_flags(struct binder_proc 
> *proc, int flags)
>   struct files_struct *files = proc->files;
>   unsigned long rlim_cur;
>   unsigned long irqs;
> + int ret;
>  
>   if (files == NULL)
>   return -ESRCH;
> @@ -389,7 +390,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
> *proc, int flags)
>   rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
>   unlock_task_sighand(proc->tsk, &irqs);
>  
> - return __alloc_fd(files, 0, rlim_cur, flags);
> + preempt_enable_no_resched();
> + ret = __alloc_fd(files, 0, rlim_cur, flags);
> + preempt_disable();
> +
> + return ret;
>  }
>  
>  /*
> @@ -398,8 +403,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
> *proc, int flags)
>  static void task_fd_install(
>   struct binder_proc *proc, unsigned int fd, struct file *file)
>  {
> - if (proc->files)
> + if (proc->files) {
> + preempt_enable_no_resched();
>   __fd_install(proc->files, fd, file);
> + preempt_disable();
> + }
>  }
>  
>  /*
> @@ -427,6 +435,7 @@ static inline void binder_lock(const char *tag)
>  {
>   trace_binder_lock(tag);
>   mutex_lock(&binder_main_lock);
> + preempt_disable();
>   trace_binder_locked(tag);
>  }
>  
> @@ -434,8 +443,65 @@ static inline void binder_unlock(const char *tag)
>  {
>   trace_binder_unlock(tag);
>   mutex_unlock(&binder_main_lock);
> + preempt_enable();
> +}
> +
> +static inline void *kzalloc_nopreempt(size_t size)
> +{
> + void *ptr;
> +
> + ptr = kzalloc(size, GFP_NOWAIT);
> + if (ptr)
> + return ptr;
> +
> + preempt_enable_no_resched();
> + ptr = kzalloc(size, GFP_KERNEL);
> + preempt_disable();

Doesn't the allocator retry if the first one fails anyway?  Why not
GFP_NOIO or GFP_ATOMIC?  Have you really hit the second GFP_KERNEL
usage?

> +
> + return ptr;
> +}
> +
> +static inline long copy_to_user_nopreempt(void __user *to,
> +   const void *from, long n)
> +{
> + long ret;
> +
> + preempt_enable_no_resched();
> + ret = copy_to_user(to, from, n);
> + preempt_disable();
> + return ret;
> +}
> +
> +static inline long copy_from_user_nopreempt(void *to,
> + const void __user *from,
> + long n)
> +{
> + long ret;
> +
> + preempt_enable_no_resched();
> + ret = copy_from_user(to, from, n);
> + preempt_disable();
> + return ret;
>  }
>  
> +#define get_user_nopreempt(x, ptr)   \
> +({   \
> + int __ret;  \
> + preempt_enable_no_resched();\
> + __ret = get_user(x, ptr);   \
> + preempt_disable();  \
> + __ret;  \
> +})
> +
> +#define put_user_nopreempt(x, ptr)   \
> +({   \
> + int __ret;  \
> + preempt_enable_no_resched();\
> + __ret = put_user(x, ptr);   \
> + preempt_disable();  \
> + __ret;  \
> +})

Any reason some of these are #defines and some are static inline
functions?

Anyway, these all seem a bit strange to me, what type of latency spikes
are you seeing that these changes resolve?  Shouldn't that be an issue
with the scheduler more than just the binder driver?

I don't know of any other driver or IPC that does this type of thing
with the scheduler in order to make things "go faster", so it feels
wrong to me, and is probably why we don't have global functions like
put_user_nopreempt() :)

And is enabling and disabling preemption around single byte copies
to/from userspace really a good idea?  That seems like a lot of overhead
you are now adding to your "fastpath" that you need to go even faster.

And finally, I'm guessing this has passed the binder test suite that is
out there for testing binder

[PATCH] staging: ks7010: fix two memory leaks on error return path

2016-09-09 Thread Colin King
From: Colin Ian King 

On the error case where there is an invalid MAC address there is
memory leak on packet and pp on the error return. Free these first
before returning to fix the leak.

Signed-off-by: Colin Ian King 
---
 drivers/staging/ks7010/ks_hostif.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index c5fc31c..e09df360 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1196,6 +1196,8 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *packet)
DPRINTK(1, "ethernet->h_source=%02X:%02X:%02X:%02X:%02X:%02X\n",
eth->h_source[0], eth->h_source[1], eth->h_source[2],
eth->h_source[3], eth->h_source[4], eth->h_source[5]);
+   dev_kfree_skb(packet);
+   kfree(pp);
return -3;
}
 
-- 
2.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-09 Thread kbuild test robot
Hi Todd,

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.8-rc5 next-20160909]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]
[Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
convenience) to record what (public, well-known) commit your patch series was 
built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:
https://github.com/0day-ci/linux/commits/Todd-Kjos/android-binder-Disable-preemption-while-holding-the-global-binder-lock/20160909-23
config: x86_64-randconfig-x008-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/android/binder.c: In function 'binder_thread_read':
>> drivers/android/binder.c:2432:4: warning: this 'else' clause does not 
>> guard... [-Wmisleading-indentation]
   else
   ^~~~
   drivers/android/binder.c:2434:5: note: ...this statement, but the latter is 
misleadingly indented as if it is guarded by the 'else'
if (put_user_nopreempt(cmd,
^~

vim +/else +2432 drivers/android/binder.c

da49889d drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  2416   
 proc->pid, thread->pid,
da49889d drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  2417   
 node->debug_id,
da49889d drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  2418   
 (u64)node->ptr,
da49889d drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  2419   
 (u64)node->cookie);
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2420   
}
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2421   
}
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2422   
} break;
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2423   
case BINDER_WORK_DEAD_BINDER:
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2424   
case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2425   
case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2426   
struct binder_ref_death *death;
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2427   
uint32_t cmd;
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2428  
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2429   
death = container_of(w, struct binder_ref_death, work);
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2430   
if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2431   
cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30 @2432   
else
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2433   
cmd = BR_DEAD_BINDER;
ddd4adb7 drivers/android/binder.c Todd Kjos  2016-09-09  2434   
if (put_user_nopreempt(cmd,
ddd4adb7 drivers/android/binder.c Todd Kjos  2016-09-09  2435   
   (uint32_t __user *) ptr))
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2436   
return -EFAULT;
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2437   
ptr += sizeof(uint32_t);
ddd4adb7 drivers/android/binder.c Todd Kjos  2016-09-09  2438   
if (put_user_nopreempt(death->cookie,
da49889d drivers/staging/android/binder.c Arve Hjønnevåg 2014-02-21  2439   
   (binder_uintptr_t __user *) ptr))
355b0502 drivers/staging/android/binder.c Greg Kroah-Hartman 2011-11-30  2440   
return -EFAULT;

:: The code at line 2432 was first introduced by commit
:: 355b0502f6efea0ff9492753888772c96972d2a3 Revert "Staging: android: 
delete android drivers"

:: TO: Greg Kroah-Hartman 
:: CC: Greg Kroah-Hartman 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data
__

Re: [PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-09 Thread Todd Kjos
On Fri, Sep 9, 2016 at 8:44 AM, Greg KH  wrote:
> On Fri, Sep 09, 2016 at 08:17:44AM -0700, Todd Kjos wrote:
>> From: Todd Kjos 
>>
>> In Android systems, the display pipeline relies on low
>> latency binder transactions and is therefore sensitive to
>> delays caused by contention for the global binder lock.
>> Jank is significantly reduced by disabling preemption
>> while the global binder lock is held.
>
> What is the technical definition of "Jank"?  :)

I'll rephrase in the next version to "dropped or delayed frames".

>
>>
>> This patch was originated by Riley Andrews 
>> with tweaks and forward-porting by me.
>>
>> Originally-from: Riley Andrews 
>> Signed-off-by: Todd Kjos 
>> ---
>>  drivers/android/binder.c | 194 
>> +++
>>  1 file changed, 146 insertions(+), 48 deletions(-)
>>
>> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
>> index 16288e7..c36e420 100644
>> --- a/drivers/android/binder.c
>> +++ b/drivers/android/binder.c
>> @@ -379,6 +379,7 @@ static int task_get_unused_fd_flags(struct binder_proc 
>> *proc, int flags)
>>   struct files_struct *files = proc->files;
>>   unsigned long rlim_cur;
>>   unsigned long irqs;
>> + int ret;
>>
>>   if (files == NULL)
>>   return -ESRCH;
>> @@ -389,7 +390,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
>> *proc, int flags)
>>   rlim_cur = task_rlimit(proc->tsk, RLIMIT_NOFILE);
>>   unlock_task_sighand(proc->tsk, &irqs);
>>
>> - return __alloc_fd(files, 0, rlim_cur, flags);
>> + preempt_enable_no_resched();
>> + ret = __alloc_fd(files, 0, rlim_cur, flags);
>> + preempt_disable();
>> +
>> + return ret;
>>  }
>>
>>  /*
>> @@ -398,8 +403,11 @@ static int task_get_unused_fd_flags(struct binder_proc 
>> *proc, int flags)
>>  static void task_fd_install(
>>   struct binder_proc *proc, unsigned int fd, struct file *file)
>>  {
>> - if (proc->files)
>> + if (proc->files) {
>> + preempt_enable_no_resched();
>>   __fd_install(proc->files, fd, file);
>> + preempt_disable();
>> + }
>>  }
>>
>>  /*
>> @@ -427,6 +435,7 @@ static inline void binder_lock(const char *tag)
>>  {
>>   trace_binder_lock(tag);
>>   mutex_lock(&binder_main_lock);
>> + preempt_disable();
>>   trace_binder_locked(tag);
>>  }
>>
>> @@ -434,8 +443,65 @@ static inline void binder_unlock(const char *tag)
>>  {
>>   trace_binder_unlock(tag);
>>   mutex_unlock(&binder_main_lock);
>> + preempt_enable();
>> +}
>> +
>> +static inline void *kzalloc_nopreempt(size_t size)
>> +{
>> + void *ptr;
>> +
>> + ptr = kzalloc(size, GFP_NOWAIT);
>> + if (ptr)
>> + return ptr;
>> +
>> + preempt_enable_no_resched();
>> + ptr = kzalloc(size, GFP_KERNEL);
>> + preempt_disable();
>
> Doesn't the allocator retry if the first one fails anyway?  Why not
> GFP_NOIO or GFP_ATOMIC?  Have you really hit the second GFP_KERNEL
> usage?

I suspect we have hit the second, since we do get into cases where
direct reclaim is needed. I can't confirm since I haven't instrumented
this case. As you say, if we use GFP_ATOMIC instead, maybe we
wouldn't, but even then I'd be concerned that we could deplete the
memory reserved for atomic. The general idea of trying for a fast,
nowait allocation and then enabling preempt for the rare potentially
blocking allocation seems reasonable, doesn't it?

>> +
>> + return ptr;
>> +}
>> +
>> +static inline long copy_to_user_nopreempt(void __user *to,
>> +   const void *from, long n)
>> +{
>> + long ret;
>> +
>> + preempt_enable_no_resched();
>> + ret = copy_to_user(to, from, n);
>> + preempt_disable();
>> + return ret;
>> +}
>> +
>> +static inline long copy_from_user_nopreempt(void *to,
>> + const void __user *from,
>> + long n)
>> +{
>> + long ret;
>> +
>> + preempt_enable_no_resched();
>> + ret = copy_from_user(to, from, n);
>> + preempt_disable();
>> + return ret;
>>  }
>>
>> +#define get_user_nopreempt(x, ptr)   \
>> +({   \
>> + int __ret;  \
>> + preempt_enable_no_resched();\
>> + __ret = get_user(x, ptr);   \
>> + preempt_disable();  \
>> + __ret;  \
>> +})
>> +
>> +#define put_user_nopreempt(x, ptr)   \
>> +({   \
>> + int __ret;  \
>> + preempt_enable_no_resched();\
>> + __ret = put_user(x, ptr);   \
>> + preempt_disable();  \
>> + __ret;  \
>> +})
>
> Any reason some of these are #defines and some are static inline
> functions?

Not that I know of. I'll change to stat

Re: [PATCH 1/3] staging: vme_user: return retval in vme_user_ioctl

2016-09-09 Thread Aaron Sierra
- Original Message -
> From: "Martyn Welch" 
> Subject: Re: [PATCH 1/3] staging: vme_user: return retval in vme_user_ioctl

> On Fri, Sep 02, 2016 at 04:16:48PM -0500, Aaron Sierra wrote:
>> Update each case to set retval and return that value at the end of the
>> function. This also replaces most case statement returns with breaks
>> and collapses some whitespace.
>> 
> 
> Sorry if I'm being dense, but is there an advantage to doing it this way?
> 
> This seems to be adding churn for no discernible gain.
> 
>> Signed-off-by: Aaron Sierra 
>> ---
>>  drivers/staging/vme/devices/vme_user.c | 22 ++
>>  1 file changed, 10 insertions(+), 12 deletions(-)
>> 
>> diff --git a/drivers/staging/vme/devices/vme_user.c
>> b/drivers/staging/vme/devices/vme_user.c
>> index fc660bd..5aa53c4 100644
>> --- a/drivers/staging/vme/devices/vme_user.c
>> +++ b/drivers/staging/vme/devices/vme_user.c
>> @@ -299,7 +299,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  struct vme_irq_id irq_req;
>>  unsigned long copied;
>>  unsigned int minor = MINOR(inode->i_rdev);
>> -int retval;
>> +int retval = -EINVAL;
>>  dma_addr_t pci_addr;
>>  void __user *argp = (void __user *)arg;
>>  
>> @@ -314,9 +314,10 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  return -EFAULT;
>>  }
>>  
>> -return vme_irq_generate(vme_user_bridge,
>> +retval = vme_irq_generate(vme_user_bridge,
>>irq_req.level,
>>irq_req.statid);
>> +break;
>>  }
>>  break;
>>  case MASTER_MINOR:
>> @@ -337,13 +338,11 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>sizeof(master));
>>  if (copied) {
>>  pr_warn("Partial copy to userspace\n");
>> -return -EFAULT;
>> +retval = -EFAULT;
>>  }
>>  
>> -return retval;
>> -
>> +break;
>>  case VME_SET_MASTER:
>> -
>>  if (image[minor].mmap_count != 0) {
>>  pr_warn("Can't adjust mapped window\n");
>>  return -EPERM;
>> @@ -358,7 +357,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -return vme_master_set(image[minor].resource,
>> +retval = vme_master_set(image[minor].resource,
>>  master.enable, master.vme_addr, master.size,
>>  master.aspace, master.cycle, master.dwidth);
>>  
>> @@ -382,11 +381,10 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>sizeof(slave));
>>  if (copied) {
>>  pr_warn("Partial copy to userspace\n");
>> -return -EFAULT;
>> +retval = -EFAULT;
>>  }
>>  
>> -return retval;
>> -
>> +break;
>>  case VME_SET_SLAVE:
>>  
>>  copied = copy_from_user(&slave, argp, sizeof(slave));
>> @@ -398,7 +396,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -return vme_slave_set(image[minor].resource,
>> +retval = vme_slave_set(image[minor].resource,
>>  slave.enable, slave.vme_addr, slave.size,
>>  image[minor].pci_buf, slave.aspace,
>>  slave.cycle);
>> @@ -408,7 +406,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  break;
>>  }
>>  
>> -return -EINVAL;
>> +return retval;

Martyn,
This last change is where the slippery slope began. With this change, the
additions I make to VME_SET_SLAVE in my "3/3" patch can use a break instead
of adding another return statement, which feels cleaner to me.

Also, this patch makes the breaks in VME_SET_MASTER and VME_SET_SLAVE do
something meaningful.

-Aaron S.

>>  }
>>  
>>  static long
>> --
> > 1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/3] staging: vme_user: look up image once in ioctl

2016-09-09 Thread Aaron Sierra
- Original Message -
> From: "Martyn Welch" 
> Sent: Thursday, September 8, 2016 2:24:11 PM

> On Fri, Sep 02, 2016 at 04:16:55PM -0500, Aaron Sierra wrote:
>> Assign a pointer to the image descriptor once at the beginning of
>> the ioctl to help keep code concise.
>> 
> 
> Same with this patch. I'm not sure what's gained by doing this.

Martyn,
As with my "1/3" patch, this allows my "3/3" patch to feel cleaner and
be easier to read. Since I can't define this variable local to the
VME_SET_SLAVE case that I modify in that patch, it seemed a shame to
introduce it early in the function and not use it throughout.

-Aaron S.

> 
>> Signed-off-by: Aaron Sierra 
>> ---
>>  drivers/staging/vme/devices/vme_user.c | 13 +++--
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/staging/vme/devices/vme_user.c
>> b/drivers/staging/vme/devices/vme_user.c
>> index 5aa53c4..c68e2b8 100644
>> --- a/drivers/staging/vme/devices/vme_user.c
>> +++ b/drivers/staging/vme/devices/vme_user.c
>> @@ -302,6 +302,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  int retval = -EINVAL;
>>  dma_addr_t pci_addr;
>>  void __user *argp = (void __user *)arg;
>> +struct image_desc *img = &image[minor];
>>  
>>  switch (type[minor]) {
>>  case CONTROL_MINOR:
>> @@ -328,7 +329,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -retval = vme_master_get(image[minor].resource,
>> +retval = vme_master_get(img->resource,
>>  &master.enable,
>>  &master.vme_addr,
>>  &master.size, &master.aspace,
>> @@ -343,7 +344,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  
>>  break;
>>  case VME_SET_MASTER:
>> -if (image[minor].mmap_count != 0) {
>> +if (img->mmap_count != 0) {
>>  pr_warn("Can't adjust mapped window\n");
>>  return -EPERM;
>>  }
>> @@ -357,7 +358,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -retval = vme_master_set(image[minor].resource,
>> +retval = vme_master_set(img->resource,
>>  master.enable, master.vme_addr, master.size,
>>  master.aspace, master.cycle, master.dwidth);
>>  
>> @@ -372,7 +373,7 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -retval = vme_slave_get(image[minor].resource,
>> +retval = vme_slave_get(img->resource,
>> &slave.enable, &slave.vme_addr,
>> &slave.size, &pci_addr,
>> &slave.aspace, &slave.cycle);
>> @@ -396,9 +397,9 @@ static int vme_user_ioctl(struct inode *inode, struct 
>> file
>> *file,
>>  /* XXX  We do not want to push aspace, cycle and width
>>   *  to userspace as they are
>>   */
>> -retval = vme_slave_set(image[minor].resource,
>> +retval = vme_slave_set(img->resource,
>>  slave.enable, slave.vme_addr, slave.size,
>> -image[minor].pci_buf, slave.aspace,
>> +img->pci_buf, slave.aspace,
>>  slave.cycle);
>>  
>>  break;
>> --
> > 1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave

2016-09-09 Thread Aaron Sierra
- Original Message -
> From: "Martyn Welch" 
> To: "Aaron Sierra" 
> Cc: "Manohar Vanga" , "Greg Kroah-Hartman" 
> , "devel"
> , "Egor Uleyskiy" , 
> "Dmitry Kalinkin" 
> Sent: Thursday, September 8, 2016 2:34:32 PM
> Subject: Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave

> On Fri, Sep 02, 2016 at 04:17:01PM -0500, Aaron Sierra wrote:
>> Some bridges support a minimum slave window larger than this driver's
>> 128 KB default buffer size. Also bridges typically require the PCI and
>> VME bases to be aligned to the size of the window.
>> 
> 
> Which bridge has a minimum slave window larger than 128KB?

Martyn,

The ALTHEA 7910 PCIe-VME bridge from IOxOS Technologies can require a
PCI-side window be larger than 128 KiB.

I've been meaning to submit our driver for it.

-Aaron S.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave

2016-09-09 Thread Martyn Welch
On Fri, Sep 09, 2016 at 02:41:43PM -0500, Aaron Sierra wrote:
> - Original Message -
> > From: "Martyn Welch" 
> > To: "Aaron Sierra" 
> > Cc: "Manohar Vanga" , "Greg Kroah-Hartman" 
> > , "devel"
> > , "Egor Uleyskiy" , 
> > "Dmitry Kalinkin" 
> > Sent: Thursday, September 8, 2016 2:34:32 PM
> > Subject: Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave
> 
> > On Fri, Sep 02, 2016 at 04:17:01PM -0500, Aaron Sierra wrote:
> >> Some bridges support a minimum slave window larger than this driver's
> >> 128 KB default buffer size. Also bridges typically require the PCI and
> >> VME bases to be aligned to the size of the window.
> >> 
> > 
> > Which bridge has a minimum slave window larger than 128KB?
> 
> Martyn,
> 
> The ALTHEA 7910 PCIe-VME bridge from IOxOS Technologies can require a
> PCI-side window be larger than 128 KiB.
> 
> I've been meaning to submit our driver for it.
> 

Ah, OK. In that case please can you submit the driver first. At this point
in time there are no in tree use cases for the changes your proposing.

Martyn

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave

2016-09-09 Thread Aaron Sierra
- Original Message -
> From: "Martyn Welch" 
> Sent: Friday, September 9, 2016 3:03:57 PM

> On Fri, Sep 09, 2016 at 02:41:43PM -0500, Aaron Sierra wrote:
>> - Original Message -
>> > From: "Martyn Welch" 
>> > To: "Aaron Sierra" 
>> > Cc: "Manohar Vanga" , "Greg Kroah-Hartman"
>> > , "devel"
>> > , "Egor Uleyskiy" ,
>> > "Dmitry Kalinkin" 
>> > Sent: Thursday, September 8, 2016 2:34:32 PM
>> > Subject: Re: [PATCH 3/3] staging: vme_user: alloc buffer when setting slave
>> 
>> > On Fri, Sep 02, 2016 at 04:17:01PM -0500, Aaron Sierra wrote:
>> >> Some bridges support a minimum slave window larger than this driver's
>> >> 128 KB default buffer size. Also bridges typically require the PCI and
>> >> VME bases to be aligned to the size of the window.
>> >> 
>> > 
>> > Which bridge has a minimum slave window larger than 128KB?
>> 
>> Martyn,
>> 
>> The ALTHEA 7910 PCIe-VME bridge from IOxOS Technologies can require a
>> PCI-side window be larger than 128 KiB.
>> 
>> I've been meaning to submit our driver for it.
>> 
> 
> Ah, OK. In that case please can you submit the driver first. At this point
> in time there are no in tree use cases for the changes your proposing.
> 

Martyn,

I could submit my driver in the state that it's in, but I don't think it's
quite ready for review. I decided to submit these patches now since I
noticed that code I rely on had been removed from the kernel because of
disuse. This patch provides the use case AND helps support my bridge.

Nothing in this patch is really ALTHEA-specific. I could easily adjust the
language in my commit log to omit the implicit reference to the ALTHEA
bridge. Would something like this be more appealing?

staging: vme_user: alloc buffer when setting slave

Don't allocate more PCI space than is absolutely needed to support the
VME bridge window. We don't know how much space is needed, until the
user calls the VME_SET_SLAVE ioctl.

-Aaron S.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] staging/fsl-mc: use consistent integer types

2016-09-09 Thread Stuart Yoder


> -Original Message-
> From: Thomas Weißschuh [mailto:li...@weissschuh.net]
> Sent: Wednesday, September 07, 2016 1:21 PM
> To: J. German Rivera ; Stuart Yoder 
> ; Greg Kroah-
> Hartman ; linux-ker...@vger.kernel.org; 
> de...@driverdev.osuosl.org
> Cc: Thomas Weißschuh 
> Subject: [PATCH] staging/fsl-mc: use consistent integer types
> 
> Signed-off-by: Thomas Weißschuh 
> ---
>  drivers/staging/fsl-mc/include/mc-private.h | 4 ++--
>  drivers/staging/fsl-mc/include/mc.h | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/fsl-mc/include/mc-private.h 
> b/drivers/staging/fsl-mc/include/mc-private.h
> index cab1ae9..f95ee74 100644
> --- a/drivers/staging/fsl-mc/include/mc-private.h
> +++ b/drivers/staging/fsl-mc/include/mc-private.h
> @@ -79,8 +79,8 @@ struct fsl_mc_addr_translation_range {
>   */
>  struct fsl_mc_resource_pool {
>   enum fsl_mc_pool_type type;
> - int16_t max_count;
> - int16_t free_count;
> + i16 max_count;
> + i16 free_count;

What is i16? ...not a valid type as far as I can see.  Did you compile this?

The codebase you are based on has changed.  There is no longer a file
called mc-private.h.  Latest should be in Greg's staging-next branch.

Stuart


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel