Re: [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv

2018-05-03 Thread Wenwen Wang
On Fri, May 4, 2018 at 12:27 AM, Dan Carpenter  wrote:
> There is no security problem here.  The user is allowed to choose either
> v1 or v3.  Using a double read race condition to choose v1 is not
> going to cause problems.  It's slightly more complicated than just
> choosing it directly but that doesn't make it a security issue.
>
> It's a bit like typing with your feet in that just because using your
> toes instead of your fingergs is more complicated, it doesn't make it a
> security issue.
>
> regards,
> dan carpenter
>

Thanks again for your comment, Dan! I revised the commit message and
removed the security risk:

However, given that the user data resides in the user space, a
malicious user-space process can race to change the data between the
two copies. By doing so, the user can provide a data with an
inconsistent version, e.g., v1 version + v3 data. To improve code
readability and make static analysis tools happy, which will warn
about read-verify-re-read type bugs, this issue should be fixed.

Thanks,

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


Re: [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv

2018-05-03 Thread Dan Carpenter
There is no security problem here.  The user is allowed to choose either
v1 or v3.  Using a double read race condition to choose v1 is not
going to cause problems.  It's slightly more complicated than just
choosing it directly but that doesn't make it a security issue.

It's a bit like typing with your feet in that just because using your
toes instead of your fingergs is more complicated, it doesn't make it a
security issue.

regards,
dan carpenter

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


[PATCH 7/8] staging: mt7621-pci: remove some dead code.

2018-05-03 Thread NeilBrown
Some code is dead because it is commented out.
Some is dead because it is uninteresting printks.
Some is dead because it declares unused functions.

Remove it all.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-pci/pci-mt7621.c |   14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 5094e90eaf69..edd95013faf3 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -56,9 +56,6 @@
 
 #include 
 
-extern void pcie_phy_init(void);
-extern void chk_phy_pll(void);
-
 /*
  * These functions and structures provide the BIOS scan and mapping of the PCI
  * devices.
@@ -364,11 +361,8 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 void
 set_pcie_phy(u32 *addr, int start_b, int bits, int val)
 {
-// printk("0x%p:", addr);
-// printk(" %x", *addr);
*(unsigned int *)(addr) &= ~(((1< %x\n", *addr);
 }
 
 void
@@ -497,7 +491,6 @@ static int mt7621_pci_probe(struct platform_device *pdev)
val |= RALINK_PCIE2_RST;
 
ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST | RALINK_PCIE1_RST | 
RALINK_PCIE2_RST);
-   printk("pull PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
 
*(unsigned int *)(0xbe60) &= ~(0x3<<10 | 0x3<<3);
*(unsigned int *)(0xbe60) |= 0x1<<10 | 0x1<<3;
@@ -513,12 +506,10 @@ static int mt7621_pci_probe(struct platform_device *pdev)
val |= RALINK_PCIE2_RST;
 
DEASSERT_SYSRST_PCIE(val);
-   printk("release PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
 
if ((*(unsigned int *)(0xbe0c)&0x) == 0x0101) // MT7621 E2
bypass_pipe_rst();
set_phy_for_ssc();
-   printk("release PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
 
read_config(0, 0, 0, 0x70c, );
printk("Port 0 N_FTS = %x\n", (unsigned int)val);
@@ -614,8 +605,6 @@ pcie(2/1/0) link status pcie2_num   pcie1_num   
pcie0_num
RALINK_PCI_PCICFG_ADDR |= 0x1 << 24;//port2
break;
}
-   printk(" -> %x\n", RALINK_PCI_PCICFG_ADDR);
-   //printk(" RALINK_PCI_ARBCTL = %x\n", RALINK_PCI_ARBCTL);
 
 /*
ioport_resource.start = mt7621_res_pci_io1.start;
@@ -653,7 +642,6 @@ pcie(2/1/0) link status pcie2_num   pcie1_num   
pcie0_num
case 7:
read_config(0, 2, 0, 0x4, );
write_config(0, 2, 0, 0x4, val|0x4);
-   // write_config(0, 1, 0, 0x4, val|0x7);
read_config(0, 2, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;
@@ -663,7 +651,6 @@ pcie(2/1/0) link status pcie2_num   pcie1_num   
pcie0_num
case 6:
read_config(0, 1, 0, 0x4, );
write_config(0, 1, 0, 0x4, val|0x4);
-   // write_config(0, 1, 0, 0x4, val|0x7);
read_config(0, 1, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;
@@ -671,7 +658,6 @@ pcie(2/1/0) link status pcie2_num   pcie1_num   
pcie0_num
default:
read_config(0, 0, 0, 0x4, );
write_config(0, 0, 0, 0x4, val|0x4); //bus master enable
-   // write_config(0, 0, 0, 0x4, val|0x7); //bus master enable
read_config(0, 0, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;


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


[PATCH 1/8] staging: mt7621-eth: Lock is never unlocked.

2018-05-03 Thread NeilBrown
mtk_phy_link_adjust takes a spinlock and disables
interrupts, but never unlocks.
This can leave interrupts disabled on one CPU and
various things stop working.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-eth/mdio.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/mt7621-eth/mdio.c 
b/drivers/staging/mt7621-eth/mdio.c
index 9d713078ef90..c6db11aad9e4 100644
--- a/drivers/staging/mt7621-eth/mdio.c
+++ b/drivers/staging/mt7621-eth/mdio.c
@@ -57,6 +57,7 @@ static void mtk_phy_link_adjust(struct net_device *dev)
}
}
}
+   spin_unlock_irqrestore(>phy->lock, flags);
 }
 
 int mtk_connect_phy_node(struct mtk_eth *eth, struct mtk_mac *mac,


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


[PATCH 6/8] staging: mt7621-pci: remove unnecessary resource details.

2018-05-03 Thread NeilBrown
These resources are extracted from devicetree, so they aren't
needed here.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-pci/pci-mt7621.c |   19 ++-
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 616960e01052..5094e90eaf69 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -302,27 +302,12 @@ struct pci_ops mt7621_pci_ops= {
.write  = pci_config_write,
 };
 
-static struct resource mt7621_res_pci_mem1 = {
-   .name   = "PCI MEM1",
-   .start  = RALINK_PCI_MM_MAP_BASE,
-   .end= (u32)((RALINK_PCI_MM_MAP_BASE + (unsigned char 
*)0x0fff)),
-   .flags  = IORESOURCE_MEM,
-};
-
-static struct resource mt7621_res_pci_io1 = {
-   .name   = "PCI I/O1",
-   .start  = RALINK_PCI_IO_MAP_BASE,
-   .end= (u32)((RALINK_PCI_IO_MAP_BASE + (unsigned char 
*)0x0)),
-   .flags  = IORESOURCE_IO,
-};
-
+static struct resource mt7621_res_pci_mem1;
+static struct resource mt7621_res_pci_io1;
 static struct pci_controller mt7621_controller = {
.pci_ops= _pci_ops,
.mem_resource   = _res_pci_mem1,
.io_resource= _res_pci_io1,
-   .mem_offset = 0xUL,
-   .io_offset  = 0xUL,
-   .io_map_base= 0xa000,
 };
 
 static void


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


[PATCH 2/8] staging: mt7621-spi: remove unused lock.

2018-05-03 Thread NeilBrown
This lock is never initialized, locked once, and never unlocked.
Clearly it is pointless - so remove it.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-spi/spi-mt7621.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
b/drivers/staging/mt7621-spi/spi-mt7621.c
index d9b55d2059b0..37f299080410 100644
--- a/drivers/staging/mt7621-spi/spi-mt7621.c
+++ b/drivers/staging/mt7621-spi/spi-mt7621.c
@@ -65,7 +65,6 @@ struct mt7621_spi {
unsigned intsys_freq;
unsigned intspeed;
struct clk  *clk;
-   spinlock_t  lock;
 
struct mt7621_spi_ops   *ops;
 };
@@ -395,7 +394,6 @@ static int mt7621_spi_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct spi_master *master;
struct mt7621_spi *rs;
-   unsigned long flags;
void __iomem *base;
struct resource *r;
int status = 0;
@@ -447,7 +445,6 @@ static int mt7621_spi_probe(struct platform_device *pdev)
rs->sys_freq = clk_get_rate(rs->clk);
rs->ops = ops;
dev_info(>dev, "sys_freq: %u\n", rs->sys_freq);
-   spin_lock_irqsave(>lock, flags);
 
device_reset(>dev);
 


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


[PATCH 8/8] staging: mt7621-dts: update nor-flash info for gnubee1

2018-05-03 Thread NeilBrown
The GNUBEE has 32MB flash, so set partitions accordingly.
Also remove "m25p,chunked-io" which isn't documented or
used anywhere (outside of freewrt).

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-dts/gbpc1.dts |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-dts/gbpc1.dts 
b/drivers/staging/mt7621-dts/gbpc1.dts
index 515c7cbdd15e..6b13d85d9d34 100644
--- a/drivers/staging/mt7621-dts/gbpc1.dts
+++ b/drivers/staging/mt7621-dts/gbpc1.dts
@@ -75,7 +75,6 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <1000>;
-   m25p,chunked-io = <32>;
 
partition@0 {
label = "u-boot";
@@ -97,7 +96,7 @@
 
partition@5 {
label = "firmware";
-   reg = <0x5 0xFB>;
+   reg = <0x5 0x1FB>;
};
 
};


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


[PATCH 5/8] staging: mt7621-pci: remove conditional compilation.

2018-05-03 Thread NeilBrown
Code currently defines:

#define CONFIG_PCIE_PORT0
#define CONFIG_PCIE_PORT1
#define CONFIG_PCIE_PORT2
#define GPIO_PERST

and then compiles code only if they are defined.
We might want to disable some of these via devicetree one
day, but for now just remove the #defines and the
conditions - all the code for different ports is
easy to identify.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-pci/pci-mt7621.c |   70 +++
 1 file changed, 15 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index c8d7b47c8952..616960e01052 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -64,9 +64,6 @@ extern void chk_phy_pll(void);
  * devices.
  */
 
-#define CONFIG_PCIE_PORT0
-#define CONFIG_PCIE_PORT1
-#define CONFIG_PCIE_PORT2
 #define RALINK_PCIE0_CLK_EN(1<<24)
 #define RALINK_PCIE1_CLK_EN(1<<25)
 #define RALINK_PCIE2_CLK_EN(1<<26)
@@ -140,7 +137,7 @@ extern void chk_phy_pll(void);
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
 
 #define RALINK_SYSTEM_CONTROL_BASE 0xbe00
-#define GPIO_PERST
+
 #define ASSERT_SYSRST_PCIE(val)\
do {\
if (*(unsigned int *)(0xbe0c) == 0x00030101)\
@@ -392,21 +389,15 @@ set_pcie_phy(u32 *addr, int start_b, int bits, int val)
 void
 bypass_pipe_rst(void)
 {
-#if defined (CONFIG_PCIE_PORT0)
/* PCIe Port 0 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c), 12, 1, 
0x01); // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c),  4, 1, 
0x01); // rg_pe1_pipe_cmd_frc[4]
-#endif
-#if defined (CONFIG_PCIE_PORT1)
/* PCIe Port 1 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c), 12, 1, 
0x01); // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c),  4, 1, 
0x01); // rg_pe1_pipe_cmd_frc[4]
-#endif
-#if defined (CONFIG_PCIE_PORT2)
/* PCIe Port 2 */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c), 12, 1, 
0x01);   // rg_pe1_pipe_rst_b
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c),  4, 1, 
0x01);   // rg_pe1_pipe_cmd_frc[4]
-#endif
 }
 
 void
@@ -415,7 +406,6 @@ set_phy_for_ssc(void)
unsigned long reg = (*(volatile u32 *)(RALINK_SYSCTL_BASE + 0x10));
 
reg = (reg >> 6) & 0x7;
-#if defined (CONFIG_PCIE_PORT0) || defined (CONFIG_PCIE_PORT1)
/* Set PCIe Port0 & Port1 PHY to disable SSC */
/* Debug Xtal Type */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  8, 1, 
0x01); // rg_pe1_frc_h_xtal_type
@@ -456,8 +446,7 @@ set_phy_for_ssc(void)
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  5, 1, 
0x01); // rg_pe1_phy_en//Port 1 enable
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  4, 1, 
0x00); // rg_pe1_frc_phy_en//Force Port 0 disable control
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  4, 1, 
0x00); // rg_pe1_frc_phy_en//Force Port 1 disable control
-#endif
-#if defined (CONFIG_PCIE_PORT2)
+
/* Set PCIe Port2 PHY to disable SSC */
/* Debug Xtal Type */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400),  8, 1, 
0x01);   // rg_pe1_frc_h_xtal_type
@@ -490,7 +479,6 @@ set_phy_for_ssc(void)
/* Enable PHY and disable force mode */
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000),  5, 1, 
0x01);   // rg_pe1_phy_en//Port 0 enable
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000),  4, 1, 
0x00);   // rg_pe1_frc_phy_en//Force Port 0 disable control
-#endif
 }
 
 void setup_cm_memory_region(struct resource *mem_resource)
@@ -519,18 +507,13 @@ static int mt7621_pci_probe(struct platform_device *pdev)
ioport_resource.start= 0;
ioport_resource.end = ~0;
 
-#if defined (CONFIG_PCIE_PORT0)
val = RALINK_PCIE0_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT1)
val |= RALINK_PCIE1_RST;
-#endif
-#if defined (CONFIG_PCIE_PORT2)
val |= RALINK_PCIE2_RST;
-#endif
+
ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST | RALINK_PCIE1_RST | 
RALINK_PCIE2_RST);
printk("pull PCIe RST: RALINK_RSTCTRL = %x\n", RALINK_RSTCTRL);
-#if defined GPIO_PERST /* add GPIO control instead of PERST_N */ /*chhung*/
+
*(unsigned int *)(0xbe60) &= ~(0x3<<10 | 0x3<<3);
*(unsigned int *)(0xbe60) |= 0x1<<10 | 0x1<<3;
mdelay(100);
@@ -539,18 +522,11 @@ static int mt7621_pci_probe(struct platform_device *pdev)
*(unsigned int *)(0xbe000620) &= ~(0x1<<19 | 0x1<<8 | 0x1<<7);  
// clear DATA
 
mdelay(100);
-#else
-   *(unsigned int *)(0xbe60) &= ~0x0c00;
-#endif
-#if 

[PATCH 3/8] staging: mt7621-pci: improve interrupt mapping

2018-05-03 Thread NeilBrown
As the Interrupts for the PCI adapters are listed in
devicetree we shouldn't need to have them explicit in the code.

The simplest way to do this is to use of_irq_parse_and_map_pci()
and specify an interrupt-map which identifies the different
PCI hosts by bus/slot numbers.
This has the advantage that the hwirq number are mapped to virq
numbers for us, so the ugly hack can go.

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-dts/mt7621.dtsi  |9 ++-
 drivers/staging/mt7621-pci/pci-mt7621.c |   90 +++
 2 files changed, 14 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index ebcaa8b1fc81..9d941b531712 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -429,10 +429,11 @@
0x0100 0 0x 0x1e16 0 0x0001 /* io 
space */
>;
 
-   interrupt-parent = <>;
-   interrupts = ;
+   #interrupt-cells = <1>;
+   interrupt-map-mask = <0xF 0 0 1>;
+   interrupt-map = <0x1 0 0 1  GIC_SHARED 4 
IRQ_TYPE_LEVEL_HIGH>,
+   <0x2 0 0 1  GIC_SHARED 24 
IRQ_TYPE_LEVEL_HIGH>,
+   <0x3 0 0 1  GIC_SHARED 25 
IRQ_TYPE_LEVEL_HIGH>;
 
status = "disabled";
 
diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index c49442c9b187..cc89d464ef7f 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -73,12 +73,6 @@ extern void chk_phy_pll(void);
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
-#define SURFBOARDINT_PCIE0   11  /* PCIE0 */
-#define RALINK_INT_PCIE0 SURFBOARDINT_PCIE0
-#define RALINK_INT_PCIE1 SURFBOARDINT_PCIE1
-#define RALINK_INT_PCIE2 SURFBOARDINT_PCIE2
-#define SURFBOARDINT_PCIE1   31 /* PCIE1 */
-#define SURFBOARDINT_PCIE2   32 /* PCIE2 */
 #define RALINK_PCI_MEMBASE  *(volatile u32 *)(RALINK_PCI_BASE + 
0x0028)
 #define RALINK_PCI_IOBASE   *(volatile u32 *)(RALINK_PCI_BASE + 
0x002C)
 #define RALINK_PCIE0_RST(1<<24)
@@ -367,68 +361,12 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 
pin)
 {
u16 cmd;
u32 val;
-   int irq = 0;
-
-   if ((dev->bus->number == 0) && (slot == 0)) {
-   write_config(0, 0, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(0, 0, 0, PCI_BASE_ADDRESS_0, (unsigned long *));
-   printk("BAR0 at slot 0 = %x\n", val);
-   printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
-   } else if((dev->bus->number == 0) && (slot == 0x1)) {
-   write_config(0, 1, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(0, 1, 0, PCI_BASE_ADDRESS_0, (unsigned long *));
-   printk("BAR0 at slot 1 = %x\n", val);
-   printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
-   } else if((dev->bus->number == 0) && (slot == 0x2)) {
-   write_config(0, 2, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(0, 2, 0, PCI_BASE_ADDRESS_0, (unsigned long *));
-   printk("BAR0 at slot 2 = %x\n", val);
-   printk("bus=0x%x, slot = 0x%x\n",dev->bus->number, slot);
-   } else if ((dev->bus->number == 1) && (slot == 0x0)) {
-   switch (pcie_link_status) {
-   case 2:
-   case 6:
-   irq = RALINK_INT_PCIE1;
-   break;
-   case 4:
-   irq = RALINK_INT_PCIE2;
-   break;
-   default:
-   irq = RALINK_INT_PCIE0;
-   }
-   printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, 
slot, dev->irq);
-   } else if ((dev->bus->number == 2) && (slot == 0x0)) {
-   switch (pcie_link_status) {
-   case 5:
-   case 6:
-   irq = RALINK_INT_PCIE2;
-   break;
-   default:
-   irq = RALINK_INT_PCIE1;
-   }
-   printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, 
slot, dev->irq);
-   } else if ((dev->bus->number == 2) && (slot == 0x1)) {
-   switch (pcie_link_status) {
-   case 5:
-   case 6:
-   irq = RALINK_INT_PCIE2;
-   break;
-   default:
-   irq = RALINK_INT_PCIE1;
-   }
-   printk("bus=0x%x, slot = 0x%x, irq=0x%x\n",dev->bus->number, 
slot, dev->irq);
-   } else if ((dev->bus->number ==3) && (slot == 0x0)) {
-   irq = RALINK_INT_PCIE2;
-   

[PATCH 4/8] staging: mt7621-pci: white-space cleanups.

2018-05-03 Thread NeilBrown
- remove white space at end of line.
- no more than 2 blank line at a time
- remove spaces before tabs
- use tabs to line things up
- re-indent some #define do{}while(0)

Signed-off-by: NeilBrown 
---
 drivers/staging/mt7621-pci/pci-mt7621.c |  291 +++
 1 file changed, 143 insertions(+), 148 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index cc89d464ef7f..c8d7b47c8952 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -67,95 +67,94 @@ extern void chk_phy_pll(void);
 #define CONFIG_PCIE_PORT0
 #define CONFIG_PCIE_PORT1
 #define CONFIG_PCIE_PORT2
-#define RALINK_PCIE0_CLK_EN (1<<24)
-#define RALINK_PCIE1_CLK_EN (1<<25)
-#define RALINK_PCIE2_CLK_EN (1<<26)
-
-#define RALINK_PCI_CONFIG_ADDR 0x20
-#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
-#define RALINK_PCI_MEMBASE  *(volatile u32 *)(RALINK_PCI_BASE + 
0x0028)
-#define RALINK_PCI_IOBASE   *(volatile u32 *)(RALINK_PCI_BASE + 
0x002C)
-#define RALINK_PCIE0_RST(1<<24)
-#define RALINK_PCIE1_RST(1<<25)
-#define RALINK_PCIE2_RST(1<<26)
-#define RALINK_SYSCTL_BASE  0xBE00
-
-#define RALINK_PCI_PCICFG_ADDR  *(volatile u32 *)(RALINK_PCI_BASE + 
0x)
-#define RALINK_PCI_PCIMSK_ADDR  *(volatile u32 *)(RALINK_PCI_BASE + 
0x000C)
-#define RALINK_PCI_BASE 0xBE14
-
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RT6855_PCIE0_OFFSET 0x2000
-#define RT6855_PCIE1_OFFSET 0x3000
-#define RT6855_PCIE2_OFFSET 0x4000
-
-#define RALINK_PCI0_BAR0SETUP_ADDR  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0010)
-#define RALINK_PCI0_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0018)
-#define RALINK_PCI0_ID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0030)
-#define RALINK_PCI0_CLASS   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0034)
-#define RALINK_PCI0_SUBID   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0038)
-#define RALINK_PCI0_STATUS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0050)
-#define RALINK_PCI0_DERR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0060)
-#define RALINK_PCI0_ECRC*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0064)
-
-#define RALINK_PCI1_BAR0SETUP_ADDR  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0010)
-#define RALINK_PCI1_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0018)
-#define RALINK_PCI1_ID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0030)
-#define RALINK_PCI1_CLASS   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0034)
-#define RALINK_PCI1_SUBID   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0038)
-#define RALINK_PCI1_STATUS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0050)
-#define RALINK_PCI1_DERR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0060)
-#define RALINK_PCI1_ECRC*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0064)
-
-#define RALINK_PCI2_BAR0SETUP_ADDR  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0010)
-#define RALINK_PCI2_IMBASEBAR0_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0018)
-#define RALINK_PCI2_ID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0030)
-#define RALINK_PCI2_CLASS   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0034)
-#define RALINK_PCI2_SUBID   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0038)
-#define RALINK_PCI2_STATUS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0050)
-#define RALINK_PCI2_DERR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0060)
-#define RALINK_PCI2_ECRC*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0064)
-
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET  (RALINK_PCI_BASE + 0x9000)
-#define RALINK_PCIEPHY_P2_CTL_OFFSET(RALINK_PCI_BASE + 0xA000)
-
-
-#define MV_WRITE(ofs, data)  \
-*(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
-#define MV_READ(ofs, data)   \
-   *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-#define MV_READ_DATA(ofs)\
-   le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-
-#define MV_WRITE_16(ofs, data)  \
-*(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
-#define MV_READ_16(ofs, data)   \
-   *(data) = 

[PATCH 0/8] staging: various mt7621 fixes

2018-05-03 Thread NeilBrown
Highlights here are a bugfix for the ethernet driver,
and proper handling of irq assignments in the PCI driver.

We also make the full 32M of the gnubee flash available and start
cleaning up the mt7621-pci code.

---

NeilBrown (8):
  staging: mt7621-eth: Lock is never unlocked.
  staging: mt7621-spi: remove unused lock.
  staging: mt7621-pci: improve interrupt mapping
  staging: mt7621-pci: white-space cleanups.
  staging: mt7621-pci: remove conditional compilation.
  staging: mt7621-pci: remove unnecessary resource details.
  staging: mt7621-pci: remove some dead code.
  staging: mt7621-dts: update nor-flash info for gnubee1


 drivers/staging/mt7621-dts/gbpc1.dts|3 
 drivers/staging/mt7621-dts/mt7621.dtsi  |9 -
 drivers/staging/mt7621-eth/mdio.c   |1 
 drivers/staging/mt7621-pci/pci-mt7621.c |  482 +++
 drivers/staging/mt7621-spi/spi-mt7621.c |3 
 5 files changed, 175 insertions(+), 323 deletions(-)

--
Signature

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


Re: [PATCH] staging: wilc1000: allocate less memory

2018-05-03 Thread Ajay Singh

On Thu, 3 May 2018 13:56:55 +0300
Dan Carpenter  wrote:

> We should be allocating space for hidden_network_info structs.  They
> are slightly smaller than hidden_network structs.  This bug doesn't
> cause a runtime issue beyond the very small ammount of extra memory
> used.
> 
> Signed-off-by: Dan Carpenter 

Reviewed-by: Ajay Singh 

Thanks for submitting the changes by using correct structure size
for memory allocation.

> 
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index
> 3ca0c97b0627..92322d6f061d 100644 ---
> a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -581,8 +581,8
> @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request
> *request, int i; int slot_id = 0;
>  
> - ntwk->net_info = kcalloc(request->n_ssids,
> -  sizeof(struct hidden_network),
> GFP_KERNEL);
> + ntwk->net_info = kcalloc(request->n_ssids,
> sizeof(*ntwk->net_info),
> +  GFP_KERNEL);
>   if (!ntwk->net_info)
>   goto out;
>  
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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


Re: [PATCH v2] staging: lustre: llite: fix potential missing-check bug when copying lumv

2018-05-03 Thread Wenwen Wang
On Tue, May 1, 2018 at 3:46 AM, Dan Carpenter  wrote:
> On Mon, Apr 30, 2018 at 05:56:10PM -0500, Wenwen Wang wrote:
>> However, given that the user data resides in the user space, a malicious
>> user-space process can race to change the data between the two copies. By
>> doing so, the attacker can provide a data with an inconsistent version,
>> e.g., v1 version + v3 data. This can lead to logical errors in the
>> following execution in ll_dir_setstripe(), which performs different actions
>> according to the version specified by the field lmm_magic.
>
> This part is misleading.  The fix is to improve readability and make
> static checkers happy.  You're over dramatizing it to make people think
> it has a security impact when it doesn't.
>
> If the user wants to specify v1 data they can just say that on the first
> read.  They don't need to do funny tricks and race between the two
> reads.  It's allowed.
>
> In other words this allows the user to do something in a very
> complicated way which they are already allowed to do in a very simple
> straight forward way.
>
> regards,
> dan carpenter

Thanks for your comment, Dan! How about this:

However, given that the user data resides in the user space, a
malicious user-space process can race to change the data between the
two copies. By doing so, the attacker can provide a data with an
inconsistent version, e.g., v1 version + v3 data. The current kernel
can handle such inconsistent data. But, it may pose a potential
security risk for future implementations. Also, to improve code
readability and make static analysis tools happy, which will warn
about read-verify-re-read type bugs, this issue should be fixed.

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


[RESEND PATCH 39/47] staging: ks7010: refactor ks_wlan_set_mlme function

2018-05-03 Thread Sergio Paracuellos
This commit refactors ks_wlan_set_mlme function changing
switch-case block for more simple if paths improving
readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 62a9d55..30f8cee 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1787,23 +1787,20 @@ static int ks_wlan_set_mlme(struct net_device *dev,
 {
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
-   __u32 mode;
+   __u32 mode = 1;
 
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
 
-   /* for SLEEP MODE */
-   switch (mlme->cmd) {
-   case IW_MLME_DEAUTH:
-   if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
-   return 0;
-   /* fall through */
-   case IW_MLME_DISASSOC:
-   mode = 1;
-   return ks_wlan_set_stop_request(dev, NULL, , NULL);
-   default:
-   return -EOPNOTSUPP; /* Not Support */
-   }
+   if (mlme->cmd != IW_MLME_DEAUTH &&
+   mlme->cmd != IW_MLME_DISASSOC)
+   return -EOPNOTSUPP;
+
+   if (mlme->cmd == IW_MLME_DEAUTH &&
+   mlme->reason_code == WLAN_REASON_MIC_FAILURE)
+   return 0;
+
+   return ks_wlan_set_stop_request(dev, NULL, , NULL);
 }
 
 static int ks_wlan_get_firmware_version(struct net_device *dev,
-- 
2.7.4

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


[RESEND PATCH 44/47] staging: ks7010: use u16 instead of unsigned short in hostif_data_indication

2018-05-03 Thread Sergio Paracuellos
Local variable 'auth_type' is declared as unsigned short in
hostif_data_indication function. Its value is got calling get_word
which returns an 'u16' so change its type to u16 which is preferred.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 1a034d5..d4ce986 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -351,7 +351,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
 {
unsigned int rx_ind_size;   /* indicate data size */
struct sk_buff *skb;
-   unsigned short auth_type;
+   u16 auth_type;
unsigned char temp[256];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
-- 
2.7.4

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


[RESEND PATCH 32/47] staging: ks7010: refactor hostif_sme_set_rsn function

2018-05-03 Thread Sergio Paracuellos
This commit make use of two introduced local variables
to make more readable code of hostif_sme_set_rsn function.
It just assign those local variables in different cases
where are needed and extract common code to assign them
at the end.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 145 +++--
 1 file changed, 44 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 30c2d3a..08f95f7 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1613,12 +1613,13 @@ struct rsn_mode {
__le16 rsn_capability;
 } __packed;
 
-static
-void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 {
struct wpa_suite wpa_suite;
struct rsn_mode rsn_mode;
size_t size;
+   u32 mode;
+   const u8 *buf = NULL;
 
memset(_suite, 0, sizeof(wpa_suite));
 
@@ -1627,47 +1628,29 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, 
int type)
wpa_suite.size = cpu_to_le16((uint16_t)1);
switch (priv->wpa.pairwise_suite) {
case IW_AUTH_CIPHER_NONE:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
-   else
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+   buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+   CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
 
+   if (buf)
+   memcpy(_suite.suite[0][0], buf, CIPHER_ID_LEN);
size = sizeof(wpa_suite.size) +
   (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
hostif_mib_set_request_ostring(priv,
@@ -1677,46 +1660,28 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, 
int type)
case SME_RSN_MCAST_REQUEST:
switch (priv->wpa.group_suite) {
case IW_AUTH_CIPHER_NONE:
-   if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
-   memcpy(_suite.suite[0][0],
-  CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- 

[RESEND PATCH 42/47] staging: ks7010: refactor LOCAL_EEPROM_SUM case in hostif_mib_get_confirm

2018-05-03 Thread Sergio Paracuellos
This commit simplify conditional paths in LOCAL_EEPROM_SUM case
inside hostif_mib_get_confirm function. It change logic to handle
invalid values first and assign good ones at the end if it is the
case.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 7a51123..3db5679 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -504,18 +504,15 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
break;
case LOCAL_EEPROM_SUM:
memcpy(>eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
-   if (priv->eeprom_sum.type == 0) {
-   priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
-   } else if (priv->eeprom_sum.type == 1) {
-   if (priv->eeprom_sum.result == 0) {
-   priv->eeprom_checksum = EEPROM_NG;
-   netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
-   } else if (priv->eeprom_sum.result == 1) {
-   priv->eeprom_checksum = EEPROM_OK;
-   }
-   } else {
+   if (priv->eeprom_sum.type != 0 &&
+   priv->eeprom_sum.type != 1) {
netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
+   return;
}
+   priv->eeprom_checksum = (priv->eeprom_sum.type == 0) ?
+EEPROM_CHECKSUM_NONE :
+(priv->eeprom_sum.result == 0) ?
+EEPROM_NG : EEPROM_OK;
break;
default:
netdev_err(priv->net_dev, "mib_attribute=%08x\n",
-- 
2.7.4

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


[RESEND PATCH 45/47] staging: ks7010: use u16 instead of unsigned short in hostif_connect_indication

2018-05-03 Thread Sergio Paracuellos
Local variable 'connect_code' is declared as unsigned short in
hostif_connect_indication function. Its value is got calling
get_word which returns an 'u16' so change its type to u16
which is preferred.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index d4ce986..fde5b6e 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -655,7 +655,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
 static
 void hostif_connect_indication(struct ks_wlan_private *priv)
 {
-   unsigned short connect_code;
+   u16 connect_code;
unsigned int tmp = 0;
unsigned int old_status = priv->connect_status;
struct net_device *netdev = priv->net_dev;
-- 
2.7.4

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


[RESEND PATCH 43/47] staging: ks7010: use u16 instead of unsigned short in hostif_event_check

2018-05-03 Thread Sergio Paracuellos
Local variable 'event' is declared as unsigned short in hostif_event_check
function. Its value is got calling get_word which returns an 'u16'
so change its type to u16 which is preferred.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 3db5679..1a034d5 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -912,7 +912,7 @@ void hostif_mic_failure_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_event_check(struct ks_wlan_private *priv)
 {
-   unsigned short event;
+   u16 event;
 
event = get_word(priv);
switch (event) {
-- 
2.7.4

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


[RESEND PATCH 47/47] staging: ks7010: review local variable types in hostif_phy_information_confirm

2018-05-03 Thread Sergio Paracuellos
This commit changes types for local variables declared in
hostif_phy_information_confirm function to use the preferred
one 'u8' and 'u32'. Its values are get using get_byte and get_dword
functions which returns 'u8' and 'u32' so it makes sense.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index cf33a1c..7b6a385 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -866,10 +866,10 @@ static
 void hostif_phy_information_confirm(struct ks_wlan_private *priv)
 {
struct iw_statistics *wstats = >wstats;
-   unsigned char rssi, signal, noise;
-   unsigned char link_speed;
-   unsigned int transmitted_frame_count, received_fragment_count;
-   unsigned int failed_count, fcs_error_count;
+   u8 rssi, signal, noise;
+   u8 link_speed;
+   u32 transmitted_frame_count, received_fragment_count;
+   u32 failed_count, fcs_error_count;
 
rssi = get_byte(priv);
signal = get_byte(priv);
-- 
2.7.4

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


[RESEND PATCH 38/47] staging: ks7010: refactor ks_wlan_set_phy_type function

2018-05-03 Thread Sergio Paracuellos
Handle invalid values first and assign good ones at the
end if it is the case. This makes code simplier.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 53288c8..62a9d55 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1960,17 +1960,14 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
 
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
-   /* for SLEEP MODE */
-   if (*uwrq == D_11B_ONLY_MODE) { /* 0 */
-   priv->reg.phy_type = D_11B_ONLY_MODE;
-   } else if (*uwrq == D_11G_ONLY_MODE) {  /* 1 */
-   priv->reg.phy_type = D_11G_ONLY_MODE;
-   } else if (*uwrq == D_11BG_COMPATIBLE_MODE) {   /* 2 */
-   priv->reg.phy_type = D_11BG_COMPATIBLE_MODE;
-   } else {
+
+   if (*uwrq != D_11B_ONLY_MODE &&
+   *uwrq != D_11G_ONLY_MODE &&
+   *uwrq != D_11BG_COMPATIBLE_MODE)
return -EINVAL;
-   }
 
+   /* for SLEEP MODE */
+   priv->reg.phy_type = *uwrq;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS;/* Call commit handler */
 }
-- 
2.7.4

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


[RESEND PATCH 25/47] staging: ks7010: change type for rsn_enabled in wpa_status struct

2018-05-03 Thread Sergio Paracuellos
Field rsn_enabled included in wpa_status struct is declared as
unsigned int but it is only be set using 0 and 1 values and
in conditional if code is just being used as a boolean. Change
its type to be a boolean.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c   | 2 +-
 drivers/staging/ks7010/ks_wlan.h | 2 +-
 drivers/staging/ks7010/ks_wlan_net.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 0ab2e1b..8cd3dac 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2296,7 +2296,7 @@ static inline void hostif_sme_init(struct ks_wlan_private 
*priv)
 static inline void hostif_wpa_init(struct ks_wlan_private *priv)
 {
memset(>wpa, 0, sizeof(priv->wpa));
-   priv->wpa.rsn_enabled = 0;
+   priv->wpa.rsn_enabled = false;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index dd42692..655f1e3 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -338,7 +338,7 @@ struct mic_failure {
 
 struct wpa_status {
int wpa_enabled;
-   unsigned int rsn_enabled;
+   bool rsn_enabled;
int version;
int pairwise_suite; /* unicast cipher */
int group_suite;/* multicast cipher */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 838db49..8b4a1ed6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1372,14 +1372,14 @@ static int ks_wlan_set_auth_mode(struct net_device *dev,
case IW_AUTH_WPA_VERSION_DISABLED:
priv->wpa.version = value;
if (priv->wpa.rsn_enabled)
-   priv->wpa.rsn_enabled = 0;
+   priv->wpa.rsn_enabled = false;
priv->need_commit |= SME_RSN;
break;
case IW_AUTH_WPA_VERSION_WPA:
case IW_AUTH_WPA_VERSION_WPA2:
priv->wpa.version = value;
if (!(priv->wpa.rsn_enabled))
-   priv->wpa.rsn_enabled = 1;
+   priv->wpa.rsn_enabled = true;
priv->need_commit |= SME_RSN;
break;
default:
-- 
2.7.4

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


[RESEND PATCH 02/47] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header

2018-05-03 Thread Sergio Paracuellos
There are some definitions for rx and tx queues in ks7010_sdio
which is not the best place to put them. Changing them into the
ks_wlan header file there is no need to explicity include ks7010_sdio.h
which makes no sense at all and can be resolved easily using
forward declarations. The functions related with the queues circular
buffers have been moved also into this header.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c |  45 --
 drivers/staging/ks7010/ks7010_sdio.h |  63 +---
 drivers/staging/ks7010/ks_wlan.h | 112 ++-
 3 files changed, 112 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 6a5565d..9c22a76 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -8,7 +8,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -98,50 +97,6 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
-static inline void inc_txqhead(struct ks_wlan_private *priv)
-{
-   priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_txqtail(struct ks_wlan_private *priv)
-{
-   priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool txq_has_space(struct ks_wlan_private *priv)
-{
-   return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail,
-  TX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline void inc_rxqhead(struct ks_wlan_private *priv)
-{
-   priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline void inc_rxqtail(struct ks_wlan_private *priv)
-{
-   priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE;
-}
-
-static inline bool rxq_has_space(struct ks_wlan_private *priv)
-{
-   return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail,
-  RX_DEVICE_BUFF_SIZE) > 0);
-}
-
-static inline unsigned int txq_count(struct ks_wlan_private *priv)
-{
-   return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail,
-  TX_DEVICE_BUFF_SIZE);
-}
-
-static inline unsigned int rxq_count(struct ks_wlan_private *priv)
-{
-   return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail,
-  RX_DEVICE_BUFF_SIZE);
-}
-
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 u32 address, u8 *byte)
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 831b2f1..891a09f 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -8,6 +8,8 @@
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
 
+struct ks_wlan_private;
+
 /**
  * struct ks_sdio_card - SDIO device data.
  *
@@ -21,65 +23,4 @@ struct ks_sdio_card {
struct ks_wlan_private *priv;
 };
 
-/* Tx Device struct */
-#defineTX_DEVICE_BUFF_SIZE 1024
-
-/**
- * struct tx_device_buffer - Queue item for the tx queue.
- * @sendp: Pointer to the send request data.
- * @size: Size of @sendp data.
- * @complete_handler: Function called once data write to device is complete.
- * @arg1: First argument to @complete_handler.
- * @arg2: Second argument to @complete_handler.
- */
-struct tx_device_buffer {
-   unsigned char *sendp;
-   unsigned int size;
-   void (*complete_handler)(struct ks_wlan_private *priv,
-struct sk_buff *skb);
-   struct sk_buff *skb;
-};
-
-/**
- * struct tx_device - Tx buffer queue.
- * @tx_device_buffer: Queue buffer.
- * @qhead: Head of tx queue.
- * @qtail: Tail of tx queue.
- * @tx_dev_lock: Queue lock.
- */
-struct tx_device {
-   struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
-   unsigned int qhead;
-   unsigned int qtail;
-   spinlock_t tx_dev_lock; /* protect access to the queue */
-};
-
-/* Rx Device struct */
-#defineRX_DATA_SIZE(2 + 2 + 2347 + 1)
-#defineRX_DEVICE_BUFF_SIZE 32
-
-/**
- * struct rx_device_buffer - Queue item for the rx queue.
- * @data: rx data.
- * @size: Size of @data.
- */
-struct rx_device_buffer {
-   unsigned char data[RX_DATA_SIZE];
-   unsigned int size;
-};
-
-/**
- * struct rx_device - Rx buffer queue.
- * @rx_device_buffer: Queue buffer.
- * @qhead: Head of rx queue.
- * @qtail: Tail of rx queue.
- * @rx_dev_lock: Queue lock.
- */
-struct rx_device {
-   struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
-   unsigned int qhead;
-   unsigned int qtail;
-   spinlock_t rx_dev_lock; /* protect access to the queue */
-};
-
 #endif /* _KS7010_SDIO_H */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 5070af8..d73f622 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ 

[RESEND PATCH 08/47] staging: ks7010: change local variable type in ks7010_rw_function

2018-05-03 Thread Sergio Paracuellos
Local variable 'byte' in ks7010_rw_function is declared as unsigned
char and can be declared as u8 which is preferred. It is being used
in ks7010_sdio_readb which is already expecting an u8.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 3574a22..dab44bb 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -477,7 +477,7 @@ static void ks7010_rw_function(struct work_struct *work)
struct ks_wlan_private,
rw_dwork.work);
struct sdio_func *func = ks7010_to_func(priv);
-   unsigned char byte;
+   u8 byte;
int ret;
 
/* wait after DOZE */
-- 
2.7.4

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


[RESEND PATCH 10/47] staging: ks7010: change local variable type in ks7010_sdio_init_irqs

2018-05-03 Thread Sergio Paracuellos
Local variable 'byte' in ks7010_sdio_init_irqs is declared as
unsigned char and can be declared as u8 which is preferred.
It is being used in calls to ks7010_sdio_writeb which is already
expected an u8.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index db954f1..9085ed7 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -904,7 +904,7 @@ static int ks7010_sdio_setup_irqs(struct sdio_func *func)
 static void ks7010_sdio_init_irqs(struct sdio_func *func,
  struct ks_wlan_private *priv)
 {
-   unsigned char byte;
+   u8 byte;
int ret;
 
/*
-- 
2.7.4

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


[RESEND PATCH 19/47] staging: ks7010: change parameter types and reorder them in hostif_mib_set_request

2018-05-03 Thread Sergio Paracuellos
This commit changes parameter types to use enum mib_attribute, enum
mib_data_type and size_t for size instead of unsigned short. It also
reorder them in a more sense way. Code is updated in different
calls to use new parameters order using 'size' auxiliar local variables
in some of them to improve readability a bit.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 144 +++--
 1 file changed, 74 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 5dceadc..9b25221 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1192,10 +1192,10 @@ void hostif_mib_get_request(struct ks_wlan_private 
*priv,
ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
 }
 
-static
-void hostif_mib_set_request(struct ks_wlan_private *priv,
-   unsigned long mib_attribute, unsigned short size,
-   unsigned short type, void *vp)
+static void hostif_mib_set_request(struct ks_wlan_private *priv,
+  enum mib_attribute attr,
+  enum mib_data_type type,
+  void *data, size_t size)
 {
struct hostif_mib_set_request_t *pp;
 
@@ -1206,10 +1206,10 @@ void hostif_mib_set_request(struct ks_wlan_private 
*priv,
if (!pp)
return;
 
-   pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
-   pp->mib_value.size = cpu_to_le16((uint16_t)size);
-   pp->mib_value.type = cpu_to_le16((uint16_t)type);
-   memcpy(>mib_value.body, vp, size);
+   pp->mib_attribute = cpu_to_le32(attr);
+   pp->mib_value.size = cpu_to_le16((u16)size);
+   pp->mib_value.type = cpu_to_le16(type);
+   memcpy(>mib_value.body, data, size);
 
/* send to device request */
ps_confirm_wait_inc(priv);
@@ -1557,44 +1557,44 @@ void hostif_sme_set_wep(struct ks_wlan_private *priv, 
int type)
case SME_WEP_INDEX_REQUEST:
val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-  sizeof(val), MIB_VALUE_TYPE_INT, );
+  MIB_VALUE_TYPE_INT, , sizeof(val));
break;
case SME_WEP_KEY1_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE1,
-  priv->reg.wep_key[0].size,
   MIB_VALUE_TYPE_OSTRING,
-  >reg.wep_key[0].val[0]);
+  >reg.wep_key[0].val[0],
+  priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE2,
-  priv->reg.wep_key[1].size,
   MIB_VALUE_TYPE_OSTRING,
-  >reg.wep_key[1].val[0]);
+  >reg.wep_key[1].val[0],
+  priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE3,
-  priv->reg.wep_key[2].size,
   MIB_VALUE_TYPE_OSTRING,
-  >reg.wep_key[2].val[0]);
+  >reg.wep_key[2].val[0],
+  priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
if (!priv->wpa.wpa_enabled)
hostif_mib_set_request(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE4,
-  priv->reg.wep_key[3].size,
   MIB_VALUE_TYPE_OSTRING,
-  >reg.wep_key[3].val[0]);
+  >reg.wep_key[3].val[0],
+  priv->reg.wep_key[3].size);
break;
case SME_WEP_FLAG_REQUEST:
val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
-  

[RESEND PATCH 28/47] staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside switch

2018-05-03 Thread Sergio Paracuellos
WLAN_EID_DS_PARAMS case inside switch case is just doing nothing
and it is located inside other cases. There is a place inside
the switch with other don't do anything cases are located. Move
this to that place.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 366801f..8bd2797 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -232,8 +232,6 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
(RATE_SET_MAX_SIZE - ap->rate_set.size);
}
break;
-   case WLAN_EID_DS_PARAMS:
-   break;
case WLAN_EID_RSN:
ap->rsn_ie.id = *bp;
ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
@@ -247,7 +245,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
  ap->wpa_ie.body);
}
break;
-
+   case WLAN_EID_DS_PARAMS:
case WLAN_EID_FH_PARAMS:
case WLAN_EID_CF_PARAMS:
case WLAN_EID_TIM:
-- 
2.7.4

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


[RESEND PATCH 40/47] staging: ks7010: refactor ks_get_wireless_stats function

2018-05-03 Thread Sergio Paracuellos
This commit refactor a bit ks_get_wireless_stats using
ternary operator for return code. It also change a comment
to use preferred style.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 30f8cee..ee164ab 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1743,14 +1743,11 @@ static struct iw_statistics 
*ks_get_wireless_stats(struct net_device *dev)
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_statistics *wstats = >wstats;
 
-   if (!atomic_read(_phyinfo)) {
-   if (priv->dev_state < DEVICE_STATE_READY)
-   return NULL;/* not finished initialize */
-   else
-   return wstats;
-   }
+   if (!atomic_read(_phyinfo))
+   return (priv->dev_state < DEVICE_STATE_READY) ? NULL : wstats;
 
-   /* Packets discarded in the wireless adapter due to wireless
+   /*
+* Packets discarded in the wireless adapter due to wireless
 * specific problems
 */
wstats->discard.nwid = 0;   /* Rx invalid nwid  */
-- 
2.7.4

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


[RESEND PATCH 09/47] staging: ks7010: change some local variables type in ks_sdio_interrupt

2018-05-03 Thread Sergio Paracuellos
Local variables 'status', 'rsize' and 'byte' are declared as
unsigned char and can be declared as u8 which is preferred.
They are being used in ks7010_sdio_readb calls which is already
expected an u8.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index dab44bb..db954f1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -542,7 +542,7 @@ static void ks_sdio_interrupt(struct sdio_func *func)
int ret;
struct ks_sdio_card *card;
struct ks_wlan_private *priv;
-   unsigned char status, rsize, byte;
+   u8 status, rsize, byte;
 
card = sdio_get_drvdata(func);
priv = card->priv;
-- 
2.7.4

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


[RESEND PATCH 23/47] staging: ks7010: avoid two long lines in hostif_sme_mode_setup

2018-05-03 Thread Sergio Paracuellos
This commit avoid two checkpatch script complains about
two long lines.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 0054c48..b812011 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1886,9 +1886,11 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
break;
case MODE_INFRASTRUCTURE:
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
-   hostif_infrastructure_set_request(priv, 
HIF_INFRA_SET_REQ);
+   hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET_REQ);
} else {
-   hostif_infrastructure_set_request(priv, 
HIF_INFRA_SET2_REQ);
+   hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET2_REQ);
netdev_dbg(priv->net_dev,
   "Infra bssid = %pM\n", priv->reg.bssid);
}
-- 
2.7.4

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


[RESEND PATCH 35/47] staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address

2018-05-03 Thread Sergio Paracuellos
Use ether_addr_copy to copy ethernet address instad of using
memcpy in ks_wlan_set_mac_address function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 8b4a1ed6..bb8ec04 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2500,7 +2500,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void 
*addr)
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
-   memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN);
+   ether_addr_copy(priv->eth_addr, mac_addr->sa_data);
 
priv->mac_address_valid = false;
hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST);
-- 
2.7.4

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


[RESEND PATCH 21/47] staging: ks7010: use ether_addr_copy in get_current_ap

2018-05-03 Thread Sergio Paracuellos
Instead of use memcpy to copy ethernet addresses use
ether_addr_copy created for that.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index b22dc0c..f8bca54 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -110,7 +110,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
return -EPERM;
}
 
-   memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+   ether_addr_copy(ap->bssid, ap_info->bssid);
memcpy(ap->ssid.body, priv->reg.ssid.body,
   priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
-- 
2.7.4

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


[RESEND PATCH 41/47] staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody

2018-05-03 Thread Sergio Paracuellos
This commit changes custom implementation of CIRC_CNT_TO_END.
Just use the linux kernel header one to simplify code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 359187e..7a51123 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -6,6 +6,7 @@
  *   Copyright (C) 2009 Renesas Technology Corp.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -26,9 +27,8 @@ static inline void inc_smeqtail(struct ks_wlan_private *priv)
 
 static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv)
 {
-   unsigned int sme_cnt = priv->sme_i.qtail - priv->sme_i.qhead;
-
-   return (sme_cnt + SME_EVENT_BUFF_SIZE) % SME_EVENT_BUFF_SIZE;
+   return CIRC_CNT_TO_END(priv->sme_i.qhead, priv->sme_i.qtail,
+  SME_EVENT_BUFF_SIZE);
 }
 
 static inline u8 get_byte(struct ks_wlan_private *priv)
-- 
2.7.4

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


[RESEND PATCH 46/47] staging: ks7010: use u32 instead of unsigned int in hostif_bss_scan_confirm

2018-05-03 Thread Sergio Paracuellos
Local variable 'result_code' is declared as unsigned int in
hostif_bss_scan_confirm function. Its value is got calling
get_dword which returns an 'u32' so change its type to u32
which is preferred

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index fde5b6e..cf33a1c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -845,7 +845,7 @@ void hostif_associate_indication(struct ks_wlan_private 
*priv)
 static
 void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
 {
-   unsigned int result_code;
+   u32 result_code;
struct net_device *dev = priv->net_dev;
union iwreq_data wrqu;
 
-- 
2.7.4

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


[RESEND PATCH 27/47] staging: ks7010: use ether_addr_copy in get_ap_information function

2018-05-03 Thread Sergio Paracuellos
This commit make use of ether_addr_copy to copy ethernet
address instead of copy it using memcpy.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 00d6318..366801f 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -200,7 +200,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
 
memset(ap, 0, sizeof(struct local_ap));
 
-   memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+   ether_addr_copy(ap->bssid, ap_info->bssid);
ap->rssi = ap_info->rssi;
ap->sq = ap_info->sq;
ap->noise = ap_info->noise;
-- 
2.7.4

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


[RESEND PATCH 30/47] staging: ks7010: fix some style issues in ks_hostif.c

2018-05-03 Thread Sergio Paracuellos
Fix some checkpatch complains about long lines in some
parts of the code. It also fix some lines where spaces
instead of tabs were inserted.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 46 +-
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 1a59218..644a083 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -153,7 +153,8 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
if (is_connect_status(priv->connect_status)) {
ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
-  "IWEVENT: connect bssid=%pM\n", 
wrqu.ap_addr.sa_data);
+  "IWEVENT: connect bssid=%pM\n",
+  wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, , NULL);
}
netdev_dbg(priv->net_dev, "Link AP\n"
@@ -254,7 +255,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct 
ap_info *ap_info,
case WLAN_EID_ERP_INFO:
break;
default:
-   netdev_err(priv->net_dev, "unknown Element ID=%d\n", 
*bp);
+   netdev_err(priv->net_dev,
+  "unknown Element ID=%d\n", *bp);
break;
}
 
@@ -322,7 +324,8 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
mic_failure->failure = 2;
mic_failure->counter =
(uint16_t)((now - 
mic_failure->last_failure_time) / HZ);
-   if (!mic_failure->counter)  /*  range 1-60 
*/
+   /*  range 1-60 */
+   if (!mic_failure->counter)
mic_failure->counter = 1;
}
priv->wpa.mic_failure.last_failure_time = now;
@@ -712,7 +715,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
int i;
struct ap_info *ap_info;
 
-   netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", 
priv->scan_ind_count);
+   netdev_dbg(priv->net_dev,
+  "scan_ind_count = %d\n", priv->scan_ind_count);
ap_info = (struct ap_info *)(priv->rxp);
 
if (priv->scan_ind_count) {
@@ -849,8 +853,8 @@ void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
union iwreq_data wrqu;
 
result_code = get_dword(priv);
-   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", 
result_code,
-  priv->scan_ind_count);
+   netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n",
+  result_code, priv->scan_ind_count);
 
priv->sme_i.sme_flag &= ~SME_AP_SCAN;
hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
@@ -903,7 +907,8 @@ void hostif_phy_information_confirm(struct ks_wlan_private 
*priv)
 static
 void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
 {
-   netdev_dbg(priv->net_dev, "mic_failure=%u\n", 
priv->wpa.mic_failure.failure);
+   netdev_dbg(priv->net_dev, "mic_failure=%u\n",
+  priv->wpa.mic_failure.failure);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
 }
 
@@ -1050,8 +1055,9 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
/* skb check */
eth = (struct ethhdr *)skb->data;
if (!ether_addr_equal(>eth_addr[0], eth->h_source)) {
-   netdev_err(priv->net_dev, "invalid mac address !!\n");
-   netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", 
eth->h_source);
+   netdev_err(priv->net_dev,
+  "Invalid mac address: ethernet->h_source=%pM\n",
+  eth->h_source);
ret = -ENXIO;
goto err_kfree;
}
@@ -1066,7 +1072,6 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
/* EtherType/Length check */
if (*(buffer + 1) + (*buffer << 8) > 1500) {
/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
-   /* netdev_dbg(priv->net_dev, "Send [SNAP]Type 
%x\n",ProtocolEAP); */
/* SAP/CTL/OUI(6 byte) add */
*p++ = 0xAA;/* DSAP */
*p++ = 0xAA;/* SSAP */
@@ -1149,7 +1154,8 @@ int hostif_data_request(struct ks_wlan_private *priv, 
struct sk_buff *skb)
priv->wpa.mic_failure.failure > 0) {
if (keyinfo & WPA_KEY_INFO_ERROR &&
keyinfo & WPA_KEY_INFO_REQUEST) {
-   netdev_err(priv->net_dev, " MIC ERROR Report SET : 
%04X\n", keyinfo);
+   

[RESEND PATCH 36/47] staging: ks7010: use ether_addr_copy in ks_wlan_net_start

2018-05-03 Thread Sergio Paracuellos
Instead of use memcpy for copying ethernet addresses, use
ether_addr_copy that do the same.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index bb8ec04..a5401db 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2633,7 +2633,7 @@ int ks_wlan_net_start(struct net_device *dev)
timer_setup(_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0);
 
/* dummy address set */
-   memcpy(priv->eth_addr, dummy_addr, ETH_ALEN);
+   ether_addr_copy(priv->eth_addr, dummy_addr);
ether_addr_copy(dev->dev_addr, priv->eth_addr);
 
/* The ks_wlan-specific entries in the device structure. */
-- 
2.7.4

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


[RESEND PATCH 33/47] staging: ks7010: change parameter types in hostif_power_mgmt_request

2018-05-03 Thread Sergio Paracuellos
Parameters for hostif_power_mgmt_request are declared as unsigned
long and then are forced to be change to be u32. Also the caller
declares explicitly unsigned long parameters just to assign them
and pass into the function. Change types for those to be u32 instead
so no conversion is needed at all and code gets more clear.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 08f95f7..3a6385c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1419,8 +1419,7 @@ void hostif_phy_information_request(struct 
ks_wlan_private *priv)
 
 static
 void hostif_power_mgmt_request(struct ks_wlan_private *priv,
-  unsigned long mode, unsigned long wake_up,
-  unsigned long receive_dtims)
+  u32 mode, u32 wake_up, u32 receive_dtims)
 {
struct hostif_power_mgmt_request *pp;
 
@@ -1428,9 +1427,9 @@ void hostif_power_mgmt_request(struct ks_wlan_private 
*priv,
if (!pp)
return;
 
-   pp->mode = cpu_to_le32((uint32_t)mode);
-   pp->wake_up = cpu_to_le32((uint32_t)wake_up);
-   pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
+   pp->mode = cpu_to_le32(mode);
+   pp->wake_up = cpu_to_le32(wake_up);
+   pp->receive_dtims = cpu_to_le32(receive_dtims);
 
send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
@@ -1884,7 +1883,7 @@ void hostif_sme_multicast_set(struct ks_wlan_private 
*priv)
 static
 void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
 {
-   unsigned long mode, wake_up, receive_dtims;
+   u32 mode, wake_up, receive_dtims;
 
switch (priv->reg.power_mgmt) {
case POWER_MGMT_SAVE1:
-- 
2.7.4

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


[RESEND PATCH 22/47] staging: ks7010: move two preprocessor definitions to ks_wlan.h

2018-05-03 Thread Sergio Paracuellos
In ks_wlan_translate_scan function there are two preprocessor
definitions:

- RSN_INFO_ELEM_ID
- GENERIC_INFO_ELEM_ID

These can be moved to common ks_wlan.h because they can be used
in get_current_ap function instead of use hardcoded values.
GENERIC_INFO_ELEM_ID has been renamed to WPA_INFO_ELEM_ID which
is more clear.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c   | 4 ++--
 drivers/staging/ks7010/ks_wlan.h | 3 +++
 drivers/staging/ks7010/ks_wlan_net.c | 4 +---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index f8bca54..0054c48 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -132,12 +132,12 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
ap_info->rsn.size : RSN_IE_BODY_MAX;
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
-   ap->rsn_ie.id = 0x30;
+   ap->rsn_ie.id = RSN_INFO_ELEM_ID;
ap->rsn_ie.size = size;
memcpy(ap->rsn_ie.body, ap_info->rsn.body, size);
} else if ((ap_info->rsn_mode & RSN_MODE_WPA) &&
   (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
-   ap->wpa_ie.id = 0xdd;
+   ap->wpa_ie.id = WPA_INFO_ELEM_ID;
ap->wpa_ie.size = size;
memcpy(ap->wpa_ie.body, ap_info->rsn.body, size);
} else {
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index fb080fe..dd42692 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -190,6 +190,9 @@ struct rsn_ie {
u8 body[RSN_IE_BODY_MAX];
 } __packed;
 
+#define WPA_INFO_ELEM_ID 0xdd
+#define RSN_INFO_ELEM_ID 0x30
+
 #define WPS_IE_BODY_MAX 255
 struct wps_ie {
u8 id;  /* 221 'dd  00 50 F2 04' */
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index e964779..838db49 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1268,14 +1268,12 @@ static inline char *ks_wlan_translate_scan(struct 
net_device *dev,
if ((current_val - current_ev) > IW_EV_LCP_LEN)
current_ev = current_val;
 
-#define GENERIC_INFO_ELEM_ID 0xdd
-#define RSN_INFO_ELEM_ID 0x30
if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0)
current_ev = ks_wlan_add_leader_event(rsn_leader, end_buf,
  current_ev, >rsn_ie,
  , info);
 
-   if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0)
+   if (ap->wpa_ie.id == WPA_INFO_ELEM_ID && ap->wpa_ie.size != 0)
current_ev = ks_wlan_add_leader_event(wpa_leader, end_buf,
  current_ev, >wpa_ie,
  , info);
-- 
2.7.4

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


[RESEND PATCH 13/47] staging: ks7010: change local variable type in ks_wlan_hw_rx

2018-05-03 Thread Sergio Paracuellos
Local variable event in ks_wlan_hw_rx function is declared
as unsigned short and can be declared as u16 which is preferred
style.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 0c487ed..0b1e352 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -425,7 +425,7 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
int ret;
struct rx_device_buffer *rx_buffer;
struct hostif_hdr *hdr;
-   unsigned short event = 0;
+   u16 event = 0;
 
/* receive data */
if (rxq_count(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
-- 
2.7.4

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


[RESEND PATCH 17/47] staging: ks7010: conver MIB attributes preprocessor defs into an enum

2018-05-03 Thread Sergio Paracuellos
This commit just change some preprocessor definitions related
with MIB attributes into an enumeration which is much cleaner
for this here. Also add kerneldoc to avoid long comment lines.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 130 -
 1 file changed, 85 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index a913e02..d576341 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -84,51 +84,91 @@ struct channel_list {
u8 pad;
 } __packed;
 
-/* MIB Attribute */
-#define DOT11_MAC_ADDRESS 0x21010100   /* MAC Address (R) */
-#define DOT11_PRODUCT_VERSION 0x31024100   /* FirmWare Version (R) 
*/
-#define DOT11_RTS_THRESHOLD   0x21020100   /* RTS Threshold (R/W) 
*/
-#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100   /* Fragment Threshold 
(R/W) */
-#define DOT11_PRIVACY_INVOKED 0x15010100   /* WEP ON/OFF (W) */
-#define DOT11_WEP_DEFAULT_KEY_ID  0x15020100   /* WEP Index (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE1  0x13020101   /* WEP Key#1(TKIP AES: 
PairwiseTemporalKey) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE2  0x13020102   /* WEP Key#2(TKIP AES: 
GroupKey1) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE3  0x13020103   /* WEP Key#3(TKIP AES: 
GroupKey2) (W) */
-#define DOT11_WEP_DEFAULT_KEY_VALUE4  0x13020104   /* WEP Key#4 (W) */
-#define DOT11_WEP_LIST0x13020100   /* WEP LIST */
-#defineDOT11_DESIRED_SSID0x11090100/* SSID */
-#defineDOT11_CURRENT_CHANNEL 0x45010100/* channel set 
*/
-#defineDOT11_OPERATION_RATE_SET  0x0100/* rate set */
-
-#define LOCAL_AP_SEARCH_INTEAVAL  0xF1010100   /* AP search interval 
(R/W) */
-#define LOCAL_CURRENTADDRESS  0xF1050100   /* MAC Address change 
(W) */
-#define LOCAL_MULTICAST_ADDRESS   0xF1060100   /* Multicast Address 
(W) */
-#define LOCAL_MULTICAST_FILTER0xF1060200   /* Multicast Address 
Filter enable/disable (W) */
-#define LOCAL_SEARCHED_AP_LIST0xF1030100   /* AP list (R) */
-#define LOCAL_LINK_AP_STATUS  0xF1040100   /* Link AP status (R) */
-#defineLOCAL_PACKET_STATISTICS   0xF1020100/* tx,rx 
packets statistics */
-#define LOCAL_AP_SCAN_LIST_TYPE_SET  0xF1030200/* AP_SCAN_LIST_TYPE */
-
-#define DOT11_RSN_ENABLED 0x15070100   /* WPA enable/disable 
(W) */
-#define LOCAL_RSN_MODE0x56010100   /* RSN mode WPA/WPA2 
(W) */
-#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100   /* GroupKeyCipherSuite 
(W) */
-#define DOT11_RSN_CONFIG_UNICAST_CIPHER   0x52020100   /* 
PairwiseKeyCipherSuite (W) */
-#define DOT11_RSN_CONFIG_AUTH_SUITE   0x53020100   /* 
AuthenticationKeyManagementSuite (W) */
-#define DOT11_RSN_CONFIG_VERSION  0x51020100   /* RSN version (W) */
-#define LOCAL_RSN_CONFIG_ALL  0x5F010100   /* RSN CONFIG ALL (W) */
-#define DOT11_PMK_TSC 0x55010100   /* PMK_TSC (W) */
-#define DOT11_GMK1_TSC0x55010101   /* GMK1_TSC (W) */
-#define DOT11_GMK2_TSC0x55010102   /* GMK2_TSC (W) */
-#define DOT11_GMK3_TSC0x55010103   /* GMK3_TSC */
-#define LOCAL_PMK 0x58010100   /* Pairwise Master Key 
cache (W) */
-
-#define LOCAL_REGION  0xF10A0100   /* Region setting */
-
-#define LOCAL_WPS_ENABLE  0xF10B0100   /* WiFi Protected Setup 
*/
-#define LOCAL_WPS_PROBE_REQ   0xF10C0100   /* WPS Probe Request */
-
-#define LOCAL_GAIN0xF10D0100   /* Carrer sense 
threshold for demo ato show */
-#define LOCAL_EEPROM_SUM  0xF10E0100   /* EEPROM checksum 
information */
+/**
+ * enum mib_attribute - Management Information Base attribute
+ * Attribute value used for accessing and updating MIB
+ *
+ * @DOT11_MAC_ADDRESS: MAC Address (R)
+ * @DOT11_PRODUCT_VERSION: FirmWare Version (R)
+ * @DOT11_RTS_THRESHOLD: RTS Threshold (R/W)
+ * @DOT11_FRAGMENTATION_THRESHOLD: Fragment Threshold (R/W)
+ * @DOT11_PRIVACY_INVOKED: WEP ON/OFF (W)
+ * @DOT11_WEP_DEFAULT_KEY_ID: WEP Index (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE1: WEP Key#1(TKIP AES: PairwiseTemporalKey) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE2: WEP Key#2(TKIP AES: GroupKey1) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE3: WEP Key#3(TKIP AES: GroupKey2) (W)
+ * @DOT11_WEP_DEFAULT_KEY_VALUE4: WEP Key#4 (W)
+ * @DOT11_WEP_LIST: WEP LIST
+ * @DOT11_DESIRED_SSID: SSID
+ * @DOT11_CURRENT_CHANNEL: channel set
+ * @DOT11_OPERATION_RATE_SET: rate set
+ * @LOCAL_AP_SEARCH_INTERVAL: AP search interval (R/W)
+ * @LOCAL_CURRENTADDRESS: MAC Address change (W)
+ * @LOCAL_MULTICAST_ADDRESS: Multicast Address (W)
+ * 

[RESEND PATCH 03/47] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header

2018-05-03 Thread Sergio Paracuellos
ks_wlan_private struct has a pointer to struct ks_sdio_card in its
fields. Because of that a forward declaration in needed in ks_wlan.h
header and also it makes necessary to have ks_sdio_card public in
a ks7010_sdio.h header. Changing this pointer into a void pointer
makes no longer necessary to have ks7010_sdio.h header as well as
removes the forward dependency in ks_wlan.h. Declaration of
ks_sdio_card has been moved to ks7010_sdio.c source file and To make
code cleaner inside this file a new ks7010_to_func function has been
added. The code has been updated to this changes.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 52 +---
 drivers/staging/ks7010/ks7010_sdio.h | 26 --
 drivers/staging/ks7010/ks_wlan.h |  4 +--
 3 files changed, 37 insertions(+), 45 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 9c22a76..d71c826 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -16,7 +16,6 @@
 #include 
 #include "ks_wlan.h"
 #include "ks_hostif.h"
-#include "ks7010_sdio.h"
 
 #define ROM_FILE "ks7010sd.rom"
 
@@ -97,11 +96,31 @@ enum gen_com_reg_b {
 
 #define KS7010_IO_BLOCK_SIZE 512
 
+/**
+ * struct ks_sdio_card - SDIO device data.
+ *
+ * Structure is used as the  sdio_func private data.
+ *
+ * @func: Pointer to the SDIO function device.
+ * @priv: Pointer to the  net_device private data.
+ */
+struct ks_sdio_card {
+   struct sdio_func *func;
+   struct ks_wlan_private *priv;
+};
+
+static struct sdio_func *ks7010_to_func(struct ks_wlan_private *priv)
+{
+   struct ks_sdio_card *ks_sdio = priv->if_hw;
+
+   return ks_sdio->func;
+}
+
 /* Read single byte from device address into byte (CMD52) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 u32 address, u8 *byte)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
int ret;
 
*byte = sdio_readb(func, address, );
@@ -113,7 +132,7 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
u8 *buffer, unsigned int length)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
 
return sdio_memcpy_fromio(func, buffer, address, length);
 }
@@ -122,7 +141,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, 
u32 address,
 static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
  u32 address, u8 byte)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
int ret;
 
sdio_writeb(func, byte, address, );
@@ -134,7 +153,7 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
 static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address,
 u8 *buffer, unsigned int length)
 {
-   struct sdio_func *func = priv->ks_sdio_card->func;
+   struct sdio_func *func = ks7010_to_func(priv);
 
return sdio_memcpy_toio(func, address, buffer, length);
 }
@@ -449,12 +468,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
 
 static void ks7010_rw_function(struct work_struct *work)
 {
-   struct ks_wlan_private *priv;
+   struct ks_wlan_private *priv = container_of(work,
+   struct ks_wlan_private,
+   rw_dwork.work);
+   struct sdio_func *func = ks7010_to_func(priv);
unsigned char byte;
int ret;
 
-   priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
-
/* wait after DOZE */
if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after DOZE\n");
@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work)
/* wait after WAKEUP */
while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
-   dev_info(>ks_sdio_card->func->dev,
-"wake: %lu %lu\n",
+   dev_info(>dev, "wake: %lu %lu\n",
 priv->last_wakeup + msecs_to_jiffies(30), jiffies);
msleep(30);
}
 
-   sdio_claim_host(priv->ks_sdio_card->func);
+   sdio_claim_host(func);
 
/* power save wakeup */
if (atomic_read(>psstatus.status) == PS_SNOOZE) {
@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work)
_ks_wlan_hw_power_save(priv);
 
 release_host:
-   

[RESEND PATCH 14/47] staging: ks7010: remove nonsense comment in ks_wlan.h file

2018-05-03 Thread Sergio Paracuellos
Header file ks_wlan.h has a lot of nonsense comments along
the different declarations included on it. Most of them are
just the same as the variable name. Just remove them all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan.h | 49 
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index ad349ef..fb080fe 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -9,35 +9,35 @@
 #ifndef _KS_WLAN_H
 #define _KS_WLAN_H
 
-#include   /* struct atomic_t */
+#include 
 #include 
-#include   /* struct completion */
-#include/* struct net_device_stats,  struct sk_buff */
-#include/* wait_queue_head_t */
-#include /* spinlock_t */
+#include 
+#include 
+#include 
+#include 
 #include 
 
 struct ks_wlan_parameter {
-   u8 operation_mode;  /* Operation Mode */
-   u8 channel; /*  Channel */
-   u8 tx_rate; /*  Transmit Rate */
+   u8 operation_mode;
+   u8 channel;
+   u8 tx_rate;
struct {
u8 size;
u8 body[16];
} rate_set;
-   u8 bssid[ETH_ALEN]; /* BSSID */
+   u8 bssid[ETH_ALEN];
struct {
u8 size;
u8 body[32 + 1];
-   } ssid; /*  SSID */
-   u8 preamble;/*  Preamble */
+   } ssid;
+   u8 preamble;
u8 power_mgmt;
-   u32 scan_type;  /*  AP List Scan Type */
+   u32 scan_type;
 #define BEACON_LOST_COUNT_MIN 0
 #define BEACON_LOST_COUNT_MAX 65535
-   u32 beacon_lost_count;  /*  Beacon Lost Count */
-   u32 rts;/*  RTS Threashold */
-   u32 fragment;   /*  Fragmentation Threshold */
+   u32 beacon_lost_count;
+   u32 rts;
+   u32 fragment;
u32 privacy_invoked;
u32 wep_index;
struct {
@@ -45,9 +45,9 @@ struct ks_wlan_parameter {
u8 val[13 * 2 + 1];
} wep_key[4];
u16 authenticate_type;
-   u16 phy_type;   /* 11b/11g/11bg mode type */
-   u16 cts_mode;   /* for 11g/11bg mode cts mode */
-   u16 phy_info_timer; /* phy information timer */
+   u16 phy_type;
+   u16 cts_mode;
+   u16 phy_info_timer;
 };
 
 enum {
@@ -155,7 +155,7 @@ enum {
SME_WEP_SET_CONFIRM,
SME_TERMINATE,
 
-   SME_EVENT_SIZE  /* end */
+   SME_EVENT_SIZE
 };
 
 /* SME Status */
@@ -330,7 +330,7 @@ struct mic_failure {
u16 failure;/* MIC Failure counter 0 or 1 or 2 */
u16 counter;/* 1sec counter 0-60 */
u32 last_failure_time;
-   int stop;   /* stop flag */
+   int stop;
 };
 
 struct wpa_status {
@@ -339,7 +339,7 @@ struct wpa_status {
int version;
int pairwise_suite; /* unicast cipher */
int group_suite;/* multicast cipher */
-   int key_mgmt_suite; /* authentication key management suite */
+   int key_mgmt_suite;
int auth_alg;
int txkey;
struct wpa_key key[WPA_KEY_INDEX_MAX];
@@ -485,17 +485,16 @@ struct ks_wlan_private {
unsigned char firmware_version[128 + 1];
int version_size;
 
-   bool mac_address_valid; /* Mac Address Status */
+   bool mac_address_valid;
 
int dev_state;
 
struct sk_buff *skb;
unsigned int cur_rx;/* Index into the Rx buffer of next Rx pkt. */
-   /* spinlock_t lock; */
 #define FORCE_DISCONNECT0x8000
 #define CONNECT_STATUS_MASK 0x7FFF
-   u32 connect_status; /* connect status */
-   int infra_status;   /* Infractructure status */
+   u32 connect_status;
+   int infra_status;
u8 scan_ssid_len;
u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
struct local_gain gain;
-- 
2.7.4

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


[RESEND PATCH 15/47] staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in hostif_sme_execute

2018-05-03 Thread Sergio Paracuellos
This commit cleans code for the event SME_MIC_FAILURE_REQUEST
changing if logic to handle invalid value first and using a
local variable.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 965a23d..5dceadc 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2070,10 +2070,10 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
 }
 
 /* execute sme */
-static
-void hostif_sme_execute(struct ks_wlan_private *priv, int event)
+static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
 {
__le32 val;
+   u16 failure;
 
switch (event) {
case SME_START:
@@ -2099,18 +2099,15 @@ void hostif_sme_execute(struct ks_wlan_private *priv, 
int event)
hostif_phy_information_request(priv);
break;
case SME_MIC_FAILURE_REQUEST:
-   if (priv->wpa.mic_failure.failure == 1) {
-   hostif_mic_failure_request(priv,
-  
priv->wpa.mic_failure.failure - 1,
-  0);
-   } else if (priv->wpa.mic_failure.failure == 2) {
-   hostif_mic_failure_request(priv,
-  
priv->wpa.mic_failure.failure - 1,
-  
priv->wpa.mic_failure.counter);
-   } else {
-   netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: 
failure count=%u error?\n",
-  priv->wpa.mic_failure.failure);
+   failure = priv->wpa.mic_failure.failure;
+   if (failure != 1 && failure != 2) {
+   netdev_err(priv->net_dev,
+  "SME_MIC_FAILURE_REQUEST: failure count=%u 
error?\n",
+  failure);
+   return;
}
+   hostif_mic_failure_request(priv, failure - 1, (failure == 1) ?
+   0 : priv->wpa.mic_failure.counter);
break;
case SME_MIC_FAILURE_CONFIRM:
if (priv->wpa.mic_failure.failure == 2) {
-- 
2.7.4

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


[RESEND PATCH 07/47] staging: ks7010: change local variable type in _ks_wlan_hw_power_save

2018-05-03 Thread Sergio Paracuellos
Local variable 'byte' in _ks_wlan_hw_power_save function is declared
as unsigned char and can be declared as u8 which is preferred. It
is being using with ks7010_sdio_readb which expects u8 already.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 71e12d6..3574a22 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -217,7 +217,7 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
 
 static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 {
-   unsigned char byte;
+   u8 byte;
int ret;
 
if (priv->reg.power_mgmt == POWER_MGMT_ACTIVE)
-- 
2.7.4

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


[RESEND PATCH 34/47] staging: ks7010: refactor hostif_sme_power_mgmt_set function

2018-05-03 Thread Sergio Paracuellos
This commit refactor hostif_sme_power_mgmt_set avoiding to
use switch-case statement and simplifying data paths. This
improves readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 33 ++---
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 3a6385c..359187e 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1880,36 +1880,23 @@ void hostif_sme_multicast_set(struct ks_wlan_private 
*priv)
spin_unlock(>multicast_spin);
 }
 
-static
-void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
+static void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
 {
u32 mode, wake_up, receive_dtims;
 
-   switch (priv->reg.power_mgmt) {
-   case POWER_MGMT_SAVE1:
-   mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
-   POWER_SAVE : POWER_ACTIVE;
-   wake_up = 0;
-   receive_dtims = 0;
-   break;
-   case POWER_MGMT_SAVE2:
-   if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
-   mode = POWER_SAVE;
-   wake_up = 0;
-   receive_dtims = 1;
-   } else {
-   mode = POWER_ACTIVE;
-   wake_up = 0;
-   receive_dtims = 0;
-   }
-   break;
-   case POWER_MGMT_ACTIVE:
-   default:
+   if (priv->reg.power_mgmt != POWER_MGMT_SAVE1 &&
+   priv->reg.power_mgmt != POWER_MGMT_SAVE2) {
mode = POWER_ACTIVE;
wake_up = 0;
receive_dtims = 0;
-   break;
+   } else {
+   mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
+   POWER_SAVE : POWER_ACTIVE;
+   wake_up = 0;
+   receive_dtims = (priv->reg.operation_mode == 
MODE_INFRASTRUCTURE &&
+priv->reg.power_mgmt == POWER_MGMT_SAVE2);
}
+
hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
 }
 
-- 
2.7.4

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


[RESEND PATCH 26/47] staging: ks7010: use ether_addr_copy to copy ethernet address sa_data

2018-05-03 Thread Sergio Paracuellos
Use ether_addr_copy kernel function to copy an ethernet address
instead of a simple memcpy with ETH_ALEN size.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 8cd3dac..00d6318 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -151,8 +151,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct 
link_ap_info *ap_info)
wrqu.data.flags = 0;
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
if (is_connect_status(priv->connect_status)) {
-   memcpy(wrqu.ap_addr.sa_data,
-  priv->current_ap.bssid, ETH_ALEN);
+   ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
   "IWEVENT: connect bssid=%pM\n", 
wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, , NULL);
-- 
2.7.4

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


[RESEND PATCH 31/47] staging: ks7010: add blank line between after definitions

2018-05-03 Thread Sergio Paracuellos
Add blank line after definitions in hostif_aplist_init function
to fix a checkpatch script complain about that.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 644a083..30c2d3a 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2255,6 +2255,7 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 
event)
 static inline void hostif_aplist_init(struct ks_wlan_private *priv)
 {
size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap);
+
priv->aplist.size = 0;
memset(>aplist.ap[0], 0, size);
 }
-- 
2.7.4

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


[RESEND PATCH 29/47] staging: ks7010: factor out send_request_to_device function

2018-05-03 Thread Sergio Paracuellos
In all functions related with requests to the device the same
patter in used and is also adding a comment to make clear the
intention of the code. Just factor out the pattern into a new
send_request_to_device function to improve readability and make
clear code intention.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 60 +-
 1 file changed, 20 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 8bd2797..1a59218 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1172,6 +1172,13 @@ static inline void ps_confirm_wait_inc(struct 
ks_wlan_private *priv)
atomic_inc(>psstatus.confirm_wait);
 }
 
+static inline void send_request_to_device(struct ks_wlan_private *priv,
+ void *data, size_t size)
+{
+   ps_confirm_wait_inc(priv);
+   ks_wlan_hw_tx(priv, data, size, NULL, NULL);
+}
+
 static
 void hostif_mib_get_request(struct ks_wlan_private *priv,
unsigned long mib_attribute)
@@ -1184,9 +1191,7 @@ void hostif_mib_get_request(struct ks_wlan_private *priv,
 
pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static void hostif_mib_set_request(struct ks_wlan_private *priv,
@@ -1208,9 +1213,7 @@ static void hostif_mib_set_request(struct ks_wlan_private 
*priv,
pp->mib_value.type = cpu_to_le16(type);
memcpy(>mib_value.body, data, size);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp) + size));
 }
 
 static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
@@ -1250,9 +1253,7 @@ void hostif_start_request(struct ks_wlan_private *priv, 
unsigned char mode)
 
pp->mode = cpu_to_le16((uint16_t)mode);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1299,9 +1300,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private 
*priv)
init_request(priv, >request);
pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1340,9 +1339,7 @@ void hostif_infrastructure_set_request(struct 
ks_wlan_private *priv, int event)
pp->channel_list.size = 14;
}
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1359,9 +1356,7 @@ void hostif_adhoc_set_request(struct ks_wlan_private 
*priv)
pp->ssid.size = priv->reg.ssid.size;
memcpy(>ssid.body[0], >reg.ssid.body[0], priv->reg.ssid.size);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1381,9 +1376,7 @@ void hostif_adhoc_set2_request(struct ks_wlan_private 
*priv)
pp->channel_list.size = 1;
memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1395,9 +1388,7 @@ void hostif_stop_request(struct ks_wlan_private *priv)
if (!pp)
return;
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1417,9 +1408,7 @@ void hostif_phy_information_request(struct 
ks_wlan_private *priv)
pp->time = cpu_to_le16((uint16_t)0);
}
 
-   /* send to device request */
-   ps_confirm_wait_inc(priv);
-   ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+   send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
 }
 
 static
@@ -1437,9 +1426,7 @@ void hostif_power_mgmt_request(struct 

[RESEND PATCH 16/47] staging: ks7010: convert MIB preprocessor defs into an enum

2018-05-03 Thread Sergio Paracuellos
This commit just change some preprocessor definitions related
with MIB data types into an enumeration which is much cleaner
for this here.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 974e639..a913e02 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -135,14 +135,25 @@ struct hostif_mib_get_request {
__le32 mib_attribute;
 } __packed;
 
+/**
+ * enum mib_data_type - Message Information Base data type.
+ * @MIB_VALUE_TYPE_NULL: NULL type
+ * @MIB_VALUE_TYPE_INT: INTEGER type
+ * @MIB_VALUE_TYPE_BOOL: BOOL type
+ * @MIB_VALUE_TYPE_COUNT32: unused
+ * @MIB_VALUE_TYPE_OSTRING: Chunk of memory
+ */
+enum mib_data_type {
+   MIB_VALUE_TYPE_NULL = 0,
+   MIB_VALUE_TYPE_INT,
+   MIB_VALUE_TYPE_BOOL,
+   MIB_VALUE_TYPE_COUNT32,
+   MIB_VALUE_TYPE_OSTRING
+};
+
 struct hostif_mib_value {
__le16 size;
__le16 type;
-#define MIB_VALUE_TYPE_NULL 0
-#define MIB_VALUE_TYPE_INT  1
-#define MIB_VALUE_TYPE_BOOL 2
-#define MIB_VALUE_TYPE_COUNT32  3
-#define MIB_VALUE_TYPE_OSTRING  4
u8 body[0];
 } __packed;
 
-- 
2.7.4

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


[RESEND PATCH 37/47] staging: ks7010: refactor ks_wlan_set_sleep_mode function

2018-05-03 Thread Sergio Paracuellos
This commit refactors ks_wlan_set_sleep_mode function
avoiding to use switch-case statement ans using simple
if logic to handle invalid values first. This simplifies
data paths as well as improves readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_wlan_net.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index a5401db..53288c8 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device 
*dev,
 {
struct ks_wlan_private *priv = netdev_priv(dev);
 
-   if (*uwrq == SLP_SLEEP) {
-   priv->sleep_mode = *uwrq;
-   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
-
-   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
-   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
-
-   } else if (*uwrq == SLP_ACTIVE) {
-   priv->sleep_mode = *uwrq;
-   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
-   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
-   } else {
+   if (*uwrq != SLP_SLEEP &&
+   *uwrq != SLP_ACTIVE) {
netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq);
return -EINVAL;
}
 
+   priv->sleep_mode = *uwrq;
+   netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
+
+   if (*uwrq == SLP_SLEEP)
+   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
+
+   hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
+
return 0;
 }
 
-- 
2.7.4

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


[RESEND PATCH 20/47] staging: ks7010: add new helpers to achieve mib set request and simplify code

2018-05-03 Thread Sergio Paracuellos
New three functions have been created to centralice and simplify
calls related with set MIB requests:

- hostif_mib_set_request_int
- hostif_mib_set_request_bool
- hostif_mib_set_request_ostring

Using these in different calls simplify functions related with
this mainly when types are bool and int because no more conversions
are needed in the caller functions. Those conversion details are
now located in the new helpers improving a lot readability. Calls
in hostif_sme_set_wep function has change also some if's to check
invalid value first avoiding one level indentation.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 225 ++---
 1 file changed, 109 insertions(+), 116 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 9b25221..b22dc0c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1216,6 +1216,32 @@ static void hostif_mib_set_request(struct 
ks_wlan_private *priv,
ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
 }
 
+static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
+ enum mib_attribute attr, int val)
+{
+   __le32 v = cpu_to_le32((u32)val);
+   size_t size = sizeof(v);
+
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, , size);
+}
+
+static inline void hostif_mib_set_request_bool(struct ks_wlan_private *priv,
+  enum mib_attribute attr,
+  bool val)
+{
+   __le32 v = cpu_to_le32((u32)val);
+   size_t size = sizeof(v);
+
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, , size);
+}
+
+static inline void hostif_mib_set_request_ostring(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ void *data, size_t size)
+{
+   hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_OSTRING, data, size);
+}
+
 static
 void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
 {
@@ -1548,53 +1574,48 @@ void hostif_receive(struct ks_wlan_private *priv, 
unsigned char *p,
hostif_event_check(priv);
 }
 
-static
-void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
 {
-   __le32 val;
-
switch (type) {
case SME_WEP_INDEX_REQUEST:
-   val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
-   hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
-  MIB_VALUE_TYPE_INT, , sizeof(val));
+   hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+  priv->reg.wep_index);
break;
case SME_WEP_KEY1_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE1,
-  MIB_VALUE_TYPE_OSTRING,
   >reg.wep_key[0].val[0],
   priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE2,
-  MIB_VALUE_TYPE_OSTRING,
   >reg.wep_key[1].val[0],
   priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
   DOT11_WEP_DEFAULT_KEY_VALUE3,
-  MIB_VALUE_TYPE_OSTRING,
   >reg.wep_key[2].val[0],
   priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
-   if (!priv->wpa.wpa_enabled)
-   hostif_mib_set_request(priv,
+   if (priv->wpa.wpa_enabled)
+   return;
+   hostif_mib_set_request_ostring(priv,
  

[RESEND PATCH 12/47] staging: ks7010: refactor ks7010_sme_enqueue_events function

2018-05-03 Thread Sergio Paracuellos
Event to send to init the card are always the same so change
code to be more readable putting them into an array and
enqueuing also using a for loop.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 31 +--
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 9085ed7..0c487ed 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -806,24 +806,19 @@ static int ks7010_upload_firmware(struct ks_sdio_card 
*card)
 
 static void ks7010_sme_enqueue_events(struct ks_wlan_private *priv)
 {
-   hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM);
-
-   /* load initial wireless parameter */
-   hostif_sme_enqueue(priv, SME_STOP_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST);
-   hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST);
-   hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST);
-
-   hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST);
-   hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST);
-   hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST);
-   hostif_sme_enqueue(priv, SME_START_REQUEST);
+   static const u16 init_events[] = {
+   SME_GET_EEPROM_CKSUM, SME_STOP_REQUEST,
+   SME_RTS_THRESHOLD_REQUEST, SME_FRAGMENTATION_THRESHOLD_REQUEST,
+   SME_WEP_INDEX_REQUEST, SME_WEP_KEY1_REQUEST,
+   SME_WEP_KEY2_REQUEST, SME_WEP_KEY3_REQUEST,
+   SME_WEP_KEY4_REQUEST, SME_WEP_FLAG_REQUEST,
+   SME_RSN_ENABLED_REQUEST, SME_MODE_SET_REQUEST,
+   SME_START_REQUEST
+   };
+   int ev;
+
+   for (ev = 0; ev < ARRAY_SIZE(init_events); ev++)
+   hostif_sme_enqueue(priv, init_events[ev]);
 }
 
 static void ks7010_card_init(struct ks_wlan_private *priv)
-- 
2.7.4

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


[RESEND PATCH 01/47] staging: ks7010: add SPDX identifiers to all files

2018-05-03 Thread Sergio Paracuellos
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Fix up the all of the staging ks7010 files to have a proper SPDX
identifier, based on the license text in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of
the full boiler plate text.

Extra GPL text wording can be removed as it is no longer needed at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c   | 5 +
 drivers/staging/ks7010/ks7010_sdio.h   | 5 +
 drivers/staging/ks7010/ks_hostif.c | 5 +
 drivers/staging/ks7010/ks_hostif.h | 5 +
 drivers/staging/ks7010/ks_wlan.h   | 5 +
 drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +
 drivers/staging/ks7010/ks_wlan_net.c   | 5 +
 drivers/staging/ks7010/michael_mic.c   | 5 +
 drivers/staging/ks7010/michael_mic.h   | 5 +
 9 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b29f48c..6a5565d 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1,13 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
  *   Copyright (C) 2016 Sang Engineering, Wolfram Sang
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 95ac86b..831b2f1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 #ifndef _KS7010_SDIO_H
 #define _KS7010_SDIO_H
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 9a05374..c0a9a67 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1,12 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *   Driver for KeyStream wireless LAN cards.
  *
  *   Copyright (C) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #include 
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 05ff5ca..172d38f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_HOSTIF_H_
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 2894b0c..5070af8 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream IEEE802.11 b/g wireless LAN cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_H
diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h 
b/drivers/staging/ks7010/ks_wlan_ioctl.h
index e45a332..97c7d95 100644
--- a/drivers/staging/ks7010/ks_wlan_ioctl.h
+++ b/drivers/staging/ks7010/ks_wlan_ioctl.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *   Driver for KeyStream 11b/g wireless LAN
  *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
  */
 
 #ifndef _KS_WLAN_IOCTL_H
diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 

[RESEND PATCH 18/47] staging: ks7010: change some casts from uint8_t to u8 in ks_hostif header

2018-05-03 Thread Sergio Paracuellos
This commit changes some type cast in rate related preprocessor
definitions included in ks_hostif header file to use preferred
u8 type.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.h | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index d576341..ca7dc8f 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED  5
 
 /* 11b rate */
-#define TX_RATE_1M (uint8_t)(10 / 5)   /* 11b 11g basic rate */
-#define TX_RATE_2M (uint8_t)(20 / 5)   /* 11b 11g basic rate */
-#define TX_RATE_5M (uint8_t)(55 / 5)   /* 11g basic rate */
-#define TX_RATE_11M(uint8_t)(110 / 5)  /* 11g basic rate */
+#define TX_RATE_1M (u8)(10 / 5)/* 11b 11g basic rate */
+#define TX_RATE_2M (u8)(20 / 5)/* 11b 11g basic rate */
+#define TX_RATE_5M (u8)(55 / 5)/* 11g basic rate */
+#define TX_RATE_11M(u8)(110 / 5)   /* 11g basic rate */
 
 /* 11g rate */
-#define TX_RATE_6M (uint8_t)(60 / 5)   /* 11g basic rate */
-#define TX_RATE_12M(uint8_t)(120 / 5)  /* 11g basic rate */
-#define TX_RATE_24M(uint8_t)(240 / 5)  /* 11g basic rate */
-#define TX_RATE_9M (uint8_t)(90 / 5)
-#define TX_RATE_18M(uint8_t)(180 / 5)
-#define TX_RATE_36M(uint8_t)(360 / 5)
-#define TX_RATE_48M(uint8_t)(480 / 5)
-#define TX_RATE_54M(uint8_t)(540 / 5)
+#define TX_RATE_6M (u8)(60 / 5)/* 11g basic rate */
+#define TX_RATE_12M(u8)(120 / 5)   /* 11g basic rate */
+#define TX_RATE_24M(u8)(240 / 5)   /* 11g basic rate */
+#define TX_RATE_9M (u8)(90 / 5)
+#define TX_RATE_18M(u8)(180 / 5)
+#define TX_RATE_36M(u8)(360 / 5)
+#define TX_RATE_48M(u8)(480 / 5)
+#define TX_RATE_54M(u8)(540 / 5)
 
 static inline bool is_11b_rate(u8 rate)
 {
-- 
2.7.4

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


[RESEND PATCH 05/47] staging: ks7010: remove missing WPS preprocessor conditional code

2018-05-03 Thread Sergio Paracuellos
Commit 92c1552caef3661f049c4e967550e933599e2663 removes WPS hardcoded
definition and its related conditional preprocessor code. There
was some missing stuff already in this files. Remove it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 6 --
 drivers/staging/ks7010/ks_hostif.h | 2 --
 2 files changed, 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index c0a9a67..ea484f2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -611,10 +611,8 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
case DOT11_PMK_TSC:
case LOCAL_PMK:
case LOCAL_GAIN:
-#ifdef WPS
case LOCAL_WPS_ENABLE:
case LOCAL_WPS_PROBE_REQ:
-#endif /* WPS */
case LOCAL_REGION:
default:
break;
@@ -644,7 +642,6 @@ void hostif_sleep_confirm(struct ks_wlan_private *priv)
 static
 void hostif_start_confirm(struct ks_wlan_private *priv)
 {
-#ifdef WPS
union iwreq_data wrqu;
 
wrqu.data.length = 0;
@@ -654,7 +651,6 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
eth_zero_addr(wrqu.ap_addr.sa_data);
wireless_send_event(priv->net_dev, SIOCGIWAP, , NULL);
}
-#endif
netdev_dbg(priv->net_dev, " scan_ind_count=%d\n", priv->scan_ind_count);
hostif_sme_enqueue(priv, SME_START_CONFIRM);
 }
@@ -2174,7 +2170,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
case SME_SET_PMKSA:
hostif_sme_set_pmksa(priv);
break;
-#ifdef WPS
case SME_WPS_ENABLE_REQUEST:
hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
   sizeof(priv->wps.wps_enabled),
@@ -2186,7 +2181,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int 
event)
   priv->wps.ielen,
   MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
break;
-#endif /* WPS */
case SME_MODE_SET_REQUEST:
hostif_sme_mode_setup(priv);
break;
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 172d38f..cb906f0 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -124,10 +124,8 @@ struct channel_list {
 
 #define LOCAL_REGION  0xF10A0100   /* Region setting */
 
-#ifdef WPS
 #define LOCAL_WPS_ENABLE  0xF10B0100   /* WiFi Protected Setup 
*/
 #define LOCAL_WPS_PROBE_REQ   0xF10C0100   /* WPS Probe Request */
-#endif /* WPS */
 
 #define LOCAL_GAIN0xF10D0100   /* Carrer sense 
threshold for demo ato show */
 #define LOCAL_EEPROM_SUM  0xF10E0100   /* EEPROM checksum 
information */
-- 
2.7.4

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


[RESEND PATCH 00/47] staging: ks7010: next cleanups

2018-05-03 Thread Sergio Paracuellos
This patch series are all of my patches that haven't been
applied yet. Most of them are from previous series and
there are also a few new patches included.

I resend them because I think Greg applies patches in FIFO
order and other patches that have been applied in other drivers
are newer than mine and there is no complain about them also, 
so I don't know if mine are not in your review queue. 
If they are, sorry in advance for inconvenience.

Sergio Paracuellos (47):
  staging: ks7010: add SPDX identifiers to all files
  staging: ks7010: move tx and rx queues definitions into ks_wlan.h
header
  staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header
  staging: ks7010: change netdev_dbg msg to avoid a long line
  staging: ks7010: remove missing WPS preprocessor conditional code
  staging: ks7010: use u8 instead of unsigned char in write_to_device
function
  staging: ks7010: change local variable type in _ks_wlan_hw_power_save
  staging: ks7010: change local variable type in ks7010_rw_function
  staging: ks7010: change some local variables type in ks_sdio_interrupt
  staging: ks7010: change local variable type in ks7010_sdio_init_irqs
  staging: ks7010: use the same parameter for 'event' in
hostif_sme_enqueue
  staging: ks7010: refactor ks7010_sme_enqueue_events function
  staging: ks7010: change local variable type in ks_wlan_hw_rx
  staging: ks7010: remove nonsense comment in ks_wlan.h file
  staging: ks7010: clean SME_MIC_FAILURE_REQUEST case in
hostif_sme_execute
  staging: ks7010: convert MIB preprocessor defs into an enum
  staging: ks7010: conver MIB attributes preprocessor defs into an enum
  staging: ks7010: change some casts from uint8_t to u8 in ks_hostif
header
  staging: ks7010: change parameter types and reorder them in
hostif_mib_set_request
  staging: ks7010: add new helpers to achieve mib set request and
simplify code
  staging: ks7010: use ether_addr_copy in get_current_ap
  staging: ks7010: move two preprocessor definitions to ks_wlan.h
  staging: ks7010: avoid two long lines in hostif_sme_mode_setup
  staging: ks7010: remove non sense comments in ks_hostif.c source file
  staging: ks7010: change type for rsn_enabled in wpa_status struct
  staging: ks7010: use ether_addr_copy to copy ethernet address sa_data
  staging: ks7010: use ether_addr_copy in get_ap_information function
  staging: ks7010: move WLAN_EID_DS_PARAMS to different place inside
switch
  staging: ks7010: factor out send_request_to_device function
  staging: ks7010: fix some style issues in ks_hostif.c
  staging: ks7010: add blank line between after definitions
  staging: ks7010: refactor hostif_sme_set_rsn function
  staging: ks7010: change parameter types in hostif_power_mgmt_request
  staging: ks7010: refactor hostif_sme_power_mgmt_set function
  staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address
  staging: ks7010: use ether_addr_copy in ks_wlan_net_start
  staging: ks7010: refactor ks_wlan_set_sleep_mode function
  staging: ks7010: refactor ks_wlan_set_phy_type function
  staging: ks7010: refactor ks_wlan_set_mlme function
  staging: ks7010: refactor ks_get_wireless_stats function
  staging: ks7010: use CIRC_CNT_TO_END macro in cnt_smeqbody
  staging: ks7010: refactor LOCAL_EEPROM_SUM case in
hostif_mib_get_confirm
  staging: ks7010: use u16 instead of unsigned short in
hostif_event_check
  staging: ks7010: use u16 instead of unsigned short in
hostif_data_indication
  staging: ks7010: use u16 instead of unsigned short in
hostif_connect_indication
  staging: ks7010: use u32 instead of unsigned int in
hostif_bss_scan_confirm
  staging: ks7010: review local variable types in
hostif_phy_information_confirm

 drivers/staging/ks7010/ks7010_sdio.c   | 145 +++-
 drivers/staging/ks7010/ks7010_sdio.h   |  88 -
 drivers/staging/ks7010/ks_hostif.c | 661 ++---
 drivers/staging/ks7010/ks_hostif.h | 184 +
 drivers/staging/ks7010/ks_wlan.h   | 171 +++--
 drivers/staging/ks7010/ks_wlan_ioctl.h |   5 +-
 drivers/staging/ks7010/ks_wlan_net.c   |  88 ++---
 drivers/staging/ks7010/michael_mic.c   |   5 +-
 drivers/staging/ks7010/michael_mic.h   |   5 +-
 9 files changed, 629 insertions(+), 723 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h

-- 
2.7.4

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


[RESEND PATCH 06/47] staging: ks7010: use u8 instead of unsigned char in write_to_device function

2018-05-03 Thread Sergio Paracuellos
Parameter buffer in write_to_device function is declared as
a pointer to unsigned char and can be declared as an u8 type
which is preferred. Internally it calls to ks7010_sdio_write
which is using also u8 as parameter type. Update calls to this
function as well.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 078f37e..71e12d6 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -318,7 +318,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
 }
 
 /* write data */
-static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
+static int write_to_device(struct ks_wlan_private *priv, u8 *buffer,
   unsigned long size)
 {
struct hostif_hdr *hdr;
@@ -1071,8 +1071,7 @@ static int send_stop_request(struct sdio_func *func)
pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
 
sdio_claim_host(func);
-   write_to_device(card->priv, (unsigned char *)pp,
-   hif_align_size(sizeof(*pp)));
+   write_to_device(card->priv, (u8 *)pp, hif_align_size(sizeof(*pp)));
sdio_release_host(func);
 
kfree(pp);
-- 
2.7.4

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


[RESEND PATCH 11/47] staging: ks7010: use the same parameter for 'event' in hostif_sme_enqueue

2018-05-03 Thread Sergio Paracuellos
Declaration of second parameter 'event' in ks_hostif .h and .c
file is different using uint16_t and unsigned short respectively.
Just unify both using 'u16' which is preferred instead.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks_hostif.c | 2 +-
 drivers/staging/ks7010/ks_hostif.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index ea484f2..965a23d 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2259,7 +2259,7 @@ void hostif_sme_task(unsigned long dev)
 }
 
 /* send to Station Management Entity module */
-void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event)
 {
/* enqueue sme event */
if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index cb906f0..974e639 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -542,7 +542,7 @@ static inline bool is_hif_conf(unsigned short event)
 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb);
 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
unsigned int size);
-void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event);
 int hostif_init(struct ks_wlan_private *priv);
 void hostif_exit(struct ks_wlan_private *priv);
 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
-- 
2.7.4

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


[RESEND PATCH 04/47] staging: ks7010: change netdev_dbg msg to avoid a long line

2018-05-03 Thread Sergio Paracuellos
This commit avoids a long line changing a bit message in
_ks_wlan_hw_power_save function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/ks7010/ks7010_sdio.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index d71c826..078f37e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -235,7 +235,12 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private 
*priv)
if (atomic_read(>psstatus.status) == PS_SNOOZE)
return;
 
-   netdev_dbg(priv->net_dev, 
"\npsstatus.status=%d\npsstatus.confirm_wait=%d\npsstatus.snooze_guard=%d\ncnt_txqbody=%d\n",
+   netdev_dbg(priv->net_dev,
+  "STATUS:\n"
+  "- psstatus.status = %d\n"
+  "- psstatus.confirm_wait = %d\n"
+  "- psstatus.snooze_guard = %d\n"
+  "- txq_count = %d\n",
   atomic_read(>psstatus.status),
   atomic_read(>psstatus.confirm_wait),
   atomic_read(>psstatus.snooze_guard),
-- 
2.7.4

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


Re: [PATCH v2 11/11] staging: iio: tsl2x7x/tsl2772: move out of staging

2018-05-03 Thread Brian Masney
Hey Jonathan,

I intentionally didn't run git format-patch with the --no-renames since
patch 10 renamed the driver. Here is the .[ch] files included inline to
make your review easier.

Brian


tsl2772.c:

// SPDX-License-Identifier: GPL-2.0+
/*
 * Device driver for monitoring ambient light intensity in (lux) and proximity
 * detection (prox) for the TAOS TSL2571, TSL2671, TMD2671, TSL2771, TMD2771,
 * TSL2572, TSL2672, TMD2672, TSL2772, and TMD2772 devices.
 *
 * Copyright (c) 2012, TAOS Corporation.
 * Copyright (c) 2017-2018 Brian Masney 
 */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

/* Cal defs */
#define PROX_STAT_CAL   0
#define PROX_STAT_SAMP  1
#define MAX_SAMPLES_CAL 200

/* TSL2772 Device ID */
#define TRITON_ID   0x00
#define SWORDFISH_ID0x30
#define HALIBUT_ID  0x20

/* Lux calculation constants */
#define TSL2772_LUX_CALC_OVER_FLOW  65535

/*
 * TAOS Register definitions - Note: depending on device, some of these register
 * are not used and the register address is benign.
 */

/* Register offsets */
#define TSL2772_MAX_CONFIG_REG  16

/* Device Registers and Masks */
#define TSL2772_CNTRL   0x00
#define TSL2772_ALS_TIME0X01
#define TSL2772_PRX_TIME0x02
#define TSL2772_WAIT_TIME   0x03
#define TSL2772_ALS_MINTHRESHLO 0X04
#define TSL2772_ALS_MINTHRESHHI 0X05
#define TSL2772_ALS_MAXTHRESHLO 0X06
#define TSL2772_ALS_MAXTHRESHHI 0X07
#define TSL2772_PRX_MINTHRESHLO 0X08
#define TSL2772_PRX_MINTHRESHHI 0X09
#define TSL2772_PRX_MAXTHRESHLO 0X0A
#define TSL2772_PRX_MAXTHRESHHI 0X0B
#define TSL2772_PERSISTENCE 0x0C
#define TSL2772_ALS_PRX_CONFIG  0x0D
#define TSL2772_PRX_COUNT   0x0E
#define TSL2772_GAIN0x0F
#define TSL2772_NOTUSED 0x10
#define TSL2772_REVID   0x11
#define TSL2772_CHIPID  0x12
#define TSL2772_STATUS  0x13
#define TSL2772_ALS_CHAN0LO 0x14
#define TSL2772_ALS_CHAN0HI 0x15
#define TSL2772_ALS_CHAN1LO 0x16
#define TSL2772_ALS_CHAN1HI 0x17
#define TSL2772_PRX_LO  0x18
#define TSL2772_PRX_HI  0x19

/* tsl2772 cmd reg masks */
#define TSL2772_CMD_REG 0x80
#define TSL2772_CMD_SPL_FN  0x60
#define TSL2772_CMD_REPEAT_PROTO0x00
#define TSL2772_CMD_AUTOINC_PROTO   0x20

#define TSL2772_CMD_PROX_INT_CLR0X05
#define TSL2772_CMD_ALS_INT_CLR 0x06
#define TSL2772_CMD_PROXALS_INT_CLR 0X07

/* tsl2772 cntrl reg masks */
#define TSL2772_CNTL_ADC_ENBL   0x02
#define TSL2772_CNTL_PWR_ON 0x01

/* tsl2772 status reg masks */
#define TSL2772_STA_ADC_VALID   0x01
#define TSL2772_STA_PRX_VALID   0x02
#define TSL2772_STA_ADC_PRX_VALID   (TSL2772_STA_ADC_VALID | \
 TSL2772_STA_PRX_VALID)
#define TSL2772_STA_ALS_INTR0x10
#define TSL2772_STA_PRX_INTR0x20

/* tsl2772 cntrl reg masks */
#define TSL2772_CNTL_REG_CLEAR  0x00
#define TSL2772_CNTL_PROX_INT_ENBL  0X20
#define TSL2772_CNTL_ALS_INT_ENBL   0X10
#define TSL2772_CNTL_WAIT_TMR_ENBL  0X08
#define TSL2772_CNTL_PROX_DET_ENBL  0X04
#define TSL2772_CNTL_PWRON  0x01
#define TSL2772_CNTL_ALSPON_ENBL0x03
#define TSL2772_CNTL_INTALSPON_ENBL 0x13
#define TSL2772_CNTL_PROXPON_ENBL   0x0F
#define TSL2772_CNTL_INTPROXPON_ENBL0x2F

/* TAOS Device family members */
enum {
tsl2571,
tsl2671,
tmd2671,
tsl2771,
tmd2771,
tsl2572,
tsl2672,
tmd2672,
tsl2772,
tmd2772
};

enum {
TSL2772_CHIP_UNKNOWN = 0,
TSL2772_CHIP_WORKING = 1,
TSL2772_CHIP_SUSPENDED = 2
};

/* Per-device data */
struct tsl2772_als_info {
u16 als_ch0;
u16 als_ch1;
u16 lux;
};

struct tsl2772_chip_info {
int chan_table_elements;
struct iio_chan_spec channel_with_events[4];
struct iio_chan_spec channel_without_events[4];
const struct iio_info *info;
};

struct tsl2772_chip {
kernel_ulong_t id;
struct mutex prox_mutex;
struct mutex als_mutex;
struct i2c_client *client;
u16 prox_data;
struct tsl2772_als_info als_cur_info;
struct tsl2772_settings settings;
struct tsl2772_platform_data *pdata;
int als_gain_time_scale;
int als_saturation;
int tsl2772_chip_status;
u8 tsl2772_config[TSL2772_MAX_CONFIG_REG];
const struct tsl2772_chip_info  *chip_info;
const struct iio_info *info;
s64 event_timestamp;
  

[PATCH v2 08/11] staging: iio: tsl2x7x: add device ids for code readability

2018-05-03 Thread Brian Masney
This patch adds the device IDs to the device_channel_config array to
improve code readability.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index e3e37501829f..39de5e60fd33 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -273,16 +273,16 @@ enum {
 };
 
 static const u8 device_channel_config[] = {
-   ALS,
-   PRX,
-   PRX,
-   ALSPRX,
-   ALSPRX,
-   ALS,
-   PRX2,
-   PRX2,
-   ALSPRX2,
-   ALSPRX2
+   [tsl2571] = ALS,
+   [tsl2671] = PRX,
+   [tmd2671] = PRX,
+   [tsl2771] = ALSPRX,
+   [tmd2771] = ALSPRX,
+   [tsl2572] = ALS,
+   [tsl2672] = PRX2,
+   [tmd2672] = PRX2,
+   [tsl2772] = ALSPRX2,
+   [tmd2772] = ALSPRX2
 };
 
 static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
-- 
2.14.3

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


[PATCH v2 09/11] staging: iio: tsl2x7x: correct IIO_EV_INFO_PERIOD values

2018-05-03 Thread Brian Masney
The thresh periods assumed an integration time of 3ms. This patch adds
support for the correct integration time (2.72ms or 2.73ms). The code
had the ALS filter values as going up to 15, however the values actually
went up to 60 since the values scaled in increments of 5 once the
persistence value went above 3.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 44 +
 drivers/staging/iio/light/tsl2x7x.h |  1 -
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 39de5e60fd33..f912f4bc61c4 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -103,8 +103,6 @@
 #define TSL2X7X_CNTL_PROXPON_ENBL  0x0F
 #define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F
 
-#define TSL2X7X_MIN_ITIME  3
-
 /* TAOS txx2x7x Device family members */
 enum {
tsl2571,
@@ -972,7 +970,7 @@ static int tsl2x7x_write_event_value(struct iio_dev 
*indio_dev,
 int val, int val2)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   int ret = -EINVAL, y, z, filter_delay;
+   int ret = -EINVAL, count, persistence;
u8 time;
 
switch (info) {
@@ -1011,15 +1009,20 @@ static int tsl2x7x_write_event_value(struct iio_dev 
*indio_dev,
else
time = chip->settings.prox_time;
 
-   y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
-   z = y * TSL2X7X_MIN_ITIME;
+   count = 256 - time;
+   persistence = ((val * 100) + val2) /
+   (count * tsl2x7x_int_time[chip->id].increment_us);
 
-   filter_delay = DIV_ROUND_UP((val * 1000) + val2, z);
+   if (chan->type == IIO_INTENSITY) {
+   /* ALS filter values are 1, 2, 3, 5, 10, 15, ..., 60 */
+   if (persistence > 3)
+   persistence = (persistence / 5) + 3;
+
+   chip->settings.als_persistence = persistence;
+   } else {
+   chip->settings.prox_persistence = persistence;
+   }
 
-   if (chan->type == IIO_INTENSITY)
-   chip->settings.als_persistence = filter_delay;
-   else
-   chip->settings.prox_persistence = filter_delay;
ret = 0;
break;
default:
@@ -1040,7 +1043,7 @@ static int tsl2x7x_read_event_value(struct iio_dev 
*indio_dev,
int *val, int *val2)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   int ret = -EINVAL, filter_delay, mult;
+   int ret = -EINVAL, filter_delay, persistence;
u8 time;
 
switch (info) {
@@ -1076,18 +1079,21 @@ static int tsl2x7x_read_event_value(struct iio_dev 
*indio_dev,
case IIO_EV_INFO_PERIOD:
if (chan->type == IIO_INTENSITY) {
time = chip->settings.als_time;
-   mult = chip->settings.als_persistence;
+   persistence = chip->settings.als_persistence;
+
+   /* ALS filter values are 1, 2, 3, 5, 10, 15, ..., 60 */
+   if (persistence > 3)
+   persistence = (persistence - 3) * 5;
} else {
time = chip->settings.prox_time;
-   mult = chip->settings.prox_persistence;
+   persistence = chip->settings.prox_persistence;
}
 
-   /* Determine integration time */
-   *val = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
-   *val2 = *val * TSL2X7X_MIN_ITIME;
-   filter_delay = *val2 * mult;
-   *val = filter_delay / 1000;
-   *val2 = filter_delay % 1000;
+   filter_delay = persistence * (256 - time) *
+   tsl2x7x_int_time[chip->id].increment_us;
+
+   *val = filter_delay / 100;
+   *val2 = filter_delay % 100;
ret = IIO_VAL_INT_PLUS_MICRO;
break;
default:
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index 1097ee890ce2..f74427f4ab6e 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -31,7 +31,6 @@ struct tsl2x7x_lux {
 #define TSL2X7X_50_mA   0x01
 #define TSL2X7X_25_mA   0x02
 #define TSL2X7X_13_mA   0x03
-#define TSL2X7X_MAX_TIMER_CNT   0xFF
 
 /**
  * struct tsl2x7x_settings - Settings for the tsl2x7x driver
-- 
2.14.3

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


[PATCH v2 06/11] staging: iio: tsl2x7x: correct integration time and lux equation

2018-05-03 Thread Brian Masney
The integration_time sysfs attribute did not report the correct
time. Changing the integration time would cause the reported lux to
change wildly. Once the integration time was corrected, all of the
equations, and lux tables needed to be corrected to match what the
data sheets expected. This patch corrects all of this, and adds some
more comments about how some of the constants were derived. Here are
the results from testing a TSL2772 hooked up to a Raspberry Pi 2:

# cat in_intensity0_integration_time
0.002730
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55
# echo 0.65 > in_intensity0_integration_time
# cat in_intensity0_integration_time
0.649740
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55 with noticeable lag to lux changes in watch
; process.

; Now test the ALS calibration routine.
# cat in_intensity0_calibbias
1000
# cat in_illuminance0_target_input
150
# echo 1 > in_illuminance0_calibrate
# cat in_intensity0_calibbias
2777
# watch -n .1 cat in_illuminance0_input
; Lux now hovers around 150-155

The returned lux values were tested on a TSL2772 in various lighting
conditions and the results are within the lux ranges described at
https://en.wikipedia.org/wiki/Lux.

The driver was primarily tested using a TSL2772, however some quick tests
were also ran against the devices TSL2771, TSL2572, and TMD2772.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 174 
 drivers/staging/iio/light/tsl2x7x.h |   3 +-
 2 files changed, 79 insertions(+), 98 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index cf582a2e3633..9b32054713fb 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -148,7 +148,7 @@ struct tsl2X7X_chip {
struct tsl2x7x_als_info als_cur_info;
struct tsl2x7x_settings settings;
struct tsl2X7X_platform_data *pdata;
-   int als_time_scale;
+   int als_gain_time_scale;
int als_saturation;
int tsl2x7x_chip_status;
u8 tsl2x7x_config[TSL2X7X_MAX_CONFIG_REG];
@@ -163,29 +163,36 @@ struct tsl2X7X_chip {
struct tsl2x7x_lux tsl2x7x_device_lux[TSL2X7X_MAX_LUX_TABLE_SIZE];
 };
 
-/* Different devices require different coefficents */
+/*
+ * Different devices require different coefficents, and these numbers were
+ * derived from the 'Lux Equation' section of the various device datasheets.
+ * All of these coefficients assume a Glass Attenuation (GA) factor of 1.
+ * The coefficients are multiplied by 1000 to avoid floating point operations.
+ * The two rows in each table correspond to the Lux1 and Lux2 equations from
+ * the datasheets.
+ */
 static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
-   { 14461,   611,   1211 },
-   { 18540,   352,623 },
-   { 0, 0,  0 },
+   { 53000, 106000 },
+   { 31800,  53000 },
+   { 0,  0 },
 };
 
 static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
-   { 11635,   115,256 },
-   { 15536,87,179 },
-   { 0, 0,  0 },
+   { 24000,  48000 },
+   { 14400,  24000 },
+   { 0,  0 },
 };
 
 static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
-   { 14013,   466,   917 },
-   { 18222,   310,   552 },
-   { 0, 0, 0 },
+   { 6, 112200 },
+   { 37800,  6 },
+   { 0,  0 },
 };
 
 static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = {
-   { 13218,   130,   262 },
-   { 17592,   92,169 },
-   { 0, 0, 0 },
+   { 2,  35000 },
+   { 12600,  2 },
+   { 0,  0 },
 };
 
 static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
@@ -343,22 +350,18 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip 
*chip, int lower_reg,
  * @indio_dev: pointer to IIO device
  *
  * The raw ch0 and ch1 values of the ambient light sensed in the last
- * integration cycle are read from the device. Time scale factor array values
- * are adjusted based on the integration time. The raw values are multiplied
- * by a scale factor, and device gain is obtained using gain index. Limit
- * checks are done next, then the ratio of a multiple of ch1 value, to the
- * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
- * find the first ratio value that is just above the ratio we just calculated.
- * The ch0 and ch1 multiplier constants in the array are then used along with
- * the time scale factor array values, to calculate the lux.
+ * integration cycle are read from the device. The raw values are multiplied
+ * by a device-specific scale factor, and divided by the integration time and
+ * device gain. The code supports multiple lux equations through the lux table
+ * coefficients. A lux gain trim is applied 

[PATCH v2 10/11] staging: iio: tsl2x7x: rename driver to tsl2772

2018-05-03 Thread Brian Masney
This patch renames this driver from tsl2x7x to tsl2772 since it is
highly likely that additional devices will be added to this driver that
do not match that wildcard. The tsl2772 driver name was selected since
that is currently the device with the most features that are supported
by this driver.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/Kconfig  |   2 +-
 drivers/staging/iio/light/Makefile |   2 +-
 drivers/staging/iio/light/{tsl2x7x.c => tsl2772.c} | 691 +++--
 drivers/staging/iio/light/{tsl2x7x.h => tsl2772.h} |  48 +-
 4 files changed, 372 insertions(+), 371 deletions(-)
 rename drivers/staging/iio/light/{tsl2x7x.c => tsl2772.c} (66%)
 rename drivers/staging/iio/light/{tsl2x7x.h => tsl2772.h} (71%)

diff --git a/drivers/staging/iio/light/Kconfig 
b/drivers/staging/iio/light/Kconfig
index aacb0ae58c0e..dfa37386ad2c 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -3,7 +3,7 @@
 #
 menu "Light sensors"
 
-config TSL2x7x
+config TSL2772
tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and 
proximity sensors"
depends on I2C
help
diff --git a/drivers/staging/iio/light/Makefile 
b/drivers/staging/iio/light/Makefile
index ab8dc3a3d10b..e7e77a11f02a 100644
--- a/drivers/staging/iio/light/Makefile
+++ b/drivers/staging/iio/light/Makefile
@@ -2,4 +2,4 @@
 # Makefile for industrial I/O Light sensors
 #
 
-obj-$(CONFIG_TSL2x7x)  += tsl2x7x.o
+obj-$(CONFIG_TSL2772)  += tsl2772.o
diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2772.c
similarity index 66%
rename from drivers/staging/iio/light/tsl2x7x.c
rename to drivers/staging/iio/light/tsl2772.c
index f912f4bc61c4..146527e41969 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2772.c
@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Device driver for monitoring ambient light intensity in (lux) and proximity
- * detection (prox) within the TAOS TSL2X7X family of devices.
+ * detection (prox) for the TAOS TSL2571, TSL2671, TMD2671, TSL2771, TMD2771,
+ * TSL2572, TSL2672, TMD2672, TSL2772, and TMD2772 devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney 
@@ -18,92 +19,92 @@
 #include 
 #include 
 #include 
-#include "tsl2x7x.h"
+#include "tsl2772.h"
 
 /* Cal defs */
 #define PROX_STAT_CAL  0
 #define PROX_STAT_SAMP 1
 #define MAX_SAMPLES_CAL200
 
-/* TSL2X7X Device ID */
+/* TSL2772 Device ID */
 #define TRITON_ID  0x00
 #define SWORDFISH_ID   0x30
 #define HALIBUT_ID 0x20
 
 /* Lux calculation constants */
-#define TSL2X7X_LUX_CALC_OVER_FLOW 65535
+#define TSL2772_LUX_CALC_OVER_FLOW 65535
 
 /*
  * TAOS Register definitions - Note: depending on device, some of these 
register
  * are not used and the register address is benign.
  */
 
-/* 2X7X register offsets */
-#define TSL2X7X_MAX_CONFIG_REG 16
+/* Register offsets */
+#define TSL2772_MAX_CONFIG_REG 16
 
 /* Device Registers and Masks */
-#define TSL2X7X_CNTRL  0x00
-#define TSL2X7X_ALS_TIME   0X01
-#define TSL2X7X_PRX_TIME   0x02
-#define TSL2X7X_WAIT_TIME  0x03
-#define TSL2X7X_ALS_MINTHRESHLO0X04
-#define TSL2X7X_ALS_MINTHRESHHI0X05
-#define TSL2X7X_ALS_MAXTHRESHLO0X06
-#define TSL2X7X_ALS_MAXTHRESHHI0X07
-#define TSL2X7X_PRX_MINTHRESHLO0X08
-#define TSL2X7X_PRX_MINTHRESHHI0X09
-#define TSL2X7X_PRX_MAXTHRESHLO0X0A
-#define TSL2X7X_PRX_MAXTHRESHHI0X0B
-#define TSL2X7X_PERSISTENCE0x0C
-#define TSL2X7X_ALS_PRX_CONFIG 0x0D
-#define TSL2X7X_PRX_COUNT  0x0E
-#define TSL2X7X_GAIN   0x0F
-#define TSL2X7X_NOTUSED0x10
-#define TSL2X7X_REVID  0x11
-#define TSL2X7X_CHIPID 0x12
-#define TSL2X7X_STATUS 0x13
-#define TSL2X7X_ALS_CHAN0LO0x14
-#define TSL2X7X_ALS_CHAN0HI0x15
-#define TSL2X7X_ALS_CHAN1LO0x16
-#define TSL2X7X_ALS_CHAN1HI0x17
-#define TSL2X7X_PRX_LO 0x18
-#define TSL2X7X_PRX_HI 0x19
-
-/* tsl2X7X cmd reg masks */
-#define TSL2X7X_CMD_REG0x80
-#define TSL2X7X_CMD_SPL_FN 0x60
-#define TSL2X7X_CMD_REPEAT_PROTO   0x00
-#define TSL2X7X_CMD_AUTOINC_PROTO  0x20
-
-#define TSL2X7X_CMD_PROX_INT_CLR   0X05
-#define TSL2X7X_CMD_ALS_INT_CLR0x06
-#define TSL2X7X_CMD_PROXALS_INT_CLR0X07
-
-/* tsl2X7X cntrl reg masks */
-#define TSL2X7X_CNTL_ADC_ENBL  0x02
-#define TSL2X7X_CNTL_PWR_ON0x01
-
-/* tsl2X7X status reg masks */
-#define 

[PATCH v2 11/11] staging: iio: tsl2x7x/tsl2772: move out of staging

2018-05-03 Thread Brian Masney
Move the tsl2772 driver out of staging and into mainline.

Signed-off-by: Brian Masney 
---
 drivers/iio/light/Kconfig  |  8 
 drivers/iio/light/Makefile |  1 +
 drivers/{staging => }/iio/light/tsl2772.c  |  2 +-
 drivers/staging/iio/Kconfig|  1 -
 drivers/staging/iio/Makefile   |  1 -
 drivers/staging/iio/light/Kconfig  | 14 --
 drivers/staging/iio/light/Makefile |  5 -
 .../iio/light => include/linux/platform_data}/tsl2772.h|  0
 8 files changed, 10 insertions(+), 22 deletions(-)
 rename drivers/{staging => }/iio/light/tsl2772.c (99%)
 delete mode 100644 drivers/staging/iio/light/Kconfig
 delete mode 100644 drivers/staging/iio/light/Makefile
 rename {drivers/staging/iio/light => include/linux/platform_data}/tsl2772.h 
(100%)

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 074e50657366..c7ef8d1862d6 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -409,6 +409,14 @@ config TSL2583
 Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices.
 Access ALS data via iio, sysfs.
 
+config TSL2772
+   tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and 
proximity sensors"
+   depends on I2C
+   help
+Support for: tsl2571, tsl2671, tmd2671, tsl2771, tmd2771, tsl2572, 
tsl2672,
+tmd2672, tsl2772, tmd2772 devices.
+Provides iio_events and direct access via sysfs.
+
 config TSL4531
tristate "TAOS TSL4531 ambient light sensors"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index f1777036d4f8..80943af5d627 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_ST_UVIS25_SPI)   += st_uvis25_spi.o
 obj-$(CONFIG_TCS3414)  += tcs3414.o
 obj-$(CONFIG_TCS3472)  += tcs3472.o
 obj-$(CONFIG_TSL2583)  += tsl2583.o
+obj-$(CONFIG_TSL2772)  += tsl2772.o
 obj-$(CONFIG_TSL4531)  += tsl4531.o
 obj-$(CONFIG_US5182D)  += us5182d.o
 obj-$(CONFIG_VCNL4000) += vcnl4000.o
diff --git a/drivers/staging/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
similarity index 99%
rename from drivers/staging/iio/light/tsl2772.c
rename to drivers/iio/light/tsl2772.c
index 146527e41969..7ed72c98ce1a 100644
--- a/drivers/staging/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@ -19,7 +19,7 @@
 #include 
 #include 
 #include 
-#include "tsl2772.h"
+#include 
 
 /* Cal defs */
 #define PROX_STAT_CAL  0
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index 8abc1ab3c0c7..ca001510782d 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -11,7 +11,6 @@ source "drivers/staging/iio/cdc/Kconfig"
 source "drivers/staging/iio/frequency/Kconfig"
 source "drivers/staging/iio/gyro/Kconfig"
 source "drivers/staging/iio/impedance-analyzer/Kconfig"
-source "drivers/staging/iio/light/Kconfig"
 source "drivers/staging/iio/meter/Kconfig"
 source "drivers/staging/iio/resolver/Kconfig"
 source "drivers/staging/iio/trigger/Kconfig"
diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile
index 455bffc29649..5c168403b873 100644
--- a/drivers/staging/iio/Makefile
+++ b/drivers/staging/iio/Makefile
@@ -10,7 +10,6 @@ obj-y += cdc/
 obj-y += frequency/
 obj-y += gyro/
 obj-y += impedance-analyzer/
-obj-y += light/
 obj-y += meter/
 obj-y += resolver/
 obj-y += trigger/
diff --git a/drivers/staging/iio/light/Kconfig 
b/drivers/staging/iio/light/Kconfig
deleted file mode 100644
index dfa37386ad2c..
--- a/drivers/staging/iio/light/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Light sensors
-#
-menu "Light sensors"
-
-config TSL2772
-   tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and 
proximity sensors"
-   depends on I2C
-   help
-Support for: tsl2571, tsl2671, tmd2671, tsl2771, tmd2771, tsl2572, 
tsl2672,
-tmd2672, tsl2772, tmd2772 devices.
-Provides iio_events and direct access via sysfs.
-
-endmenu
diff --git a/drivers/staging/iio/light/Makefile 
b/drivers/staging/iio/light/Makefile
deleted file mode 100644
index e7e77a11f02a..
--- a/drivers/staging/iio/light/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for industrial I/O Light sensors
-#
-
-obj-$(CONFIG_TSL2772)  += tsl2772.o
diff --git a/drivers/staging/iio/light/tsl2772.h 
b/include/linux/platform_data/tsl2772.h
similarity index 100%
rename from drivers/staging/iio/light/tsl2772.h
rename to include/linux/platform_data/tsl2772.h
-- 
2.14.3

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


[PATCH v2 07/11] staging: iio: tsl2x7x: support 2.72 and 2.73 ALS increments

2018-05-03 Thread Brian Masney
The driver assumed that the ALS increment was 2.72 ms, and the upper
range was 696 ms. Some other supported devices use 2.73 ms - 699 ms.
This patch adds support for the multiple ranges.

Signed-off-by: Brian Masney 
---
I debated whether or not this change should even be included. I feel
pretty confident that I can cleanly fold the tsl2583 driver into this
driver once the staging graduation is done. Those devices have an ALS
range of 2.7 ms - 688.5 ms.

 drivers/staging/iio/light/tsl2x7x.c | 50 +
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 9b32054713fb..e3e37501829f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -209,9 +209,9 @@ static const struct tsl2x7x_lux 
*tsl2x7x_default_lux_table_group[] = {
 };
 
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
-   .als_time = 255, /* 2.73 ms */
+   .als_time = 255, /* 2.72 / 2.73 ms */
.als_gain = 0,
-   .prox_time = 255, /* 2.73 ms */
+   .prox_time = 255, /* 2.72 / 2.73 ms */
.prox_gain = 0,
.wait_time = 255,
.als_prox_config = 0,
@@ -245,6 +245,24 @@ static const s16 tsl2x7x_prox_gain[] = {
8
 };
 
+struct tsl2x7x_int_time {
+   int increment_us;
+   char *display_range;
+};
+
+static const struct tsl2x7x_int_time tsl2x7x_int_time[] = {
+   [tsl2571] = { 2720, "0.00272 - 0.696" },
+   [tsl2671] = { 2720, "0.00272 - 0.696" },
+   [tmd2671] = { 2720, "0.00272 - 0.696" },
+   [tsl2771] = { 2720, "0.00272 - 0.696" },
+   [tmd2771] = { 2720, "0.00272 - 0.696" },
+   [tsl2572] = { 2730, "0.00273 - 0.699" },
+   [tsl2672] = { 2730, "0.00273 - 0.699" },
+   [tmd2672] = { 2730, "0.00273 - 0.699" },
+   [tsl2772] = { 2730, "0.00273 - 0.699" },
+   [tmd2772] = { 2730, "0.00273 - 0.699" },
+};
+
 /* Channel variations */
 enum {
ALS,
@@ -626,7 +644,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
 
/* set chip time scaling and saturation */
als_count = 256 - chip->settings.als_time;
-   als_time_us = als_count * 2720;
+   als_time_us = als_count * tsl2x7x_int_time[chip->id].increment_us;
chip->als_saturation = als_count * 768; /* 75% of full scale */
chip->als_gain_time_scale = als_time_us *
tsl2x7x_als_gain[chip->settings.als_gain];
@@ -764,8 +782,16 @@ static IIO_CONST_ATTR(in_intensity0_calibscale_available, 
"1 8 16 120");
 
 static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
-static IIO_CONST_ATTR(in_intensity0_integration_time_available,
-   ".00272 - .696");
+static ssize_t
+in_intensity0_integration_time_available_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+
+   return snprintf(buf, PAGE_SIZE, "%s\n",
+   tsl2x7x_int_time[chip->id].display_range);
+}
 
 static ssize_t in_illuminance0_target_input_show(struct device *dev,
 struct device_attribute *attr,
@@ -1124,7 +1150,8 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
break;
case IIO_CHAN_INFO_INT_TIME:
*val = 0;
-   *val2 = (256 - chip->settings.als_time) * 2720;
+   *val2 = (256 - chip->settings.als_time) *
+   tsl2x7x_int_time[chip->id].increment_us;
ret = IIO_VAL_INT_PLUS_MICRO;
break;
default:
@@ -1184,7 +1211,8 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
chip->settings.als_gain_trim = val;
break;
case IIO_CHAN_INFO_INT_TIME:
-   chip->settings.als_time = 256 - (val2 / 2720);
+   chip->settings.als_time = 256 -
+   (val2 / tsl2x7x_int_time[chip->id].increment_us);
break;
default:
return -EINVAL;
@@ -1193,6 +1221,8 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
return tsl2x7x_invoke_change(indio_dev);
 }
 
+static DEVICE_ATTR_RO(in_intensity0_integration_time_available);
+
 static DEVICE_ATTR_RW(in_illuminance0_target_input);
 
 static DEVICE_ATTR_WO(in_illuminance0_calibrate);
@@ -1266,7 +1296,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
_const_attr_in_intensity0_calibscale_available.dev_attr.attr,
-   _const_attr_in_intensity0_integration_time_available.dev_attr.attr,
+   _attr_in_intensity0_integration_time_available.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,

[PATCH v2 04/11] staging: iio: tsl2x7x: move calibscale_available attribute to IIO_INTENSITY channel

2018-05-03 Thread Brian Masney
The calibscale_available attribute is currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. This patch corrects that association and it also corrects
lines that were unnecessarily split for the
in_intensity0_integration_time sysfs attribute.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 7e8db5178a2c..9aee04fb4168 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -777,9 +777,9 @@ static int tsl2x7x_prox_cal(struct iio_dev *indio_dev)
 }
 
 static ssize_t
-in_illuminance0_calibscale_available_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+in_intensity0_calibscale_available_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
 {
struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 
@@ -1247,7 +1247,7 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
return tsl2x7x_invoke_change(indio_dev);
 }
 
-static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
+static DEVICE_ATTR_RO(in_intensity0_calibscale_available);
 
 static DEVICE_ATTR_RW(in_illuminance0_target_input);
 
@@ -1321,9 +1321,8 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 }
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
-   _attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_intensity0_integration_time_available
-   .dev_attr.attr,
+   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
_attr_in_illuminance0_lux_table.attr,
@@ -1336,9 +1335,8 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 };
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
-   _attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_intensity0_integration_time_available
-   .dev_attr.attr,
+   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
_attr_in_illuminance0_lux_table.attr,
@@ -1352,9 +1350,8 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 };
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
-   _attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_intensity0_integration_time_available
-   .dev_attr.attr,
+   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
_attr_in_illuminance0_lux_table.attr,
-- 
2.14.3

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


[PATCH v2 02/11] staging: iio: tsl2x7x: add range checking to three sysfs attributes

2018-05-03 Thread Brian Masney
The sysfs attributes in_illuminance0_target_input,
in_illuminance0_calibrate, and in_proximity0_calibrate did not have
proper range checking in place so this patch adds the correct range
checks.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 01bff4593640..b4d77f65ca12 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -814,15 +814,13 @@ static ssize_t in_illuminance0_target_input_store(struct 
device *dev,
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   unsigned long value;
+   u16 value;
int ret;
 
-   if (kstrtoul(buf, 0, ))
+   if (kstrtou16(buf, 0, ))
return -EINVAL;
 
-   if (value)
-   chip->settings.als_cal_target = value;
-
+   chip->settings.als_cal_target = value;
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
return ret;
@@ -838,14 +836,12 @@ static ssize_t in_illuminance0_calibrate_store(struct 
device *dev,
bool value;
int ret;
 
-   if (strtobool(buf, ))
+   if (kstrtobool(buf, ) || !value)
return -EINVAL;
 
-   if (value) {
-   ret = tsl2x7x_als_calibrate(indio_dev);
-   if (ret < 0)
-   return ret;
-   }
+   ret = tsl2x7x_als_calibrate(indio_dev);
+   if (ret < 0)
+   return ret;
 
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
@@ -932,14 +928,12 @@ static ssize_t in_proximity0_calibrate_store(struct 
device *dev,
bool value;
int ret;
 
-   if (strtobool(buf, ))
+   if (kstrtobool(buf, ) || !value)
return -EINVAL;
 
-   if (value) {
-   ret = tsl2x7x_prox_cal(indio_dev);
-   if (ret < 0)
-   return ret;
-   }
+   ret = tsl2x7x_prox_cal(indio_dev);
+   if (ret < 0)
+   return ret;
 
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
-- 
2.14.3

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


[PATCH v2 00/11] staging: iio: tsl2x7x: move out of staging

2018-05-03 Thread Brian Masney
Here is a patch set that should hopefully be the last of the changes
required for a staging graduation. Changes since v1:

- Use correct syntax for SPDX license identifier
- Use kstrtou16 for range checking
- Correct integration time sysfs attribute. This fix required correcting
  all of the equations and coefficients. Fortunately TAOS / AMS has
  really good documentation available.
- Rename driver from tsl2x7x to tsl2772.

Datasheet for TSL2772
https://ams.com/eng/content/download/291503/1066377/file/TSL2772_DS000181_2-00.pdf

Other datasheets:

ALS only
- 
https://ams.com/eng/content/download/250043/975277/file/TSL2571_DS000114_2-00.pdf
- 
https://ams.com/eng/content/download/291224/1065822/file/TSL2572_DS000178_2-00.pdf

Proximity Only
- 
https://ams.com/eng/content/download/250323/976177/file/TSL2671_DS000111_2-00.pdf
- 
https://ams.com/eng/content/download/250304/976107/file/TMD2671_DS000176_2-00.pdf
- 
https://ams.com/eng/content/download/291443/1066277/file/TSL2672_Datasheet_EN_v1.pdf
- 
https://ams.com/eng/content/download/364923/1210537/file/TMD2672_Datasheet_EN_v1.pdf

ALS / Proximity
- 
https://ams.com/eng/content/download/250264/976045/file/TSL2771_DS000105_3-00.pdf
- 
https://ams.com/eng/content/download/250283/976077/file/TMD2771_DS000177_2-00.pdf
- https://ams.com/eng/content/download/365023/1210677/file/TMD2772-E.pdf

Brian Masney (11):
  staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  staging: iio: tsl2x7x: add range checking to three sysfs attributes
  staging: iio: tsl2x7x: don't setup event handlers if interrupts are
not configured
  staging: iio: tsl2x7x: move calibscale_available attribute to
IIO_INTENSITY channel
  staging: iio: tsl2x7x: use IIO_CONST_ATTR for calibscale_available
  staging: iio: tsl2x7x: correct integration time and lux equation
  staging: iio: tsl2x7x: support 2.72 and 2.73 ALS increments
  staging: iio: tsl2x7x: add device ids for code readability
  staging: iio: tsl2x7x: correct IIO_EV_INFO_PERIOD values
  staging: iio: tsl2x7x: rename driver to tsl2772
  staging: iio: tsl2x7x/tsl2772: move out of staging

 drivers/iio/light/Kconfig  |8 +
 drivers/iio/light/Makefile |1 +
 .../iio/light/tsl2x7x.c => iio/light/tsl2772.c}| 1137 ++--
 drivers/staging/iio/Kconfig|1 -
 drivers/staging/iio/Makefile   |1 -
 drivers/staging/iio/light/Kconfig  |   14 -
 drivers/staging/iio/light/Makefile |5 -
 .../linux/platform_data/tsl2772.h  |   65 +-
 8 files changed, 631 insertions(+), 601 deletions(-)
 rename drivers/{staging/iio/light/tsl2x7x.c => iio/light/tsl2772.c} (50%)
 delete mode 100644 drivers/staging/iio/light/Kconfig
 delete mode 100644 drivers/staging/iio/light/Makefile
 rename drivers/staging/iio/light/tsl2x7x.h => 
include/linux/platform_data/tsl2772.h (58%)

-- 
2.14.3

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


[PATCH v2 05/11] staging: iio: tsl2x7x: use IIO_CONST_ATTR for calibscale_available

2018-05-03 Thread Brian Masney
The in_intensity0_calibscale_available sysfs attribute has code that
checks the device type to determine which calibration scales are
available. This check is not necessary since all of the supported
ALS device types use the scales 1 8 16 120. This patch converts the
sysfs attribute to use IIO_CONST_ATTR. The following device datasheets
were checked: tsl2571, tsl2771, tmd2771, tsl2572, tsl2772, tmd2772.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 46 -
 1 file changed, 4 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 9aee04fb4168..cf582a2e3633 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -776,24 +776,7 @@ static int tsl2x7x_prox_cal(struct iio_dev *indio_dev)
return tsl2x7x_invoke_change(indio_dev);
 }
 
-static ssize_t
-in_intensity0_calibscale_available_show(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
-{
-   struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-
-   switch (chip->id) {
-   case tsl2571:
-   case tsl2671:
-   case tmd2671:
-   case tsl2771:
-   case tmd2771:
-   return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 128");
-   }
-
-   return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
-}
+static IIO_CONST_ATTR(in_intensity0_calibscale_available, "1 8 16 120");
 
 static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
@@ -1190,25 +1173,6 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
chip->settings.als_gain = 2;
break;
case 120:
-   switch (chip->id) {
-   case tsl2572:
-   case tsl2672:
-   case tmd2672:
-   case tsl2772:
-   case tmd2772:
-   return -EINVAL;
-   }
-   chip->settings.als_gain = 3;
-   break;
-   case 128:
-   switch (chip->id) {
-   case tsl2571:
-   case tsl2671:
-   case tmd2671:
-   case tsl2771:
-   case tmd2771:
-   return -EINVAL;
-   }
chip->settings.als_gain = 3;
break;
default:
@@ -1247,8 +1211,6 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
return tsl2x7x_invoke_change(indio_dev);
 }
 
-static DEVICE_ATTR_RO(in_intensity0_calibscale_available);
-
 static DEVICE_ATTR_RW(in_illuminance0_target_input);
 
 static DEVICE_ATTR_WO(in_illuminance0_calibrate);
@@ -1321,7 +1283,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 }
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
-   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_calibscale_available.dev_attr.attr,
_const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1335,7 +1297,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 };
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
-   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_calibscale_available.dev_attr.attr,
_const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1350,7 +1312,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 };
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
-   _attr_in_intensity0_calibscale_available.attr,
+   _const_attr_in_intensity0_calibscale_available.dev_attr.attr,
_const_attr_in_intensity0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
-- 
2.14.3

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


[PATCH v2 03/11] staging: iio: tsl2x7x: don't setup event handlers if interrupts are not configured

2018-05-03 Thread Brian Masney
The driver would expose to userspace the events directory even if the
interrupts were not configured. This patch changes the driver so that
the events directory is not exposed to user space if interrupts are
not configured. This patch also corrects the indentation of the
chan_table_elements and info structure members.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 130 +++-
 1 file changed, 112 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index b4d77f65ca12..7e8db5178a2c 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -134,8 +134,9 @@ struct tsl2x7x_als_info {
 
 struct tsl2x7x_chip_info {
int chan_table_elements;
-   struct iio_chan_specchannel[4];
-   const struct iio_info   *info;
+   struct iio_chan_spec channel_with_events[4];
+   struct iio_chan_spec channel_without_events[4];
+   const struct iio_info *info;
 };
 
 struct tsl2X7X_chip {
@@ -1447,7 +1448,7 @@ static const struct iio_event_spec tsl2x7x_events[] = {
 
 static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
[ALS] = {
-   .channel = {
+   .channel_with_events = {
{
.type = IIO_LIGHT,
.indexed = 1,
@@ -1469,11 +1470,31 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.channel = 1,
},
},
-   .chan_table_elements = 3,
-   .info = _device_info[ALS],
+   .channel_without_events = {
+   {
+   .type = IIO_LIGHT,
+   .indexed = 1,
+   .channel = 0,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+   }, {
+   .type = IIO_INTENSITY,
+   .indexed = 1,
+   .channel = 0,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+   BIT(IIO_CHAN_INFO_INT_TIME) |
+   BIT(IIO_CHAN_INFO_CALIBSCALE) |
+   BIT(IIO_CHAN_INFO_CALIBBIAS),
+   }, {
+   .type = IIO_INTENSITY,
+   .indexed = 1,
+   .channel = 1,
+   },
+   },
+   .chan_table_elements = 3,
+   .info = _device_info[ALS],
},
[PRX] = {
-   .channel = {
+   .channel_with_events = {
{
.type = IIO_PROXIMITY,
.indexed = 1,
@@ -1483,11 +1504,19 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
},
},
-   .chan_table_elements = 1,
-   .info = _device_info[PRX],
+   .channel_without_events = {
+   {
+   .type = IIO_PROXIMITY,
+   .indexed = 1,
+   .channel = 0,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   },
+   },
+   .chan_table_elements = 1,
+   .info = _device_info[PRX],
},
[ALSPRX] = {
-   .channel = {
+   .channel_with_events = {
{
.type = IIO_LIGHT,
.indexed = 1,
@@ -1517,11 +1546,37 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
},
},
-   .chan_table_elements = 4,
-   .info = _device_info[ALSPRX],
+   .channel_without_events = {
+   {
+   .type = IIO_LIGHT,
+   .indexed = 1,
+   .channel = 0,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+   }, {
+   .type = IIO_INTENSITY,
+   .indexed = 1,
+   .channel = 0,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+   BIT(IIO_CHAN_INFO_INT_TIME) |
+   BIT(IIO_CHAN_INFO_CALIBSCALE) |
+   BIT(IIO_CHAN_INFO_CALIBBIAS),
+   }, {
+   .type = IIO_INTENSITY,
+   .indexed = 1,
+   .channel = 1,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   }, {
+   .type = IIO_PROXIMITY,
+

[PATCH v2 01/11] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier

2018-05-03 Thread Brian Masney
The summary text for the GPL is not needed since the SPDX identifier
is a legally binding shorthand that can be used instead.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 11 +--
 drivers/staging/iio/light/tsl2x7x.h | 15 +--
 2 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index e65621948cf8..01bff4593640 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1,19 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Device driver for monitoring ambient light intensity in (lux) and proximity
  * detection (prox) within the TAOS TSL2X7X family of devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
  */
 
 #include 
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index 91ce8f98982e..8eb7f4749ea7 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -1,22 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Device driver for monitoring ambient light intensity (lux)
  * and proximity (prox) within the TAOS TSL2X7X family of devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifndef __TSL2X7X_H
-- 
2.14.3

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


Re: [PATCH 4/4] staging: lustre: obdclass: change object lookup to no wait mode

2018-05-03 Thread NeilBrown
On Wed, May 02 2018, James Simmons wrote:

> From: Lai Siyao 
>
> Currently we set LU_OBJECT_HEARD_BANSHEE on object when we want
> to remove object from cache, but this may lead to deadlock, because
> when other process lookup such object, it needs to wait for this
> object until release (done at last refcount put), while that process
> maybe already hold an LDLM lock.
>
> Now that current code can handle dying object correctly, we can just
> return such object in lookup, thus the above deadlock can be avoided.

I think one of the reasons that I didn't apply this to mainline myself
is that "Now that" comment.  When is the "now" that it is referring to?
Are were sure that all code in mainline "can handle dying objects
correctly"??


>
> Signed-off-by: Lai Siyao 
> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9049
> Reviewed-on: https://review.whamcloud.com/26965
> Reviewed-by: Alex Zhuravlev 
> Tested-by: Cliff White 
> Reviewed-by: Fan Yong 
> Reviewed-by: Oleg Drokin 
> Signed-off-by: James Simmons 
> ---
>  drivers/staging/lustre/lustre/include/lu_object.h  |  2 +-
>  drivers/staging/lustre/lustre/obdclass/lu_object.c | 82 
> +-
>  2 files changed, 36 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lu_object.h 
> b/drivers/staging/lustre/lustre/include/lu_object.h
> index f29bbca..232063a 100644
> --- a/drivers/staging/lustre/lustre/include/lu_object.h
> +++ b/drivers/staging/lustre/lustre/include/lu_object.h
> @@ -673,7 +673,7 @@ static inline void lu_object_get(struct lu_object *o)
>  }
>  
>  /**
> - * Return true of object will not be cached after last reference to it is
> + * Return true if object will not be cached after last reference to it is
>   * released.
>   */
>  static inline int lu_object_is_dying(const struct lu_object_header *h)
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c 
> b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 8b507f1..9311703 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -589,19 +589,13 @@ static struct lu_object *htable_lookup(struct lu_site 
> *s,
>  const struct lu_fid *f,
>  __u64 *version)
>  {
> - struct cfs_hash *hs = s->ls_obj_hash;
>   struct lu_site_bkt_data *bkt;
>   struct lu_object_header *h;
>   struct hlist_node   *hnode;
> - __u64 ver;
> - wait_queue_entry_t waiter;
> + u64 ver = cfs_hash_bd_version_get(bd);
>  
> -retry:
> - ver = cfs_hash_bd_version_get(bd);
> -
> - if (*version == ver) {
> + if (*version == ver)
>   return ERR_PTR(-ENOENT);
> - }
>  
>   *version = ver;
>   bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd);
> @@ -615,31 +609,13 @@ static struct lu_object *htable_lookup(struct lu_site 
> *s,
>   }
>  
>   h = container_of(hnode, struct lu_object_header, loh_hash);
> - if (likely(!lu_object_is_dying(h))) {
> - cfs_hash_get(s->ls_obj_hash, hnode);
> - lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
> - if (!list_empty(>loh_lru)) {
> - list_del_init(>loh_lru);
> - percpu_counter_dec(>ls_lru_len_counter);
> - }
> - return lu_object_top(h);
> + cfs_hash_get(s->ls_obj_hash, hnode);
> + lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
> + if (!list_empty(>loh_lru)) {
> + list_del_init(>loh_lru);
> + percpu_counter_dec(>ls_lru_len_counter);
>   }
> -
> - /*
> -  * Lookup found an object being destroyed this object cannot be
> -  * returned (to assure that references to dying objects are eventually
> -  * drained), and moreover, lookup has to wait until object is freed.
> -  */
> -
> - init_waitqueue_entry(, current);
> - add_wait_queue(>lsb_marche_funebre, );
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_DEATH_RACE);
> - cfs_hash_bd_unlock(hs, bd, 1);
> - schedule();
> - remove_wait_queue(>lsb_marche_funebre, );
> - cfs_hash_bd_lock(hs, bd, 1);
> - goto retry;
> + return lu_object_top(h);
>  }
>  
>  /**
> @@ -680,6 +656,8 @@ static void lu_object_limit(const struct lu_env *env, 
> struct lu_device *dev)
>  }
>  
>  /**
> + * Core logic of lu_object_find*() functions.
> + *
>   * Much like lu_object_find(), but top level device of object is specifically
>   * \a dev rather than top level device of the site. This interface allows
>   * objects of different "stacking" to be created within the same site.
> @@ -713,36 +691,46 @@ struct lu_object *lu_object_find_at(const struct lu_env 
> *env,
>* It 

Re: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock

2018-05-03 Thread NeilBrown
On Fri, May 04 2018, Dilger, Andreas wrote:

> On May 3, 2018, at 07:50, David Laight  wrote:
>> 
>> From: James Simmons
>>> Sent: 02 May 2018 19:22
>>> From: Li Xi 
>>> 
>>> Most of the time, keys are never changed. So rwlock might be
>>> better for the concurrency of key read.
>> 
>> OTOH unless there is contention on the spin lock during reads the
>> additional cost of a rwlock (probably double that of a spinlock)
>> will hurt performance.
>> 
>> ...
>>> -   spin_lock(_keys_guard);
>>> +   read_lock(_keys_guard);
>>> atomic_inc(_key_initing_cnt);
>>> -   spin_unlock(_keys_guard);
>>> +   read_unlock(_keys_guard);
>> 
>> WTF, seems unlikely that you need to hold any kind of lock
>> over an atomic_inc().
>> 
>> If this is just ensuring that no code holds the lock then
>> it would need to request the write_lock().
>> (and would need a comment)
>
> There was a fair amount of benchmarking done for this that shows the
> performance is significantly improved with the patch, which can be
> seen in the ticket that was referenced in the original commit comment:
>
> https://jira.hpdd.intel.com/browse/LU-6800?focusedCommentId=121776#comment-121776

That does surprise me.  The only places where the lock is held for read
are very short - clearing a few fields or incrementing a value.
But numbers don't lie.
I wonder if the next patch would have had just as big an effect. Taking
and dropping the lock 40 times is not likely to be good for performance.

Thanks,
NeilBrown


>
> That said, it might be good to include this information into the
> commit comment itself.
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation


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


Re: [PATCH v3 2/5] efi: Add embedded peripheral firmware support

2018-05-03 Thread Luis R. Rodriguez
Android folks, poke below. otherwise we'll have no option but to seriously
consider Mimi's patch to prevent these calls when IMA appraisal is enforced:

http://lkml.kernel.org/r/1525182503-13849-7-git-send-email-zo...@linux.vnet.ibm.com

Please read below

On Wed, Apr 25, 2018 at 05:55:57PM +, Luis R. Rodriguez wrote:
> On Wed, Apr 25, 2018 at 01:00:09AM -0400, Mimi Zohar wrote:
> > On Tue, 2018-04-24 at 23:42 +, Luis R. Rodriguez wrote:
> > > On Tue, Apr 24, 2018 at 12:07:01PM -0400, Mimi Zohar wrote:
> > > > On Tue, 2018-04-24 at 17:09 +0200, Hans de Goede wrote:
> > > If its of any help --
> > > 
> > > drivers/soc/qcom/mdt_loader.c is the only driver currently using
> > > request_firmware_into_buf() however I'll note qcom_mdt_load() is used in 
> > > many
> > > other drivers so they are wrappers around request_firmware_into_buf():
> > > 
> > > drivers/gpu/drm/msm/adreno/a5xx_gpu.c:   * adreno_request_fw() handles 
> > > this, but qcom_mdt_load() does
> > > drivers/gpu/drm/msm/adreno/a5xx_gpu.c:  ret = qcom_mdt_load(dev, 
> > > fw, fwname, GPU_PAS_ID,
> > > drivers/gpu/drm/msm/adreno/a5xx_gpu.c:  ret = qcom_mdt_load(dev, 
> > > fw, newname, GPU_PAS_ID,
> > > drivers/media/platform/qcom/venus/firmware.c:   ret = qcom_mdt_load(dev, 
> > > mdt, fwname, VENUS_PAS_ID, mem_va, mem_phys,
> > > drivers/remoteproc/qcom_adsp_pil.c: return qcom_mdt_load(adsp->dev, 
> > > fw, rproc->firmware, adsp->pas_id,
> > > drivers/remoteproc/qcom_wcnss.c:return qcom_mdt_load(wcnss->dev, 
> > > fw, rproc->firmware, WCNSS_PAS_ID,
> > > 
> > > > > As such the current IMA code (from v4.17-rc2) actually does
> > > > > not handle READING_FIRMWARE_PREALLOC_BUFFER at all, 
> > > > 
> > > > Right, it doesn't yet address READING_FIRMWARE_PREALLOC_BUFFER, but
> > > > should.
> > > > 
> > > > Depending on whether the device requesting the firmware has access to
> > > > the DMA memory, before the signature verification, 
> > > 
> > > It would seem from the original patch review about 
> > > READING_FIRMWARE_PREALLOC_BUFFER
> > > that this is not a DMA buffer.

To be very clear I believe Stephen implied this was not DMA buffer. Mimi
asked for READING_FIRMWARE_DMA if it was:

https://patchwork.kernel.org/patch/9074611/

> > The call sequence:
> > qcom_mdt_load() -> qcom_scm_pas_init_image() -> dma_alloc_coherent()
> > 
> > If dma_alloc_coherent() isn't allocating a DMA buffer, then the
> > function name is misleading/confusing.
> 
> Hah, by *definition* the device *and* processor has immediate access
> to data written *immediately* when dma_alloc_coherent() is used. From
> Documentation/DMA-API.txt:
> 
> ---
> Part Ia - Using large DMA-coherent buffers
>   
> --
>   
>   
>   
> ::
>   
>   
>   
> void *
>   
> dma_alloc_coherent(struct device *dev, size_t size,   
>   
>dma_addr_t *dma_handle, gfp_t flag)
>   
>   
>   
> Consistent memory is memory for which a write by either the device or 
>   
> the processor can immediately be read by the processor or device  
>   
> without having to worry about caching effects.  (You may however need 
>   
> to make sure to flush the processor's write buffers before telling
>   
> devices to read that memory.)  
> 
> 
> Is ptr below
> 
>   ret = request_firmware_into_buf(_fw, fw_name, dev,  
>   ptr, phdr->p_filesz); 
> 
> Also part of the DMA buffer allocated earlier via:
> 
> ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size);
>   
> 
> Android folks?

Android folks?

> > > The device driver should have access to the buffer pointer with write 
> > > given
> > > that with request_firmware_into_buf() the driver is giving full write 
> > > access to
> > > the memory pointer so that the firmware API can stuff the firmware it 
> > > finds
> > > there.
> > > 
> > > Firmware signature verification would be up to the device hardware to do 
> > > upon
> > > load *after* request_firmware_into_buf().
> > 
> > We're discussing the kernel's signature verification, not the device
> > hardware's signature verification.  Can the device driver access the
> > buffer, before IMA-appraisal has verified the firmware's signature?
> 
> It will depend on the above question.

  Luis

Re: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock

2018-05-03 Thread Dilger, Andreas
On May 3, 2018, at 07:50, David Laight  wrote:
> 
> From: James Simmons
>> Sent: 02 May 2018 19:22
>> From: Li Xi 
>> 
>> Most of the time, keys are never changed. So rwlock might be
>> better for the concurrency of key read.
> 
> OTOH unless there is contention on the spin lock during reads the
> additional cost of a rwlock (probably double that of a spinlock)
> will hurt performance.
> 
> ...
>> -spin_lock(_keys_guard);
>> +read_lock(_keys_guard);
>>  atomic_inc(_key_initing_cnt);
>> -spin_unlock(_keys_guard);
>> +read_unlock(_keys_guard);
> 
> WTF, seems unlikely that you need to hold any kind of lock
> over an atomic_inc().
> 
> If this is just ensuring that no code holds the lock then
> it would need to request the write_lock().
> (and would need a comment)

There was a fair amount of benchmarking done for this that shows the
performance is significantly improved with the patch, which can be
seen in the ticket that was referenced in the original commit comment:

https://jira.hpdd.intel.com/browse/LU-6800?focusedCommentId=121776#comment-121776

That said, it might be good to include this information into the
commit comment itself.

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation







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


RE: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock

2018-05-03 Thread NeilBrown
On Thu, May 03 2018, David Laight wrote:

> From: James Simmons
>> Sent: 02 May 2018 19:22
>> From: Li Xi 
>> 
>> Most of the time, keys are never changed. So rwlock might be
>> better for the concurrency of key read.
>
> OTOH unless there is contention on the spin lock during reads the
> additional cost of a rwlock (probably double that of a spinlock)
> will hurt performance.

That's roughly what I was going to say - rwlocks are rarely a win.
I think the second patch which caused the lock to be taken less often
would have a bigger impact that the switch to rwlocks.

However I suspect a better approach would be to investigate some sort of
lockless solution.
I think the use of the spinlock in lu_context_key_register() could be
replaced with a careful cmp_xchg().  I'm less sure about
lu_context_key_degister(), but it might be possible.

>
> ...
>> -spin_lock(_keys_guard);
>> +read_lock(_keys_guard);
>>  atomic_inc(_key_initing_cnt);
>> -spin_unlock(_keys_guard);
>> +read_unlock(_keys_guard);
>
> WTF, seems unlikely that you need to hold any kind of lock
> over an atomic_inc().
>
> If this is just ensuring that no code holds the lock then
> it would need to request the write_lock().
> (and would need a comment)

There is a comment - that patch showed the last 2 lines of it.
This is for synchronization with lu_context_key_quiesce().
That spins(!! calling schedule, but still... not good) until
the lu_key_initing_cnt is zero while it holds the write lock.
Then it is sure that the code protected by this counter isn't
running.
I'm sure this can be improved!  I would need to study it carefully to
see how.

Note that I don't object to these patches going in - if they provide a
measurable improvement which seems likely, then in they go.  But I
hope the code won't stay like this long term.

Thanks,
NeilBrown


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


Re: [PATCH 3/3] staging: Android: Fix sparse warnings in vsoc driver.

2018-05-03 Thread Greg Kroah-Hartman
On Wed, May 02, 2018 at 09:46:16PM -0700, Alistair Strachan wrote:
> Cc: Greg Kroah-Hartman 
> Cc: Arve Hjønnevåg 
> Cc: Todd Kjos 
> Cc: Martijn Coenen 
> Cc: Greg Hartman 
> Cc: de...@driverdev.osuosl.org
> Cc: kernel-t...@android.com
> Signed-off-by: Alistair Strachan 

Normally I don't like to merge patches without any changelog text, so in
the future please provide it for all patches.

thanks,

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


Re: [PATCH] ANDROID: binder: fix binder work return error is wrongly consumed

2018-05-03 Thread Martijn Coenen
On Wed, May 2, 2018 at 7:30 AM,   wrote:
> But there is potential risks in the future, future functional extensions
> need to consider nesting issues, maybe extending more methods where we
> push to thread->todo. I think that using queueing return error transaction
> to the head of thread todo list is more appropriate, as follows:

Historically it was not safe to issue binder transactions from death
recipients because of issues like this - though I don't think we've
ever been clear about that in the documentation. "ANDROID: binder:
don't enqueue
death notifications to thread todo" fixes that, and makes it safe to
do - though the current driver may still have an issue if two death
receipts are queued (need to look into that). If we ever were to add
functionality into the driver again that queues something to
thread->todo that could result in nesting, we would need to do more
than just this change to make it safe. Consider this scenario, which
would fail even with your patch:

1) BR_DEAD_BINDER is in thread->todo
2) We issue a new transaction T1 to a different process, which succeeds
3) We queue the reply BR_REPLY for T1 to thread->todo and return to userspace
4) userspace finds BR_DEAD_BINDER first, runs a death recipient which
issues a new binder transaction, T2
5) We find the BR_REPLY for T1 instead of T2, and now we have a problem

So, this fix by itself won't make it safe, so I think instead we
should always prevent such nesting in the driver. That also keeps the
code simpler and easier to understand - just queue things in order.

Thanks,
Martijn

>
> 1) During a transaction, the client will add BINDER_WORK_RETURN_ERROR into
> thread->todo list, however, it would be better to pick up
> BINDER_WORK_RETURN_ERROR firstly and finish the transaction immediately,
> jump out of the nest.
>
> 2) Client pick up the left binder work from thread->todo, using the
> same thread, do not need wake up other idle binder thread.
>
> 3) It works fine in the old binder version (before split big binder
> lock), binder_transaction only set thread return_error when target
> process has dead, do not add BINDER_WORK_RETURN_ERROR into thread->todo,
> but binder_thread_read() check return_error firstly. If occurs return_error,
> finish this transaction and back to userspace immediately.
>
> So I prefer to put the BINDER_WORK_RETURN_ERROR to the head of the
> queue, same as the old version of binder driver, once and for all.
>
> Signed-off-by: yuanhuihui 
> ---
>  drivers/android/binder.c | 59 
> ++--
>  1 file changed, 57 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 4eab5be3d00f..1ed1809b8769 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -861,6 +861,60 @@ binder_enqueue_thread_work(struct binder_thread *thread,
> binder_inner_proc_unlock(thread->proc);
>  }
>
> +/**
> + * binder_enqueue_work_head_ilocked() - Add an item to the head of work list
> + * @work: struct binder_work to add to list
> + * @target_list:  list to add work to
> + *
> + * Adds the work to the specified list. Asserts that work
> + * is not already on a list.
> + *
> + * Requires the proc->inner_lock to be held.
> + */
> +static void
> +binder_enqueue_work_head_ilocked(struct binder_work *work,
> +  struct list_head *target_list)
> +{
> +   BUG_ON(target_list == NULL);
> +   BUG_ON(work->entry.next && !list_empty(>entry));
> +   list_add(>entry, target_list);
> +}
> +
> +/**
> + * binder_enqueue_thread_work_head_ilocked() - Add an item to the head of 
> thread work list
> + * @thread:   thread to queue work to
> + * @work: struct binder_work to add to list
> + *
> + * Adds the work to the head of thread todo list, and enables processing
> + * of the todo queue.
> + *
> + * Requires the proc->inner_lock to be held.
> + */
> +static void
> +binder_enqueue_thread_work_head_ilocked(struct binder_thread *thread,
> +  struct binder_work *work)
> +{
> +   binder_enqueue_work_head_ilocked(work, >todo);
> +   thread->process_todo = true;
> +}
> +
> +/**
> + * binder_enqueue_thread_work_head() - Add an item to the head of thread 
> work list
> + * @thread:   thread to queue work to
> + * @work: struct binder_work to add to list
> + *
> + * Adds the work to the head of thread todo list, and enables processing
> + * of the todo queue.
> + */
> +static void
> +binder_enqueue_thread_work_head(struct binder_thread *thread,
> +  struct binder_work *work)
> +{
> +   binder_inner_proc_lock(thread->proc);
> +   binder_enqueue_thread_work_head_ilocked(thread, work);
> +   binder_inner_proc_unlock(thread->proc);
> +}
> +
>  static void
>  binder_dequeue_work_ilocked(struct binder_work *work)
>  {
> @@ -3287,11 +3341,11 @@ static void 

[PATCH v2] staging: lustre: o2iblnd: Enable Multiple OPA Endpoints between Nodes

2018-05-03 Thread Doug Oucharek
OPA driver optimizations are based on the MPI model where it is
expected to have multiple endpoints between two given nodes. To
enable this optimization for Lustre, we need to make it possible,
via an LND-specific tuneable, to create multiple endpoints and to
balance the traffic over them.

Both sides of a connection must have this patch for it to work.
Only the active side of the connection (usually the client)
needs to have the new tuneable set > 1.

Signed-off-by: Doug Oucharek 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8943
Reviewed-on: https://review.whamcloud.com/25168
Reviewed-by: Amir Shehata 
Reviewed-by: Dmitry Eremin 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: Doug Oucharek 
---
 .../lustre/include/uapi/linux/lnet/lnet-dlc.h  |  3 ++-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h| 17 ---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 25 +++---
 .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c  |  9 
 4 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h 
b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
index e45d828..c1619f4 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-dlc.h
@@ -53,7 +53,8 @@ struct lnet_ioctl_config_o2iblnd_tunables {
__u32 lnd_fmr_pool_size;
__u32 lnd_fmr_flush_trigger;
__u32 lnd_fmr_cache;
-   __u32 pad;
+   __u16 lnd_conns_per_peer;
+   __u16 pad;
 };
 
 struct lnet_ioctl_config_lnd_tunables {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index ca6e09d..bb663d6 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -568,6 +568,8 @@ struct kib_peer {
lnet_nid_t   ibp_nid; /* who's on the other end(s) */
struct lnet_ni  *ibp_ni; /* LNet interface */
struct list_head ibp_conns;   /* all active connections */
+   struct kib_conn *ibp_next_conn;  /* next connection to send on for
+ * round robin */
struct list_head ibp_tx_queue;/* msgs waiting for a conn */
__u64ibp_incarnation; /* incarnation of peer */
/* when (in jiffies) I was last alive */
@@ -581,7 +583,7 @@ struct kib_peer {
/* current active connection attempts */
unsigned short  ibp_connecting;
/* reconnect this peer later */
-   unsigned short  ibp_reconnecting:1;
+   unsigned char   ibp_reconnecting;
/* counter of how many times we triggered a conn race */
unsigned char   ibp_races;
/* # consecutive reconnection attempts to this peer */
@@ -744,10 +746,19 @@ struct kib_peer {
 static inline struct kib_conn *
 kiblnd_get_conn_locked(struct kib_peer *peer)
 {
+   struct list_head *next;
+
LASSERT(!list_empty(>ibp_conns));
 
-   /* just return the first connection */
-   return list_entry(peer->ibp_conns.next, struct kib_conn, ibc_list);
+   /* Advance to next connection, be sure to skip the head node */
+   if (!peer->ibp_next_conn ||
+   peer->ibp_next_conn->ibc_list.next == >ibp_conns)
+   next = peer->ibp_conns.next;
+   else
+   next = peer->ibp_next_conn->ibc_list.next;
+   peer->ibp_next_conn = list_entry(next, struct kib_conn, ibc_list);
+
+   return peer->ibp_next_conn;
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index b4a182d..77b3ae6 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1250,7 +1250,6 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
LASSERT(net);
LASSERT(peer->ibp_connecting > 0);
-   LASSERT(!peer->ibp_reconnecting);
 
cmid = kiblnd_rdma_create_id(kiblnd_cm_callback, peer, RDMA_PS_TCP,
 IB_QPT_RC);
@@ -1332,7 +1331,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 
LASSERT(!peer->ibp_accepting && !peer->ibp_connecting &&
list_empty(>ibp_conns));
-   peer->ibp_reconnecting = 0;
+   peer->ibp_reconnecting--;
 
if (!kiblnd_peer_active(peer)) {
list_splice_init(>ibp_tx_queue, );
@@ -1365,6 +1364,8 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
rwlock_t *g_lock = _data.kib_global_lock;
unsigned long flags;
int rc;
+   inti;
+   struct lnet_ioctl_config_o2iblnd_tunables 

[PATCH] staging: r8822be: fix typo in variable name "offest" -> "offset"

2018-05-03 Thread Colin King
From: Colin Ian King 

There are multiple occurrances of typos of "offest" that should be
"offset". Fix these.

Signed-off-by: Colin Ian King 
---
 .../rtlwifi/phydm/rtl8822b/halphyrf_8822b.c   | 34 +--
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c 
b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
index ae3e2278fefd..14c3fb52f5b8 100644
--- a/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
+++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halphyrf_8822b.c
@@ -29,7 +29,7 @@
 static bool
 get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
  enum pwrtrack_method method,
- u8 rf_path, u8 tx_power_index_offest)
+ u8 rf_path, u8 tx_power_index_offset)
 {
struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void;
struct dm_rf_calibration_struct *cali_info = >rf_calibrate_info;
@@ -42,24 +42,24 @@ get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
 
ODM_RT_TRACE(
dm, ODM_COMP_TX_PWR_TRACK,
-   "Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d, 
tx_power_index_offest=%d\n",
+   "Path_%d cali_info->absolute_ofdm_swing_idx[rf_path]=%d, 
tx_power_index_offset=%d\n",
rf_path, cali_info->absolute_ofdm_swing_idx[rf_path],
-   tx_power_index_offest);
+   tx_power_index_offset);
 
-   if (tx_power_index_offest > 0XF)
-   tx_power_index_offest = 0XF;
+   if (tx_power_index_offset > 0XF)
+   tx_power_index_offset = 0XF;
 
if (cali_info->absolute_ofdm_swing_idx[rf_path] >= 0 &&
cali_info->absolute_ofdm_swing_idx[rf_path] <=
-   tx_power_index_offest) {
+   tx_power_index_offset) {
tx_agc_index = cali_info->absolute_ofdm_swing_idx[rf_path];
tx_bb_swing_index = cali_info->default_ofdm_index;
} else if (cali_info->absolute_ofdm_swing_idx[rf_path] >
-  tx_power_index_offest) {
-   tx_agc_index = tx_power_index_offest;
+  tx_power_index_offset) {
+   tx_agc_index = tx_power_index_offset;
cali_info->remnant_ofdm_swing_idx[rf_path] =
cali_info->absolute_ofdm_swing_idx[rf_path] -
-   tx_power_index_offest;
+   tx_power_index_offset;
tx_bb_swing_index = cali_info->default_ofdm_index +
cali_info->remnant_ofdm_swing_idx[rf_path];
 
@@ -85,9 +85,9 @@ get_mix_mode_tx_agc_bb_swing_offset_8822b(void *dm_void,
 
ODM_RT_TRACE(
dm, ODM_COMP_TX_PWR_TRACK,
-   "MixMode Offset Path_%d   
cali_info->absolute_ofdm_swing_idx[rf_path]=%d   
cali_info->bb_swing_idx_ofdm[rf_path]=%d   tx_power_index_offest=%d\n",
+   "MixMode Offset Path_%d   
cali_info->absolute_ofdm_swing_idx[rf_path]=%d   
cali_info->bb_swing_idx_ofdm[rf_path]=%d   tx_power_index_offset=%d\n",
rf_path, cali_info->absolute_ofdm_swing_idx[rf_path],
-   cali_info->bb_swing_idx_ofdm[rf_path], tx_power_index_offest);
+   cali_info->bb_swing_idx_ofdm[rf_path], tx_power_index_offset);
 
return true;
 }
@@ -97,7 +97,7 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum 
pwrtrack_method method,
 {
struct phy_dm_struct *dm = (struct phy_dm_struct *)dm_void;
struct dm_rf_calibration_struct *cali_info = >rf_calibrate_info;
-   u8 tx_power_index_offest = 0;
+   u8 tx_power_index_offset = 0;
u8 tx_power_index = 0;
 
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
@@ -139,11 +139,11 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum 
pwrtrack_method method,
if (tx_power_index >= 63)
tx_power_index = 63;
 
-   tx_power_index_offest = 63 - tx_power_index;
+   tx_power_index_offset = 63 - tx_power_index;
 
ODM_RT_TRACE(dm, ODM_COMP_TX_PWR_TRACK,
-"tx_power_index=%d tx_power_index_offest=%d rf_path=%d\n",
-tx_power_index, tx_power_index_offest, rf_path);
+"tx_power_index=%d tx_power_index_offset=%d rf_path=%d\n",
+tx_power_index, tx_power_index_offset, rf_path);
 
if (method ==
BBSWING) { /*use for mp driver clean power tracking status*/
@@ -178,7 +178,7 @@ void odm_tx_pwr_track_set_pwr8822b(void *dm_void, enum 
pwrtrack_method method,
switch (rf_path) {
case ODM_RF_PATH_A:
get_mix_mode_tx_agc_bb_swing_offset_8822b(
-   dm, method, rf_path, tx_power_index_offest);
+   dm, method, rf_path, 

RE: [PATCH 1/4] staging: lustre: obdclass: change spinlock of key to rwlock

2018-05-03 Thread David Laight
From: James Simmons
> Sent: 02 May 2018 19:22
> From: Li Xi 
> 
> Most of the time, keys are never changed. So rwlock might be
> better for the concurrency of key read.

OTOH unless there is contention on the spin lock during reads the
additional cost of a rwlock (probably double that of a spinlock)
will hurt performance.

...
> - spin_lock(_keys_guard);
> + read_lock(_keys_guard);
>   atomic_inc(_key_initing_cnt);
> - spin_unlock(_keys_guard);
> + read_unlock(_keys_guard);

WTF, seems unlikely that you need to hold any kind of lock
over an atomic_inc().

If this is just ensuring that no code holds the lock then
it would need to request the write_lock().
(and would need a comment)

David

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


Re: [PATCH v3 09/20] iommu: Remove depends on HAS_DMA in case of platform dependency

2018-05-03 Thread Joerg Roedel
On Tue, Apr 17, 2018 at 07:49:09PM +0200, Geert Uytterhoeven wrote:
> Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
> symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
> In most cases this other symbol is an architecture or platform specific
> symbol, or PCI.
> 
> Generic symbols and drivers without platform dependencies keep their
> dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
> cannot work anyway.
> 
> This simplifies the dependencies, and allows to improve compile-testing.
> 
> Signed-off-by: Geert Uytterhoeven 
> Reviewed-by: Mark Brown 
> Acked-by: Robin Murphy 
> Acked-by: Joerg Roedel 

Applied, thanks.

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


team of photo editors for you

2018-05-03 Thread Edward Nelson

We are a good photo team, who can process 200+ images each day.

If you need any image editing service, just let us know.
Such as ecommerce photos cutting out, clipping path, masking. Jewelry
photos cut out and retouching
Beauty model retouching and skin image retouching,
also wedding photo editing,

Our advantages:
Quality
Turnaround time fast
7/24 available

Best Regards,
Edward Nelson

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


Re: [PATCH v8] PCI: hv: Make sure the bus domain is really unique

2018-05-03 Thread Lorenzo Pieralisi
On Tue, May 01, 2018 at 05:56:32PM +, Sridhar Pitchai wrote:
> When Linux runs as a guest VM in Hyper-V and Hyper-V adds the virtual PCI
> bus to the guest, Hyper-V always provides unique PCI domain.
> 
> commit 4a9b0933bdfc ("PCI: hv: Use device serial number as PCI domain")
> overrode unique domain with the serial number of the first device added to
> the virtual PCI bus.
> 
> The reason for that patch was to have a consistent and short name for the
> device, but Hyper-V doesn't provide unique serial numbers. Using non-unique
> serial numbers as domain IDs leads to duplicate device addresses, which
> causes PCI bus registration to fail.
> 
> commit 0c195567a8f6 ("netvsc: transparent VF management") avoids the need
> for commit 4a9b0933bdfc ("PCI: hv: Use device serial number as PCI
> domain").  When scripts were used to configure VF devices, the name of
> the VF needed to be consistent and short, but with commit 0c195567a8f6
> ("netvsc: transparent VF management") all the setup is done in the kernel,
> and we do not need to maintain consistent name.
> 
> Revert commit 4a9b0933bdfc ("PCI: hv: Use device serial number as PCI
> domain") so we can reliably support multiple devices being assigned to
> a guest.
> 
> This revert should only be backported to kernels that contain commit
> 0c195567a8f6 ("netvsc: transparent VF management").

I removed this last paragraph, the information is in the stable tag
below.

> Fixes: 4a9b0933bdfc ("PCI: hv: Use device serial number as PCI domain")
> Signed-off-by: Sridhar Pitchai 
> Cc: sta...@vger.kernel.org # v4.14+
> Reviewed-by: Bjorn Helgaas 
> 
> ---
> Changes in v8:
> * fix the commit comment. [Lorenzo Pieralisi, Bjorn Helgaas]
> ---
>  drivers/pci/host/pci-hyperv.c | 11 ---
>  1 file changed, 11 deletions(-)

Applied to pci/hv for v4.18, thanks.

Lorenzo

> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 2faf38eab785..ac67e56e451a 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1518,17 +1518,6 @@ static struct hv_pci_dev *new_pcichild_device(struct 
> hv_pcibus_device *hbus,
>   get_pcichild(hpdev, hv_pcidev_ref_childlist);
>   spin_lock_irqsave(>device_list_lock, flags);
>  
> - /*
> -  * When a device is being added to the bus, we set the PCI domain
> -  * number to be the device serial number, which is non-zero and
> -  * unique on the same VM.  The serial numbers start with 1, and
> -  * increase by 1 for each device.  So device names including this
> -  * can have shorter names than based on the bus instance UUID.
> -  * Only the first device serial number is used for domain, so the
> -  * domain number will not change after the first device is added.
> -  */
> - if (list_empty(>children))
> - hbus->sysdata.domain = desc->ser;
>   list_add_tail(>list_entry, >children);
>   spin_unlock_irqrestore(>device_list_lock, flags);
>   return hpdev;
> -- 
> 2.14.1
> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: allocate less memory

2018-05-03 Thread Dan Carpenter
We should be allocating space for hidden_network_info structs.  They are
slightly smaller than hidden_network structs.  This bug doesn't cause a
runtime issue beyond the very small ammount of extra memory used.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 3ca0c97b0627..92322d6f061d 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -581,8 +581,8 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request 
*request,
int i;
int slot_id = 0;
 
-   ntwk->net_info = kcalloc(request->n_ssids,
-sizeof(struct hidden_network), GFP_KERNEL);
+   ntwk->net_info = kcalloc(request->n_ssids, sizeof(*ntwk->net_info),
+GFP_KERNEL);
if (!ntwk->net_info)
goto out;
 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: most: video: use __func__ instead of function name

2018-05-03 Thread Abdun Nihaal
This fixes the following checkpatch warning in video.c:

WARNING: Prefer using '\"%s...\", __func__' to using function's name
in a string

Signed-off-by: Abdun Nihaal 
---
 drivers/staging/most/video/video.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/most/video/video.c 
b/drivers/staging/most/video/video.c
index 9d7e747519d9..c85e289275a9 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -73,7 +73,7 @@ static int comp_vdev_open(struct file *filp)
struct most_video_dev *mdev = video_drvdata(filp);
struct comp_fh *fh;
 
-   v4l2_info(>v4l2_dev, "comp_vdev_open()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
@@ -122,7 +122,7 @@ static int comp_vdev_close(struct file *filp)
struct most_video_dev *mdev = fh->mdev;
struct mbo *mbo, *tmp;
 
-   v4l2_info(>v4l2_dev, "comp_vdev_close()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
/*
 * We need to put MBOs back before we call most_stop_channel()
@@ -250,7 +250,7 @@ static int vidioc_querycap(struct file *file, void *priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_querycap()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
strlcpy(cap->driver, "v4l2_component", sizeof(cap->driver));
strlcpy(cap->card, "MOST", sizeof(cap->card));
@@ -270,7 +270,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void 
*priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_enum_fmt_vid_cap() %d\n", f->index);
+   v4l2_info(>v4l2_dev, "%s() %d\n", __func__, f->index);
 
if (f->index)
return -EINVAL;
@@ -289,7 +289,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void 
*priv,
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_g_fmt_vid_cap()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
comp_set_format_struct(f);
return 0;
@@ -318,7 +318,7 @@ static int vidioc_g_std(struct file *file, void *priv, 
v4l2_std_id *norm)
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_g_std()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
*norm = V4L2_STD_UNKNOWN;
return 0;
@@ -355,7 +355,7 @@ static int vidioc_s_input(struct file *file, void *priv, 
unsigned int index)
struct comp_fh *fh = priv;
struct most_video_dev *mdev = fh->mdev;
 
-   v4l2_info(>v4l2_dev, "vidioc_s_input(%d)\n", index);
+   v4l2_info(>v4l2_dev, "%s(%d)\n", __func__, index);
 
if (index >= V4L2_CMP_MAX_INPUT)
return -EINVAL;
@@ -435,7 +435,7 @@ static int comp_register_videodev(struct most_video_dev 
*mdev)
 {
int ret;
 
-   v4l2_info(>v4l2_dev, "comp_register_videodev()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
init_waitqueue_head(>wait_data);
 
@@ -465,7 +465,7 @@ static int comp_register_videodev(struct most_video_dev 
*mdev)
 
 static void comp_unregister_videodev(struct most_video_dev *mdev)
 {
-   v4l2_info(>v4l2_dev, "comp_unregister_videodev()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
video_unregister_device(mdev->vdev);
 }
@@ -485,7 +485,7 @@ static int comp_probe_channel(struct most_interface *iface, 
int channel_idx,
int ret;
struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
 
-   pr_info("comp_probe_channel(%s)\n", name);
+   pr_info("%s(%s)\n", __func__, name);
 
if (mdev) {
pr_err("channel already linked\n");
@@ -531,7 +531,7 @@ static int comp_probe_channel(struct most_interface *iface, 
int channel_idx,
spin_lock_irq(_lock);
list_add(>list, _devices);
spin_unlock_irq(_lock);
-   v4l2_info(>v4l2_dev, "comp_probe_channel() done\n");
+   v4l2_info(>v4l2_dev, "%s() done\n", __func__);
return 0;
 
 err_unreg:
@@ -550,7 +550,7 @@ static int comp_disconnect_channel(struct most_interface 
*iface,
return -ENOENT;
}
 
-   v4l2_info(>v4l2_dev, "comp_disconnect_channel()\n");
+   v4l2_info(>v4l2_dev, "%s()\n", __func__);
 
spin_lock_irq(_lock);
list_del(>list);
-- 
2.17.0

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