[PATCH 1/8] staging: wilc1000: make use of FIELD_GET/_PREP macro

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Simplified the code by making use of FIELD_GET/_PREP bitfield macro.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/cfg80211.c |  2 +-
 drivers/staging/wilc1000/mon.c  |  2 +-
 drivers/staging/wilc1000/netdev.h   |  2 --
 drivers/staging/wilc1000/spi.c  |  2 +-
 drivers/staging/wilc1000/wlan.c | 32 +++--
 drivers/staging/wilc1000/wlan.h | 20 +-
 6 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/wilc1000/cfg80211.c 
b/drivers/staging/wilc1000/cfg80211.c
index d9c7bed2e6fb..995b1f306807 100644
--- a/drivers/staging/wilc1000/cfg80211.c
+++ b/drivers/staging/wilc1000/cfg80211.c
@@ -988,7 +988,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 
size)
s32 freq;
 
header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
-   pkt_offset = GET_PKT_OFFSET(header);
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
 
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
bool ack = false;
diff --git a/drivers/staging/wilc1000/mon.c b/drivers/staging/wilc1000/mon.c
index 48ac33f06f63..60331417bd98 100644
--- a/drivers/staging/wilc1000/mon.c
+++ b/drivers/staging/wilc1000/mon.c
@@ -40,7 +40,7 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 
*buff, u32 size)
 * The packet offset field contain info about what type of management
 * the frame we are dealing with and ack status
 */
-   pkt_offset = GET_PKT_OFFSET(header);
+   pkt_offset = FIELD_GET(WILC_PKT_HDR_OFFSET_FIELD, header);
 
if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
/* hostapd callback mgmt frame */
diff --git a/drivers/staging/wilc1000/netdev.h 
b/drivers/staging/wilc1000/netdev.h
index c475e78e3a69..e3689e2a4abb 100644
--- a/drivers/staging/wilc1000/netdev.h
+++ b/drivers/staging/wilc1000/netdev.h
@@ -29,8 +29,6 @@
 #define TCP_ACK_FILTER_LINK_SPEED_THRESH   54
 #define DEFAULT_LINK_SPEED 72
 
-#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
-
 struct wilc_wfi_stats {
unsigned long rx_packets;
unsigned long tx_packets;
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index 9a9f3624e158..300c5c832572 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -898,7 +898,7 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
int ret;
 
ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, size);
-   *size = *size & IRQ_DMA_WD_CNT_MASK;
+   *size = FIELD_GET(IRQ_DMA_WD_CNT_MASK, *size);
 
return ret;
 }
diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c
index 601e4d1345d2..9dfabd1af4e7 100644
--- a/drivers/staging/wilc1000/wlan.c
+++ b/drivers/staging/wilc1000/wlan.c
@@ -568,8 +568,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®);
if (ret)
break;
-   if ((reg >> 2) & 0x1) {
-   entries = ((reg >> 3) & 0x3f);
+   if (FIELD_GET(WILC_VMM_ENTRY_AVAILABLE, reg)) {
+   entries = FIELD_GET(WILC_VMM_ENTRY_COUNT, reg);
break;
}
release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
@@ -610,6 +610,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
do {
u32 header, buffer_offset;
char *bssid;
+   u8 mgmt_ptk = 0;
 
tqe = wilc_wlan_txq_remove_from_head(dev);
if (!tqe)
@@ -620,15 +621,16 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 
*txq_count)
break;
 
le32_to_cpus(&vmm_table[i]);
-   vmm_sz = (vmm_table[i] & 0x3ff);
+   vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]);
vmm_sz *= 4;
-   header = (tqe->type << 31) |
-(tqe->buffer_size << 15) |
-vmm_sz;
+
if (tqe->type == WILC_MGMT_PKT)
-   header |= BIT(30);
-   else
-   header &= ~BIT(30);
+   mgmt_ptk = 1;
+
+   header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tqe->type) |
+ FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) |
+ FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) |
+ FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz));
 
cpu_to_le32s(&header);
memcpy(&txb[offset], &header, 4);
@@ -686,10 +688,10 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, 
u8 *buffer, int size)
buff_ptr = buffer + offset;
header = get_unaligned_le32(buff_ptr)

[PATCH 8/8] staging: wilc1000: define macros to replace magic number values

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Define macros for global as well as SPI/SDIO specific register to avoid
use of magic numbers.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c |  7 ++-
 drivers/staging/wilc1000/spi.c  | 17 ---
 drivers/staging/wilc1000/wlan.c | 83 +++--
 drivers/staging/wilc1000/wlan.h | 35 ++
 4 files changed, 99 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 0670c5956aef..2301e90c21ca 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -686,13 +686,16 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
 *  make sure can read back chip id correctly
 **/
if (!resume) {
-   ret = wilc_sdio_read_reg(wilc, 0x1000, &chipid);
+   int rev;
+
+   ret = wilc_sdio_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret) {
dev_err(&func->dev, "Fail cmd read chip id...\n");
return ret;
}
dev_err(&func->dev, "chipid (%08x)\n", chipid);
-   if ((chipid & 0xfff) > 0x2a0)
+   rev = FIELD_GET(WILC_CHIP_REV_FIELD, chipid);
+   if (rev > FIELD_GET(WILC_CHIP_REV_FIELD, WILC_1000_BASE_ID_2A))
sdio_priv->has_thrpt_enh3 = 1;
else
sdio_priv->has_thrpt_enh3 = 0;
diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
index 37be627e72ce..44f7d48851b5 100644
--- a/drivers/staging/wilc1000/spi.c
+++ b/drivers/staging/wilc1000/spi.c
@@ -683,7 +683,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, 
u32 *data)
u8 cmd = CMD_SINGLE_READ;
u8 clockless = 0;
 
-   if (addr < 0x30) {
+   if (addr < WILC_SPI_CLOCKLESS_ADDR_LIMIT) {
/* Clockless register */
cmd = CMD_INTERNAL_READ;
clockless = 1;
@@ -760,7 +760,7 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, 
u32 data)
u8 cmd = CMD_SINGLE_WRITE;
u8 clockless = 0;
 
-   if (addr < 0x30) {
+   if (addr < WILC_SPI_CLOCKLESS_ADDR_LIMIT) {
/* Clockless register */
cmd = CMD_INTERNAL_WRITE;
clockless = 1;
@@ -829,7 +829,7 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
int ret;
 
if (isinit) {
-   ret = wilc_spi_read_reg(wilc, 0x1000, &chipid);
+   ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret)
dev_err(&spi->dev, "Fail cmd read chip id...\n");
 
@@ -881,7 +881,7 @@ static int wilc_spi_init(struct wilc *wilc, bool resume)
/*
 * make sure can read back chip id correctly
 */
-   ret = wilc_spi_read_reg(wilc, 0x1000, &chipid);
+   ret = wilc_spi_read_reg(wilc, WILC_CHIPID, &chipid);
if (ret) {
dev_err(&spi->dev, "Fail cmd read chip id...\n");
return ret;
@@ -896,7 +896,8 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
 {
int ret;
 
-   ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, size);
+   ret = spi_internal_read(wilc,
+   WILC_SPI_INT_STATUS - WILC_SPI_REG_BASE, size);
*size = FIELD_GET(IRQ_DMA_WD_CNT_MASK, *size);
 
return ret;
@@ -904,12 +905,14 @@ static int wilc_spi_read_size(struct wilc *wilc, u32 
*size)
 
 static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
 {
-   return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, int_status);
+   return spi_internal_read(wilc, WILC_SPI_INT_STATUS - WILC_SPI_REG_BASE,
+int_status);
 }
 
 static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
 {
-   return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE, val);
+   return spi_internal_write(wilc, WILC_SPI_INT_CLEAR - WILC_SPI_REG_BASE,
+ val);
 }
 
 static int wilc_spi_sync_ext(struct wilc *wilc, int nint)
diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c
index 31f424efe01d..f633c6b9f0a9 100644
--- a/drivers/staging/wilc1000/wlan.c
+++ b/drivers/staging/wilc1000/wlan.c
@@ -11,7 +11,7 @@
 
 static inline bool is_wilc1000(u32 id)
 {
-   return (id & 0xf000) == 0x10;
+   return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID;
 }
 
 static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
@@ -393,10 +393,11 @@ void chip_allow_sleep(struct wilc *wilc)
 {
u32 reg = 0;
 
-   wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
+   wilc->hif_func->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®);
 
-   wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0));
-   wilc->hif_func->hif_write_reg(wilc, 0xfa, 0);
+   wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_WAK

[PATCH 7/8] staging: wilc1000: use short name for hif local variable in chip_wakeup()

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Make use of a shorter name for 'hif' variable to avoid possible 80
character checkpatch warning while the replacing hardcoded value with
macros in chip_wakeup().

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wlan.c | 35 +++--
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c
index db4ef175ccee..31f424efe01d 100644
--- a/drivers/staging/wilc1000/wlan.c
+++ b/drivers/staging/wilc1000/wlan.c
@@ -403,37 +403,34 @@ EXPORT_SYMBOL_GPL(chip_allow_sleep);
 void chip_wakeup(struct wilc *wilc)
 {
u32 reg, clk_status_reg;
+   const struct wilc_hif_func *h = wilc->hif_func;
 
-   if ((wilc->io_type & 0x1) == WILC_HIF_SPI) {
+   if (wilc->io_type == WILC_HIF_SPI) {
do {
-   wilc->hif_func->hif_read_reg(wilc, 1, ®);
-   wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1));
-   wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1));
+   h->hif_read_reg(wilc, 1, ®);
+   h->hif_write_reg(wilc, 1, reg | BIT(1));
+   h->hif_write_reg(wilc, 1, reg & ~BIT(1));
 
do {
usleep_range(2000, 2500);
wilc_get_chipid(wilc, true);
} while (wilc_get_chipid(wilc, true) == 0);
} while (wilc_get_chipid(wilc, true) == 0);
-   } else if ((wilc->io_type & 0x1) == WILC_HIF_SDIO) {
-   wilc->hif_func->hif_write_reg(wilc, 0xfa, 1);
+   } else if (wilc->io_type == WILC_HIF_SDIO) {
+   h->hif_write_reg(wilc, 0xfa, 1);
usleep_range(200, 400);
-   wilc->hif_func->hif_read_reg(wilc, 0xf0, ®);
+   h->hif_read_reg(wilc, 0xf0, ®);
do {
-   wilc->hif_func->hif_write_reg(wilc, 0xf0,
- reg | BIT(0));
-   wilc->hif_func->hif_read_reg(wilc, 0xf1,
-&clk_status_reg);
+   h->hif_write_reg(wilc, 0xf0, reg | BIT(0));
+   h->hif_read_reg(wilc, 0xf1, &clk_status_reg);
 
while ((clk_status_reg & 0x1) == 0) {
usleep_range(2000, 2500);
 
-   wilc->hif_func->hif_read_reg(wilc, 0xf1,
-&clk_status_reg);
+   h->hif_read_reg(wilc, 0xf1, &clk_status_reg);
}
if ((clk_status_reg & 0x1) == 0) {
-   wilc->hif_func->hif_write_reg(wilc, 0xf0,
- reg & (~BIT(0)));
+   h->hif_write_reg(wilc, 0xf0, reg & (~BIT(0)));
}
} while ((clk_status_reg & 0x1) == 0);
}
@@ -442,13 +439,13 @@ void chip_wakeup(struct wilc *wilc)
if (wilc_get_chipid(wilc, false) < 0x1002b0) {
u32 val32;
 
-   wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32);
+   h->hif_read_reg(wilc, 0x1e1c, &val32);
val32 |= BIT(6);
-   wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32);
+   h->hif_write_reg(wilc, 0x1e1c, val32);
 
-   wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32);
+   h->hif_read_reg(wilc, 0x1e9c, &val32);
val32 |= BIT(6);
-   wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32);
+   h->hif_write_reg(wilc, 0x1e9c, val32);
}
}
wilc->chip_ps_state = WILC_CHIP_WAKEDUP;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/8] staging: wilc1000: remove use of MAX_NUN_INT_THRPT_ENH2 macro

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Make use of MAX_NUM_INT existing macro to handle the maximum supported
interrupts count and removed MAX_NUN_INT_THRPT_ENH2 macro.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 20 +++-
 drivers/staging/wilc1000/wlan.h |  2 +-
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index ca99335687c4..77ef84f9cc37 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -27,8 +27,6 @@ struct wilc_sdio {
bool irq_gpio;
u32 block_size;
int nint;
-/* Max num interrupts allowed in registers 0xf7, 0xf8 */
-#define MAX_NUN_INT_THRPT_ENH2 (5)
int has_thrpt_enh3;
 };
 
@@ -818,8 +816,6 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 
*int_status)
tmp |= INT_3;
if (cmd.data & BIT(5))
tmp |= INT_4;
-   if (cmd.data & BIT(6))
-   tmp |= INT_5;
for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) {
if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) {
dev_err(&func->dev,
@@ -854,16 +850,11 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 
val)
int vmm_ctl;
 
if (sdio_priv->has_thrpt_enh3) {
-   u32 reg;
+   u32 reg = 0;
 
-   if (sdio_priv->irq_gpio) {
-   u32 flags;
+   if (sdio_priv->irq_gpio)
+   reg = val & (BIT(MAX_NUM_INT) - 1);
 
-   flags = val & (BIT(MAX_NUN_INT_THRPT_ENH2) - 1);
-   reg = flags;
-   } else {
-   reg = 0;
-   }
/* select VMM table 0 */
if (val & SEL_VMM_TBL0)
reg |= BIT(5);
@@ -975,11 +966,6 @@ static int wilc_sdio_sync_ext(struct wilc *wilc, int nint)
dev_err(&func->dev, "Too many interrupts (%d)...\n", nint);
return -EINVAL;
}
-   if (nint > MAX_NUN_INT_THRPT_ENH2) {
-   dev_err(&func->dev,
-   "Cannot support more than 5 interrupts when 
has_thrpt_enh2=1.\n");
-   return -EINVAL;
-   }
 
sdio_priv->nint = nint;
 
diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h
index d3e822c374eb..876b02e93a81 100644
--- a/drivers/staging/wilc1000/wlan.h
+++ b/drivers/staging/wilc1000/wlan.h
@@ -175,7 +175,7 @@
 #define INT_3  BIT(IRG_FLAGS_OFFSET + 3)
 #define INT_4  BIT(IRG_FLAGS_OFFSET + 4)
 #define INT_5  BIT(IRG_FLAGS_OFFSET + 5)
-#define MAX_NUM_INT6
+#define MAX_NUM_INT5
 
 /***/
 /*E0 and later Interrupt flags.*/
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/8] staging: wilc1000: define macros for different register address for SDIO

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Instead of using hardcoded value for SDIO register address added the
macro for them.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 77 +
 drivers/staging/wilc1000/wlan.h | 36 +++
 2 files changed, 76 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 57c0e8415bc9..0670c5956aef 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -183,8 +183,8 @@ static int wilc_sdio_reset(struct wilc *wilc)
cmd.read_write = 1;
cmd.function = 0;
cmd.raw = 0;
-   cmd.address = 0x6;
-   cmd.data = 0x8;
+   cmd.address = SDIO_CCCR_ABORT;
+   cmd.data = WILC_SDIO_CCCR_ABORT_RESET;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
dev_err(&func->dev, "Fail cmd 52, reset cmd ...\n");
@@ -266,27 +266,30 @@ static int wilc_sdio_set_func0_csa_address(struct wilc 
*wilc, u32 adr)
cmd.read_write = 1;
cmd.function = 0;
cmd.raw = 0;
-   cmd.address = 0x10c;
+   cmd.address = WILC_SDIO_FBR_CSA_REG;
cmd.data = (u8)adr;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x10c data...\n");
+   dev_err(&func->dev, "Failed cmd52, set %04x data...\n",
+   cmd.address);
return ret;
}
 
-   cmd.address = 0x10d;
+   cmd.address = WILC_SDIO_FBR_CSA_REG + 1;
cmd.data = (u8)(adr >> 8);
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x10d data...\n");
+   dev_err(&func->dev, "Failed cmd52, set %04x data...\n",
+   cmd.address);
return ret;
}
 
-   cmd.address = 0x10e;
+   cmd.address = WILC_SDIO_FBR_CSA_REG + 2;
cmd.data = (u8)(adr >> 16);
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x10e data...\n");
+   dev_err(&func->dev, "Failed cmd52, set %04x data...\n",
+   cmd.address);
return ret;
}
 
@@ -337,7 +340,7 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, 
u32 data)
 
cpu_to_le32s(&data);
 
-   if (addr >= 0xf0 && addr <= 0xff) {
+   if (addr >= 0xf0 && addr <= 0xff) { /* only vendor specific registers */
struct sdio_cmd52 cmd;
 
cmd.read_write = 1;
@@ -361,7 +364,7 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, 
u32 data)
 
cmd.read_write = 1;
cmd.function = 0;
-   cmd.address = 0x10f;
+   cmd.address = WILC_SDIO_FBR_DATA_REG;
cmd.block_mode = 0;
cmd.increment = 1;
cmd.count = 4;
@@ -390,13 +393,13 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, 
u8 *buf, u32 size)
 *  func 0 access
 **/
cmd.function = 0;
-   cmd.address = 0x10f;
+   cmd.address = WILC_SDIO_FBR_DATA_REG;
} else {
/**
 *  func 1 access
 **/
cmd.function = 1;
-   cmd.address = 0;
+   cmd.address = WILC_SDIO_F1_DATA_REG;
}
 
size = ALIGN(size, 4);
@@ -455,7 +458,7 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, 
u32 *data)
struct wilc_sdio *sdio_priv = wilc->bus_data;
int ret;
 
-   if (addr >= 0xf0 && addr <= 0xff) {
+   if (addr >= 0xf0 && addr <= 0xff) { /* only vendor specific registers */
struct sdio_cmd52 cmd;
 
cmd.read_write = 0;
@@ -478,7 +481,7 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, 
u32 *data)
 
cmd.read_write = 0;
cmd.function = 0;
-   cmd.address = 0x10f;
+   cmd.address = WILC_SDIO_FBR_DATA_REG;
cmd.block_mode = 0;
cmd.increment = 1;
cmd.count = 4;
@@ -511,13 +514,13 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
 *  func 0 access
 **/
cmd.function = 0;
-   cmd.address = 0x10f;
+   cmd.address = WILC_SDIO_FBR_DATA_REG;
} else {
/**
 *  func 1 access
 **/
cmd.function = 1;
-   cmd.address = 0;
+   cmd.address = WILC_SDIO_F1_DATA_REG;
}
 
size = ALIGN(size, 4);
@@ -598,8 +601,8 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
cmd.read_write = 1;
cmd.function = 0;
cmd.raw = 1;
-   cmd.address = 0x100;
-   cmd.data = 0x80;
+   cmd.address = SDIO_FBR_B

[PATCH 0/8] staging: wilc1000: remove magic values and handle review comments

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

This patch series mainly contains changes to remove the magic value for
different registers and define the macros for constant numbers.
Also, it contains few patches to make use FIELD_GET/_PUT macro
to extract the bitfield element.

Ajay Singh (8):
  staging: wilc1000: make use of FIELD_GET/_PREP macro
  staging: wilc1000: remove use of MAX_NUN_INT_THRPT_ENH2 macro
  staging: wilc1000: refactor interrupt handling for sdio
  staging: wilc1000: make use of ALIGN macro
  staging: wilc1000: use commmon function to set SDIO block size
  staging: wilc1000: define macros for different register address for
SDIO
  staging: wilc1000: use short name for hif local variable in
chip_wakeup()
  staging: wilc1000: define macros to replace magic number values

 drivers/staging/wilc1000/cfg80211.c |   2 +-
 drivers/staging/wilc1000/mon.c  |   2 +-
 drivers/staging/wilc1000/netdev.h   |   2 -
 drivers/staging/wilc1000/sdio.c | 281 ++--
 drivers/staging/wilc1000/spi.c  |  23 ++-
 drivers/staging/wilc1000/wlan.c | 128 +++--
 drivers/staging/wilc1000/wlan.h |  96 +-
 7 files changed, 271 insertions(+), 263 deletions(-)

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


[PATCH 5/8] staging: wilc1000: use commmon function to set SDIO block size

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Use common function wilc_sdio_set_block_size() to set the block size for
SDIO.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 51 +++--
 1 file changed, 11 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 212affc4b9c1..57c0e8415bc9 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "netdev.h"
 #include "cfg80211.h"
@@ -292,7 +293,8 @@ static int wilc_sdio_set_func0_csa_address(struct wilc 
*wilc, u32 adr)
return 0;
 }
 
-static int wilc_sdio_set_func0_block_size(struct wilc *wilc, u32 block_size)
+static int wilc_sdio_set_block_size(struct wilc *wilc, u8 func_num,
+   u32 block_size)
 {
struct sdio_func *func = dev_to_sdio_func(wilc->dev);
struct sdio_cmd52 cmd;
@@ -301,52 +303,21 @@ static int wilc_sdio_set_func0_block_size(struct wilc 
*wilc, u32 block_size)
cmd.read_write = 1;
cmd.function = 0;
cmd.raw = 0;
-   cmd.address = 0x10;
+   cmd.address = SDIO_FBR_BASE(func_num) + SDIO_CCCR_BLKSIZE;
cmd.data = (u8)block_size;
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x10 data...\n");
+   dev_err(&func->dev, "Failed cmd52, set %04x data...\n",
+   cmd.address);
return ret;
}
 
-   cmd.address = 0x11;
+   cmd.address = SDIO_FBR_BASE(func_num) + SDIO_CCCR_BLKSIZE +  1;
cmd.data = (u8)(block_size >> 8);
ret = wilc_sdio_cmd52(wilc, &cmd);
if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x11 data...\n");
-   return ret;
-   }
-
-   return 0;
-}
-
-/
- *
- *  Function 1
- *
- /
-
-static int wilc_sdio_set_func1_block_size(struct wilc *wilc, u32 block_size)
-{
-   struct sdio_func *func = dev_to_sdio_func(wilc->dev);
-   struct sdio_cmd52 cmd;
-   int ret;
-
-   cmd.read_write = 1;
-   cmd.function = 0;
-   cmd.raw = 0;
-   cmd.address = 0x110;
-   cmd.data = (u8)block_size;
-   ret = wilc_sdio_cmd52(wilc, &cmd);
-   if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x110 data...\n");
-   return ret;
-   }
-   cmd.address = 0x111;
-   cmd.data = (u8)(block_size >> 8);
-   ret = wilc_sdio_cmd52(wilc, &cmd);
-   if (ret) {
-   dev_err(&func->dev, "Failed cmd52, set 0x111 data...\n");
+   dev_err(&func->dev, "Failed cmd52, set %04x data...\n",
+   cmd.address);
return ret;
}
 
@@ -638,7 +609,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
/**
 *  function 0 block size
 **/
-   ret = wilc_sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE);
+   ret = wilc_sdio_set_block_size(wilc, 0, WILC_SDIO_BLOCK_SIZE);
if (ret) {
dev_err(&func->dev, "Fail cmd 52, set func 0 block size...\n");
return ret;
@@ -688,7 +659,7 @@ static int wilc_sdio_init(struct wilc *wilc, bool resume)
/**
 *  func 1 is ready, set func 1 block size
 **/
-   ret = wilc_sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE);
+   ret = wilc_sdio_set_block_size(wilc, 1, WILC_SDIO_BLOCK_SIZE);
if (ret) {
dev_err(&func->dev, "Fail set func 1 block size...\n");
return ret;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/8] staging: wilc1000: make use of ALIGN macro

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'ALIGN' macro to align the size data value.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 34 ++---
 drivers/staging/wilc1000/wlan.c |  4 +---
 2 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 66706efc5711..212affc4b9c1 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -415,28 +415,12 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, 
u8 *buf, u32 size)
 
cmd.read_write = 1;
if (addr > 0) {
-   /**
-*  has to be word aligned...
-**/
-   if (size & 0x3) {
-   size += 4;
-   size &= ~0x3;
-   }
-
/**
 *  func 0 access
 **/
cmd.function = 0;
cmd.address = 0x10f;
} else {
-   /**
-*  has to be word aligned...
-**/
-   if (size & 0x3) {
-   size += 4;
-   size &= ~0x3;
-   }
-
/**
 *  func 1 access
 **/
@@ -444,6 +428,7 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
cmd.address = 0;
}
 
+   size = ALIGN(size, 4);
nblk = size / block_size;
nleft = size % block_size;
 
@@ -551,28 +536,12 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
 
cmd.read_write = 0;
if (addr > 0) {
-   /**
-*  has to be word aligned...
-**/
-   if (size & 0x3) {
-   size += 4;
-   size &= ~0x3;
-   }
-
/**
 *  func 0 access
 **/
cmd.function = 0;
cmd.address = 0x10f;
} else {
-   /**
-*  has to be word aligned...
-**/
-   if (size & 0x3) {
-   size += 4;
-   size &= ~0x3;
-   }
-
/**
 *  func 1 access
 **/
@@ -580,6 +549,7 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 
*buf, u32 size)
cmd.address = 0;
}
 
+   size = ALIGN(size, 4);
nblk = size / block_size;
nleft = size % block_size;
 
diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c
index 9dfabd1af4e7..db4ef175ccee 100644
--- a/drivers/staging/wilc1000/wlan.c
+++ b/drivers/staging/wilc1000/wlan.c
@@ -508,9 +508,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
vmm_sz = HOST_HDR_OFFSET;
 
vmm_sz += tqe->buffer_size;
-
-   if (vmm_sz & 0x3)
-   vmm_sz = (vmm_sz + 4) & ~0x3;
+   vmm_sz = ALIGN(vmm_sz, 4);
 
if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE)
break;
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/8] staging: wilc1000: refactor interrupt handling for sdio

2020-02-14 Thread Ajay.Kathat
From: Ajay Singh 

Make use of FIELD_PREP/FIELD_GET macro to refactor the interrupt
handling for SDIO.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/sdio.c | 98 -
 drivers/staging/wilc1000/spi.c  |  4 --
 drivers/staging/wilc1000/wlan.h |  3 +
 3 files changed, 39 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c
index 77ef84f9cc37..66706efc5711 100644
--- a/drivers/staging/wilc1000/sdio.c
+++ b/drivers/staging/wilc1000/sdio.c
@@ -26,7 +26,6 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
 struct wilc_sdio {
bool irq_gpio;
u32 block_size;
-   int nint;
int has_thrpt_enh3;
 };
 
@@ -790,6 +789,7 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 
*int_status)
struct sdio_func *func = dev_to_sdio_func(wilc->dev);
struct wilc_sdio *sdio_priv = wilc->bus_data;
u32 tmp;
+   u8 irq_flags;
struct sdio_cmd52 cmd;
 
wilc_sdio_read_size(wilc, &tmp);
@@ -798,44 +798,22 @@ static int wilc_sdio_read_int(struct wilc *wilc, u32 
*int_status)
 *  Read IRQ flags
 **/
if (!sdio_priv->irq_gpio) {
-   int i;
-
-   cmd.read_write = 0;
cmd.function = 1;
cmd.address = 0x04;
-   cmd.data = 0;
-   wilc_sdio_cmd52(wilc, &cmd);
-
-   if (cmd.data & BIT(0))
-   tmp |= INT_0;
-   if (cmd.data & BIT(2))
-   tmp |= INT_1;
-   if (cmd.data & BIT(3))
-   tmp |= INT_2;
-   if (cmd.data & BIT(4))
-   tmp |= INT_3;
-   if (cmd.data & BIT(5))
-   tmp |= INT_4;
-   for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) {
-   if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) {
-   dev_err(&func->dev,
-   "Unexpected interrupt (1) : tmp=%x, 
data=%x\n",
-   tmp, cmd.data);
-   break;
-   }
-   }
} else {
-   u32 irq_flags;
-
-   cmd.read_write = 0;
cmd.function = 0;
-   cmd.raw = 0;
cmd.address = 0xf7;
-   cmd.data = 0;
-   wilc_sdio_cmd52(wilc, &cmd);
-   irq_flags = cmd.data & 0x1f;
-   tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET);
}
+   cmd.raw = 0;
+   cmd.read_write = 0;
+   cmd.data = 0;
+   wilc_sdio_cmd52(wilc, &cmd);
+   irq_flags = cmd.data;
+   tmp |= FIELD_PREP(IRG_FLAGS_MASK, cmd.data);
+
+   if (FIELD_GET(UNHANDLED_IRQ_MASK, irq_flags))
+   dev_err(&func->dev, "Unexpected interrupt (1) int=%lx\n",
+   FIELD_GET(UNHANDLED_IRQ_MASK, irq_flags));
 
*int_status = tmp;
 
@@ -890,38 +868,36 @@ static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 
val)
 * Must clear each interrupt individually.
 */
u32 flags;
+   int i;
 
flags = val & (BIT(MAX_NUM_INT) - 1);
-   if (flags) {
-   int i;
-
-   for (i = 0; i < sdio_priv->nint; i++) {
-   if (flags & 1) {
-   struct sdio_cmd52 cmd;
-
-   cmd.read_write = 1;
-   cmd.function = 0;
-   cmd.raw = 0;
-   cmd.address = 0xf8;
-   cmd.data = BIT(i);
-
-   ret = wilc_sdio_cmd52(wilc, &cmd);
-   if (ret) {
-   dev_err(&func->dev,
-   "Failed cmd52, set 0xf8 
data (%d) ...\n",
-   __LINE__);
-   return ret;
-   }
+   for (i = 0; i < NUM_INT_EXT && flags; i++) {
+   if (flags & BIT(i)) {
+   struct sdio_cmd52 cmd;
+
+   cmd.read_write = 1;
+   cmd.function = 0;
+   cmd.raw = 0;
+   cmd.address = 0xf8;
+   cmd.data = BIT(i);
+
+   ret = wilc_sdio_cmd52(wilc, &cmd);
+   if (ret) {
+   dev_err(&func->dev,
+   "Failed cmd52, set 0xf8 data 
(%d) ...\n",
+  

[PATCH AUTOSEL 5.5 019/542] media: meson: add missing allocation failure check on new_buf

2020-02-14 Thread Sasha Levin
From: Colin Ian King 

[ Upstream commit 11e0e167d071a28288a7a0a211d48c571d19b56f ]

Currently if the allocation of new_buf fails then a null pointer
dereference occurs when assiging new_buf->vb. Avoid this by returning
early on a memory allocation failure as there is not much more can
be done at this point.

Addresses-Coverity: ("Dereference null return")

Fixes: 3e7f51bd9607 ("media: meson: add v4l2 m2m video decoder driver")
Signed-off-by: Colin Ian King 
Reviewed-by: Kevin Hilman 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/meson/vdec/vdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/meson/vdec/vdec.c 
b/drivers/staging/media/meson/vdec/vdec.c
index 0a1a04fd5d13d..8dd1396909d7e 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -133,6 +133,8 @@ vdec_queue_recycle(struct amvdec_session *sess, struct 
vb2_buffer *vb)
struct amvdec_buffer *new_buf;
 
new_buf = kmalloc(sizeof(*new_buf), GFP_KERNEL);
+   if (!new_buf)
+   return;
new_buf->vb = vb;
 
mutex_lock(&sess->bufs_recycle_lock);
-- 
2.20.1

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


RE

2020-02-14 Thread David Abula
Hallo,
Schönen Tag,
Bitte nehmen Sie meine aufrichtigen Glückwünsche an und ich weiß, dass
diese Botschaft Sie überraschen kann, aber ich rate Ihnen, sie mit
gutem Verständnis zu lesen. Ich bin Rechtsanwalt David Abula aus Togo.
Daher gibt es einen bestimmten Betrag von 11,7 Mio. USD, der von
meinem verstorbenen Kunden, einem Staatsbürger Ihres Landes, der vor
einigen Jahren hier in meinem Land gestorben ist, übrig geblieben ist.
Kann ich Ihnen vertrauen, dass Sie mit Ihnen zusammenarbeiten, um den
Gesamtbetrag von 11,7 Mio. USD auf Ihr Konto in Ihrem Land zu
überweisen? und nachdem wir den Gesamtfonds zu 50% bis 50% geteilt
haben. Außerdem ist meine Frau krank und ich muss sie ins Krankenhaus
im Ausland fliegen, daher möchte ich zum Erfolg dieser Transaktion
gelangen, damit ich mit dem weitermachen kann Behandlung meiner Frau
Wenn Sie Interesse haben, mit mir zusammenzuarbeiten, empfehle ich
Ihnen, mir in meiner E-Mail-Adresse zu antworten, oder Sie geben mir
Ihre E-Mail-Adresse, damit ich Ihnen die vollständigen Details über
die Transaktion senden kann, damit Sie kann mit mir lesen und zu einem
guten Verständnis kommen. Antworten Sie mir auf meine E-Mail-Adresse
(davidabula...@gmail.com). Vielen Dank und ich warte auf Ihre
sofortige
Antwort.
Mit freundlichen Grüßen,
Rechtsanwalt David Abula
Telefon: +22890712188
davidabula...@gmail.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.5 313/542] staging: rtl8188: avoid excessive stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit c497ae2077c055b85c1bf04f3d182a84bd8f365b ]

The rtl8188 copy of the os_dep support code causes a
warning about a very significant stack usage in the translate_scan()
function:

drivers/staging/rtl8188eu/os_dep/ioctl_linux.c: In function 'translate_scan':
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:306:1: error: the frame size of 
1560 bytes is larger than 1400 bytes [-Werror=frame-larger-than=]

Use the same trick as in the rtl8723bs copy of the same function, and
allocate it dynamically.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200104214832.558198-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 710c33fd49658..47f4cc6a19a9a 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -222,18 +222,21 @@ static char *translate_scan(struct adapter *padapter,
 
/* parsing WPA/WPA2 IE */
{
-   u8 buf[MAX_WPA_IE_LEN];
+   u8 *buf;
u8 wpa_ie[255], rsn_ie[255];
u16 wpa_len = 0, rsn_len = 0;
u8 *p;
 
+   buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
+   if (!buf)
+   return start;
+
rtw_get_sec_ie(pnetwork->network.ies, 
pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.ssid.ssid));
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
 
if (wpa_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "wpa_ie=");
for (i = 0; i < wpa_len; i++)
p += sprintf(p, "%02x", wpa_ie[i]);
@@ -250,7 +253,6 @@ static char *translate_scan(struct adapter *padapter,
}
if (rsn_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "rsn_ie=");
for (i = 0; i < rsn_len; i++)
p += sprintf(p, "%02x", rsn_ie[i]);
@@ -264,6 +266,7 @@ static char *translate_scan(struct adapter *padapter,
iwe.u.data.length = rsn_len;
start = iwe_stream_add_point(info, start, stop, &iwe, 
rsn_ie);
}
+   kfree(buf);
}
 
{/* parsing WPS IE */
-- 
2.20.1

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


[PATCH AUTOSEL 5.5 353/542] vme: bridges: reduce stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]

With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake
grows above the warning limit:

drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':
drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':
drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]

The problem is that in some configurations, each call to
fake_vmereadX() puts another variable on the stack.

Reduce the amount of inlining to get back to the previous state,
with no function using more than 200 bytes each.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200107200610.3482901-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/vme/bridges/vme_fake.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 3208a4409e44e..6a1bc284f297c 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -414,8 +414,9 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
}
 }
 
-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
+  unsigned long long addr,
+  u32 aspace, u32 cycle)
 {
u8 retval = 0xff;
int i;
@@ -446,8 +447,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u16 retval = 0x;
int i;
@@ -478,8 +480,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u32 retval = 0x;
int i;
@@ -609,8 +612,9 @@ static ssize_t fake_master_read(struct vme_master_resource 
*image, void *buf,
return retval;
 }
 
-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
-  unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
+ u8 *buf, unsigned long long addr,
+ u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -639,8 +643,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 
*buf,
 
 }
 
-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
+  u16 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -669,8 +674,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 
*buf,
 
 }
 
-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
+  u32 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
-- 
2.20.1

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


[PATCH AUTOSEL 5.5 392/542] staging: wfx: fix possible overflow on jiffies comparaison

2020-02-14 Thread Sasha Levin
From: Jérôme Pouiller 

[ Upstream commit def39be019b6494acd3570ce6f3f11ba1c3203a3 ]

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is recommended to use function time_*() to compare jiffies.

Signed-off-by: Jérôme Pouiller 
Link: 
https://lore.kernel.org/r/20200115135338.14374-45-jerome.pouil...@silabs.com
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/wfx/data_tx.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index b13d7341f8bba..0c6a3a1a1ddfd 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -282,8 +282,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif)
 static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
 {
int i, ret = 0;
-   unsigned long max_inactivity = 0;
-   unsigned long now = jiffies;
+   unsigned long oldest;
 
spin_lock_bh(&wvif->ps_state_lock);
for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) {
@@ -292,13 +291,10 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const 
u8 *mac)
break;
} else if (wvif->link_id_db[i].status != WFX_LINK_HARD &&
   !wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) {
-   unsigned long inactivity =
-   now - wvif->link_id_db[i].timestamp;
-
-   if (inactivity < max_inactivity)
-   continue;
-   max_inactivity = inactivity;
-   ret = i + 1;
+   if (!ret || time_after(oldest, 
wvif->link_id_db[i].timestamp)) {
+   oldest = wvif->link_id_db[i].timestamp;
+   ret = i + 1;
+   }
}
}
 
-- 
2.20.1

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


[PATCH AUTOSEL 5.4 015/459] media: meson: add missing allocation failure check on new_buf

2020-02-14 Thread Sasha Levin
From: Colin Ian King 

[ Upstream commit 11e0e167d071a28288a7a0a211d48c571d19b56f ]

Currently if the allocation of new_buf fails then a null pointer
dereference occurs when assiging new_buf->vb. Avoid this by returning
early on a memory allocation failure as there is not much more can
be done at this point.

Addresses-Coverity: ("Dereference null return")

Fixes: 3e7f51bd9607 ("media: meson: add v4l2 m2m video decoder driver")
Signed-off-by: Colin Ian King 
Reviewed-by: Kevin Hilman 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/meson/vdec/vdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/meson/vdec/vdec.c 
b/drivers/staging/media/meson/vdec/vdec.c
index 0a1a04fd5d13d..8dd1396909d7e 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -133,6 +133,8 @@ vdec_queue_recycle(struct amvdec_session *sess, struct 
vb2_buffer *vb)
struct amvdec_buffer *new_buf;
 
new_buf = kmalloc(sizeof(*new_buf), GFP_KERNEL);
+   if (!new_buf)
+   return;
new_buf->vb = vb;
 
mutex_lock(&sess->bufs_recycle_lock);
-- 
2.20.1

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


[PATCH AUTOSEL 5.4 272/459] staging: rtl8188: avoid excessive stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit c497ae2077c055b85c1bf04f3d182a84bd8f365b ]

The rtl8188 copy of the os_dep support code causes a
warning about a very significant stack usage in the translate_scan()
function:

drivers/staging/rtl8188eu/os_dep/ioctl_linux.c: In function 'translate_scan':
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:306:1: error: the frame size of 
1560 bytes is larger than 1400 bytes [-Werror=frame-larger-than=]

Use the same trick as in the rtl8723bs copy of the same function, and
allocate it dynamically.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200104214832.558198-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index ec5835d1aa8ce..9f0418ee75284 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -229,18 +229,21 @@ static char *translate_scan(struct adapter *padapter,
 
/* parsing WPA/WPA2 IE */
{
-   u8 buf[MAX_WPA_IE_LEN];
+   u8 *buf;
u8 wpa_ie[255], rsn_ie[255];
u16 wpa_len = 0, rsn_len = 0;
u8 *p;
 
+   buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
+   if (!buf)
+   return start;
+
rtw_get_sec_ie(pnetwork->network.ies, 
pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.ssid.ssid));
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
 
if (wpa_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "wpa_ie=");
for (i = 0; i < wpa_len; i++)
p += sprintf(p, "%02x", wpa_ie[i]);
@@ -257,7 +260,6 @@ static char *translate_scan(struct adapter *padapter,
}
if (rsn_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "rsn_ie=");
for (i = 0; i < rsn_len; i++)
p += sprintf(p, "%02x", rsn_ie[i]);
@@ -271,6 +273,7 @@ static char *translate_scan(struct adapter *padapter,
iwe.u.data.length = rsn_len;
start = iwe_stream_add_point(info, start, stop, &iwe, 
rsn_ie);
}
+   kfree(buf);
}
 
{/* parsing WPS IE */
-- 
2.20.1

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


[PATCH AUTOSEL 5.4 308/459] vme: bridges: reduce stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]

With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake
grows above the warning limit:

drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':
drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':
drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]

The problem is that in some configurations, each call to
fake_vmereadX() puts another variable on the stack.

Reduce the amount of inlining to get back to the previous state,
with no function using more than 200 bytes each.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200107200610.3482901-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/vme/bridges/vme_fake.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 3208a4409e44e..6a1bc284f297c 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -414,8 +414,9 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
}
 }
 
-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
+  unsigned long long addr,
+  u32 aspace, u32 cycle)
 {
u8 retval = 0xff;
int i;
@@ -446,8 +447,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u16 retval = 0x;
int i;
@@ -478,8 +480,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u32 retval = 0x;
int i;
@@ -609,8 +612,9 @@ static ssize_t fake_master_read(struct vme_master_resource 
*image, void *buf,
return retval;
 }
 
-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
-  unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
+ u8 *buf, unsigned long long addr,
+ u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -639,8 +643,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 
*buf,
 
 }
 
-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
+  u16 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -669,8 +674,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 
*buf,
 
 }
 
-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
+  u32 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
-- 
2.20.1

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


[PATCH AUTOSEL 4.19 167/252] vme: bridges: reduce stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]

With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake
grows above the warning limit:

drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':
drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':
drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]

The problem is that in some configurations, each call to
fake_vmereadX() puts another variable on the stack.

Reduce the amount of inlining to get back to the previous state,
with no function using more than 200 bytes each.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200107200610.3482901-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/vme/bridges/vme_fake.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 7d83691047f47..685a43bdc2a1d 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -418,8 +418,9 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
}
 }
 
-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
+  unsigned long long addr,
+  u32 aspace, u32 cycle)
 {
u8 retval = 0xff;
int i;
@@ -450,8 +451,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u16 retval = 0x;
int i;
@@ -482,8 +484,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u32 retval = 0x;
int i;
@@ -613,8 +616,9 @@ static ssize_t fake_master_read(struct vme_master_resource 
*image, void *buf,
return retval;
 }
 
-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
-  unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
+ u8 *buf, unsigned long long addr,
+ u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -643,8 +647,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 
*buf,
 
 }
 
-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
+  u16 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -673,8 +678,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 
*buf,
 
 }
 
-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
+  u32 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
-- 
2.20.1

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


[PATCH AUTOSEL 4.19 144/252] staging: rtl8188: avoid excessive stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit c497ae2077c055b85c1bf04f3d182a84bd8f365b ]

The rtl8188 copy of the os_dep support code causes a
warning about a very significant stack usage in the translate_scan()
function:

drivers/staging/rtl8188eu/os_dep/ioctl_linux.c: In function 'translate_scan':
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:306:1: error: the frame size of 
1560 bytes is larger than 1400 bytes [-Werror=frame-larger-than=]

Use the same trick as in the rtl8723bs copy of the same function, and
allocate it dynamically.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200104214832.558198-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index bee3c3a7a7a99..2db267a74 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -229,18 +229,21 @@ static char *translate_scan(struct adapter *padapter,
 
/* parsing WPA/WPA2 IE */
{
-   u8 buf[MAX_WPA_IE_LEN];
+   u8 *buf;
u8 wpa_ie[255], rsn_ie[255];
u16 wpa_len = 0, rsn_len = 0;
u8 *p;
 
+   buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC);
+   if (!buf)
+   return start;
+
rtw_get_sec_ie(pnetwork->network.ies, 
pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len);
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid));
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, 
("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
 
if (wpa_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "wpa_ie=");
for (i = 0; i < wpa_len; i++)
p += sprintf(p, "%02x", wpa_ie[i]);
@@ -257,7 +260,6 @@ static char *translate_scan(struct adapter *padapter,
}
if (rsn_len > 0) {
p = buf;
-   memset(buf, 0, MAX_WPA_IE_LEN);
p += sprintf(p, "rsn_ie=");
for (i = 0; i < rsn_len; i++)
p += sprintf(p, "%02x", rsn_ie[i]);
@@ -271,6 +273,7 @@ static char *translate_scan(struct adapter *padapter,
iwe.u.data.length = rsn_len;
start = iwe_stream_add_point(info, start, stop, &iwe, 
rsn_ie);
}
+   kfree(buf);
}
 
{/* parsing WPS IE */
-- 
2.20.1

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


[PATCH AUTOSEL 4.14 124/186] vme: bridges: reduce stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]

With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake
grows above the warning limit:

drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':
drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':
drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]

The problem is that in some configurations, each call to
fake_vmereadX() puts another variable on the stack.

Reduce the amount of inlining to get back to the previous state,
with no function using more than 200 bytes each.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200107200610.3482901-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/vme/bridges/vme_fake.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 30b3acc938330..e81ec763b 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -418,8 +418,9 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
}
 }
 
-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
+  unsigned long long addr,
+  u32 aspace, u32 cycle)
 {
u8 retval = 0xff;
int i;
@@ -450,8 +451,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u16 retval = 0x;
int i;
@@ -482,8 +484,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u32 retval = 0x;
int i;
@@ -613,8 +616,9 @@ static ssize_t fake_master_read(struct vme_master_resource 
*image, void *buf,
return retval;
 }
 
-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
-  unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
+ u8 *buf, unsigned long long addr,
+ u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -643,8 +647,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 
*buf,
 
 }
 
-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
+  u16 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -673,8 +678,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 
*buf,
 
 }
 
-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
+  u32 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
-- 
2.20.1

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


[PATCH AUTOSEL 4.9 097/141] vme: bridges: reduce stack usage

2020-02-14 Thread Sasha Levin
From: Arnd Bergmann 

[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]

With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake
grows above the warning limit:

drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':
drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]
drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':
drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is 
larger than 1024 bytes [-Werror=frame-larger-than=]

The problem is that in some configurations, each call to
fake_vmereadX() puts another variable on the stack.

Reduce the amount of inlining to get back to the previous state,
with no function using more than 200 bytes each.

Signed-off-by: Arnd Bergmann 
Link: https://lore.kernel.org/r/20200107200610.3482901-1-a...@arndb.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/vme/bridges/vme_fake.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 30b3acc938330..e81ec763b 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -418,8 +418,9 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
}
 }
 
-static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge,
+  unsigned long long addr,
+  u32 aspace, u32 cycle)
 {
u8 retval = 0xff;
int i;
@@ -450,8 +451,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u16 retval = 0x;
int i;
@@ -482,8 +484,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, 
unsigned long long addr,
return retval;
 }
 
-static u32 fake_vmeread32(struct fake_driver *bridge, unsigned long long addr,
-   u32 aspace, u32 cycle)
+static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge,
+unsigned long long addr,
+u32 aspace, u32 cycle)
 {
u32 retval = 0x;
int i;
@@ -613,8 +616,9 @@ static ssize_t fake_master_read(struct vme_master_resource 
*image, void *buf,
return retval;
 }
 
-static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf,
-  unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge,
+ u8 *buf, unsigned long long addr,
+ u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -643,8 +647,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 
*buf,
 
 }
 
-static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge,
+  u16 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
@@ -673,8 +678,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 
*buf,
 
 }
 
-static void fake_vmewrite32(struct fake_driver *bridge, u32 *buf,
-   unsigned long long addr, u32 aspace, u32 cycle)
+static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge,
+  u32 *buf, unsigned long long 
addr,
+  u32 aspace, u32 cycle)
 {
int i;
unsigned long long start, end, offset;
-- 
2.20.1

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


Re: [PATCH v2 1/2] staging: exfat: remove DOSNAMEs.

2020-02-14 Thread Greg Kroah-Hartman
On Fri, Feb 14, 2020 at 12:31:39PM +0900, Tetsuhiro Kohada wrote:
> remove 'dos_name','ShortName' and related definitions.
> 
> 'dos_name' and 'ShortName' are definitions before VFAT.
> These are never used in exFAT.
> 
> Signed-off-by: Tetsuhiro Kohada 
> ---
> Changes in v2:
> - Rebase to linux-next-next-20200213.

I think you might need to rebase again, this patch doesn't apply at all
to my tree :(

sorry,

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


Re: [PATCH v4 01/10] staging: most: remove device from interface structure

2020-02-14 Thread Greg KH
On Thu, Feb 06, 2020 at 09:14:55AM +, christian.gr...@microchip.com wrote:
> On Fri, 2020-01-24 at 10:09 +0100, Greg KH wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > On Fri, Jan 24, 2020 at 08:56:56AM +, 
> > christian.gr...@microchip.com wrote:
> > > On Thu, 2020-01-23 at 19:18 +0100, Greg KH wrote:
> > > > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > > > know the content is safe
> > > > 
> > > > On Thu, Jan 23, 2020 at 04:38:17PM +0100, Christian Gromm wrote:
> > > > > This patch makes the adapter drivers use their own device
> > > > > structures
> > > > > when registering a most interface with the core module.
> > > > > With this the module that actually operates the physical device
> > > > > is
> > > > > the
> > > > > owner of the device.
> > > > 
> > > > Ick, why?  The interface should be part of sysfs, right, and now
> > > > it
> > > > isn't?
> > > 
> > > It still is. What has changed is that the device that actually
> > > represents the attached hardware is used (see probe function of
> > > the USB adapter driver for instance).
> > 
> > Ah.  Ick.  odd...
> > 
> > > > Who handles the lifetime rules of these interfaces now?  Why
> > > > remove this?
> > > 
> > > The struct device that is allocated when attaching a MOST device is
> > > handling the lifetime and the struct most_interface is
> > > representing this device in the kernel. Hence, registered with
> > > sysfs.
> > > 
> > > This ensures that the device is present in the kernel until its
> > > physical stature is being detached from the system.
> > > The core driver is just the man in the middle that registers the
> > > bus and itself as the driver and organizes the configfs, sysfs and
> > > communication paths to user space.
> > > 
> > > > 
> > > > Why isn't the interface dynamically created properly?  That
> > > > should
> > > > solve
> > > > the lifetime rules here, right?
> > > 
> > > The interface is dynamically allocated. This happens inside the
> > > USB, DIM2, I2C etc. drivers. The struct most_interface is part of
> > > the container struct there.
> > 
> > Ok, I'll take the first 7 of these patches and see what the end
> > result
> > looks like after that, it will make reviewing the code easier...
> 
> Did you find some time for the review yet?

I haven't, sorry.  Can you resend the movement patch so that I can just
see it from that point?

thanks,

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


Re: Fwd: GS_FPGABOOT

2020-02-14 Thread Greg KH
On Fri, Feb 14, 2020 at 07:07:23PM +0530, Shubakar Gowda wrote:
> -- Forwarded message -
> From: Shubakar Gowda 
> Date: Fri, 14 Feb 2020 at 19:04
> Subject: GS_FPGABOOT
> To: 
> 
> 
> Hi,
> 
> I am trying for Selectmap Programming using the driver gs_fgpaboot, But
> when I load the driver I am getting the following errors, please help me
> out to resolve this issue.
> 
> I have configured io file according to our platform.
> 
> root@selectmap_zcu102:~# insmod gs_fpga.ko file="selectmap_top.bit";
> [  477.915891] gs_fpga: module is from the staging directory, the quality
> is unknown, you have been warned.
> [  477.925649] FPGA DOWNLOAD ,
> [  477.930796] FPGA image file name: selectmap_top.bit
> [  477.936190] load fpgaimage selectmap_top.bit
> [  477.940409] platform fpgaboot: Direct firmware load for
> selectmap_top.bit failed with error -2
> [  477.948983] firmware selectmap_top.bit is missing, cannot continue.
> [  477.955224] firmware selectmap_top.bit is missing, cannot continue.
> [  477.961474] gs_load_image error
> [  477.964591] FPGA DOWNLOAD FAIL!!

You do not have the needed firmware file present on your filesystem, not
much the kernel driver can do other than tell you this :)

good luck!

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


Re: [PATCH] staging: exfat: add exfat filesystem code to staging

2020-02-14 Thread Pali Rohár
On Friday 14 February 2020 17:16:18 Valdis Klētnieks wrote:
> On Thu, 13 Feb 2020 16:18:47 -0500, Sasha Levin said:
> 
> > >> I was hoping that it would be possible to easily use secondary FAT table
> > >> (from TexFAT extension) for redundancy without need to implement full
> > >> TexFAT, which could be also backward compatible with systems which do
> > >> not implement TexFAT extension at all. Similarly like using FAT32 disk
> > >> with two FAT tables is possible also on system which use first FAT
> > >> table.
> 
> OK.. maybe I'm not sufficiently caffeinated, but how do you use 2 FAT tables 
> on
> a physical device and expect it to work properly on a system that uses just 
> the
> first FAT table, if the device is set to "use second table" when you mount it?
> That sounds just too much like the failure modes of running fsck on a mounted
> filesystem

Idea is simple. Expects that we have a clean filesystem in correct
state. We load primary/active/main FAT table (just call it FAT1) and all
changes to filesystem would be done via second non-active FAT table
(FAT2). At unmount or sync or flush buffer times, FAT2 would be copied
back to the FAT1 and filesystem would be back in clean state.

So this should not break support for implementations which use just
FAT1. And if above implementation which use both FAT1 and FAT2 "crash"
during write operations to FAT2 it may be possible to reconstruct and
repair some parts of filesystem from FAT1 (as it would contain previous
state of some filesystem parts).

Via dirty bit can be detected if proper unmount occurred or not, and
fsck implementation could do use this fact and try to do repairing
(possible by asking user what should do).

Of course if implementation use only FAT1 we cannot use FAT2 for
repairing and therefore fsck should really ask user if it should use
FAT2 for repair or not.

If implementation use only FAT1, does not crash and let filesystem in
clean/correct state then there should not be any problem for
implementation which can use both FATs as it reads main state from FAT1.
Therefore these two implementations should be compatible and problem can
happen only if they let filesystem in inconsistent state. (But if they
let it in inconsistent state, then any implementation may have troubles
and fsck is needed).

I hope that it is more clear now...

> > >By the chance, is there any possibility to release TexFAT specification?
> > >Usage of more FAT tables (even for Linux) could help with data recovery.
> >
> > This would be a major pain in the arse to pull off (even more that
> > releasing exFAT itself) because TexFAT is effectively dead and no one
> > here cares about it. It's not even the case that there are devices which
> > are now left unsupported, the whole TexFAT scheme is just dead and gone.
> >
> > Could I point you to the TexFAT patent instead
> > (https://patents.google.com/patent/US7613738B2/en)? It describes well
> > how TexFAT used to work.
> 
> I don't think anybody wants the full TexFAT support - but having a backup copy
> of the FAT would be nice in some circumstances.

Main problem is that we do not know what "full TexFAT support" means as
currently it is secret.

My original question for TexFAT was also because of NumberOfFats set to
2 is according to released exFAT specification possible only for TexFAT
volumes.

And from reading whole exFAT specification I see that better data
recovery can be achieved only by having backup copy of FAT table (and
allocation bitmap), which is limited to (currently undocumented) TexFAT
extension.

-- 
Pali Rohár
pali.ro...@gmail.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: exfat: add exfat filesystem code to staging

2020-02-14 Thread Valdis Klētnieks
On Thu, 13 Feb 2020 16:18:47 -0500, Sasha Levin said:

> >> I was hoping that it would be possible to easily use secondary FAT table
> >> (from TexFAT extension) for redundancy without need to implement full
> >> TexFAT, which could be also backward compatible with systems which do
> >> not implement TexFAT extension at all. Similarly like using FAT32 disk
> >> with two FAT tables is possible also on system which use first FAT
> >> table.

OK.. maybe I'm not sufficiently caffeinated, but how do you use 2 FAT tables on
a physical device and expect it to work properly on a system that uses just the
first FAT table, if the device is set to "use second table" when you mount it?
That sounds just too much like the failure modes of running fsck on a mounted
filesystem

> >By the chance, is there any possibility to release TexFAT specification?
> >Usage of more FAT tables (even for Linux) could help with data recovery.
>
> This would be a major pain in the arse to pull off (even more that
> releasing exFAT itself) because TexFAT is effectively dead and no one
> here cares about it. It's not even the case that there are devices which
> are now left unsupported, the whole TexFAT scheme is just dead and gone.
>
> Could I point you to the TexFAT patent instead
> (https://patents.google.com/patent/US7613738B2/en)? It describes well
> how TexFAT used to work.

I don't think anybody wants the full TexFAT support - but having a backup copy
of the FAT would be nice in some circumstances.

Actually, that raises an question

What the published spec says:

The File Allocation Table (FAT) region may contain up to two FATs, one in the
First FAT sub-region and another in the Second FAT sub-region. The NumberOfFats
field describes how many FATs this region contains. The valid values for the
NumberOfFats field are 1 and 2. Therefore, the First FAT sub-region always
contains a FAT. If the NumberOfFats field is two, then the Second FAT
sub-region also contains a FAT.

The ActiveFat field of the VolumeFlags field describes which FAT is active.
Only the VolumeFlags field in the Main Boot Sector is current. Implementations
shall treat the FAT which is not active as stale. Use of the inactive FAT and
switching between FATs is implementation specific.

Sasha:  can you find out what the Windows implementation does regarding that
last sentence?  Does it actively use both FAT sub-regions and switch between
them (probably not), or does it read the ActiveFAT value and use that one, or
does Windows just use NumberOfFats == 1?

I'm assuming that the fact the doc also says "NumberOfFats == 2 is only valid
for TexFAT volumes" possibly means "Microsoft thinks that's hardcoded at 1"
given the death of TexFAT.  That would make adding alternate FAT support a
major challenge.

On the other hand, if Windows actually looks at the NumberOfFats value, finds
a 2, and ActiveFAT ==1 (meaning use second table) and says "OK, whatever" and
just uses the second table from there on out, it becomes a lot easier.




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


[PATCH] staging: fsl-dpaa2: ethsw: ethsw.c: Fix line over 80 characters

2020-02-14 Thread Sandesh Kenjana Ashok
Issue found by checkpatch.

Signed-off-by: Sandesh Kenjana Ashok 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 39c0fe347188..676d1ad1b50d 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1492,7 +1492,8 @@ static void ethsw_unregister_notifier(struct device *dev)
err = unregister_switchdev_blocking_notifier(nb);
if (err)
dev_err(dev,
-   "Failed to unregister switchdev blocking notifier 
(%d)\n", err);
+   "Failed to unregister switchdev blocking notifier 
(%d)\n",
+   err);
 
err = unregister_switchdev_notifier(ðsw->port_switchdev_nb);
if (err)
-- 
2.17.1

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


Re: [PATCH] staging: exfat: add exfat filesystem code to staging

2020-02-14 Thread Valdis Klētnieks

> Idea is simple. Expects that we have a clean filesystem in correct
> state. We load primary/active/main FAT table (just call it FAT1) and all
> changes to filesystem would be done via second non-active FAT table
> (FAT2). At unmount or sync or flush buffer times, FAT2 would be copied
> back to the FAT1 and filesystem would be back in clean state.

Somehow, scribbling on the non-active table for actual changes sounds like a
bad idea waiting to happen (partly because if you do that and crash, after the
reboot you remount, and it starts up with the now-stale FAT1 because you never
flagged that FAT as stale.

That means that if we started using the secondary FAT, we'd change the
ActiveFAT variable to indicate that.  And if we do that, we need to also set
num_fat to 2 because num_fat 1 and ActiveFAT pointing at the second FAT is
*definitely* bogus.

And that could result in us crashing and leaving the device with a header that
says 'num_fat == 2', ActiveFAT == second, and the dirty bit set - and the user
next uses the  filesystem on a system/device that hard-codes that there's only 
1 FAT,
so it blindly goes on its merry way using a FAT that's stale and never 
realizing it.

And that's actually the same failure mode as in the first paragraph - you start
off using FAT1 because you don't see an indication that it's stale.


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