Re: [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL

2019-05-16 Thread Joe Perches
On Thu, 2019-05-16 at 23:55 +0530, Hariprasad Kelam wrote:
> On Thu, May 16, 2019 at 11:00:56AM +0300, Dan Carpenter wrote:
> > On Wed, May 15, 2019 at 11:15:36PM +0530, Hariprasad Kelam wrote:
> > > @@ -1042,7 +1042,7 @@ sint sta2ap_data_frame(
> > >   }
> > >  
> > >   *psta = rtw_get_stainfo(pstapriv, pattrib->src);
> > > - if (*psta == NULL) {
> > > + if (!*psta == NULL) {
> > ^^
> > It's surprising that this didn't cause some kind of warning somewhere...
> 
> Thanks for pointing out this error. Here my intention is to write
> if(!*psta) 
> but somehow i missed it .
> 
> Will resend this patch after correcting the same.Like below
> 
> > -   if (*psta == NULL) {
> > > +   if (!*psta) {

You could run the coccinelle spatch file for bool
comparisons on the files instead.  It's much less
error prone.

$ spatch --sp-file scripts/coccinelle/misc/boolconv.cocci --in-place 
drivers/staging/rtl8723bs/

Or you could use a patch to checkpatch like below and then use

$ git ls-files drivers/staging/rtl8723bs | \
  xargs ./scripts/checkpatch.pl -f --fix-inplace --types=bool_comparison

but that definitely would not be as good as the coccinelle
tool use as coccinelle is much better at parsing expressions.

---
 scripts/checkpatch.pl | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1c421ac42b07..fe83aa0b1f97 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6407,11 +6407,13 @@ sub process {
$op = "";
}
 
-   CHK("BOOL_COMPARISON",
-   "Using comparison to $otype is error 
prone\n" . $herecurr);
-
+   if (CHK("BOOL_COMPARISON",
+   "Using comparison to $otype is error 
prone\n" . $herecurr) &&
+   $fix) {
+   $fixed[$fixlinenr] =~ 
s/\b(?:true|false|$Lval)\s*(?:==|\!=)\s*(?:true|false|$Lval)\b/${op}${arg}/;
+   }
 ## maybe suggesting a correct construct would better
-## "Using comparison to $otype is error prone. 
 Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr);
+## "Using comparison to $otype is error 
prone.  Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr);
 
}
}


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


RE: [PATCH 02/11] staging: kpc2000: add separate show functions for kpc_uio_class device attributes.

2019-05-16 Thread Matt Sickler
>-Original Message-
>From: devel  On Behalf Of
>Define separate simple show functions for each attribute instead of having a
>one big one containing a chain of conditionals.
>
>+static ssize_t s2c_dma_ch_show(struct device *dev,
>+  struct device_attribute *attr, char *buf)
>+{
>+   return 0;
>+}
>+
>+static ssize_t c2s_dma_ch_show(struct device *dev,
>+  struct device_attribute *attr, char *buf)
>+{
>+   return 0;
>+}

These two can be removed.  Technically, that would be a userspace-breaking
change, but I can guarantee that all existing userspace consumers don't actually
read that sysfs node.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH v2 5/9] staging: kpc2000: use atomic_t to assign card numbers.

2019-05-16 Thread Matt Sickler
>-Original Message-
>From: devel  On Behalf Of
>Previously the next card number was assigned from a static int local variable,
>which was read and later incremented.  This was not thread- safe, so now we
>use an atomic_t and atomic_fetch_add instead.

Switching to atomic_fetch_add is definitely an improvement over what that code
was doing prior, but is that the proper solution?  How do other parts of the
kernel handle giving devices unique ID numbers?

Honestly, the atomic_t solution might be "good enough".  Our PCIe devices get
removed and reprobed at least once per boot.  We do this so they boot into a
"bootloader" program so we can verify that the "production" image stored in
the on-board flash is the correct type/version.  We then tell the card to
reconfigure itself while we remove the PCIe device and then rescan the PCIe
bus for the "new" device.  That ends up increasing this card count more.
This would never be a problem in production (given that we only do this maybe
a half dozen times per boot, worst case).  Even in dev, we've never reconfigured
enough times for this counter to overflow.
That was maybe rambling a bit, just wanted to point it out in case there's a
"proper" way we should be doing this.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/9] staging: kpc2000: removed trailing white-space.

2019-05-16 Thread Jeremy Sowden
Removed trailing white-space from four files.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 62 ++---
 drivers/staging/kpc2000/kpc2000/core.c   | 98 ++--
 drivers/staging/kpc2000/kpc2000/fileops.c|  2 +-
 drivers/staging/kpc2000/kpc2000/pcie.h   | 10 +-
 4 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index bce2bf9eee04..6a2ebdf20113 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -106,24 +106,24 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 };
 
 dev_dbg(>pdev->dev, "Found Basic core: type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
-
-
+
+
 cell.platform_data = _pdata;
 cell.pdata_size = sizeof(struct kpc_core_device_platdata);
 cell.num_resources = 2;
-
+
 memset(, 0, sizeof(resources));
 
 resources[0].start = cte.offset;
 resources[0].end   = cte.offset + (cte.length - 1);
 resources[0].flags = IORESOURCE_MEM;
-
+
 resources[1].start = pcard->pdev->irq;
 resources[1].end   = pcard->pdev->irq;
 resources[1].flags = IORESOURCE_IRQ;
-
+
 cell.resources = resources;
-
+
 return mfd_add_devices(
 PCARD_TO_DEV(pcard),// parent
 pcard->card_num * 100,  // id
@@ -148,7 +148,7 @@ struct kpc_uio_device {
 static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
 struct kpc_uio_device *kudev = dev_get_drvdata(dev);
-
+
 #define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
 if ATTR_NAME_CMP("offset"){
 return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
@@ -228,7 +228,7 @@ irqreturn_t  kuio_handler(int irq, struct uio_info *uioinfo)
 struct kpc_uio_device *kudev = uioinfo->priv;
 if (irq != kudev->pcard->pdev->irq)
 return IRQ_NONE;
-
+
 if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){
 writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base 
+ REG_INTERRUPT_ACTIVE); // Clear the active flag
 return IRQ_HANDLED;
@@ -242,7 +242,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 struct kpc_uio_device *kudev = uioinfo->priv;
 struct kp2000_device *pcard = kudev->pcard;
 u64 mask;
-
+
 lock_card(pcard);
 mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 if (irq_on){
@@ -252,7 +252,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 }
 writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 unlock_card(pcard);
-
+
 return 0;
 }
 
@@ -263,18 +263,18 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 int rv;
 
 dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
-
+
 kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
 if (!kudev){
 dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
 return -ENOMEM;
 }
-
+
 INIT_LIST_HEAD(>list);
 kudev->pcard = pcard;
 kudev->cte = cte;
 kudev->core_num = core_num;
-
+
 kudev->uioinfo.priv = kudev;
 kudev->uioinfo.name = name;
 kudev->uioinfo.version = "0.0";
@@ -291,7 +291,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + 
cte.offset;
 kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); 
// Round up to nearest PAGE_SIZE boundary
 kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS;
-
+
 kudev->dev = device_create(kpc_uio_class, >pdev->dev, MKDEV(0,0), 
kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, 
kudev->core_num);
 if (IS_ERR(kudev->dev)) {
 dev_err(>pdev->dev, "probe_core_uio device_create failed!\n");
@@ -299,7 +299,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 return -ENODEV;
 }
 dev_set_drvdata(kudev->dev, kudev);
-
+
 rv = uio_register_device(kudev->dev, >uioinfo);
 if (rv){
 dev_err(>pdev->dev, "probe_core_uio failed uio_register_device: 
%d\n", rv);
@@ -307,9 +307,9 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 kfree(kudev);
 return rv;
 }
-
+
 list_add_tail(>list, >uio_devices_list);
-
+
 return 0;
 }
 
@@ -320,24 +320,24 @@ static int  create_dma_engine_core(struct kp2000_device 
*pcard, size_t 

[PATCH v2 5/9] staging: kpc2000: use atomic_t to assign card numbers.

2019-05-16 Thread Jeremy Sowden
Previously the next card number was assigned from a static int local
variable, which was read and later incremented.  This was not thread-
safe, so now we use an atomic_t and atomic_fetch_add instead.

Updated TODO.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/TODO   | 1 -
 drivers/staging/kpc2000/kpc2000/core.c | 7 ---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO
index 669fe5bf9637..47530e23e940 100644
--- a/drivers/staging/kpc2000/TODO
+++ b/drivers/staging/kpc2000/TODO
@@ -1,6 +1,5 @@
 - the kpc_spi driver doesn't seem to let multiple transactions (to different 
instances of the core) happen in parallel...
 - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton.  
It functions against current hardware though.
-- pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic 
/ locking / something better.
 - would be nice if the AIO fileops in kpc_dma could be made to work
 - probably want to add a CONFIG_ option to control compilation of the AIO 
functions
 - if the AIO fileops in kpc_dma start working, next would be making iov_count 
> 1 work too
diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index eb8bac62d33d..72130a50afd6 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include 
 #include 
 #include 
 #include 
@@ -19,6 +20,8 @@
 #include "pcie.h"
 
 
+static atomic_t next_card_num = ATOMIC_INIT(1);
+
 /***
   * SysFS Attributes
   **/
@@ -202,7 +205,6 @@ int  kp2000_pcie_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 {
 int err = 0;
 struct kp2000_device *pcard;
-static int card_count = 1;
 int rv;
 unsigned long reg_bar_phys_addr;
 unsigned long reg_bar_phys_len;
@@ -222,8 +224,7 @@ int  kp2000_pcie_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 //}
 
 //{ Step 2: Initialize trivial pcard elements
-pcard->card_num = card_count;
-card_count++;
+pcard->card_num = atomic_fetch_add(1, _card_num);
 scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num);
 
 mutex_init(>sem);
-- 
2.20.1

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


[PATCH v2 2/9] staging: kpc2000: add separate show functions for kpc_uio_class device attributes and defined them as read-only.

2019-05-16 Thread Jeremy Sowden
Define separate simple show functions for each attribute instead of
having a one big one containing a chain of conditionals.

Replaced scnprintf calls with sprintf since all the outputs are short
bounded strings or single integers.

All of the device attributes are read-only, so use DEVICE_ATTR_RO to
define them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 136 ---
 1 file changed, 90 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 6a2ebdf20113..3798f8e2e165 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -145,55 +145,100 @@ struct kpc_uio_device {
 u16 core_num;
 };
 
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+static ssize_t offset_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
 {
-struct kpc_uio_device *kudev = dev_get_drvdata(dev);
-
-#define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
-if ATTR_NAME_CMP("offset"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
-} else if ATTR_NAME_CMP("size"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
-} else if ATTR_NAME_CMP("type"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
-}
-else if ATTR_NAME_CMP("s2c_dma"){
-if (kudev->cte.s2c_dma_present){
-return scnprintf(buf, PAGE_SIZE, "%u\n", 
kudev->cte.s2c_dma_channel_num);
-} else {
-return scnprintf(buf, PAGE_SIZE, "not present\n");
-}
-} else if ATTR_NAME_CMP("c2s_dma"){
-if (kudev->cte.c2s_dma_present){
-return scnprintf(buf, PAGE_SIZE, "%u\n", 
kudev->cte.c2s_dma_channel_num);
-} else {
-return scnprintf(buf, PAGE_SIZE, "not present\n");
-}
-}
-else if ATTR_NAME_CMP("irq_count"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count);
-} else if ATTR_NAME_CMP("irq_base_num"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_base_num);
-} else if ATTR_NAME_CMP("core_num"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
-} else {
-return 0;
-}
-#undef ATTR_NAME_CMP
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%u\n", kudev->cte.offset);
+}
+
+static ssize_t size_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%u\n", kudev->cte.length);
 }
 
+static ssize_t type_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%u\n", kudev->cte.type);
+}
+
+static ssize_t s2c_dma_ch_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   return 0;
+}
+
+static ssize_t c2s_dma_ch_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   return 0;
+}
+
+static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
 
-DEVICE_ATTR(offset,  0444, show_attr, NULL);
-DEVICE_ATTR(size,0444, show_attr, NULL);
-DEVICE_ATTR(type,0444, show_attr, NULL);
-DEVICE_ATTR(s2c_dma_ch, 0444, show_attr, NULL);
-DEVICE_ATTR(c2s_dma_ch, 0444, show_attr, NULL);
-DEVICE_ATTR(s2c_dma, 0444, show_attr, NULL);
-DEVICE_ATTR(c2s_dma, 0444, show_attr, NULL);
-DEVICE_ATTR(irq_count, 0444, show_attr, NULL);
-DEVICE_ATTR(irq_base_num, 0444, show_attr, NULL);
-DEVICE_ATTR(core_num, 0444, show_attr, NULL);
-struct attribute * kpc_uio_class_attrs[] = {
+   if (!kudev->cte.s2c_dma_present)
+   return sprintf(buf, "%s", "not present\n");
+
+   return sprintf(buf, "%u\n", kudev->cte.s2c_dma_channel_num);
+}
+
+static ssize_t c2s_dma_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   if (!kudev->cte.c2s_dma_present)
+   return sprintf(buf, "%s", "not present\n");
+
+   return sprintf(buf, "%u\n", kudev->cte.c2s_dma_channel_num);
+}
+
+static ssize_t irq_count_show(struct device *dev, struct device_attribute 
*attr,
+ char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%u\n", kudev->cte.irq_count);
+}
+
+static ssize_t irq_base_num_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   

[PATCH v2 3/9] staging: kpc2000: declare all kpc_uio_class device attributes as static.

2019-05-16 Thread Jeremy Sowden
The definitions are only used to populate the kpc_uio_class_attrs
attribute array, so declare them as static.

Fixes the following sparse warnings:

  drivers/staging/kpc2000/kpc2000/cell_probe.c:220:1: warning: symbol 
'dev_attr_offset' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:221:1: warning: symbol 
'dev_attr_size' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:222:1: warning: symbol 
'dev_attr_type' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:223:1: warning: symbol 
'dev_attr_s2c_dma' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:224:1: warning: symbol 
'dev_attr_c2s_dma' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:225:1: warning: symbol 
'dev_attr_irq_count' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:226:1: warning: symbol 
'dev_attr_irq_base_num' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:227:1: warning: symbol 
'dev_attr_core_num' was not declared. Should it be static?

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 3798f8e2e165..3073b4813b7a 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -227,16 +227,16 @@ static ssize_t core_num_show(struct device *dev, struct 
device_attribute *attr,
return sprintf(buf, "%u\n", kudev->core_num);
 }
 
-DEVICE_ATTR_RO(offset);
-DEVICE_ATTR_RO(size);
-DEVICE_ATTR_RO(type);
-DEVICE_ATTR_RO(s2c_dma_ch);
-DEVICE_ATTR_RO(c2s_dma_ch);
-DEVICE_ATTR_RO(s2c_dma);
-DEVICE_ATTR_RO(c2s_dma);
-DEVICE_ATTR_RO(irq_count);
-DEVICE_ATTR_RO(irq_base_num);
-DEVICE_ATTR_RO(core_num);
+static DEVICE_ATTR_RO(offset);
+static DEVICE_ATTR_RO(size);
+static DEVICE_ATTR_RO(type);
+static DEVICE_ATTR_RO(s2c_dma_ch);
+static DEVICE_ATTR_RO(c2s_dma_ch);
+static DEVICE_ATTR_RO(s2c_dma);
+static DEVICE_ATTR_RO(c2s_dma);
+static DEVICE_ATTR_RO(irq_count);
+static DEVICE_ATTR_RO(irq_base_num);
+static DEVICE_ATTR_RO(core_num);
 
 struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
-- 
2.20.1

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


[PATCH v2 0/9] staging: kpc2000: another batch of fixes

2019-05-16 Thread Jeremy Sowden
These apply on top of the ones I sent earlier this week, which are
currently in the staging-test branch.

There's one white-space patch, a number relating to device attributes
and one that fixes a race affecting the assignment of card numbers.

Jeremy Sowden (9):
  staging: kpc2000: removed trailing white-space.
  staging: kpc2000: add separate show functions for kpc_uio_class device
attributes and defined them as read-only.
  staging: kpc2000: declare all kpc_uio_class device attributes as
static.
  staging: kpc2000: removed two kpc_uio_class device attributes.
  staging: kpc2000: use atomic_t to assign card numbers.
  staging: kpc2000: simplified kp2000_device retrieval in device
attributes call-backs.
  staging: kpc2000: formatting fixes for kp device attributes.
  staging: kpc2000: add separate show functions for readable kp device
attributes, and defined them as read-only.
  staging: kpc2000: declare all kp device attributes as static.

 drivers/staging/kpc2000/TODO |   1 -
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 184 +++--
 drivers/staging/kpc2000/kpc2000/core.c   | 255 +++
 drivers/staging/kpc2000/kpc2000/fileops.c|   2 +-
 drivers/staging/kpc2000/kpc2000/pcie.h   |  10 +-
 5 files changed, 254 insertions(+), 198 deletions(-)

Since v1:

  * merged the DEVICE_ATTR_RO patches with the ones that split up the
show call-backs;
  * converted the show call-backs to use sprintf, instead of scnprintf.

-- 
2.20.1

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


[PATCH v2 7/9] staging: kpc2000: formatting fixes for kp device attributes.

2019-05-16 Thread Jeremy Sowden
Fixed indentation of cpld_reconfigure store call-back and definition of
attribute list.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 55 ++
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index c05864cf33ce..6147c47c44ab 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -47,23 +47,27 @@ static ssize_t  show_cpld_config_reg(struct device *dev, 
struct device_attribute
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
-static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
-{
-struct kp2000_device *pcard = dev_get_drvdata(dev);
-long wr_val;
-int rv;
-
-rv = kstrtol(buf, 0, _val);
-if (rv < 0)  return rv;
-if (wr_val > 7)  return -EINVAL;
 
-wr_val = wr_val << 8;
-wr_val |= 0x1; // Set the "Configure Go" bit
-writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
-return count;
+static ssize_t cpld_reconfigure(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+   long wr_val;
+   int rv;
+
+   rv = kstrtol(buf, 0, _val);
+   if (rv < 0)
+   return rv;
+   if (wr_val > 7)
+   return -EINVAL;
+
+   wr_val = wr_val << 8;
+   wr_val |= 0x1; // Set the "Configure Go" bit
+   writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
+   return count;
 }
 
-
 DEVICE_ATTR(ssid,   0444, show_attr, NULL);
 DEVICE_ATTR(ddna,   0444, show_attr, NULL);
 DEVICE_ATTR(card_id,0444, show_attr, NULL);
@@ -74,20 +78,19 @@ DEVICE_ATTR(build_time, 0444, show_attr, NULL);
 DEVICE_ATTR(cpld_reg,   0444, show_cpld_config_reg, NULL);
 DEVICE_ATTR(cpld_reconfigure,   0220, NULL, cpld_reconfigure);
 
-static const struct attribute *  kp_attr_list[] = {
-_attr_ssid.attr,
-_attr_ddna.attr,
-_attr_card_id.attr,
-_attr_hw_rev.attr,
-_attr_build.attr,
-_attr_build_date.attr,
-_attr_build_time.attr,
-_attr_cpld_reg.attr,
-_attr_cpld_reconfigure.attr,
-NULL,
+static const struct attribute *kp_attr_list[] = {
+   _attr_ssid.attr,
+   _attr_ddna.attr,
+   _attr_card_id.attr,
+   _attr_hw_rev.attr,
+   _attr_build.attr,
+   _attr_build_date.attr,
+   _attr_build_time.attr,
+   _attr_cpld_reg.attr,
+   _attr_cpld_reconfigure.attr,
+   NULL,
 };
 
-
 /***
   * Functions
   **/
-- 
2.20.1

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


[PATCH v2 8/9] staging: kpc2000: add separate show functions for readable kp device attributes, and defined them as read-only.

2019-05-16 Thread Jeremy Sowden
Define separate simple show functions for each attribute instead of
having a one big one containing a chain of conditionals.

Replaced calls to scnprintf with sprintf since all the outputs are
single integers.

All the readable device attributes are read-only, so use DEVICE_ATTR_RO
to define them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 89 +++---
 1 file changed, 66 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 6147c47c44ab..6fa3dd6531ef 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -19,33 +19,76 @@
 #include 
 #include "pcie.h"
 
-
 static atomic_t next_card_num = ATOMIC_INIT(1);
 
 /***
   * SysFS Attributes
   **/
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+
+static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%016llx\n", pcard->ssid);
+}
+
+static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%016llx\n", pcard->ddna);
+}
+
+static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%08x\n", pcard->card_id);
+}
+
+static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
 {
-struct kp2000_device *pcard = dev_get_drvdata(dev);
-
-if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
-if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
-if (strcmp("card_id", attr->attr.name) == 0){  return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->card_id);  } else
-if (strcmp("hw_rev", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->hardware_revision);  } else
-if (strcmp("build", attr->attr.name) == 0){return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_version);  } else
-if (strcmp("build_date", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_datestamp);  } else
-if (strcmp("build_time", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_timestamp);  } else
-{ return -ENXIO; }
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%08x\n", pcard->hardware_revision);
+}
+
+static ssize_t build_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%08x\n", pcard->build_version);
+}
+
+static ssize_t build_date_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%08x\n", pcard->build_datestamp);
+}
+
+static ssize_t build_time_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%08x\n", pcard->build_timestamp);
 }
 
-static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr,
+char *buf)
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
-   return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
+   return sprintf(buf, "%016llx\n", val);
 }
 
 static ssize_t cpld_reconfigure(struct device *dev,
@@ -68,15 +111,15 @@ static ssize_t cpld_reconfigure(struct device *dev,
return count;
 }
 
-DEVICE_ATTR(ssid,   0444, show_attr, NULL);
-DEVICE_ATTR(ddna,   0444, show_attr, NULL);
-DEVICE_ATTR(card_id,0444, show_attr, NULL);
-DEVICE_ATTR(hw_rev, 0444, show_attr, NULL);
-DEVICE_ATTR(build,  0444, show_attr, NULL);
-DEVICE_ATTR(build_date, 0444, show_attr, NULL);
-DEVICE_ATTR(build_time, 0444, show_attr, NULL);
-DEVICE_ATTR(cpld_reg,   0444, show_cpld_config_reg, NULL);
-DEVICE_ATTR(cpld_reconfigure,   0220, NULL, cpld_reconfigure);
+DEVICE_ATTR_RO(ssid);
+DEVICE_ATTR_RO(ddna);
+DEVICE_ATTR_RO(card_id);
+DEVICE_ATTR_RO(hw_rev);
+DEVICE_ATTR_RO(build);
+DEVICE_ATTR_RO(build_date);

[PATCH v2 9/9] staging: kpc2000: declare all kp device attributes as static.

2019-05-16 Thread Jeremy Sowden
The definitions are only used to populate the kp_attr_list attribute
array, so declare them as static.

Fixes the following sparse warnings:

  drivers/staging/kpc2000/kpc2000/core.c:152:1: warning: symbol 'dev_attr_ssid' 
was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:153:1: warning: symbol 'dev_attr_ddna' 
was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:154:1: warning: symbol 
'dev_attr_card_id' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:155:1: warning: symbol 
'dev_attr_hw_rev' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:156:1: warning: symbol 
'dev_attr_build' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:157:1: warning: symbol 
'dev_attr_build_date' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:158:1: warning: symbol 
'dev_attr_build_time' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:159:1: warning: symbol 
'dev_attr_cpld_reg' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:161:1: warning: symbol 
'dev_attr_cpld_reconfigure' was not declared. Should it be static?

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 6fa3dd6531ef..6a06153a20ec 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -111,15 +111,15 @@ static ssize_t cpld_reconfigure(struct device *dev,
return count;
 }
 
-DEVICE_ATTR_RO(ssid);
-DEVICE_ATTR_RO(ddna);
-DEVICE_ATTR_RO(card_id);
-DEVICE_ATTR_RO(hw_rev);
-DEVICE_ATTR_RO(build);
-DEVICE_ATTR_RO(build_date);
-DEVICE_ATTR_RO(build_time);
-DEVICE_ATTR_RO(cpld_reg);
-DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure);
+static DEVICE_ATTR_RO(ssid);
+static DEVICE_ATTR_RO(ddna);
+static DEVICE_ATTR_RO(card_id);
+static DEVICE_ATTR_RO(hw_rev);
+static DEVICE_ATTR_RO(build);
+static DEVICE_ATTR_RO(build_date);
+static DEVICE_ATTR_RO(build_time);
+static DEVICE_ATTR_RO(cpld_reg);
+static DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure);
 
 static const struct attribute *kp_attr_list[] = {
_attr_ssid.attr,
-- 
2.20.1

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


[PATCH v2 4/9] staging: kpc2000: removed two kpc_uio_class device attributes.

2019-05-16 Thread Jeremy Sowden
The show functions of two attributes output nothing and they are unused.
Removed them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 3073b4813b7a..c93156ba5c31 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -169,18 +169,6 @@ static ssize_t type_show(struct device *dev, struct 
device_attribute *attr,
return sprintf(buf, "%u\n", kudev->cte.type);
 }
 
-static ssize_t s2c_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-
-static ssize_t c2s_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-
 static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr,
char *buf)
 {
@@ -230,8 +218,6 @@ static ssize_t core_num_show(struct device *dev, struct 
device_attribute *attr,
 static DEVICE_ATTR_RO(offset);
 static DEVICE_ATTR_RO(size);
 static DEVICE_ATTR_RO(type);
-static DEVICE_ATTR_RO(s2c_dma_ch);
-static DEVICE_ATTR_RO(c2s_dma_ch);
 static DEVICE_ATTR_RO(s2c_dma);
 static DEVICE_ATTR_RO(c2s_dma);
 static DEVICE_ATTR_RO(irq_count);
@@ -242,8 +228,6 @@ struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
_attr_size.attr,
_attr_type.attr,
-   _attr_s2c_dma_ch.attr,
-   _attr_c2s_dma_ch.attr,
_attr_s2c_dma.attr,
_attr_c2s_dma.attr,
_attr_irq_count.attr,
-- 
2.20.1

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


[PATCH v2 6/9] staging: kpc2000: simplified kp2000_device retrieval in device attributes call-backs.

2019-05-16 Thread Jeremy Sowden
The call-backs used the same recipe to get the pcard from dev:

  struct pci_dev *pdev = to_pci_dev(dev);
  struct kp2000_device *pcard;

  if (!pdev) return -ENXIO;
  pcard = pci_get_drvdata(pdev);
  if (!pcard) return -ENXIO;

where to_pci_dev is a wrapper for container_of.

However, pci_set_drvdata is called before the sysfs files are created:

  int  kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  {
// ...

pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);

// ...

pcard->pdev = pdev;
pci_set_drvdata(pdev, pcard);

// ...

err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list);

Therefore, to_pci_dev and pci_get_drvdata cannot return NULL, and pcard
can be initialized directly from dev:

  struct kp2000_device *pcard = dev_get_drvdata(dev);

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 72130a50afd6..c05864cf33ce 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -27,12 +27,7 @@ static atomic_t next_card_num = ATOMIC_INIT(1);
   **/
 static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct kp2000_device *pcard;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
+struct kp2000_device *pcard = dev_get_drvdata(dev);
 
 if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
 if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
@@ -46,31 +41,18 @@ static ssize_t  show_attr(struct device *dev, struct 
device_attribute *attr, cha
 
 static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
-   if (!pdev)
-   return -ENXIO;
-
-   pcard = pci_get_drvdata(pdev);
-   if (!pcard)
-   return -ENXIO;
-
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
 static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
+struct kp2000_device *pcard = dev_get_drvdata(dev);
 long wr_val;
-struct kp2000_device *pcard;
 int rv;
 
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
 rv = kstrtol(buf, 0, _val);
 if (rv < 0)  return rv;
 if (wr_val > 7)  return -EINVAL;
-- 
2.20.1

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


[PATCH v2] Staging: bcm2835-camera: Prefer kernel types

2019-05-16 Thread Madhumitha Prabakaran
Fix the warning issued by checkpatch
Prefer kernel type 'u32' over 'uint32_t'.
Along with that include a blank line after a declaration
to maintain Linux kernel coding style.

Signed-off-by: Madhumitha Prabakaran 

---
Changes in v2:
- Modified subject line
- Included one more change in control.c
---
 drivers/staging/vc04_services/bcm2835-camera/controls.c | 3 ++-
 drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c 
b/drivers/staging/vc04_services/bcm2835-camera/controls.c
index 74410fedffad..5ad957e23895 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
@@ -52,7 +52,8 @@ static const s64 ev_bias_qmenu[] = {
 static const s64 iso_qmenu[] = {
0, 10, 20, 40, 80,
 };
-static const uint32_t iso_values[] = {
+
+static const u32 iso_values[] = {
0, 100, 200, 400, 800,
 };
 
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h 
b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
index d1c57edbe2b8..90793c9f9a0f 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
@@ -309,7 +309,7 @@ struct mmal_msg_port_parameter_set {
u32 port_handle;  /* port */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 struct mmal_msg_port_parameter_set_reply {
@@ -331,7 +331,7 @@ struct mmal_msg_port_parameter_get_reply {
u32 status;   /* Status of mmal_port_parameter_get call */
u32 id; /* Parameter ID  */
u32 size;  /* Parameter size */
-   uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
+   u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 };
 
 /* event messages */
-- 
2.17.1

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


Re: [PATCH 02/11] staging: kpc2000: add separate show functions for kpc_uio_class device attributes.

2019-05-16 Thread Jeremy Sowden
On 2019-05-16, at 22:45:33 +0200, Greg KH wrote:
> On Thu, May 16, 2019 at 09:04:02PM +0100, Jeremy Sowden wrote:
> > Define separate simple show functions for each attribute instead of
> > having a one big one containing a chain of conditionals.
>
> There's nothing wrong with a change of contitionals, if you do it right
> :)
>
> > Signed-off-by: Jeremy Sowden 
> > ---
> >  drivers/staging/kpc2000/kpc2000/cell_probe.c | 138 ---
> >  1 file changed, 92 insertions(+), 46 deletions(-)
> >
> > diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
> > b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > index 6a2ebdf20113..101eb23caaac 100644
> > --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > @@ -145,55 +145,102 @@ struct kpc_uio_device {
> >  u16 core_num;
> >  };
> >
> > -static ssize_t  show_attr(struct device *dev, struct device_attribute 
> > *attr, char *buf)
> > +static ssize_t offset_show(struct device *dev, struct device_attribute 
> > *attr,
> > +  char *buf)
> >  {
> > -struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> > -
> > -#define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
> > -if ATTR_NAME_CMP("offset"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
> > -} else if ATTR_NAME_CMP("size"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
> > -} else if ATTR_NAME_CMP("type"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
> > -}
> > -else if ATTR_NAME_CMP("s2c_dma"){
> > -if (kudev->cte.s2c_dma_present){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", 
> > kudev->cte.s2c_dma_channel_num);
> > -} else {
> > -return scnprintf(buf, PAGE_SIZE, "not present\n");
> > -}
> > -} else if ATTR_NAME_CMP("c2s_dma"){
> > -if (kudev->cte.c2s_dma_present){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", 
> > kudev->cte.c2s_dma_channel_num);
> > -} else {
> > -return scnprintf(buf, PAGE_SIZE, "not present\n");
> > -}
> > -}
> > -else if ATTR_NAME_CMP("irq_count"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count);
> > -} else if ATTR_NAME_CMP("irq_base_num"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_base_num);
> > -} else if ATTR_NAME_CMP("core_num"){
> > -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
> > -} else {
> > -return 0;
> > -}
> > -#undef ATTR_NAME_CMP
> > +   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> > +
> > +   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
> > +}
> > +
> > +static ssize_t size_show(struct device *dev, struct device_attribute *attr,
> > +char *buf)
> > +{
> > +   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> > +
> > +   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
> >  }
> >
> > +static ssize_t type_show(struct device *dev, struct device_attribute *attr,
> > +char *buf)
> > +{
> > +   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> > +
> > +   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
> > +}
> > +
> > +static ssize_t s2c_dma_ch_show(struct device *dev,
> > +  struct device_attribute *attr, char *buf)
> > +{
> > +   return 0;
> > +}
> > +
> > +static ssize_t c2s_dma_ch_show(struct device *dev,
> > +  struct device_attribute *attr, char *buf)
> > +{
> > +   return 0;
> > +}
> > +
> > +static ssize_t s2c_dma_show(struct device *dev, struct device_attribute 
> > *attr,
> > +   char *buf)
> > +{
> > +   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> >
> > -DEVICE_ATTR(offset,  0444, show_attr, NULL);
> > -DEVICE_ATTR(size,0444, show_attr, NULL);
> > -DEVICE_ATTR(type,0444, show_attr, NULL);
> > -DEVICE_ATTR(s2c_dma_ch, 0444, show_attr, NULL);
> > -DEVICE_ATTR(c2s_dma_ch, 0444, show_attr, NULL);
> > -DEVICE_ATTR(s2c_dma, 0444, show_attr, NULL);
> > -DEVICE_ATTR(c2s_dma, 0444, show_attr, NULL);
> > -DEVICE_ATTR(irq_count, 0444, show_attr, NULL);
> > -DEVICE_ATTR(irq_base_num, 0444, show_attr, NULL);
> > -DEVICE_ATTR(core_num, 0444, show_attr, NULL);
> > -struct attribute * kpc_uio_class_attrs[] = {
> > +   if (!kudev->cte.s2c_dma_present)
> > +   return scnprintf(buf, PAGE_SIZE, "not present\n");
> > +
> > +   return scnprintf(buf, PAGE_SIZE, "%u\n",
> > +kudev->cte.s2c_dma_channel_num);
> > +}
> > +
> > +static ssize_t c2s_dma_show(struct device *dev, struct device_attribute 
> > *attr,
> > +   char *buf)
> > +{
> > +   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> > +
> > +   if (!kudev->cte.c2s_dma_present)
> > +   return scnprintf(buf, PAGE_SIZE, "not present\n");
> > +
> > +   return scnprintf(buf, 

Re: [PATCH 02/11] staging: kpc2000: add separate show functions for kpc_uio_class device attributes.

2019-05-16 Thread Jeremy Sowden
On 2019-05-16, at 20:17:51 +, Matt Sickler wrote:
> >-Original Message-
> >From: devel  On Behalf Of
> >Define separate simple show functions for each attribute instead of having a
> >one big one containing a chain of conditionals.
> >
> >+static ssize_t s2c_dma_ch_show(struct device *dev,
> >+  struct device_attribute *attr, char *buf)
> >+{
> >+   return 0;
> >+}
> >+
> >+static ssize_t c2s_dma_ch_show(struct device *dev,
> >+  struct device_attribute *attr, char *buf)
> >+{
> >+   return 0;
> >+}
>
> These two can be removed.  Technically, that would be a
> userspace-breaking change, but I can guarantee that all existing
> userspace consumers don't actually read that sysfs node.

Took them out in a subsequent patch.  Thanks for the confirmation.

J.


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


Re: [PATCH 02/11] staging: kpc2000: add separate show functions for kpc_uio_class device attributes.

2019-05-16 Thread Greg KH
On Thu, May 16, 2019 at 09:04:02PM +0100, Jeremy Sowden wrote:
> Define separate simple show functions for each attribute instead of
> having a one big one containing a chain of conditionals.

There's nothing wrong with a change of contitionals, if you do it right
:)

> Signed-off-by: Jeremy Sowden 
> ---
>  drivers/staging/kpc2000/kpc2000/cell_probe.c | 138 ---
>  1 file changed, 92 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
> b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> index 6a2ebdf20113..101eb23caaac 100644
> --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
> +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> @@ -145,55 +145,102 @@ struct kpc_uio_device {
>  u16 core_num;
>  };
>  
> -static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
> char *buf)
> +static ssize_t offset_show(struct device *dev, struct device_attribute *attr,
> +char *buf)
>  {
> -struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> -
> -#define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
> -if ATTR_NAME_CMP("offset"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
> -} else if ATTR_NAME_CMP("size"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
> -} else if ATTR_NAME_CMP("type"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
> -}
> -else if ATTR_NAME_CMP("s2c_dma"){
> -if (kudev->cte.s2c_dma_present){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", 
> kudev->cte.s2c_dma_channel_num);
> -} else {
> -return scnprintf(buf, PAGE_SIZE, "not present\n");
> -}
> -} else if ATTR_NAME_CMP("c2s_dma"){
> -if (kudev->cte.c2s_dma_present){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", 
> kudev->cte.c2s_dma_channel_num);
> -} else {
> -return scnprintf(buf, PAGE_SIZE, "not present\n");
> -}
> -}
> -else if ATTR_NAME_CMP("irq_count"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count);
> -} else if ATTR_NAME_CMP("irq_base_num"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_base_num);
> -} else if ATTR_NAME_CMP("core_num"){
> -return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
> -} else {
> -return 0;
> -}
> -#undef ATTR_NAME_CMP
> + struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
> +}
> +
> +static ssize_t size_show(struct device *dev, struct device_attribute *attr,
> +  char *buf)
> +{
> + struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
>  }
>  
> +static ssize_t type_show(struct device *dev, struct device_attribute *attr,
> +  char *buf)
> +{
> + struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
> +}
> +
> +static ssize_t s2c_dma_ch_show(struct device *dev,
> +struct device_attribute *attr, char *buf)
> +{
> + return 0;
> +}
> +
> +static ssize_t c2s_dma_ch_show(struct device *dev,
> +struct device_attribute *attr, char *buf)
> +{
> + return 0;
> +}
> +
> +static ssize_t s2c_dma_show(struct device *dev, struct device_attribute 
> *attr,
> + char *buf)
> +{
> + struct kpc_uio_device *kudev = dev_get_drvdata(dev);
>  
> -DEVICE_ATTR(offset,  0444, show_attr, NULL);
> -DEVICE_ATTR(size,0444, show_attr, NULL);
> -DEVICE_ATTR(type,0444, show_attr, NULL);
> -DEVICE_ATTR(s2c_dma_ch, 0444, show_attr, NULL);
> -DEVICE_ATTR(c2s_dma_ch, 0444, show_attr, NULL);
> -DEVICE_ATTR(s2c_dma, 0444, show_attr, NULL);
> -DEVICE_ATTR(c2s_dma, 0444, show_attr, NULL);
> -DEVICE_ATTR(irq_count, 0444, show_attr, NULL);
> -DEVICE_ATTR(irq_base_num, 0444, show_attr, NULL);
> -DEVICE_ATTR(core_num, 0444, show_attr, NULL);
> -struct attribute * kpc_uio_class_attrs[] = {
> + if (!kudev->cte.s2c_dma_present)
> + return scnprintf(buf, PAGE_SIZE, "not present\n");
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n",
> +  kudev->cte.s2c_dma_channel_num);
> +}
> +
> +static ssize_t c2s_dma_show(struct device *dev, struct device_attribute 
> *attr,
> + char *buf)
> +{
> + struct kpc_uio_device *kudev = dev_get_drvdata(dev);
> +
> + if (!kudev->cte.c2s_dma_present)
> + return scnprintf(buf, PAGE_SIZE, "not present\n");
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n",
> +  kudev->cte.c2s_dma_channel_num);
> +}
> +
> +static ssize_t irq_count_show(struct device *dev, struct device_attribute 
> *attr,
> +   char *buf)
> +{
> + struct kpc_uio_device *kudev 

[PATCH 10/11] staging: kpc2000: define read-only kp device attributes as read-only.

2019-05-16 Thread Jeremy Sowden
Most of the device attributes are read-only, so use DEVICE_ATTR_RO
to define them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 7a5dd5f2300b..55e9038117a4 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -111,15 +111,15 @@ static ssize_t cpld_reconfigure(struct device *dev,
return count;
 }
 
-DEVICE_ATTR(ssid, 0444, ssid_show,   NULL);
-DEVICE_ATTR(ddna, 0444, ddna_show,   NULL);
-DEVICE_ATTR(card_id,  0444, card_id_show,NULL);
-DEVICE_ATTR(hw_rev,   0444, hw_rev_show, NULL);
-DEVICE_ATTR(build,0444, build_show,  NULL);
-DEVICE_ATTR(build_date,   0444, build_date_show, NULL);
-DEVICE_ATTR(build_time,   0444, build_time_show, NULL);
-DEVICE_ATTR(cpld_reg, 0444, cpld_reg_show,   NULL);
-DEVICE_ATTR(cpld_reconfigure, 0220, NULL,cpld_reconfigure);
+DEVICE_ATTR_RO(ssid);
+DEVICE_ATTR_RO(ddna);
+DEVICE_ATTR_RO(card_id);
+DEVICE_ATTR_RO(hw_rev);
+DEVICE_ATTR_RO(build);
+DEVICE_ATTR_RO(build_date);
+DEVICE_ATTR_RO(build_time);
+DEVICE_ATTR_RO(cpld_reg);
+DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure);
 
 static const struct attribute *kp_attr_list[] = {
_attr_ssid.attr,
-- 
2.20.1

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


[PATCH 11/11] staging: kpc2000: declare all kp device attributes as static.

2019-05-16 Thread Jeremy Sowden
The definitions are only used to populate the kp_attr_list attribute
array, so declare them as static.

Fixes the following sparse warnings:

  drivers/staging/kpc2000/kpc2000/core.c:152:1: warning: symbol 'dev_attr_ssid' 
was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:153:1: warning: symbol 'dev_attr_ddna' 
was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:154:1: warning: symbol 
'dev_attr_card_id' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:155:1: warning: symbol 
'dev_attr_hw_rev' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:156:1: warning: symbol 
'dev_attr_build' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:157:1: warning: symbol 
'dev_attr_build_date' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:158:1: warning: symbol 
'dev_attr_build_time' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:159:1: warning: symbol 
'dev_attr_cpld_reg' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/core.c:161:1: warning: symbol 
'dev_attr_cpld_reconfigure' was not declared. Should it be static?

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 55e9038117a4..05fca0581e93 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -111,15 +111,15 @@ static ssize_t cpld_reconfigure(struct device *dev,
return count;
 }
 
-DEVICE_ATTR_RO(ssid);
-DEVICE_ATTR_RO(ddna);
-DEVICE_ATTR_RO(card_id);
-DEVICE_ATTR_RO(hw_rev);
-DEVICE_ATTR_RO(build);
-DEVICE_ATTR_RO(build_date);
-DEVICE_ATTR_RO(build_time);
-DEVICE_ATTR_RO(cpld_reg);
-DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure);
+static DEVICE_ATTR_RO(ssid);
+static DEVICE_ATTR_RO(ddna);
+static DEVICE_ATTR_RO(card_id);
+static DEVICE_ATTR_RO(hw_rev);
+static DEVICE_ATTR_RO(build);
+static DEVICE_ATTR_RO(build_date);
+static DEVICE_ATTR_RO(build_time);
+static DEVICE_ATTR_RO(cpld_reg);
+static DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure);
 
 static const struct attribute *kp_attr_list[] = {
_attr_ssid.attr,
-- 
2.20.1

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


[PATCH 05/11] staging: kpc2000: declare all kpc_uio_class device attributes as static.

2019-05-16 Thread Jeremy Sowden
The definitions are only used to populate the kpc_uio_class_attrs
attribute array, so declare them as static.

Fixes the following sparse warnings:

  drivers/staging/kpc2000/kpc2000/cell_probe.c:220:1: warning: symbol 
'dev_attr_offset' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:221:1: warning: symbol 
'dev_attr_size' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:222:1: warning: symbol 
'dev_attr_type' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:223:1: warning: symbol 
'dev_attr_s2c_dma' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:224:1: warning: symbol 
'dev_attr_c2s_dma' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:225:1: warning: symbol 
'dev_attr_irq_count' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:226:1: warning: symbol 
'dev_attr_irq_base_num' was not declared. Should it be static?
  drivers/staging/kpc2000/kpc2000/cell_probe.c:227:1: warning: symbol 
'dev_attr_core_num' was not declared. Should it be static?

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 38c3738209a7..4a1fec7f563b 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -217,14 +217,14 @@ static ssize_t core_num_show(struct device *dev, struct 
device_attribute *attr,
return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
 }
 
-DEVICE_ATTR_RO(offset);
-DEVICE_ATTR_RO(size);
-DEVICE_ATTR_RO(type);
-DEVICE_ATTR_RO(s2c_dma);
-DEVICE_ATTR_RO(c2s_dma);
-DEVICE_ATTR_RO(irq_count);
-DEVICE_ATTR_RO(irq_base_num);
-DEVICE_ATTR_RO(core_num);
+static DEVICE_ATTR_RO(offset);
+static DEVICE_ATTR_RO(size);
+static DEVICE_ATTR_RO(type);
+static DEVICE_ATTR_RO(s2c_dma);
+static DEVICE_ATTR_RO(c2s_dma);
+static DEVICE_ATTR_RO(irq_count);
+static DEVICE_ATTR_RO(irq_base_num);
+static DEVICE_ATTR_RO(core_num);
 
 struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
-- 
2.20.1

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


[PATCH 01/11] staging: kpc2000: removed trailing white-space.

2019-05-16 Thread Jeremy Sowden
Removed trailing white-space from four files.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 62 ++---
 drivers/staging/kpc2000/kpc2000/core.c   | 98 ++--
 drivers/staging/kpc2000/kpc2000/fileops.c|  2 +-
 drivers/staging/kpc2000/kpc2000/pcie.h   | 10 +-
 4 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index bce2bf9eee04..6a2ebdf20113 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -106,24 +106,24 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 };
 
 dev_dbg(>pdev->dev, "Found Basic core: type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
-
-
+
+
 cell.platform_data = _pdata;
 cell.pdata_size = sizeof(struct kpc_core_device_platdata);
 cell.num_resources = 2;
-
+
 memset(, 0, sizeof(resources));
 
 resources[0].start = cte.offset;
 resources[0].end   = cte.offset + (cte.length - 1);
 resources[0].flags = IORESOURCE_MEM;
-
+
 resources[1].start = pcard->pdev->irq;
 resources[1].end   = pcard->pdev->irq;
 resources[1].flags = IORESOURCE_IRQ;
-
+
 cell.resources = resources;
-
+
 return mfd_add_devices(
 PCARD_TO_DEV(pcard),// parent
 pcard->card_num * 100,  // id
@@ -148,7 +148,7 @@ struct kpc_uio_device {
 static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
 struct kpc_uio_device *kudev = dev_get_drvdata(dev);
-
+
 #define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
 if ATTR_NAME_CMP("offset"){
 return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
@@ -228,7 +228,7 @@ irqreturn_t  kuio_handler(int irq, struct uio_info *uioinfo)
 struct kpc_uio_device *kudev = uioinfo->priv;
 if (irq != kudev->pcard->pdev->irq)
 return IRQ_NONE;
-
+
 if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){
 writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base 
+ REG_INTERRUPT_ACTIVE); // Clear the active flag
 return IRQ_HANDLED;
@@ -242,7 +242,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 struct kpc_uio_device *kudev = uioinfo->priv;
 struct kp2000_device *pcard = kudev->pcard;
 u64 mask;
-
+
 lock_card(pcard);
 mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 if (irq_on){
@@ -252,7 +252,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 }
 writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 unlock_card(pcard);
-
+
 return 0;
 }
 
@@ -263,18 +263,18 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 int rv;
 
 dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
-
+
 kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
 if (!kudev){
 dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
 return -ENOMEM;
 }
-
+
 INIT_LIST_HEAD(>list);
 kudev->pcard = pcard;
 kudev->cte = cte;
 kudev->core_num = core_num;
-
+
 kudev->uioinfo.priv = kudev;
 kudev->uioinfo.name = name;
 kudev->uioinfo.version = "0.0";
@@ -291,7 +291,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + 
cte.offset;
 kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); 
// Round up to nearest PAGE_SIZE boundary
 kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS;
-
+
 kudev->dev = device_create(kpc_uio_class, >pdev->dev, MKDEV(0,0), 
kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, 
kudev->core_num);
 if (IS_ERR(kudev->dev)) {
 dev_err(>pdev->dev, "probe_core_uio device_create failed!\n");
@@ -299,7 +299,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 return -ENODEV;
 }
 dev_set_drvdata(kudev->dev, kudev);
-
+
 rv = uio_register_device(kudev->dev, >uioinfo);
 if (rv){
 dev_err(>pdev->dev, "probe_core_uio failed uio_register_device: 
%d\n", rv);
@@ -307,9 +307,9 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 kfree(kudev);
 return rv;
 }
-
+
 list_add_tail(>list, >uio_devices_list);
-
+
 return 0;
 }
 
@@ -320,24 +320,24 @@ static int  create_dma_engine_core(struct kp2000_device 
*pcard, size_t 

[PATCH 07/11] staging: kpc2000: simplified kp2000_device retrieval in device attributes call-backs.

2019-05-16 Thread Jeremy Sowden
The call-backs used the same recipe to get the pcard from dev:

  struct pci_dev *pdev = to_pci_dev(dev);
  struct kp2000_device *pcard;

  if (!pdev) return -ENXIO;
  pcard = pci_get_drvdata(pdev);
  if (!pcard) return -ENXIO;

where to_pci_dev is a wrapper for container_of.

However, pci_set_drvdata is called before the sysfs files are created:

  int  kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  {
// ...

pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);

// ...

pcard->pdev = pdev;
pci_set_drvdata(pdev, pcard);

// ...

err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list);

Therefore, to_pci_dev and pci_get_drvdata cannot return NULL, and pcard
can be initialized directly from dev:

  struct kp2000_device *pcard = dev_get_drvdata(dev);

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 72130a50afd6..c05864cf33ce 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -27,12 +27,7 @@ static atomic_t next_card_num = ATOMIC_INIT(1);
   **/
 static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct kp2000_device *pcard;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
+struct kp2000_device *pcard = dev_get_drvdata(dev);
 
 if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
 if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
@@ -46,31 +41,18 @@ static ssize_t  show_attr(struct device *dev, struct 
device_attribute *attr, cha
 
 static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
-   if (!pdev)
-   return -ENXIO;
-
-   pcard = pci_get_drvdata(pdev);
-   if (!pcard)
-   return -ENXIO;
-
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
 static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
+struct kp2000_device *pcard = dev_get_drvdata(dev);
 long wr_val;
-struct kp2000_device *pcard;
 int rv;
 
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
 rv = kstrtol(buf, 0, _val);
 if (rv < 0)  return rv;
 if (wr_val > 7)  return -EINVAL;
-- 
2.20.1

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


[PATCH 00/11] staging: kpc2000: another batch of fixes

2019-05-16 Thread Jeremy Sowden
These apply on top of the ones I sent earlier this week, which are
currently in the staging-test branch.

There's one white-space patch, a number relating to device attributes
and one that fixes a race affecting the assignment of card numbers.

Jeremy Sowden (11):
  staging: kpc2000: removed trailing white-space.
  staging: kpc2000: add separate show functions for kpc_uio_class device
attributes.
  staging: kpc2000: define all kpc_uio_class device attributes as
read-only.
  staging: kpc2000: removed two kpc_uio_class device attributes.
  staging: kpc2000: declare all kpc_uio_class device attributes as
static.
  staging: kpc2000: use atomic_t to assign card numbers.
  staging: kpc2000: simplified kp2000_device retrieval in device
attributes call-backs.
  staging: kpc2000: add separate show functions for readable kp device
attributes.
  staging: kpc2000: formatting fixes for kp device attributes.
  staging: kpc2000: define read-only kp device attributes as read-only.
  staging: kpc2000: declare all kp device attributes as static.

 drivers/staging/kpc2000/TODO |   1 -
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 186 --
 drivers/staging/kpc2000/kpc2000/core.c   | 253 +++
 drivers/staging/kpc2000/kpc2000/fileops.c|   2 +-
 drivers/staging/kpc2000/kpc2000/pcie.h   |  10 +-
 5 files changed, 255 insertions(+), 197 deletions(-)

-- 
2.20.1

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


[PATCH 02/11] staging: kpc2000: add separate show functions for kpc_uio_class device attributes.

2019-05-16 Thread Jeremy Sowden
Define separate simple show functions for each attribute instead of
having a one big one containing a chain of conditionals.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 138 ---
 1 file changed, 92 insertions(+), 46 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 6a2ebdf20113..101eb23caaac 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -145,55 +145,102 @@ struct kpc_uio_device {
 u16 core_num;
 };
 
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+static ssize_t offset_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
 {
-struct kpc_uio_device *kudev = dev_get_drvdata(dev);
-
-#define ATTR_NAME_CMP(v)  (strcmp(v, attr->attr.name) == 0)
-if ATTR_NAME_CMP("offset"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
-} else if ATTR_NAME_CMP("size"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
-} else if ATTR_NAME_CMP("type"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
-}
-else if ATTR_NAME_CMP("s2c_dma"){
-if (kudev->cte.s2c_dma_present){
-return scnprintf(buf, PAGE_SIZE, "%u\n", 
kudev->cte.s2c_dma_channel_num);
-} else {
-return scnprintf(buf, PAGE_SIZE, "not present\n");
-}
-} else if ATTR_NAME_CMP("c2s_dma"){
-if (kudev->cte.c2s_dma_present){
-return scnprintf(buf, PAGE_SIZE, "%u\n", 
kudev->cte.c2s_dma_channel_num);
-} else {
-return scnprintf(buf, PAGE_SIZE, "not present\n");
-}
-}
-else if ATTR_NAME_CMP("irq_count"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count);
-} else if ATTR_NAME_CMP("irq_base_num"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_base_num);
-} else if ATTR_NAME_CMP("core_num"){
-return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
-} else {
-return 0;
-}
-#undef ATTR_NAME_CMP
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset);
+}
+
+static ssize_t size_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length);
 }
 
+static ssize_t type_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
+}
+
+static ssize_t s2c_dma_ch_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   return 0;
+}
+
+static ssize_t c2s_dma_ch_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   return 0;
+}
+
+static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
 
-DEVICE_ATTR(offset,  0444, show_attr, NULL);
-DEVICE_ATTR(size,0444, show_attr, NULL);
-DEVICE_ATTR(type,0444, show_attr, NULL);
-DEVICE_ATTR(s2c_dma_ch, 0444, show_attr, NULL);
-DEVICE_ATTR(c2s_dma_ch, 0444, show_attr, NULL);
-DEVICE_ATTR(s2c_dma, 0444, show_attr, NULL);
-DEVICE_ATTR(c2s_dma, 0444, show_attr, NULL);
-DEVICE_ATTR(irq_count, 0444, show_attr, NULL);
-DEVICE_ATTR(irq_base_num, 0444, show_attr, NULL);
-DEVICE_ATTR(core_num, 0444, show_attr, NULL);
-struct attribute * kpc_uio_class_attrs[] = {
+   if (!kudev->cte.s2c_dma_present)
+   return scnprintf(buf, PAGE_SIZE, "not present\n");
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n",
+kudev->cte.s2c_dma_channel_num);
+}
+
+static ssize_t c2s_dma_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   if (!kudev->cte.c2s_dma_present)
+   return scnprintf(buf, PAGE_SIZE, "not present\n");
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n",
+kudev->cte.c2s_dma_channel_num);
+}
+
+static ssize_t irq_count_show(struct device *dev, struct device_attribute 
*attr,
+ char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count);
+}
+
+static ssize_t irq_base_num_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct kpc_uio_device *kudev = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%u\n", 

[PATCH 03/11] staging: kpc2000: define all kpc_uio_class device attributes as read-only.

2019-05-16 Thread Jeremy Sowden
All of the device attributes are read-only, so use DEVICE_ATTR_RO to
define them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 101eb23caaac..da15ae5b5a3d 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -229,16 +229,16 @@ static ssize_t core_num_show(struct device *dev, struct 
device_attribute *attr,
return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num);
 }
 
-DEVICE_ATTR(offset,   0444, offset_show,   NULL);
-DEVICE_ATTR(size, 0444, size_show, NULL);
-DEVICE_ATTR(type, 0444, type_show, NULL);
-DEVICE_ATTR(s2c_dma_ch,   0444, s2c_dma_ch_show,   NULL);
-DEVICE_ATTR(c2s_dma_ch,   0444, c2s_dma_ch_show,   NULL);
-DEVICE_ATTR(s2c_dma,  0444, s2c_dma_show,  NULL);
-DEVICE_ATTR(c2s_dma,  0444, c2s_dma_show,  NULL);
-DEVICE_ATTR(irq_count,0444, irq_count_show,NULL);
-DEVICE_ATTR(irq_base_num, 0444, irq_base_num_show, NULL);
-DEVICE_ATTR(core_num, 0444, core_num_show, NULL);
+DEVICE_ATTR_RO(offset);
+DEVICE_ATTR_RO(size);
+DEVICE_ATTR_RO(type);
+DEVICE_ATTR_RO(s2c_dma_ch);
+DEVICE_ATTR_RO(c2s_dma_ch);
+DEVICE_ATTR_RO(s2c_dma);
+DEVICE_ATTR_RO(c2s_dma);
+DEVICE_ATTR_RO(irq_count);
+DEVICE_ATTR_RO(irq_base_num);
+DEVICE_ATTR_RO(core_num);
 
 struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
-- 
2.20.1

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


[PATCH 04/11] staging: kpc2000: removed two kpc_uio_class device attributes.

2019-05-16 Thread Jeremy Sowden
The show functions of two attributes output nothing.  Removed them.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index da15ae5b5a3d..38c3738209a7 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -169,18 +169,6 @@ static ssize_t type_show(struct device *dev, struct 
device_attribute *attr,
return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type);
 }
 
-static ssize_t s2c_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-
-static ssize_t c2s_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-
 static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr,
char *buf)
 {
@@ -232,8 +220,6 @@ static ssize_t core_num_show(struct device *dev, struct 
device_attribute *attr,
 DEVICE_ATTR_RO(offset);
 DEVICE_ATTR_RO(size);
 DEVICE_ATTR_RO(type);
-DEVICE_ATTR_RO(s2c_dma_ch);
-DEVICE_ATTR_RO(c2s_dma_ch);
 DEVICE_ATTR_RO(s2c_dma);
 DEVICE_ATTR_RO(c2s_dma);
 DEVICE_ATTR_RO(irq_count);
@@ -244,8 +230,6 @@ struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
_attr_size.attr,
_attr_type.attr,
-   _attr_s2c_dma_ch.attr,
-   _attr_c2s_dma_ch.attr,
_attr_s2c_dma.attr,
_attr_c2s_dma.attr,
_attr_irq_count.attr,
-- 
2.20.1

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


[PATCH 09/11] staging: kpc2000: formatting fixes for kp device attributes.

2019-05-16 Thread Jeremy Sowden
Fixed indentation of cpld_reconfigure store call-back and definition of
attribute list.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 51 ++
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index e7e0d188ff73..7a5dd5f2300b 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -91,20 +91,24 @@ static ssize_t cpld_reg_show(struct device *dev, struct 
device_attribute *attr,
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
 
-static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
+static ssize_t cpld_reconfigure(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
-struct kp2000_device *pcard = dev_get_drvdata(dev);
-long wr_val;
-int rv;
-
-rv = kstrtol(buf, 0, _val);
-if (rv < 0)  return rv;
-if (wr_val > 7)  return -EINVAL;
-
-wr_val = wr_val << 8;
-wr_val |= 0x1; // Set the "Configure Go" bit
-writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
-return count;
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+   long wr_val;
+   int rv;
+
+   rv = kstrtol(buf, 0, _val);
+   if (rv < 0)
+   return rv;
+   if (wr_val > 7)
+   return -EINVAL;
+
+   wr_val = wr_val << 8;
+   wr_val |= 0x1; // Set the "Configure Go" bit
+   writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
+   return count;
 }
 
 DEVICE_ATTR(ssid, 0444, ssid_show,   NULL);
@@ -118,19 +122,18 @@ DEVICE_ATTR(cpld_reg, 0444, cpld_reg_show,   
NULL);
 DEVICE_ATTR(cpld_reconfigure, 0220, NULL,cpld_reconfigure);
 
 static const struct attribute *kp_attr_list[] = {
-_attr_ssid.attr,
-_attr_ddna.attr,
-_attr_card_id.attr,
-_attr_hw_rev.attr,
-_attr_build.attr,
-_attr_build_date.attr,
-_attr_build_time.attr,
-_attr_cpld_reg.attr,
-_attr_cpld_reconfigure.attr,
-NULL,
+   _attr_ssid.attr,
+   _attr_ddna.attr,
+   _attr_card_id.attr,
+   _attr_hw_rev.attr,
+   _attr_build.attr,
+   _attr_build_date.attr,
+   _attr_build_time.attr,
+   _attr_cpld_reg.attr,
+   _attr_cpld_reconfigure.attr,
+   NULL,
 };
 
-
 /***
   * Functions
   **/
-- 
2.20.1

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


[PATCH 08/11] staging: kpc2000: add separate show functions for readable kp device attributes.

2019-05-16 Thread Jeremy Sowden
Define separate simple show functions for each attribute instead of
having a one big one containing a chain of conditionals.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/kpc2000/core.c | 91 +++---
 1 file changed, 67 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index c05864cf33ce..e7e0d188ff73 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -19,27 +19,70 @@
 #include 
 #include "pcie.h"
 
-
 static atomic_t next_card_num = ATOMIC_INIT(1);
 
 /***
   * SysFS Attributes
   **/
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+
+static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
+char *buf)
 {
-struct kp2000_device *pcard = dev_get_drvdata(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid);
+}
+
+static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna);
+}
+
+static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id);
+}
+
+static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
-if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
-if (strcmp("card_id", attr->attr.name) == 0){  return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->card_id);  } else
-if (strcmp("hw_rev", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->hardware_revision);  } else
-if (strcmp("build", attr->attr.name) == 0){return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_version);  } else
-if (strcmp("build_date", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_datestamp);  } else
-if (strcmp("build_time", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_timestamp);  } else
-{ return -ENXIO; }
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->hardware_revision);
 }
 
-static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t build_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_version);
+}
+
+static ssize_t build_date_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_datestamp);
+}
+
+static ssize_t build_time_show(struct device *dev,
+  struct device_attribute *attr, char *buf)
+{
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_timestamp);
+}
+
+static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr,
+char *buf)
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
@@ -47,6 +90,7 @@ static ssize_t  show_cpld_config_reg(struct device *dev, 
struct device_attribute
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
+
 static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
 {
 struct kp2000_device *pcard = dev_get_drvdata(dev);
@@ -63,18 +107,17 @@ static ssize_t cpld_reconfigure(struct device *dev, struct 
device_attribute *att
 return count;
 }
 
-
-DEVICE_ATTR(ssid,   0444, show_attr, NULL);
-DEVICE_ATTR(ddna,   0444, show_attr, NULL);
-DEVICE_ATTR(card_id,0444, show_attr, NULL);
-DEVICE_ATTR(hw_rev, 0444, show_attr, NULL);
-DEVICE_ATTR(build,  0444, show_attr, NULL);
-DEVICE_ATTR(build_date, 0444, show_attr, NULL);
-DEVICE_ATTR(build_time, 0444, show_attr, NULL);
-DEVICE_ATTR(cpld_reg,   0444, show_cpld_config_reg, NULL);
-DEVICE_ATTR(cpld_reconfigure,   0220, NULL, cpld_reconfigure);
-
-static const struct attribute *  

[PATCH 06/11] staging: kpc2000: use atomic_t to assign card numbers.

2019-05-16 Thread Jeremy Sowden
Previously the next card number was assigned from a static int local
variable, which was read and later incremented.  This was not thread-
safe, so now we use an atomic_t and atomic_fetch_add instead.

Updated TODO.

Signed-off-by: Jeremy Sowden 
---
 drivers/staging/kpc2000/TODO   | 1 -
 drivers/staging/kpc2000/kpc2000/core.c | 7 ---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO
index 669fe5bf9637..47530e23e940 100644
--- a/drivers/staging/kpc2000/TODO
+++ b/drivers/staging/kpc2000/TODO
@@ -1,6 +1,5 @@
 - the kpc_spi driver doesn't seem to let multiple transactions (to different 
instances of the core) happen in parallel...
 - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton.  
It functions against current hardware though.
-- pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic 
/ locking / something better.
 - would be nice if the AIO fileops in kpc_dma could be made to work
 - probably want to add a CONFIG_ option to control compilation of the AIO 
functions
 - if the AIO fileops in kpc_dma start working, next would be making iov_count 
> 1 work too
diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index eb8bac62d33d..72130a50afd6 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include 
 #include 
 #include 
 #include 
@@ -19,6 +20,8 @@
 #include "pcie.h"
 
 
+static atomic_t next_card_num = ATOMIC_INIT(1);
+
 /***
   * SysFS Attributes
   **/
@@ -202,7 +205,6 @@ int  kp2000_pcie_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 {
 int err = 0;
 struct kp2000_device *pcard;
-static int card_count = 1;
 int rv;
 unsigned long reg_bar_phys_addr;
 unsigned long reg_bar_phys_len;
@@ -222,8 +224,7 @@ int  kp2000_pcie_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 //}
 
 //{ Step 2: Initialize trivial pcard elements
-pcard->card_num = card_count;
-card_count++;
+pcard->card_num = atomic_fetch_add(1, _card_num);
 scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num);
 
 mutex_init(>sem);
-- 
2.20.1

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


Re: [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL

2019-05-16 Thread Hariprasad Kelam
On Thu, May 16, 2019 at 11:00:56AM +0300, Dan Carpenter wrote:
> On Wed, May 15, 2019 at 11:15:36PM +0530, Hariprasad Kelam wrote:
> > @@ -1042,7 +1042,7 @@ sint sta2ap_data_frame(
> > }
> >  
> > *psta = rtw_get_stainfo(pstapriv, pattrib->src);
> > -   if (*psta == NULL) {
> > +   if (!*psta == NULL) {
> ^^
> It's surprising that this didn't cause some kind of warning somewhere...

Thanks for pointing out this error. Here my intention is to write
if(!*psta) 
but somehow i missed it .

Will resend this patch after correcting the same.Like below

> -   if (*psta == NULL) {
> > +   if (!*psta) {


Do let me know if the above propose change is fine or not.
> 
> > RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't 
> > get psta under AP_MODE; drop pkt\n"));
> > DBG_871X("issue_deauth to sta =" MAC_FMT " for the 
> > reason(7)\n", MAC_ARG(pattrib->src));
> >  
> 
> regards,
> dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] iio: adc: ad7606: Add support for software mode for ad7616

2019-05-16 Thread Beniamin Bia
Support for ad7616 running in software was added. In order
to activate the software mode, HW_RNGSEL pins must be pulled low.
Oversampling and input ranges are now configured in corresponding
registers. Ad7616 has multiple scale options when it is configured
in software mode.

Signed-off-by: Beniamin Bia 
---
 drivers/iio/adc/ad7606.c | 111 ---
 1 file changed, 103 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 6df81117cacc..f77df3efe43f 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -29,6 +29,20 @@
 
 #include "ad7606.h"
 
+#define AD7606_RANGE_CH_ADDR(ch)   (0x03 + ((ch) >> 1))
+#define AD7606_OS_MODE 0x08
+
+#define AD7616_CONFIGURATION_REGISTER  0x02
+#define AD7616_OS_MASK GENMASK(4,  2)
+#define AD7616_BURST_MODE  BIT(6)
+#define AD7616_SEQEN_MODE  BIT(5)
+#define AD7616_RANGE_CH_ADDR_OFF   0x04
+#define AD7616_RANGE_CH_ADDR(ch)   ch) & 0x1) << 1) + ((ch) >> 3))
+#define AD7616_RANGE_CH_MSK(ch)(GENMASK(1, 0) << ((ch) & 0x6))
+#define AD7616_RANGE_CH_MODE(ch, mode) ((mode) << (ch & GENMASK(2, 1)))
+
+static int ad7616_sw_mode_config(struct iio_dev *indio_dev);
+
 /*
  * Scales are computed as 5000/32768 and 1/32768 respectively,
  * so that when applied to the raw values they provide mV values
@@ -37,6 +51,11 @@ static const unsigned int ad7606_scale_avail[2] = {
152588, 305176
 };
 
+
+static const unsigned int ad7616_sw_scale_avail[3] = {
+   76293, 152588, 305176
+};
+
 static const unsigned int ad7606_oversampling_avail[7] = {
1, 2, 4, 8, 16, 32, 64,
 };
@@ -282,6 +301,26 @@ static int ad7606_write_os_hw(struct iio_dev *indio_dev, 
int val)
return 0;
 }
 
+static int ad7616_write_scale_sw(struct iio_dev *indio_dev, int ch, int val)
+{
+   struct ad7606_state *st = iio_priv(indio_dev);
+   unsigned int ch_addr, mode;
+
+   ch_addr = AD7616_RANGE_CH_ADDR_OFF + AD7616_RANGE_CH_ADDR(ch);
+   mode = AD7616_RANGE_CH_MODE(ch, ((val + 1) & 0x3));
+
+   return ad7606_spi_write_mask(st, ch_addr, AD7616_RANGE_CH_MSK(ch),
+mode);
+}
+
+static int ad7616_write_os_sw(struct iio_dev *indio_dev, int val)
+{
+   struct ad7606_state *st = iio_priv(indio_dev);
+
+   return ad7606_spi_write_mask(st, AD7616_CONFIGURATION_REGISTER,
+AD7616_OS_MASK, val << 2);
+}
+
 static int ad7606_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
@@ -368,14 +407,14 @@ static const struct attribute_group 
ad7606_attribute_group_range = {
.attrs = ad7606_attributes_range,
 };
 
-#define AD760X_CHANNEL(num, mask) {\
+#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all) {   \
.type = IIO_VOLTAGE,\
.indexed = 1,   \
.channel = num, \
.address = num, \
-   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),   \
-   .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\
-   .info_mask_shared_by_all = mask,\
+   .info_mask_separate = mask_sep, \
+   .info_mask_shared_by_type = mask_type,  \
+   .info_mask_shared_by_all = mask_all,\
.scan_index = num,  \
.scan_type = {  \
.sign = 's',\
@@ -385,11 +424,18 @@ static const struct attribute_group 
ad7606_attribute_group_range = {
},  \
 }
 
-#define AD7605_CHANNEL(num)\
-   AD760X_CHANNEL(num, 0)
+#define AD7605_CHANNEL(num)\
+   AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \
+   BIT(IIO_CHAN_INFO_SCALE), 0)
+
+#define AD7606_CHANNEL(num)\
+   AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \
+   BIT(IIO_CHAN_INFO_SCALE),   \
+   BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
 
-#define AD7606_CHANNEL(num)\
-   AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
+#define AD7616_CHANNEL(num)\
+   AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),\
+   0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
 
 static const struct iio_chan_spec ad7605_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(4),
@@ -441,6 +487,26 @@ static const struct iio_chan_spec ad7616_channels[] = {
AD7606_CHANNEL(15),
 };
 
+static const struct iio_chan_spec ad7616_sw_channels[] = {
+   

代 鐦 醥

2019-05-16 Thread yRb1
187口216口21564薇
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] iio: adc: ad7606: Make SPI register calculation generic and add spi support

2019-05-16 Thread Beniamin Bia
In order to support AD7616 software mode, the spi register access must be
added and the calculation of registers address must be generic.
The length of address and bit which specifies the read/write operation is
different for every device, that is why it was made generic.

Signed-off-by: Beniamin Bia 
---
 drivers/iio/adc/ad7606.c | 60 
 drivers/iio/adc/ad7606.h |  2 ++
 2 files changed, 62 insertions(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index aba0fd123a51..6df81117cacc 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 #include "ad7606.h"
 
 /*
@@ -43,6 +45,11 @@ static const unsigned int ad7616_oversampling_avail[8] = {
1, 2, 4, 8, 16, 32, 64, 128,
 };
 
+static int ad7616_spi_rd_wr_cmd(int addr, char isWriteOp)
+{
+   return ((addr & 0x7F) << 1) | ((isWriteOp & 0x1) << 7);
+}
+
 static int ad7606_reset(struct ad7606_state *st)
 {
if (st->gpio_reset) {
@@ -55,6 +62,59 @@ static int ad7606_reset(struct ad7606_state *st)
return -ENODEV;
 }
 
+static int ad7606_spi_reg_read(struct ad7606_state *st, unsigned int addr)
+{
+   struct spi_device *spi = to_spi_device(st->dev);
+   struct spi_transfer t[] = {
+   {
+   .tx_buf = >data[0],
+   .len = 2,
+   .cs_change = 0,
+   }, {
+   .rx_buf = >data[1],
+   .len = 2,
+   },
+   };
+   int ret;
+
+   st->data[0] = cpu_to_be16(st->chip_info->spi_rd_wr_cmd(addr, 0) << 8);
+
+   ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t));
+   if (ret < 0)
+   return ret;
+
+   return be16_to_cpu(st->data[1]);
+}
+
+static int ad7606_spi_reg_write(struct ad7606_state *st,
+   unsigned int addr,
+   unsigned int val)
+{
+   struct spi_device *spi = to_spi_device(st->dev);
+
+   st->data[0] = cpu_to_be16((st->chip_info->spi_rd_wr_cmd(addr, 1) << 8) |
+ (val & 0x1FF));
+
+   return spi_write(spi, >data[0], sizeof(st->data[0]));
+}
+
+static int ad7606_spi_write_mask(struct ad7606_state *st,
+unsigned int addr,
+unsigned long mask,
+unsigned int val)
+{
+   int readval;
+
+   readval = ad7606_spi_reg_read(st, addr);
+   if (readval < 0)
+   return readval;
+
+   readval &= ~mask;
+   readval |= val;
+
+   return ad7606_spi_reg_write(st, addr, readval);
+}
+
 static int ad7606_read_samples(struct ad7606_state *st)
 {
unsigned int num = st->chip_info->num_channels;
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index d8a509c2c428..dfc60af9b8ac 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -16,6 +16,7 @@
  * oversampling ratios.
  * @oversampling_num   number of elements stored in oversampling_avail array
  * @os_req_reset   some devices require a reset to update oversampling
+ * @spi_rd_wr_cmd  pointer to the function which calculates the spi address
  * @write_scale_sw pointer to the function which writes the scale via spi
in software mode
  * @write_os_swpointer to the function which writes the os via 
spi
@@ -29,6 +30,7 @@ struct ad7606_chip_info {
const unsigned int  *oversampling_avail;
unsigned intoversampling_num;
boolos_req_reset;
+   int (*spi_rd_wr_cmd)(int addr, char isWriteOp);
int (*write_scale_sw)(struct iio_dev *indio_dev, int ch, int val);
int (*write_os_sw)(struct iio_dev *indio_dev, int val);
int (*sw_mode_config)(struct iio_dev *indio_dev);
-- 
2.17.1

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


[PATCH 5/5] iio: adc: ad7606: Add debug mode for ad7616

2019-05-16 Thread Beniamin Bia
Support for register access was added for spi devices.

Signed-off-by: Beniamin Bia 
---
 drivers/iio/adc/ad7606.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index f77df3efe43f..b03bdce4fd4e 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -134,6 +134,30 @@ static int ad7606_spi_write_mask(struct ad7606_state *st,
return ad7606_spi_reg_write(st, addr, readval);
 }
 
+static int ad7606_reg_access(struct iio_dev *indio_dev,
+unsigned int reg,
+unsigned int writeval,
+unsigned int *readval)
+{
+   struct ad7606_state *st = iio_priv(indio_dev);
+   int ret;
+
+   mutex_lock(>lock);
+   if (readval) {
+   ret = ad7606_spi_reg_read(st, reg);
+   if (ret < 0)
+   goto err_unlock;
+   *readval = ret;
+   ret = 0;
+   } else {
+   ret = ad7606_spi_reg_write(st, reg, writeval);
+   }
+err_unlock:
+   mutex_unlock(>lock);
+
+   return ret;
+}
+
 static int ad7606_read_samples(struct ad7606_state *st)
 {
unsigned int num = st->chip_info->num_channels;
@@ -645,6 +669,7 @@ static const struct iio_info ad7606_info_no_os_or_range = {
 static const struct iio_info ad7606_info_os_and_range = {
.read_raw = _read_raw,
.write_raw = _write_raw,
+   .debugfs_reg_access = _reg_access,
.attrs = _attribute_group_os_and_range,
.validate_trigger = _validate_trigger,
 };
-- 
2.17.1

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


[PATCH 1/5] iio: adc: ad7606: Move oversampling and scale options to chip info

2019-05-16 Thread Beniamin Bia
The device dependent options which are going to be different for devices
which will be supported  in the future by this driver,
were moved in chip info for a more generic driver. This patch allows
supporting more devices by the driver. Also, it is an intermediate
step of adding support for ad7616 in software mode.

Signed-off-by: Beniamin Bia 
---
 drivers/iio/adc/ad7606.c | 61 +---
 drivers/iio/adc/ad7606.h | 15 +-
 2 files changed, 58 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 24c70c3cefb4..c66ff22f32d2 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -158,7 +158,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
*val = 0;
-   *val2 = st->scale_avail[st->range];
+   *val2 = st->scale_avail[st->range[0]];
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
*val = st->oversampling;
@@ -194,6 +194,32 @@ static ssize_t in_voltage_scale_available_show(struct 
device *dev,
 
 static IIO_DEVICE_ATTR_RO(in_voltage_scale_available, 0);
 
+static int ad7606_write_scale_hw(struct iio_dev *indio_dev, int ch, int val)
+{
+   struct ad7606_state *st = iio_priv(indio_dev);
+
+   gpiod_set_value(st->gpio_range, val);
+
+   return 0;
+}
+
+static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val)
+{
+   struct ad7606_state *st = iio_priv(indio_dev);
+   DECLARE_BITMAP(values, 3);
+
+   values[0] = val;
+
+   gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
+ st->gpio_os->info, values);
+
+   /* AD7616 requires a reset to update value */
+   if (st->chip_info->os_req_reset)
+   ad7606_reset(st);
+
+   return 0;
+}
+
 static int ad7606_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
@@ -201,15 +227,18 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
long mask)
 {
struct ad7606_state *st = iio_priv(indio_dev);
-   DECLARE_BITMAP(values, 3);
-   int i;
+   int i, ret, ch = 0;
 
switch (mask) {
case IIO_CHAN_INFO_SCALE:
mutex_lock(>lock);
i = find_closest(val2, st->scale_avail, st->num_scales);
-   gpiod_set_value(st->gpio_range, i);
-   st->range = i;
+   ret = st->write_scale(indio_dev, chan->address, i);
+   if (ret < 0) {
+   mutex_unlock(>lock);
+   return ret;
+   }
+   st->range[ch] = i;
mutex_unlock(>lock);
 
return 0;
@@ -218,17 +247,12 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
return -EINVAL;
i = find_closest(val, st->oversampling_avail,
 st->num_os_ratios);
-
-   values[0] = i;
-
mutex_lock(>lock);
-   gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
- st->gpio_os->info, values);
-
-   /* AD7616 requires a reset to update value */
-   if (st->chip_info->os_req_reset)
-   ad7606_reset(st);
-
+   ret = st->write_os(indio_dev, i);
+   if (ret < 0) {
+   mutex_unlock(>lock);
+   return ret;
+   }
st->oversampling = st->oversampling_avail[i];
mutex_unlock(>lock);
 
@@ -536,7 +560,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem 
*base_address,
st->bops = bops;
st->base_address = base_address;
/* tied to logic low, analog input range is +/- 5V */
-   st->range = 0;
+   st->range[0] = 0;
st->oversampling = 1;
st->scale_avail = ad7606_scale_avail;
st->num_scales = ARRAY_SIZE(ad7606_scale_avail);
@@ -589,6 +613,9 @@ int ad7606_probe(struct device *dev, int irq, void __iomem 
*base_address,
if (ret)
dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n");
 
+   st->write_scale = ad7606_write_scale_hw;
+   st->write_os = ad7606_write_os_hw;
+
st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
  indio_dev->name, indio_dev->id);
if (!st->trig)
@@ -643,7 +670,7 @@ static int ad7606_resume(struct device *dev)
struct ad7606_state *st = iio_priv(indio_dev);
 
if (st->gpio_standby) {
-   gpiod_set_value(st->gpio_range, st->range);
+   gpiod_set_value(st->gpio_range, st->range[0]);
gpiod_set_value(st->gpio_standby, 1);
ad7606_reset(st);
}
diff 

[PATCH 2/5] iio: adc: ad7606: Add software configuration

2019-05-16 Thread Beniamin Bia
Because this driver will support multiple configurations for software,
the software configuration was made generic.

Signed-off-by: Beniamin Bia 
---
 drivers/iio/adc/ad7606.c | 40 +---
 drivers/iio/adc/ad7606.h |  2 ++
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index c66ff22f32d2..aba0fd123a51 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -140,7 +140,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
   int *val2,
   long m)
 {
-   int ret;
+   int ret, ch = 0;
struct ad7606_state *st = iio_priv(indio_dev);
 
switch (m) {
@@ -157,8 +157,10 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
*val = (short)ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
+   if (st->sw_mode_en)
+   ch = chan->address;
*val = 0;
-   *val2 = st->scale_avail[st->range[0]];
+   *val2 = st->scale_avail[st->range[ch]];
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
*val = st->oversampling;
@@ -233,7 +235,9 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
mutex_lock(>lock);
i = find_closest(val2, st->scale_avail, st->num_scales);
-   ret = st->write_scale(indio_dev, chan->address, i);
+   if (st->sw_mode_en)
+   ch = chan->address;
+   ret = st->write_scale(indio_dev, ch, i);
if (ret < 0) {
mutex_unlock(>lock);
return ret;
@@ -616,6 +620,36 @@ int ad7606_probe(struct device *dev, int irq, void __iomem 
*base_address,
st->write_scale = ad7606_write_scale_hw;
st->write_os = ad7606_write_os_hw;
 
+   if (st->chip_info->sw_mode_config)
+   st->sw_mode_en = device_property_present(st->dev,
+"adi,sw-mode");
+
+   if (st->sw_mode_en) {
+   /* After reset, in software mode, ±10 V is set by default */
+   memset32(st->range, 2, ARRAY_SIZE(st->range));
+   indio_dev->info = _info_os_and_range;
+
+   /*
+* In software mode, the range gpio has no longer its function.
+* Instead, the scale can be configured individually for each
+* channel from the range registers.
+*/
+   if (st->chip_info->write_scale_sw)
+   st->write_scale = st->chip_info->write_scale_sw;
+
+   /*
+* In software mode, the oversampling is no longer configured
+* with GPIO pins. Instead, the oversampling can be configured
+* in configuratiion register.
+*/
+   if (st->chip_info->write_os_sw)
+   st->write_os = st->chip_info->write_os_sw;
+
+   ret = st->chip_info->sw_mode_config(indio_dev);
+   if (ret < 0)
+   return ret;
+   }
+
st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
  indio_dev->name, indio_dev->id);
if (!st->trig)
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index 143c30163df9..d8a509c2c428 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -43,6 +43,7 @@ struct ad7606_chip_info {
  * @range  voltage range selection, selects which scale to apply
  * @oversampling   oversampling selection
  * @base_address   address from where to read data in parallel operation
+ * @sw_mode_en software mode enabled
  * @scale_availpointer to the array which stores the available 
scales
  * @num_scales number of elements stored in the scale_avail array
  * @oversampling_avail pointer to the array which stores the available
@@ -71,6 +72,7 @@ struct ad7606_state {
unsigned intrange[16];
unsigned intoversampling;
void __iomem*base_address;
+   boolsw_mode_en;
const unsigned int  *scale_avail;
unsigned intnum_scales;
const unsigned int  *oversampling_avail;
-- 
2.17.1

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


Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android

2019-05-16 Thread Oleg Nesterov
On 05/15, Sultan Alsawaf wrote:
>
> On Wed, May 15, 2019 at 04:58:32PM +0200, Oleg Nesterov wrote:
> > Could you explain in detail what exactly did you do and what do you see in 
> > dmesg?
> >
> > Just in case, lockdep complains only once, print_circular_bug() does 
> > debug_locks_off()
> > so it it has already reported another false positive __lock_acquire() will 
> > simply
> > return after that.
> >
> > Oleg.
>
> This is what I did:
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 774ab79d3ec7..009e7d431a88 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -3078,6 +3078,7 @@ static int __lock_acquire(struct lockdep_map *lock, 
> unsigned int subclass,
> int class_idx;
> u64 chain_key;
>
> +   BUG_ON(!debug_locks || !prove_locking);
> if (unlikely(!debug_locks))
> return 0;
>
> diff --git a/lib/debug_locks.c b/lib/debug_locks.c
> index 124fdf238b3d..4003a18420fb 100644
> --- a/lib/debug_locks.c
> +++ b/lib/debug_locks.c
> @@ -37,6 +37,7 @@ EXPORT_SYMBOL_GPL(debug_locks_silent);
>   */
>  int debug_locks_off(void)
>  {
> +   return 0;
> if (debug_locks && __debug_locks_off()) {
> if (!debug_locks_silent) {
> console_verbose();

OK, this means that debug_locks_off() always returns 0, as if debug_locks was 
already
cleared.

Thus print_deadlock_bug() will do nothing, it does

if (!debug_locks_off_graph_unlock() || debug_locks_silent)
return 0;

iow this means that even if lockdep finds a problem, the problem won't be 
reported.

> [1.492128] BUG: key  not in .data!
> [1.492141] BUG: key  not in .data!
> [1.492152] BUG: key  not in .data!
> [1.492228] BUG: key  not in .data!
> [1.492238] BUG: key  not in .data!
> [1.492248] BUG: key  not in .data!

I guess this is lockdep_init_map() which does printk("BUG:") itself, but due to 
your
change above it doesn't do WARN(1) and thus there is no call trace.

Oleg.

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


[PATCH v2] staging: vt6656: returns error code on vnt_int_start_interrupt fail

2019-05-16 Thread Quentin Deslandes
Returns error code from 'vnt_int_start_interrupt()' so the device's private
buffers will be correctly freed and 'struct ieee80211_hw' start function
will return an error code.

Signed-off-by: Quentin Deslandes 
---
 drivers/staging/vt6656/int.c  |  4 +++-
 drivers/staging/vt6656/int.h  |  2 +-
 drivers/staging/vt6656/main_usb.c | 12 +---
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 504424b19fcf..f3ee2198e1b3 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -39,7 +39,7 @@ static const u8 fallback_rate1[5][5] = {
{RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
 };
 
-void vnt_int_start_interrupt(struct vnt_private *priv)
+int vnt_int_start_interrupt(struct vnt_private *priv)
 {
unsigned long flags;
int status;
@@ -51,6 +51,8 @@ void vnt_int_start_interrupt(struct vnt_private *priv)
status = vnt_start_interrupt_urb(priv);
 
spin_unlock_irqrestore(>lock, flags);
+
+   return status;
 }
 
 static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index 987c454e99e9..8a6d60569ceb 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -41,7 +41,7 @@ struct vnt_interrupt_data {
u8 sw[2];
 } __packed;
 
-void vnt_int_start_interrupt(struct vnt_private *priv);
+int vnt_int_start_interrupt(struct vnt_private *priv);
 void vnt_int_process_data(struct vnt_private *priv);
 
 #endif /* __INT_H__ */
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index ccafcc2c87ac..71e10b9ae253 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -483,6 +483,7 @@ static void vnt_tx_80211(struct ieee80211_hw *hw,
 
 static int vnt_start(struct ieee80211_hw *hw)
 {
+   int err = 0;
struct vnt_private *priv = hw->priv;
 
priv->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
@@ -496,15 +497,20 @@ static int vnt_start(struct ieee80211_hw *hw)
 
if (vnt_init_registers(priv) == false) {
dev_dbg(>usb->dev, " init register fail\n");
+   err = -ENOMEM;
goto free_all;
}
 
-   if (vnt_key_init_table(priv))
+   if (vnt_key_init_table(priv)) {
+   err = -ENOMEM;
goto free_all;
+   }
 
priv->int_interval = 1;  /* bInterval is set to 1 */
 
-   vnt_int_start_interrupt(priv);
+   err = vnt_int_start_interrupt(priv);
+   if (err)
+   goto free_all;
 
ieee80211_wake_queues(hw);
 
@@ -518,7 +524,7 @@ static int vnt_start(struct ieee80211_hw *hw)
usb_kill_urb(priv->interrupt_urb);
usb_free_urb(priv->interrupt_urb);
 
-   return -ENOMEM;
+   return err;
 }
 
 static void vnt_stop(struct ieee80211_hw *hw)
-- 
2.17.1

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


[PATCH] staging: vt6656: returns error code on vnt_int_start_interrupt fail

2019-05-16 Thread Quentin Deslandes
Returns error code from 'vnt_int_start_interrupt()' so the device's private
buffers will be correctly freed and 'struct ieee80211_hw' start function
will return an error code.

Signed-off-by: Quentin Deslandes 
---
v2: instead of removing status variable, returns its value to caller and
handle error in caller.

 drivers/staging/vt6656/int.c  |  4 +++-
 drivers/staging/vt6656/int.h  |  2 +-
 drivers/staging/vt6656/main_usb.c | 12 +---
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 504424b19fcf..f3ee2198e1b3 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -39,7 +39,7 @@ static const u8 fallback_rate1[5][5] = {
{RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
 };
 
-void vnt_int_start_interrupt(struct vnt_private *priv)
+int vnt_int_start_interrupt(struct vnt_private *priv)
 {
unsigned long flags;
int status;
@@ -51,6 +51,8 @@ void vnt_int_start_interrupt(struct vnt_private *priv)
status = vnt_start_interrupt_urb(priv);
 
spin_unlock_irqrestore(>lock, flags);
+
+   return status;
 }
 
 static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index 987c454e99e9..8a6d60569ceb 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -41,7 +41,7 @@ struct vnt_interrupt_data {
u8 sw[2];
 } __packed;
 
-void vnt_int_start_interrupt(struct vnt_private *priv);
+int vnt_int_start_interrupt(struct vnt_private *priv);
 void vnt_int_process_data(struct vnt_private *priv);
 
 #endif /* __INT_H__ */
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index ccafcc2c87ac..71e10b9ae253 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -483,6 +483,7 @@ static void vnt_tx_80211(struct ieee80211_hw *hw,
 
 static int vnt_start(struct ieee80211_hw *hw)
 {
+   int err = 0;
struct vnt_private *priv = hw->priv;
 
priv->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
@@ -496,15 +497,20 @@ static int vnt_start(struct ieee80211_hw *hw)
 
if (vnt_init_registers(priv) == false) {
dev_dbg(>usb->dev, " init register fail\n");
+   err = -ENOMEM;
goto free_all;
}
 
-   if (vnt_key_init_table(priv))
+   if (vnt_key_init_table(priv)) {
+   err = -ENOMEM;
goto free_all;
+   }
 
priv->int_interval = 1;  /* bInterval is set to 1 */
 
-   vnt_int_start_interrupt(priv);
+   err = vnt_int_start_interrupt(priv);
+   if (err)
+   goto free_all;
 
ieee80211_wake_queues(hw);
 
@@ -518,7 +524,7 @@ static int vnt_start(struct ieee80211_hw *hw)
usb_kill_urb(priv->interrupt_urb);
usb_free_urb(priv->interrupt_urb);
 
-   return -ENOMEM;
+   return err;
 }
 
 static void vnt_stop(struct ieee80211_hw *hw)
-- 
2.17.1

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


Re: [PATCH] staging: vt6656: remove unused variable

2019-05-16 Thread Quentin Deslandes
On Thu, May 16, 2019 at 11:39:51AM +0200, Greg Kroah-Hartman wrote:
> On Thu, May 16, 2019 at 09:31:05AM +, Quentin Deslandes wrote:
> > Fixed 'set but not used' warning message on a status variable. The
> > called function returning the status code 'vnt_start_interrupt_urb()'
> > clean up after itself and the caller function
> > 'vnt_int_start_interrupt()' does not returns any value.
> > 
> > Signed-off-by: Quentin Deslandes 
> > ---
> >  drivers/staging/vt6656/int.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
> > index 504424b19fcf..ac30ce72db5a 100644
> > --- a/drivers/staging/vt6656/int.c
> > +++ b/drivers/staging/vt6656/int.c
> > @@ -42,13 +42,12 @@ static const u8 fallback_rate1[5][5] = {
> >  void vnt_int_start_interrupt(struct vnt_private *priv)
> >  {
> > unsigned long flags;
> > -   int status;
> >  
> > dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
> >  
> > spin_lock_irqsave(>lock, flags);
> >  
> > -   status = vnt_start_interrupt_urb(priv);
> > +   vnt_start_interrupt_urb(priv);
> 
> Shouldn't you fix this by erroring out if this fails?  Why ignore the
> errors?
> 
> thanks,
> 
> greg k-h

I could, however 'vnt_start_interrupt_urb()' already call 'dev_dbg()' if
it fails. Nothing is done after this debug call except returning an
error code.

'vnt_int_start_interrupt()' should, IMHO, return a status code, but the
original developer may have good reasons not to do so.

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


Re: [PATCH] staging: vt6656: remove unused variable

2019-05-16 Thread Quentin Deslandes
On Thu, May 16, 2019 at 12:19:53PM +0200, Greg Kroah-Hartman wrote:
> On Thu, May 16, 2019 at 09:50:38AM +, Quentin Deslandes wrote:
> > On Thu, May 16, 2019 at 11:39:51AM +0200, Greg Kroah-Hartman wrote:
> > > On Thu, May 16, 2019 at 09:31:05AM +, Quentin Deslandes wrote:
> > > > Fixed 'set but not used' warning message on a status variable. The
> > > > called function returning the status code 'vnt_start_interrupt_urb()'
> > > > clean up after itself and the caller function
> > > > 'vnt_int_start_interrupt()' does not returns any value.
> > > > 
> > > > Signed-off-by: Quentin Deslandes 
> > > > ---
> > > >  drivers/staging/vt6656/int.c | 3 +--
> > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
> > > > index 504424b19fcf..ac30ce72db5a 100644
> > > > --- a/drivers/staging/vt6656/int.c
> > > > +++ b/drivers/staging/vt6656/int.c
> > > > @@ -42,13 +42,12 @@ static const u8 fallback_rate1[5][5] = {
> > > >  void vnt_int_start_interrupt(struct vnt_private *priv)
> > > >  {
> > > > unsigned long flags;
> > > > -   int status;
> > > >  
> > > > dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
> > > >  
> > > > spin_lock_irqsave(>lock, flags);
> > > >  
> > > > -   status = vnt_start_interrupt_urb(priv);
> > > > +   vnt_start_interrupt_urb(priv);
> > > 
> > > Shouldn't you fix this by erroring out if this fails?  Why ignore the
> > > errors?
> > > 
> > > thanks,
> > > 
> > > greg k-h
> > 
> > I could, however 'vnt_start_interrupt_urb()' already call 'dev_dbg()' if
> > it fails. Nothing is done after this debug call except returning an
> > error code.
> 
> Returning an error code is fine for that function.  But then you have to
> do something with that error.
> 
> > 'vnt_int_start_interrupt()' should, IMHO, return a status code, but the
> > original developer may have good reasons not to do so.
> 
> I think that is the real problem that needs to be fixed here, don't
> paper over the issue by ignoring the return value.
> 
> thanks,
> 
> greg k-h

Thus I'll return an error value to handle this in the caller function
and then send a v2.

Thank you for your help,
Quentin
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: vt6656: remove unused variable

2019-05-16 Thread Greg Kroah-Hartman
On Thu, May 16, 2019 at 09:50:38AM +, Quentin Deslandes wrote:
> On Thu, May 16, 2019 at 11:39:51AM +0200, Greg Kroah-Hartman wrote:
> > On Thu, May 16, 2019 at 09:31:05AM +, Quentin Deslandes wrote:
> > > Fixed 'set but not used' warning message on a status variable. The
> > > called function returning the status code 'vnt_start_interrupt_urb()'
> > > clean up after itself and the caller function
> > > 'vnt_int_start_interrupt()' does not returns any value.
> > > 
> > > Signed-off-by: Quentin Deslandes 
> > > ---
> > >  drivers/staging/vt6656/int.c | 3 +--
> > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
> > > index 504424b19fcf..ac30ce72db5a 100644
> > > --- a/drivers/staging/vt6656/int.c
> > > +++ b/drivers/staging/vt6656/int.c
> > > @@ -42,13 +42,12 @@ static const u8 fallback_rate1[5][5] = {
> > >  void vnt_int_start_interrupt(struct vnt_private *priv)
> > >  {
> > >   unsigned long flags;
> > > - int status;
> > >  
> > >   dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
> > >  
> > >   spin_lock_irqsave(>lock, flags);
> > >  
> > > - status = vnt_start_interrupt_urb(priv);
> > > + vnt_start_interrupt_urb(priv);
> > 
> > Shouldn't you fix this by erroring out if this fails?  Why ignore the
> > errors?
> > 
> > thanks,
> > 
> > greg k-h
> 
> I could, however 'vnt_start_interrupt_urb()' already call 'dev_dbg()' if
> it fails. Nothing is done after this debug call except returning an
> error code.

Returning an error code is fine for that function.  But then you have to
do something with that error.

> 'vnt_int_start_interrupt()' should, IMHO, return a status code, but the
> original developer may have good reasons not to do so.

I think that is the real problem that needs to be fixed here, don't
paper over the issue by ignoring the return value.

thanks,

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


Re: [PATCH] staging: vt6656: remove unused variable

2019-05-16 Thread Greg Kroah-Hartman
On Thu, May 16, 2019 at 09:31:05AM +, Quentin Deslandes wrote:
> Fixed 'set but not used' warning message on a status variable. The
> called function returning the status code 'vnt_start_interrupt_urb()'
> clean up after itself and the caller function
> 'vnt_int_start_interrupt()' does not returns any value.
> 
> Signed-off-by: Quentin Deslandes 
> ---
>  drivers/staging/vt6656/int.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
> index 504424b19fcf..ac30ce72db5a 100644
> --- a/drivers/staging/vt6656/int.c
> +++ b/drivers/staging/vt6656/int.c
> @@ -42,13 +42,12 @@ static const u8 fallback_rate1[5][5] = {
>  void vnt_int_start_interrupt(struct vnt_private *priv)
>  {
>   unsigned long flags;
> - int status;
>  
>   dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
>  
>   spin_lock_irqsave(>lock, flags);
>  
> - status = vnt_start_interrupt_urb(priv);
> + vnt_start_interrupt_urb(priv);

Shouldn't you fix this by erroring out if this fails?  Why ignore the
errors?

thanks,

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


[PATCH] staging: vt6656: remove unused variable

2019-05-16 Thread Quentin Deslandes
Fixed 'set but not used' warning message on a status variable. The
called function returning the status code 'vnt_start_interrupt_urb()'
clean up after itself and the caller function
'vnt_int_start_interrupt()' does not returns any value.

Signed-off-by: Quentin Deslandes 
---
 drivers/staging/vt6656/int.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 504424b19fcf..ac30ce72db5a 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -42,13 +42,12 @@ static const u8 fallback_rate1[5][5] = {
 void vnt_int_start_interrupt(struct vnt_private *priv)
 {
unsigned long flags;
-   int status;
 
dev_dbg(>usb->dev, ">Interrupt Polling Thread\n");
 
spin_lock_irqsave(>lock, flags);
 
-   status = vnt_start_interrupt_urb(priv);
+   vnt_start_interrupt_urb(priv);
 
spin_unlock_irqrestore(>lock, flags);
 }
-- 
2.17.1

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


[PATCH] Staging: rtl8723bs: hal: Fix comparison to bool in if statements

2019-05-16 Thread Puranjay Mohan
Fix following warnings reported by coccicheck:
WARNING: Comparison to bool
by using !x in place of (x == false) and
x in place of (x == true).

Signed-off-by: Puranjay Mohan 
---
 drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c  | 4 ++--
 drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c | 2 +-
 drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c  | 2 +-
 drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c| 6 +++---
 drivers/staging/rtl8723bs/hal/hal_com.c   | 2 +-
 drivers/staging/rtl8723bs/hal/odm_DIG.c   | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c 
b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
index bae59e515348..19856e806b1f 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c
@@ -299,7 +299,7 @@ void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
READ_NEXT_PAIR(v1, v2, i);
}
 
-   if (bMatched == false) {
+   if (!bMatched) {
/*  Condition isn't matched.
*   Discard the following (offset, data) pairs.
*/
@@ -568,7 +568,7 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
READ_NEXT_PAIR(v1, v2, i);
}
 
-   if (bMatched == false) {
+   if (!bMatched) {
/*  Condition isn't matched.
*   Discard the following (offset, data) pairs.
*/
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c 
b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
index 3c8e26aba406..b80c5b11796b 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c
@@ -270,7 +270,7 @@ void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
READ_NEXT_PAIR(v1, v2, i);
}
 
-   if (bMatched == false) {
+   if (!bMatched) {
/*  Condition isn't matched. Discard the 
following (offset, data) pairs. */
while (v1 < 0x4000 && i < ArrayLen-2)
READ_NEXT_PAIR(v1, v2, i);
diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c 
b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
index ba42b4d2a9c4..426f68b8f0d2 100644
--- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
+++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c
@@ -301,7 +301,7 @@ void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm)
READ_NEXT_PAIR(v1, v2, i);
}
 
-   if (bMatched == false) {
+   if (!bMatched) {
/*  Condition isn't matched.
*   Discard the following (offset, data) pairs.
*/
diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c 
b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
index 53d3bdf21a6f..3239d37087c8 100644
--- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
+++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c
@@ -1292,7 +1292,7 @@ static void _PHY_SaveADDARegisters8723B(
struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
PDM_ODM_T pDM_Odm = >odmpriv;
 
-   if (ODM_CheckPowerStatus(padapter) == false)
+   if (!ODM_CheckPowerStatus(padapter))
return;
 
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA 
parameters.\n"));
@@ -1363,7 +1363,7 @@ static void _PHY_PathADDAOn8723B(
ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA 
ON.\n"));
 
pathOn = 0x01c00014;
-   if (false == is2T) {
+   if (!is2T) {
pathOn = 0x01c00014;
PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[0], bMaskDWord, 
0x01c00014);
} else {
@@ -1811,7 +1811,7 @@ void PHY_IQCalibrate_8723B(
u32 StartTime;
s32 ProgressingTime;
 
-   if (ODM_CheckPowerStatus(padapter) == false)
+   if (!ODM_CheckPowerStatus(padapter))
return;
 
if (!(pDM_Odm->SupportAbility & ODM_RF_CALIBRATION))
diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c 
b/drivers/staging/rtl8723bs/hal/hal_com.c
index e5f1153527b9..2763479f7601 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com.c
@@ -125,7 +125,7 @@ u8 hal_com_config_channel_plan(
if (0xFF == hw_channel_plan)
AutoLoadFail = true;
 
-   if (false == AutoLoadFail) {
+   if (!AutoLoadFail) {
u8 hw_chnlPlan;
 
hw_chnlPlan = 

Re: [PATCH] staging: Add rtl8821ce PCIe WiFi driver

2019-05-16 Thread Joe Perches
On Wed, 2019-05-15 at 18:39 +0200, Greg KH wrote:
> On Wed, May 15, 2019 at 09:06:44PM +0800, Kai-Heng Feng wrote:
> > 296 files changed, 206166 insertions(+)
> I'm not going to take another 200k lines for a simple wifi driver.

Good.

Realtek _really_ needs to improve the driver software.


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


Re: [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL

2019-05-16 Thread Dan Carpenter
On Wed, May 15, 2019 at 11:15:36PM +0530, Hariprasad Kelam wrote:
> @@ -1042,7 +1042,7 @@ sint sta2ap_data_frame(
>   }
>  
>   *psta = rtw_get_stainfo(pstapriv, pattrib->src);
> - if (*psta == NULL) {
> + if (!*psta == NULL) {
^^
It's surprising that this didn't cause some kind of warning somewhere...

>   RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't 
> get psta under AP_MODE; drop pkt\n"));
>   DBG_871X("issue_deauth to sta =" MAC_FMT " for the 
> reason(7)\n", MAC_ARG(pattrib->src));
>  

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