Re: [PATCH v3 3/7] lib/hexdump.c: Optionally suppress lines of repeated bytes

2019-06-16 Thread Alastair D'Silva
On Mon, 2019-06-17 at 12:04 +1000, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> Some buffers may only be partially filled with useful data, while the
> rest
> is padded (typically with 0x00 or 0xff).
> 
> This patch introduces a flag to allow the supression of lines of
> repeated
> bytes, which are replaced with '** Skipped %u bytes of value 0x%x **'
> 
> An inline wrapper function is provided for backwards compatibility
> with
> existing code, which maintains the original behaviour.
> 
> Signed-off-by: Alastair D'Silva 
> ---
>  include/linux/printk.h | 25 +---
>  lib/hexdump.c  | 91 --
> 
>  2 files changed, 99 insertions(+), 17 deletions(-)
> 
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index cefd374c47b1..d7754799cfe0 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -481,13 +481,18 @@ enum {
>   DUMP_PREFIX_ADDRESS,
>   DUMP_PREFIX_OFFSET
>  };
> +
>  extern int hex_dump_to_buffer(const void *buf, size_t len, int
> rowsize,
> int groupsize, char *linebuf, size_t
> linebuflen,
> bool ascii);
> +
> +#define HEXDUMP_ASCIIBIT(0)
> +#define HEXDUMP_SUPPRESS_REPEATEDBIT(1)
> +

This is missing the include of linux/bits.h, I'll fix this in the next
version.

-- 
Alastair D'Silva   mob: 0423 762 819
skype: alastair_dsilva
Twitter: @EvilDeece
blog: http://alastair.d-silva.org


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


Re: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function

2019-06-16 Thread Greg Ungerer

Hi Brett,

On 15/6/19 11:53 pm, Brett Neumeier wrote:
[snip]

For what it's worth -- possibly nothing? -- I grabbed the most recent six 
versions of the patch from this thread, including the one here, and did test 
boots of all of them on both a GnuBee PC1 and PC2 (based on 5.1.7). There were 
no perfect results, which is probably not surprising. Here I'm referring to 
different versions of the patch based on the date of the email where it was 
attached, I don't know if there's a better approach.

2019-05-29: 9 success, 1 hang
2019-05-31: 8 success, 2 hang
2019-06-03: 7 success, 3 hang
2019-06-04: 8 success, 2 hang
2019-06-05: 6 success, 4 hang
2019-06-06: 7 success, 3 hang


That is valuable feedback, thanks for taking the time to run
through those variations.

Your results pretty much mirror what I see. Very inconsistent
booting behavior. Sometimes boots, sometimes doesn't. When it
doesn't it is always somewhere in the PCI startup.

Regards
Greg




I've put all the boot message logs (for both successes and hangs) at 
https://repo.freesa.org/gnubee/ in case they are interesting. There are a few 
different common sequences of boot messages before the hangs occur, which I'll 
summarize here:

This happened 10 times:

[    9.056069] mt7621-pci 1e14.pcie: Error applying setting, reverse things 
back
[   10.187679] mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
[   10.198796] mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
[   10.327667] mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
[   10.338771] mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
[   10.467668] mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
[   10.480904] mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
[   11.556073] mt7621-pci 1e14.pcie: PCIE0 enabled
[   11.565784] mt7621-pci 1e14.pcie: PCIE0 enabled
[   11.575497] mt7621-pci 1e14.pcie: PCIE0 enabled
[   11.585244] mt7621-pci 1e14.pcie: PCI coherence region base: 0x6000, 
mask/settings: 0xf002
[   11.603982] mt7621-pci 1e14.pcie: PCI host bridge to bus :00
[   11.616664] pci_bus :00: root bus resource [io  0x]
[   11.628457] pci_bus :00: root bus resource [mem 0x6000-0x6fff]
[   11.642155] pci_bus :00: root bus resource [bus 00-ff]
[   11.655286] pci :00:00.0: bridge configuration invalid ([bus 00-00]), 
reconfiguring
[   11.671259] pci :00:01.0: bridge configuration invalid ([bus 00-00]), 
reconfiguring
[   11.687206] pci :00:02.0: bridge configuration invalid ([bus 00-00]), 
reconfiguring

This happened 4 times, but only when using the 2019-06-04 and 2019-06-05 
patches:

[    9.071852] mt7621-pci 1e14.pcie: Error applying setting, reverse things 
back
[   10.197138] mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
[   10.208254] mt7621-pci 1e14.pcie: Port 0 N_FTS = 1b102800
[   10.337129] mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
[   10.348232] mt7621-pci 1e14.pcie: Port 1 N_FTS = 1b102800
[   10.477129] mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
[   10.490365] mt7621-pci 1e14.pcie: Port 2 N_FTS = 1b102800
[   11.565525] mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
[   11.579392] mt7621-pci 1e14.pcie: PCIE0 enabled
[   11.589105] mt7621-pci 1e14.pcie: PCIE0 enabled
[   11.598853] mt7621-pci 1e14.pcie: PCI coherence region base: 0x6000, 
mask/settings: 0xf002
[   11.617590] mt7621-pci 1e14.pcie: PCI host bridge to bus :00
[   11.630266] pci_bus :00: root bus resource [io  0x]
[   11.642059] pci_bus :00: root bus resource [mem 0x6000-0x6fff]
[   11.655757] pci_bus :00: root bus resource [bus 00-ff]
[   11.668437] pci :00:00.0: bridge configuration invalid ([bus 00-00]), 
reconfiguring
[   11.684402] pci :00:01.0: bridge configuration invalid ([bus 00-00]), 
reconfiguring
[   11.700805] pci :01:00.0: 2.000 Gb/s available PCIe bandwidth, limited 
by 2.5 GT/s x1 link at :00:00.0 (capable of 4.000
Gb/s with 5 GT/s x1 link)
[   11.729362] pci :00:00.0: PCI bridge to [bus 01-ff]
[   11.740320] pci :02:00.0: 2.000 Gb/s available PCIe bandwidth, limited 
by 2.5 GT/s x1 link at :00:01.0 (capable of 4.000
Gb/s with 5 GT/s x1 link)
[   11.768887] pci :00:01.0: PCI bridge to [bus 02-ff]
[   11.779414] pci :00:01.0: BAR 0: no space for [mem size 0x8000]
[   11.792587] pci :00:01.0: BAR 0: failed to assign [mem size 0x8000]
[   11.806461] pci :00:00.0: BAR 0: assigned [mem 0x6000-0x61ff]
[   11.819988] pci :00:00.0: BAR 8: assigned [mem 0x6200-0x620f]
[   11.833516] pci :00:00.0: BAR 9: assigned [mem 0x6210-0x621f 
pref]
[   11.847902] pci :00:01.0: BAR 8: assigned [mem 0x6220-0x622f]
[   11.861431] pci :00:01.0: BAR 9: assigned [mem 0x6230-0x623f 
pref]
[   11.875819] pci :00:00.0: BAR 1: assigned [mem 0x6240-0x6240]
[   11.889350] pci :00:01.0: BAR 1: assigned [mem 0x6241-0x6241]
[   

Re: [PATCH V4 11/16] scsi: aha152x: use sg helper to operate scatterlist

2019-06-16 Thread Finn Thain
On Mon, 17 Jun 2019, Ming Lei wrote:

> Use the scatterlist iterators and remove direct indexing of the
> scatterlist array.
> 
> This way allows us to pre-allocate one small scatterlist, which can be
> chained with one runtime allocated scatterlist if the pre-allocated one
> isn't enough for the whole request.
> 
> Finn added the change to replace SCp.buffers_residual with sg_is_last()
> for fixing updating it, and the similar change has been applied on
> NCR5380.c
> 
> Cc: Finn Thain 
> Signed-off-by: Ming Lei 

Reviewed-by: Finn Thain 

-- 

> ---
>  drivers/scsi/aha152x.c | 42 --
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
> index 97872838b983..6d0518f616cb 100644
> --- a/drivers/scsi/aha152x.c
> +++ b/drivers/scsi/aha152x.c
> @@ -948,7 +948,6 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt,
>  SCp.ptr  : buffer pointer
>  SCp.this_residual: buffer length
>  SCp.buffer   : next buffer
> -SCp.buffers_residual : left buffers in list
>  SCp.phase: current state of the command */
>  
>   if ((phase & resetting) || !scsi_sglist(SCpnt)) {
> @@ -956,13 +955,11 @@ static int aha152x_internal_queue(struct scsi_cmnd 
> *SCpnt,
>   SCpnt->SCp.this_residual = 0;
>   scsi_set_resid(SCpnt, 0);
>   SCpnt->SCp.buffer   = NULL;
> - SCpnt->SCp.buffers_residual = 0;
>   } else {
>   scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
>   SCpnt->SCp.buffer   = scsi_sglist(SCpnt);
>   SCpnt->SCp.ptr  = SG_ADDRESS(SCpnt->SCp.buffer);
>   SCpnt->SCp.this_residual= SCpnt->SCp.buffer->length;
> - SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
>   }
>  
>   DO_LOCK(flags);
> @@ -2030,10 +2027,9 @@ static void datai_run(struct Scsi_Host *shpnt)
>   }
>  
>   if (CURRENT_SC->SCp.this_residual == 0 &&
> - CURRENT_SC->SCp.buffers_residual > 0) {
> + !sg_is_last(CURRENT_SC->SCp.buffer)) {
>   /* advance to next buffer */
> - CURRENT_SC->SCp.buffers_residual--;
> - CURRENT_SC->SCp.buffer++;
> + CURRENT_SC->SCp.buffer = 
> sg_next(CURRENT_SC->SCp.buffer);
>   CURRENT_SC->SCp.ptr   = 
> SG_ADDRESS(CURRENT_SC->SCp.buffer);
>   CURRENT_SC->SCp.this_residual = 
> CURRENT_SC->SCp.buffer->length;
>   }
> @@ -2136,10 +2132,10 @@ static void datao_run(struct Scsi_Host *shpnt)
>   CMD_INC_RESID(CURRENT_SC, -2 * data_count);
>   }
>  
> - if(CURRENT_SC->SCp.this_residual==0 && 
> CURRENT_SC->SCp.buffers_residual>0) {
> + if(CURRENT_SC->SCp.this_residual==0 &&
> +!sg_is_last(CURRENT_SC->SCp.buffer)) {
>   /* advance to next buffer */
> - CURRENT_SC->SCp.buffers_residual--;
> - CURRENT_SC->SCp.buffer++;
> + CURRENT_SC->SCp.buffer = 
> sg_next(CURRENT_SC->SCp.buffer);
>   CURRENT_SC->SCp.ptr   = 
> SG_ADDRESS(CURRENT_SC->SCp.buffer);
>   CURRENT_SC->SCp.this_residual = 
> CURRENT_SC->SCp.buffer->length;
>   }
> @@ -2158,22 +2154,24 @@ static void datao_run(struct Scsi_Host *shpnt)
>  static void datao_end(struct Scsi_Host *shpnt)
>  {
>   if(TESTLO(DMASTAT, DFIFOEMP)) {
> - int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
> - GETSTCNT();
> + int done = GETSTCNT();
> + int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - done;
> + struct scatterlist *sg = scsi_sglist(CURRENT_SC);
>  
>   CMD_INC_RESID(CURRENT_SC, data_count);
>  
> - data_count -= CURRENT_SC->SCp.ptr -
> - SG_ADDRESS(CURRENT_SC->SCp.buffer);
> - while(data_count>0) {
> - CURRENT_SC->SCp.buffer--;
> - CURRENT_SC->SCp.buffers_residual++;
> - data_count -= CURRENT_SC->SCp.buffer->length;
> + /* Locate the first SG entry not yet sent */
> + while (done > 0 && !sg_is_last(sg)) {
> + if (done < sg->length)
> + break;
> + done -= sg->length;
> + sg = sg_next(sg);
>   }
> - CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
> - data_count;
> - CURRENT_SC->SCp.this_residual = 

[PATCH V4 16/16] NCR5380: Support chained sg lists

2019-06-16 Thread Ming Lei
From: Finn Thain 

My understanding is that support for chained scatterlists is to
become mandatory for LLDs.

Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Cc: Michael Schmitz 
Reviewed-by: Michael Schmitz 
Signed-off-by: Finn Thain 
---
 drivers/scsi/NCR5380.c | 41 ++---
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index fe0535affc14..4ef44fafe6ca 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -149,12 +149,10 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
 
if (scsi_bufflen(cmd)) {
cmd->SCp.buffer = scsi_sglist(cmd);
-   cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
cmd->SCp.this_residual = cmd->SCp.buffer->length;
} else {
cmd->SCp.buffer = NULL;
-   cmd->SCp.buffers_residual = 0;
cmd->SCp.ptr = NULL;
cmd->SCp.this_residual = 0;
}
@@ -163,6 +161,17 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
cmd->SCp.Message = 0;
 }
 
+static inline void advance_sg_buffer(struct scsi_cmnd *cmd)
+{
+   struct scatterlist *s = cmd->SCp.buffer;
+
+   if (!cmd->SCp.this_residual && s && !sg_is_last(s)) {
+   cmd->SCp.buffer = sg_next(s);
+   cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
+   cmd->SCp.this_residual = cmd->SCp.buffer->length;
+   }
+}
+
 /**
  * NCR5380_poll_politely2 - wait for two chip register values
  * @hostdata: host private data
@@ -1672,12 +1681,7 @@ static void NCR5380_information_transfer(struct 
Scsi_Host *instance)
sun3_dma_setup_done != cmd) {
int count;
 
-   if (!cmd->SCp.this_residual && 
cmd->SCp.buffers_residual) {
-   ++cmd->SCp.buffer;
-   --cmd->SCp.buffers_residual;
-   cmd->SCp.this_residual = 
cmd->SCp.buffer->length;
-   cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
-   }
+   advance_sg_buffer(cmd);
 
count = sun3scsi_dma_xfer_len(hostdata, cmd);
 
@@ -1727,15 +1731,11 @@ static void NCR5380_information_transfer(struct 
Scsi_Host *instance)
 * scatter-gather list, move onto the next one.
 */
 
-   if (!cmd->SCp.this_residual && 
cmd->SCp.buffers_residual) {
-   ++cmd->SCp.buffer;
-   --cmd->SCp.buffers_residual;
-   cmd->SCp.this_residual = 
cmd->SCp.buffer->length;
-   cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
-   dsprintk(NDEBUG_INFORMATION, instance, 
"%d bytes and %d buffers left\n",
-cmd->SCp.this_residual,
-cmd->SCp.buffers_residual);
-   }
+   advance_sg_buffer(cmd);
+   dsprintk(NDEBUG_INFORMATION, instance,
+   "this residual %d, sg ents %d\n",
+   cmd->SCp.this_residual,
+   sg_nents(cmd->SCp.buffer));
 
/*
 * The preferred transfer method is going to be
@@ -2136,12 +2136,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
if (sun3_dma_setup_done != tmp) {
int count;
 
-   if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) {
-   ++tmp->SCp.buffer;
-   --tmp->SCp.buffers_residual;
-   tmp->SCp.this_residual = tmp->SCp.buffer->length;
-   tmp->SCp.ptr = sg_virt(tmp->SCp.buffer);
-   }
+   advance_sg_buffer(tmp);
 
count = sun3scsi_dma_xfer_len(hostdata, tmp);
 
-- 
2.20.1

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


[PATCH V4 14/16] scsi: ppa: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/ppa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 35213082e933..a406cc825426 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -590,7 +590,7 @@ static int ppa_completion(struct scsi_cmnd *cmd)
if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
/* if scatter/gather, advance to the next segment */
if (cmd->SCp.buffers_residual--) {
-   cmd->SCp.buffer++;
+   cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
cmd->SCp.this_residual =
cmd->SCp.buffer->length;
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
-- 
2.20.1

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


[PATCH V4 12/16] scsi: imm: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/imm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 64ae418d29f3..56d29f157749 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -686,7 +686,7 @@ static int imm_completion(struct scsi_cmnd *cmd)
if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
/* if scatter/gather, advance to the next segment */
if (cmd->SCp.buffers_residual--) {
-   cmd->SCp.buffer++;
+   cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
cmd->SCp.this_residual =
cmd->SCp.buffer->length;
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
-- 
2.20.1

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


[PATCH V4 11/16] scsi: aha152x: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Finn added the change to replace SCp.buffers_residual with sg_is_last()
for fixing updating it, and the similar change has been applied on
NCR5380.c

Cc: Finn Thain 
Signed-off-by: Ming Lei 
---
 drivers/scsi/aha152x.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 97872838b983..6d0518f616cb 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -948,7 +948,6 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt,
   SCp.ptr  : buffer pointer
   SCp.this_residual: buffer length
   SCp.buffer   : next buffer
-  SCp.buffers_residual : left buffers in list
   SCp.phase: current state of the command */
 
if ((phase & resetting) || !scsi_sglist(SCpnt)) {
@@ -956,13 +955,11 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt,
SCpnt->SCp.this_residual = 0;
scsi_set_resid(SCpnt, 0);
SCpnt->SCp.buffer   = NULL;
-   SCpnt->SCp.buffers_residual = 0;
} else {
scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
SCpnt->SCp.buffer   = scsi_sglist(SCpnt);
SCpnt->SCp.ptr  = SG_ADDRESS(SCpnt->SCp.buffer);
SCpnt->SCp.this_residual= SCpnt->SCp.buffer->length;
-   SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
}
 
DO_LOCK(flags);
@@ -2030,10 +2027,9 @@ static void datai_run(struct Scsi_Host *shpnt)
}
 
if (CURRENT_SC->SCp.this_residual == 0 &&
-   CURRENT_SC->SCp.buffers_residual > 0) {
+   !sg_is_last(CURRENT_SC->SCp.buffer)) {
/* advance to next buffer */
-   CURRENT_SC->SCp.buffers_residual--;
-   CURRENT_SC->SCp.buffer++;
+   CURRENT_SC->SCp.buffer = 
sg_next(CURRENT_SC->SCp.buffer);
CURRENT_SC->SCp.ptr   = 
SG_ADDRESS(CURRENT_SC->SCp.buffer);
CURRENT_SC->SCp.this_residual = 
CURRENT_SC->SCp.buffer->length;
}
@@ -2136,10 +2132,10 @@ static void datao_run(struct Scsi_Host *shpnt)
CMD_INC_RESID(CURRENT_SC, -2 * data_count);
}
 
-   if(CURRENT_SC->SCp.this_residual==0 && 
CURRENT_SC->SCp.buffers_residual>0) {
+   if(CURRENT_SC->SCp.this_residual==0 &&
+  !sg_is_last(CURRENT_SC->SCp.buffer)) {
/* advance to next buffer */
-   CURRENT_SC->SCp.buffers_residual--;
-   CURRENT_SC->SCp.buffer++;
+   CURRENT_SC->SCp.buffer = 
sg_next(CURRENT_SC->SCp.buffer);
CURRENT_SC->SCp.ptr   = 
SG_ADDRESS(CURRENT_SC->SCp.buffer);
CURRENT_SC->SCp.this_residual = 
CURRENT_SC->SCp.buffer->length;
}
@@ -2158,22 +2154,24 @@ static void datao_run(struct Scsi_Host *shpnt)
 static void datao_end(struct Scsi_Host *shpnt)
 {
if(TESTLO(DMASTAT, DFIFOEMP)) {
-   int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
-   GETSTCNT();
+   int done = GETSTCNT();
+   int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - done;
+   struct scatterlist *sg = scsi_sglist(CURRENT_SC);
 
CMD_INC_RESID(CURRENT_SC, data_count);
 
-   data_count -= CURRENT_SC->SCp.ptr -
-   SG_ADDRESS(CURRENT_SC->SCp.buffer);
-   while(data_count>0) {
-   CURRENT_SC->SCp.buffer--;
-   CURRENT_SC->SCp.buffers_residual++;
-   data_count -= CURRENT_SC->SCp.buffer->length;
+   /* Locate the first SG entry not yet sent */
+   while (done > 0 && !sg_is_last(sg)) {
+   if (done < sg->length)
+   break;
+   done -= sg->length;
+   sg = sg_next(sg);
}
-   CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
-   data_count;
-   CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
-   data_count;
+
+   CURRENT_SC->SCp.buffer = sg;
+   CURRENT_SC->SCp.ptr = 

[PATCH V4 15/16] scsi: wd33c93: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/wd33c93.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index 74be04f2357c..ae5935c0a149 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -744,7 +744,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd 
*cmd,
  * source or destination for THIS transfer.
  */
if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
-   ++cmd->SCp.buffer;
+   cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
--cmd->SCp.buffers_residual;
cmd->SCp.this_residual = cmd->SCp.buffer->length;
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
-- 
2.20.1

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


[PATCH V4 13/16] scsi: pcmcia: nsp_cs: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/pcmcia/nsp_cs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index a81748e6e8fb..97416e1dcc5b 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -789,7 +789,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
SCpnt->SCp.buffers_residual != 0 ) {
//nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next 
timeout=%d", time_out);
SCpnt->SCp.buffers_residual--;
-   SCpnt->SCp.buffer++;
+   SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
SCpnt->SCp.ptr   = BUFFER_ADDR;
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
time_out = 1000;
@@ -887,7 +887,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
SCpnt->SCp.buffers_residual != 0 ) {
//nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next");
SCpnt->SCp.buffers_residual--;
-   SCpnt->SCp.buffer++;
+   SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
SCpnt->SCp.ptr   = BUFFER_ADDR;
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
time_out = 1000;
-- 
2.20.1

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


[PATCH V4 10/16] s390: zfcp_fc: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Cc: Steffen Maier 
Cc: Benjamin Block 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: linux-s...@vger.kernel.org
Acked-by: Benjamin Block 
Signed-off-by: Ming Lei 
---
 drivers/s390/scsi/zfcp_fc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 33eddb02ee30..b018b61bd168 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -620,7 +620,7 @@ static void zfcp_fc_sg_free_table(struct scatterlist *sg, 
int count)
 {
int i;
 
-   for (i = 0; i < count; i++, sg++)
+   for (i = 0; i < count; i++, sg = sg_next(sg))
if (sg)
free_page((unsigned long) sg_virt(sg));
else
@@ -641,7 +641,7 @@ static int zfcp_fc_sg_setup_table(struct scatterlist *sg, 
int count)
int i;
 
sg_init_table(sg, count);
-   for (i = 0; i < count; i++, sg++) {
+   for (i = 0; i < count; i++, sg = sg_next(sg)) {
addr = (void *) get_zeroed_page(GFP_KERNEL);
if (!addr) {
zfcp_fc_sg_free_table(sg, i);
-- 
2.20.1

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


[PATCH V4 09/16] staging: rtsx: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Cc: Kim Bradley 
Cc: de...@driverdev.osuosl.org
Cc: Greg Kroah-Hartman 
Signed-off-by: Ming Lei 
---
 drivers/staging/rts5208/rtsx_transport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c 
b/drivers/staging/rts5208/rtsx_transport.c
index 8277d7895608..407c9079b052 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -63,6 +63,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
struct scatterlist *sg =
(struct scatterlist *)scsi_sglist(srb)
+ *index;
+   if (sg_is_chain(sg))
+   sg = sg_chain_ptr(sg);
 
/*
 * This loop handles a single s-g list entry, which may
@@ -86,7 +88,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
/* Transfer continues to next s-g entry */
*offset = 0;
++*index;
-   ++sg;
+   sg = sg_next(sg);
}
 
while (sglen > 0) {
-- 
2.20.1

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


[PATCH V4 05/16] scsi: ipr: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/ipr.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 6d053e220153..383603973937 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3915,22 +3915,22 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist 
*sglist,
 u8 *buffer, u32 len)
 {
int bsize_elem, i, result = 0;
-   struct scatterlist *scatterlist;
+   struct scatterlist *sg;
void *kaddr;
 
/* Determine the actual number of bytes per element */
bsize_elem = PAGE_SIZE * (1 << sglist->order);
 
-   scatterlist = sglist->scatterlist;
+   sg = sglist->scatterlist;
 
-   for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
-   struct page *page = sg_page([i]);
+   for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg), buffer += 
bsize_elem) {
+   struct page *page = sg_page(sg);
 
kaddr = kmap(page);
memcpy(kaddr, buffer, bsize_elem);
kunmap(page);
 
-   scatterlist[i].length = bsize_elem;
+   sg->length = bsize_elem;
 
if (result != 0) {
ipr_trace;
@@ -3939,13 +3939,13 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist 
*sglist,
}
 
if (len % bsize_elem) {
-   struct page *page = sg_page([i]);
+   struct page *page = sg_page(sg);
 
kaddr = kmap(page);
memcpy(kaddr, buffer, len % bsize_elem);
kunmap(page);
 
-   scatterlist[i].length = len % bsize_elem;
+   sg->length = len % bsize_elem;
}
 
sglist->buffer_len = len;
@@ -3966,6 +3966,7 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd 
*ipr_cmd,
struct ipr_ioarcb *ioarcb = _cmd->ioarcb;
struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64;
struct scatterlist *scatterlist = sglist->scatterlist;
+   struct scatterlist *sg;
int i;
 
ipr_cmd->dma_use_sg = sglist->num_dma_sg;
@@ -3974,10 +3975,10 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd 
*ipr_cmd,
 
ioarcb->ioadl_len =
cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * 
ipr_cmd->dma_use_sg);
-   for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
+   for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
ioadl64[i].flags = cpu_to_be32(IPR_IOADL_FLAGS_WRITE);
-   ioadl64[i].data_len = cpu_to_be32(sg_dma_len([i]));
-   ioadl64[i].address = 
cpu_to_be64(sg_dma_address([i]));
+   ioadl64[i].data_len = cpu_to_be32(sg_dma_len(sg));
+   ioadl64[i].address = cpu_to_be64(sg_dma_address(sg));
}
 
ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST);
@@ -3997,6 +3998,7 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd 
*ipr_cmd,
struct ipr_ioarcb *ioarcb = _cmd->ioarcb;
struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl;
struct scatterlist *scatterlist = sglist->scatterlist;
+   struct scatterlist *sg;
int i;
 
ipr_cmd->dma_use_sg = sglist->num_dma_sg;
@@ -4006,11 +4008,11 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd 
*ipr_cmd,
ioarcb->ioadl_len =
cpu_to_be32(sizeof(struct ipr_ioadl_desc) * 
ipr_cmd->dma_use_sg);
 
-   for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
+   for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
ioadl[i].flags_and_data_len =
-   cpu_to_be32(IPR_IOADL_FLAGS_WRITE | 
sg_dma_len([i]));
+   cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(sg));
ioadl[i].address =
-   cpu_to_be32(sg_dma_address([i]));
+   cpu_to_be32(sg_dma_address(sg));
}
 
ioadl[i-1].flags_and_data_len |=
-- 
2.20.1

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


[PATCH V4 08/16] staging: unisys: visorhba: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Cc: de...@driverdev.osuosl.org
Cc: Greg Kroah-Hartman 
Acked-by: Greg Kroah-Hartman 
Signed-off-by: Ming Lei 
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
b/drivers/staging/unisys/visorhba/visorhba_main.c
index 2dad36a05518..dd979ee4dcf1 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -871,12 +871,11 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp,
return;
}
 
-   sg = scsi_sglist(scsicmd);
-   for (i = 0; i < scsi_sg_count(scsicmd); i++) {
-   this_page_orig = kmap_atomic(sg_page(sg + i));
+   scsi_for_each_sg(scsicmd, sg, scsi_sg_count(scsicmd), i) {
+   this_page_orig = kmap_atomic(sg_page(sg));
this_page = (void *)((unsigned long)this_page_orig |
-sg[i].offset);
-   memcpy(this_page, buf + bufind, sg[i].length);
+sg->offset);
+   memcpy(this_page, buf + bufind, sg->length);
kunmap_atomic(this_page_orig);
}
kfree(buf);
-- 
2.20.1

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


[PATCH V4 06/16] scsi: pmcraid: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Signed-off-by: Ming Lei 
---
 drivers/scsi/pmcraid.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index e338d7a4f571..286cac59cb5f 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3270,7 +3270,7 @@ static int pmcraid_copy_sglist(
int direction
 )
 {
-   struct scatterlist *scatterlist;
+   struct scatterlist *sg;
void *kaddr;
int bsize_elem;
int i;
@@ -3279,10 +3279,10 @@ static int pmcraid_copy_sglist(
/* Determine the actual number of bytes per element */
bsize_elem = PAGE_SIZE * (1 << sglist->order);
 
-   scatterlist = sglist->scatterlist;
+   sg = sglist->scatterlist;
 
-   for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
-   struct page *page = sg_page([i]);
+   for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg), buffer += 
bsize_elem) {
+   struct page *page = sg_page(sg);
 
kaddr = kmap(page);
if (direction == DMA_TO_DEVICE)
@@ -3297,11 +3297,11 @@ static int pmcraid_copy_sglist(
return -EFAULT;
}
 
-   scatterlist[i].length = bsize_elem;
+   sg->length = bsize_elem;
}
 
if (len % bsize_elem) {
-   struct page *page = sg_page([i]);
+   struct page *page = sg_page(sg);
 
kaddr = kmap(page);
 
@@ -3312,7 +3312,7 @@ static int pmcraid_copy_sglist(
 
kunmap(page);
 
-   scatterlist[i].length = len % bsize_elem;
+   sg->length = len % bsize_elem;
}
 
if (rc) {
-- 
2.20.1

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


[PATCH V4 07/16] usb: image: microtek: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Cc: Oliver Neukum 
Cc: Greg Kroah-Hartman 
Cc: linux-...@vger.kernel.org
Signed-off-by: Ming Lei 
---
 drivers/usb/image/microtek.c | 20 
 drivers/usb/image/microtek.h |  2 +-
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 607be1f4fe27..0a57c2cc8e5a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -488,7 +488,6 @@ static void mts_command_done( struct urb *transfer )
 
 static void mts_do_sg (struct urb* transfer)
 {
-   struct scatterlist * sg;
int status = transfer->status;
MTS_INT_INIT();
 
@@ -500,13 +499,12 @@ static void mts_do_sg (struct urb* transfer)
mts_transfer_cleanup(transfer);
 }
 
-   sg = scsi_sglist(context->srb);
-   context->fragment++;
+   context->curr_sg = sg_next(context->curr_sg);
mts_int_submit_urb(transfer,
   context->data_pipe,
-  sg_virt([context->fragment]),
-  sg[context->fragment].length,
-  context->fragment + 1 == scsi_sg_count(context->srb) 
?
+  sg_virt(context->curr_sg),
+  context->curr_sg->length,
+  sg_is_last(context->curr_sg) ?
   mts_data_done : mts_do_sg);
 }
 
@@ -526,22 +524,20 @@ static void
 mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
 {
int pipe;
-   struct scatterlist * sg;
-   
+
MTS_DEBUG_GOT_HERE();
 
desc->context.instance = desc;
desc->context.srb = srb;
-   desc->context.fragment = 0;
 
if (!scsi_bufflen(srb)) {
desc->context.data = NULL;
desc->context.data_length = 0;
return;
} else {
-   sg = scsi_sglist(srb);
-   desc->context.data = sg_virt([0]);
-   desc->context.data_length = sg[0].length;
+   desc->context.curr_sg = scsi_sglist(srb);
+   desc->context.data = sg_virt(desc->context.curr_sg);
+   desc->context.data_length = desc->context.curr_sg->length;
}
 
 
diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h
index 66685e59241a..7bd5f4639c4a 100644
--- a/drivers/usb/image/microtek.h
+++ b/drivers/usb/image/microtek.h
@@ -21,7 +21,7 @@ struct mts_transfer_context
void *data;
unsigned data_length;
int data_pipe;
-   int fragment;
+   struct scatterlist *curr_sg;
 
u8 *scsi_status; /* status returned from ep_response after command 
completion */
 };
-- 
2.20.1

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


[PATCH V4 02/16] scsi: advansys: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Reviewed-by: Ewan D. Milne 
Signed-off-by: Ming Lei 
---
 drivers/scsi/advansys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index d37584403c33..b87de8d3d844 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7714,7 +7714,7 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in 
list. */
return ADV_SUCCESS;
}
-   slp++;
+   slp = sg_next(slp);
}
sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
prev_sg_block = sg_block;
-- 
2.20.1

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


[PATCH V4 01/16] scsi: vmw_pscsi: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the scatterlist
array.

This way allows us to pre-allocate one small scatterlist, which can be chained
with one runtime allocated scatterlist if the pre-allocated one isn't enough
for the whole request.

Reviewed-by: Ewan D. Milne 
Signed-off-by: Ming Lei 
---
 drivers/scsi/vmw_pvscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index ecee4b3ff073..d71abd416eb4 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -335,7 +335,7 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx,
BUG_ON(count > PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT);
 
sge = >sgl->sge[0];
-   for (i = 0; i < count; i++, sg++) {
+   for (i = 0; i < count; i++, sg = sg_next(sg)) {
sge[i].addr   = sg_dma_address(sg);
sge[i].length = sg_dma_len(sg);
sge[i].flags  = 0;
-- 
2.20.1

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


[PATCH V4 03/16] scsi: lpfc: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one isn't
enough for the whole request.

Reviewed by: Ewan D. Milne 
Signed-off-by: Ming Lei 
---
 drivers/scsi/lpfc/lpfc_nvmet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index f3d9a5545164..3f803982bd1e 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -2887,8 +2887,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba,
nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT;
nvmewqe->context1 = ndlp;
 
-   for (i = 0; i < rsp->sg_cnt; i++) {
-   sgel = >sg[i];
+   for_each_sg(rsp->sg, sgel, rsp->sg_cnt, i) {
physaddr = sg_dma_address(sgel);
cnt = sg_dma_len(sgel);
sgl->addr_hi = putPaddrHigh(physaddr);
-- 
2.20.1

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


[PATCH V4 04/16] scsi: mvumi: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Use the scatterlist iterators and remove direct indexing of the
scatterlist array.

This way allows us to pre-allocate one small scatterlist, which can be
chained with one runtime allocated scatterlist if the pre-allocated one
isn't enough for the whole request.

Reviewed-by: Ewan D. Milne 
Signed-off-by: Ming Lei 
---
 drivers/scsi/mvumi.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index a5410615edac..0022cd31500a 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -211,8 +211,7 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct 
scsi_cmnd *scmd,
unsigned int sgnum = scsi_sg_count(scmd);
dma_addr_t busaddr;
 
-   sg = scsi_sglist(scmd);
-   *sg_count = dma_map_sg(>pdev->dev, sg, sgnum,
+   *sg_count = dma_map_sg(>pdev->dev, scsi_sglist(scmd), sgnum,
   scmd->sc_data_direction);
if (*sg_count > mhba->max_sge) {
dev_err(>pdev->dev,
@@ -222,12 +221,12 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct 
scsi_cmnd *scmd,
 scmd->sc_data_direction);
return -1;
}
-   for (i = 0; i < *sg_count; i++) {
-   busaddr = sg_dma_address([i]);
+   scsi_for_each_sg(scmd, sg, *sg_count, i) {
+   busaddr = sg_dma_address(sg);
m_sg->baseaddr_l = cpu_to_le32(lower_32_bits(busaddr));
m_sg->baseaddr_h = cpu_to_le32(upper_32_bits(busaddr));
m_sg->flags = 0;
-   sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len([i])));
+   sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len(sg)));
if ((i + 1) == *sg_count)
m_sg->flags |= 1U << mhba->eot_flag;
 
-- 
2.20.1

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


[PATCH V4 00/16] use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
Hi,

Scsi MQ makes a large static allocation for the first scatter gather
list chunk for the driver to use.  This is a performance headache we'd
like to fix by reducing the size of the allocation to a 2 element
array.  Doing this will break the current guarantee that any driver
using SG_ALL doesn't need to use the scatterlist iterators and can get
away with directly dereferencing the array.  Thus we need to update all
drivers to use the scatterlist iterators and remove direct indexing of
the scatterlist array before reducing the initial scatterlist
allocation size in SCSI.

So convert drivers to use scatterlist helper.

There are two types of direct access on scatterlist in SCSI drivers:

1) operate on the scatterlist via scsi_sglist(scmd) directly, then one
local variable of 'struct scatterlist *' is involved.

2) scsi_sglist(scmd) is stored to cmd->SCp.buffer and the scatterlist is
used via cmd->SCp.buffer.

The following coccinelle semantic patch is developed for finding the
above two types of direct scatterlist uses:

@@ struct scatterlist *p; @@
(
- ++p
+ p = sg_next(p)
|
- p++
+ p = sg_next(p)
|
- p = p + 1
+ p = sg_next(p)
|
- p += 1
+ p = sg_next(p)
|
- --p
+ p = sg_non_exist_prev(p)
|
- p--
+ p = sg_non_exist_prev(p)
|
- p = p - 1
+ p = sg_non_exist_prev(p)
|
- p -= 1
+ p = sg_non_exist_prev(p)
)

@@
struct scatterlist *p;
expression data != 0;
@@
- p[data]
+ '!!use sg iterator helper!!'

@@
struct scatterlist[] p;
expression data != 0;
@@
- p[data]
+ '!!use sg iterator helper!!'


@@ struct scsi_cmnd *scmd; @@
(
-   scmd->SCp.buffer++
+   scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
|
-   ++scmd->SCp.buffer
+   scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
|
-   scmd->SCp.buffer += 1
+   scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
|
-   scmd->SCp.buffer = scmd->SCp.buffer + 1
+   scmd->SCp.buffer = sg_next(scmd->SCp.buffer)
|
-   scmd->SCp.buffer--
+   scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
|
-   --scmd->SCp.buffer
+   scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
|
-   scmd->SCp.buffer -= 1
+   scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
|
-   scmd->SCp.buffer = scmd->SCp.buffer - 1
+   scmd->SCp.buffer = sg_no_exit_prev(scmd->SCp.buffer)
)

@@
struct scsi_cmnd *scmd;
expression data != 0;
@@
- scmd->SCp.buffer[data]
+ '!!use sg iterator helper!!'


The 1st 10 patches are for handling type #1, and the other 6 patches
for handling type #2, and all the 16 are found by the above coccinelle
semantic patch.

V4:
- fix building failure on pmcraid's conversion 
- improve the coccinelle semantic patch to cover both two types of
scatterlist direct use
- driver 'staging: rtsx' is covered

V3:
- update commit log and cover letter, most of words are from
James Bottomley 

V2:
- use coccinelle semantic patch for finding direct sgl uses from
scsi command(9 drivers found)
- run 'git grep -E "SCp.buffer"' to find direct sgl uses
from SCp.buffer(6 drivers are found)


Finn Thain (1):
  NCR5380: Support chained sg lists

Ming Lei (15):
  scsi: vmw_pscsi: use sg helper to operate scatterlist
  scsi: advansys: use sg helper to operate scatterlist
  scsi: lpfc: use sg helper to operate scatterlist
  scsi: mvumi: use sg helper to operate scatterlist
  scsi: ipr: use sg helper to operate scatterlist
  scsi: pmcraid: use sg helper to operate scatterlist
  usb: image: microtek: use sg helper to operate scatterlist
  staging: unisys: visorhba: use sg helper to operate scatterlist
  staging: rtsx: use sg helper to operate scatterlist
  s390: zfcp_fc: use sg helper to operate scatterlist
  scsi: aha152x: use sg helper to operate scatterlist
  scsi: imm: use sg helper to operate scatterlist
  scsi: pcmcia: nsp_cs: use sg helper to operate scatterlist
  scsi: ppa: use sg helper to operate scatterlist
  scsi: wd33c93: use sg helper to operate scatterlist

 drivers/s390/scsi/zfcp_fc.c   |  4 +-
 drivers/scsi/NCR5380.c| 41 --
 drivers/scsi/advansys.c   |  2 +-
 drivers/scsi/aha152x.c| 42 +--
 drivers/scsi/imm.c|  2 +-
 drivers/scsi/ipr.c| 28 +++--
 

[PATCH v3 6/7] lib/hexdump.c: Allow multiple groups to be separated by spaces

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

Similar to the previous patch, this patch separates groups by 2 spaces for
the hex fields, and 1 space for the ASCII field.

eg.
buf:: 454d414e 43415053  4e495f45 00584544  NAMESPAC E_INDEX.
buf:0010:  0002      

Signed-off-by: Alastair D'Silva 
---
 include/linux/printk.h |  3 ++
 lib/hexdump.c  | 65 +++---
 2 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index c6b748f66a82..04416e788802 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -487,6 +487,9 @@ enum {
 #define HEXDUMP_2_GRP_LINESBIT(2)
 #define HEXDUMP_4_GRP_LINESBIT(3)
 #define HEXDUMP_8_GRP_LINESBIT(4)
+#define HEXDUMP_2_GRP_SPACES   BIT(5)
+#define HEXDUMP_4_GRP_SPACES   BIT(6)
+#define HEXDUMP_8_GRP_SPACES   BIT(7)
 
 extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
  int groupsize, char *linebuf, size_t linebuflen,
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 4da7d24826fb..dc85ef0dbb0a 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -91,9 +91,37 @@ static const char *group_separator(int group, u64 flags)
if ((flags & HEXDUMP_2_GRP_LINES) && !((group) % 2))
return "|";
 
+   if ((flags & HEXDUMP_8_GRP_SPACES) && !((group) % 8))
+   return "  ";
+
+   if ((flags & HEXDUMP_4_GRP_SPACES) && !((group) % 4))
+   return "  ";
+
+   if ((flags & HEXDUMP_2_GRP_SPACES) && !((group) % 2))
+   return "  ";
+
return " ";
 }
 
+static void separator_parameters(u64 flags, int groupsize, int *sep_chars,
+char *sep)
+{
+   if (flags & (HEXDUMP_2_GRP_LINES | HEXDUMP_2_GRP_SPACES))
+   *sep_chars = groupsize * 2;
+   if (flags & (HEXDUMP_4_GRP_LINES | HEXDUMP_4_GRP_SPACES))
+   *sep_chars = groupsize * 4;
+   if (flags & (HEXDUMP_8_GRP_LINES | HEXDUMP_8_GRP_SPACES))
+   *sep_chars = groupsize * 8;
+
+   if (flags & (HEXDUMP_2_GRP_LINES | HEXDUMP_4_GRP_LINES |
+  HEXDUMP_8_GRP_LINES))
+   *sep = '|';
+
+   if (flags & (HEXDUMP_2_GRP_SPACES | HEXDUMP_4_GRP_SPACES |
+  HEXDUMP_8_GRP_SPACES))
+   *sep = ' ';
+}
+
 /**
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
  * @buf: data blob to dump
@@ -107,6 +135,9 @@ static const char *group_separator(int group, u64 flags)
  * HEXDUMP_2_GRP_LINES:insert a '|' after every 2 groups
  * HEXDUMP_4_GRP_LINES:insert a '|' after every 4 groups
  * HEXDUMP_8_GRP_LINES:insert a '|' after every 8 groups
+ * HEXDUMP_2_GRP_SPACES:   insert a ' ' after every 2 groups
+ * HEXDUMP_4_GRP_SPACES:   insert a ' ' after every 4 groups
+ * HEXDUMP_8_GRP_SPACES:   insert a ' ' after every 8 groups
  *
  * hex_dump_to_buffer() works on one "line" of output at a time, converting
  *  bytes of input to hexadecimal (and optionally printable ASCII)
@@ -138,7 +169,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
int j, lx = 0;
int ascii_column;
int ret;
-   int line_chars = 0;
+   int sep_chars = 0;
+   char sep = 0;
 
if (!is_power_of_2(groupsize) || groupsize > 8)
groupsize = 1;
@@ -152,8 +184,14 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
len = rowsize;
 
ngroups = len / groupsize;
+
ascii_column = rowsize * 2 + rowsize / groupsize + 1;
 
+   // space separators use 2 spaces in the hex output
+   separator_parameters(flags, groupsize, _chars, );
+   if (sep == ' ')
+   ascii_column += rowsize / sep_chars;
+
if (!linebuflen)
goto overflow1;
 
@@ -221,24 +259,17 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
linebuf[lx++] = ' ';
}
 
-   if (flags & HEXDUMP_2_GRP_LINES)
-   line_chars = groupsize * 2;
-   if (flags & HEXDUMP_4_GRP_LINES)
-   line_chars = groupsize * 4;
-   if (flags & HEXDUMP_8_GRP_LINES)
-   line_chars = groupsize * 8;
-
for (j = 0; j < len; j++) {
if (linebuflen < lx + 2)
goto overflow2;
ch = ptr[j];
linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.';
 
-   if (line_chars && ((j + 1) < len) &&
-   ((j + 1) % line_chars == 0)) {
+   if (sep_chars && ((j + 1) < len) &&
+   ((j + 1) % sep_chars == 0)) {
if (linebuflen < lx + 2)

[PATCH v3 5/7] lib/hexdump.c: Allow multiple groups to be separated by lines '|'

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

With the wider display format, it can become hard to identify how many
bytes into the line you are looking at.

The patch adds new flags to hex_dump_to_buffer() and print_hex_dump() to
print vertical lines to separate every N groups of bytes.

eg.
buf:: 454d414e 43415053|4e495f45 00584544  NAMESPAC|E_INDEX.
buf:0010:  0002|   |

Signed-off-by: Alastair D'Silva 
---
 include/linux/printk.h |  3 +++
 lib/hexdump.c  | 59 --
 2 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 97dd29a2bd77..c6b748f66a82 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -484,6 +484,9 @@ enum {
 
 #define HEXDUMP_ASCII  BIT(0)
 #define HEXDUMP_SUPPRESS_REPEATED  BIT(1)
+#define HEXDUMP_2_GRP_LINESBIT(2)
+#define HEXDUMP_4_GRP_LINESBIT(3)
+#define HEXDUMP_8_GRP_LINESBIT(4)
 
 extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
  int groupsize, char *linebuf, size_t linebuflen,
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 08c6084d7daa..4da7d24826fb 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -77,6 +77,23 @@ char *bin2hex(char *dst, const void *src, size_t count)
 }
 EXPORT_SYMBOL(bin2hex);
 
+static const char *group_separator(int group, u64 flags)
+{
+   if (group == 0)
+   return " ";
+
+   if ((flags & HEXDUMP_8_GRP_LINES) && !((group) % 8))
+   return "|";
+
+   if ((flags & HEXDUMP_4_GRP_LINES) && !((group) % 4))
+   return "|";
+
+   if ((flags & HEXDUMP_2_GRP_LINES) && !((group) % 2))
+   return "|";
+
+   return " ";
+}
+
 /**
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
  * @buf: data blob to dump
@@ -87,6 +104,9 @@ EXPORT_SYMBOL(bin2hex);
  * @linebuflen: total size of @linebuf, including space for terminating NUL
  * @flags: A bitwise OR of the following flags:
  * HEXDUMP_ASCII:  include ASCII after the hex output
+ * HEXDUMP_2_GRP_LINES:insert a '|' after every 2 groups
+ * HEXDUMP_4_GRP_LINES:insert a '|' after every 4 groups
+ * HEXDUMP_8_GRP_LINES:insert a '|' after every 8 groups
  *
  * hex_dump_to_buffer() works on one "line" of output at a time, converting
  *  bytes of input to hexadecimal (and optionally printable ASCII)
@@ -118,6 +138,7 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
int j, lx = 0;
int ascii_column;
int ret;
+   int line_chars = 0;
 
if (!is_power_of_2(groupsize) || groupsize > 8)
groupsize = 1;
@@ -144,7 +165,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
 
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,
-  "%s%16.16llx", j ? " " : "",
+  "%s%16.16llx",
+  j ? group_separator(j, flags) : "",
   get_unaligned(ptr8 + j));
if (ret >= linebuflen - lx)
goto overflow1;
@@ -155,7 +177,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
 
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,
-  "%s%8.8x", j ? " " : "",
+  "%s%8.8x",
+  j ? group_separator(j, flags) : "",
   get_unaligned(ptr4 + j));
if (ret >= linebuflen - lx)
goto overflow1;
@@ -166,7 +189,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
 
for (j = 0; j < ngroups; j++) {
ret = snprintf(linebuf + lx, linebuflen - lx,
-  "%s%4.4x", j ? " " : "",
+  "%s%4.4x",
+  j ? group_separator(j, flags) : "",
   get_unaligned(ptr2 + j));
if (ret >= linebuflen - lx)
goto overflow1;
@@ -196,11 +220,26 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
goto overflow2;
linebuf[lx++] = ' ';
}
+
+   if (flags & HEXDUMP_2_GRP_LINES)
+   line_chars = groupsize * 2;
+   if (flags & HEXDUMP_4_GRP_LINES)
+   line_chars = groupsize * 4;
+   if (flags & HEXDUMP_8_GRP_LINES)
+   line_chars = 

[PATCH v3 7/7] lib/hexdump.c: Optionally retain byte ordering

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

The behaviour of hexdump groups is to print the data out as if
it was a native-endian number.

This patch tweaks the documentation to make this clear, and also
adds the HEXDUMP_RETAIN_BYTE_ORDER flag to allow groups of
multiple bytes to be printed without affecting the ordering
of the printed bytes.

Signed-off-by: Alastair D'Silva 
---
 include/linux/printk.h |  1 +
 lib/hexdump.c  | 30 +
 lib/test_hexdump.c | 60 +-
 3 files changed, 68 insertions(+), 23 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 04416e788802..ffc94bedd737 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -490,6 +490,7 @@ enum {
 #define HEXDUMP_2_GRP_SPACES   BIT(5)
 #define HEXDUMP_4_GRP_SPACES   BIT(6)
 #define HEXDUMP_8_GRP_SPACES   BIT(7)
+#define HEXDUMP_RETAIN_BYTE_ORDER  BIT(8)
 
 extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
  int groupsize, char *linebuf, size_t linebuflen,
diff --git a/lib/hexdump.c b/lib/hexdump.c
index dc85ef0dbb0a..ce14abc7701f 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -127,7 +127,8 @@ static void separator_parameters(u64 flags, int groupsize, 
int *sep_chars,
  * @buf: data blob to dump
  * @len: number of bytes in the @buf
  * @rowsize: number of bytes to print per line; must be a multiple of groupsize
- * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
+ * @groupsize: number of bytes to convert to a native endian number and print:
+ *1, 2, 4, 8; default = 1
  * @linebuf: where to put the converted data
  * @linebuflen: total size of @linebuf, including space for terminating NUL
  * @flags: A bitwise OR of the following flags:
@@ -138,6 +139,9 @@ static void separator_parameters(u64 flags, int groupsize, 
int *sep_chars,
  * HEXDUMP_2_GRP_SPACES:   insert a ' ' after every 2 groups
  * HEXDUMP_4_GRP_SPACES:   insert a ' ' after every 4 groups
  * HEXDUMP_8_GRP_SPACES:   insert a ' ' after every 8 groups
+ * HEXDUMP_RETAIN_BYTE_ORDER:  Retain the byte ordering of groups
+ * instead of treating each group as a
+ * native-endian number
  *
  * hex_dump_to_buffer() works on one "line" of output at a time, converting
  *  bytes of input to hexadecimal (and optionally printable ASCII)
@@ -171,6 +175,7 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
int ret;
int sep_chars = 0;
char sep = 0;
+   bool big_endian = (flags & HEXDUMP_RETAIN_BYTE_ORDER) ? 1 : 0;
 
if (!is_power_of_2(groupsize) || groupsize > 8)
groupsize = 1;
@@ -202,10 +207,13 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
const u64 *ptr8 = buf;
 
for (j = 0; j < ngroups; j++) {
+   u64 val = big_endian ?
+   be64_to_cpu(get_unaligned(ptr8 + j)) :
+   get_unaligned(ptr8 + j);
ret = snprintf(linebuf + lx, linebuflen - lx,
   "%s%16.16llx",
   j ? group_separator(j, flags) : "",
-  get_unaligned(ptr8 + j));
+  val);
if (ret >= linebuflen - lx)
goto overflow1;
lx += ret;
@@ -214,10 +222,14 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
const u32 *ptr4 = buf;
 
for (j = 0; j < ngroups; j++) {
+   u32 val = big_endian ?
+   be32_to_cpu(get_unaligned(ptr4 + j)) :
+   get_unaligned(ptr4 + j);
+
ret = snprintf(linebuf + lx, linebuflen - lx,
   "%s%8.8x",
   j ? group_separator(j, flags) : "",
-  get_unaligned(ptr4 + j));
+  val);
if (ret >= linebuflen - lx)
goto overflow1;
lx += ret;
@@ -226,10 +238,14 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
const u16 *ptr2 = buf;
 
for (j = 0; j < ngroups; j++) {
+   u16 val = big_endian ?
+   be16_to_cpu(get_unaligned(ptr2 + j)) :
+   get_unaligned(ptr2 + j);
+
ret = snprintf(linebuf + lx, linebuflen - lx,
   "%s%4.4x",
   

[PATCH v3 2/7] lib/hexdump.c: Relax rowsize checks in hex_dump_to_buffer

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

This patch removes the hardcoded row limits and allows for
other lengths. These lengths must still be a multiple of
groupsize.

This allows structs that are not 16/32 bytes to display on
a single line.

This patch also expands the self-tests to test row sizes
up to 64 bytes (though they can now be arbitrarily long).

Signed-off-by: Alastair D'Silva 
---
 lib/hexdump.c  | 48 --
 lib/test_hexdump.c | 52 ++
 2 files changed, 75 insertions(+), 25 deletions(-)

diff --git a/lib/hexdump.c b/lib/hexdump.c
index 81b70ed37209..3943507bc0e9 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 const char hex_asc[] = "0123456789abcdef";
@@ -80,14 +81,15 @@ EXPORT_SYMBOL(bin2hex);
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
  * @buf: data blob to dump
  * @len: number of bytes in the @buf
- * @rowsize: number of bytes to print per line; must be 16 or 32
+ * @rowsize: number of bytes to print per line; must be a multiple of groupsize
  * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
  * @linebuf: where to put the converted data
  * @linebuflen: total size of @linebuf, including space for terminating NUL
  * @ascii: include ASCII after the hex output
  *
- * hex_dump_to_buffer() works on one "line" of output at a time, i.e.,
- * 16 or 32 bytes of input data converted to hex + ASCII output.
+ * hex_dump_to_buffer() works on one "line" of output at a time, converting
+ *  bytes of input to hexadecimal (and optionally printable ASCII)
+ * until  bytes have been emitted.
  *
  * Given a buffer of u8 data, hex_dump_to_buffer() converts the input data
  * to a hex + ASCII dump at the supplied memory location.
@@ -116,16 +118,17 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
int ascii_column;
int ret;
 
-   if (rowsize != 16 && rowsize != 32)
-   rowsize = 16;
-
-   if (len > rowsize)  /* limit to one line at a time */
-   len = rowsize;
if (!is_power_of_2(groupsize) || groupsize > 8)
groupsize = 1;
if ((len % groupsize) != 0) /* no mixed size output */
groupsize = 1;
 
+   if (rowsize % groupsize)
+   rowsize -= rowsize % groupsize;
+
+   if (len > rowsize)  /* limit to one line at a time */
+   len = rowsize;
+
ngroups = len / groupsize;
ascii_column = rowsize * 2 + rowsize / groupsize + 1;
 
@@ -216,7 +219,7 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
  *  caller supplies trailing spaces for alignment if desired
  * @prefix_type: controls whether prefix of an offset, address, or none
  *  is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
- * @rowsize: number of bytes to print per line; must be 16 or 32
+ * @rowsize: number of bytes to print per line; must be a multiple of groupsize
  * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
  * @buf: data blob to dump
  * @len: number of bytes in the @buf
@@ -226,10 +229,9 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
  * to the kernel log at the specified kernel log level, with an optional
  * leading prefix.
  *
- * print_hex_dump() works on one "line" of output at a time, i.e.,
- * 16 or 32 bytes of input data converted to hex + ASCII output.
  * print_hex_dump() iterates over the entire input @buf, breaking it into
- * "line size" chunks to format and print.
+ * lines of rowsize/groupsize groups of input data converted to hex +
+ * (optionally) ASCII output.
  *
  * E.g.:
  *   print_hex_dump(KERN_DEBUG, "raw data: ", DUMP_PREFIX_ADDRESS,
@@ -246,17 +248,29 @@ void print_hex_dump(const char *level, const char 
*prefix_str, int prefix_type,
 {
const u8 *ptr = buf;
int i, linelen, remaining = len;
-   unsigned char linebuf[32 * 3 + 2 + 32 + 1];
+   unsigned char *linebuf;
+   unsigned int linebuf_len;
 
-   if (rowsize != 16 && rowsize != 32)
-   rowsize = 16;
+   if (rowsize % groupsize)
+   rowsize -= rowsize % groupsize;
+
+   /* Worst case line length:
+* 2 hex chars + space per byte in, 2 spaces, 1 char per byte in, NULL
+*/
+   linebuf_len = rowsize * 3 + 2 + rowsize + 1;
+   linebuf = kzalloc(linebuf_len, GFP_KERNEL);
+   if (!linebuf) {
+   printk("%s%shexdump: Could not alloc %u bytes for buffer\n",
+   level, prefix_str, linebuf_len);
+   return;
+   }
 
for (i = 0; i < len; i += rowsize) {
linelen = min(remaining, rowsize);
remaining -= rowsize;
 
hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
-  linebuf, sizeof(linebuf), ascii);
+

[PATCH v3 4/7] lib/hexdump.c: Replace ascii bool in hex_dump_to_buffer with flags

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

In order to support additional features in hex_dump_to_buffer, replace
the ascii bool parameter with flags.

Signed-off-by: Alastair D'Silva 
---
 drivers/gpu/drm/i915/intel_engine_cs.c|  2 +-
 drivers/isdn/hardware/mISDN/mISDNisar.c   |  6 --
 drivers/mailbox/mailbox-test.c|  2 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c  |  2 +-
 drivers/net/ethernet/synopsys/dwc-xlgmac-common.c |  2 +-
 drivers/net/wireless/ath/ath10k/debug.c   |  3 ++-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c|  2 +-
 drivers/platform/chrome/wilco_ec/debugfs.c|  2 +-
 drivers/scsi/scsi_logging.c   |  8 +++-
 drivers/staging/fbtft/fbtft-core.c|  2 +-
 fs/seq_file.c |  3 ++-
 include/linux/printk.h|  8 
 lib/hexdump.c | 15 ---
 lib/test_hexdump.c|  5 +++--
 14 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c 
b/drivers/gpu/drm/i915/intel_engine_cs.c
index eea9bec04f1b..5df5fffdb848 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1340,7 +1340,7 @@ static void hexdump(struct drm_printer *m, const void 
*buf, size_t len)
WARN_ON_ONCE(hex_dump_to_buffer(buf + pos, len - pos,
rowsize, sizeof(u32),
line, sizeof(line),
-   false) >= sizeof(line));
+   0) >= sizeof(line));
drm_printf(m, "[%04zx] %s\n", pos, line);
 
prev = buf + pos;
diff --git a/drivers/isdn/hardware/mISDN/mISDNisar.c 
b/drivers/isdn/hardware/mISDN/mISDNisar.c
index fd5c52f37802..ccc0ee9d894f 100644
--- a/drivers/isdn/hardware/mISDN/mISDNisar.c
+++ b/drivers/isdn/hardware/mISDN/mISDNisar.c
@@ -71,7 +71,8 @@ send_mbox(struct isar_hw *isar, u8 his, u8 creg, u8 len, u8 
*msg)
 
while (l < (int)len) {
hex_dump_to_buffer(msg + l, len - l, 32, 1,
-  isar->log, 256, 1);
+  isar->log, 256,
+  HEXDUMP_ASCII);
pr_debug("%s: %s %02x: %s\n", isar->name,
 __func__, l, isar->log);
l += 32;
@@ -100,7 +101,8 @@ rcv_mbox(struct isar_hw *isar, u8 *msg)
 
while (l < (int)isar->clsb) {
hex_dump_to_buffer(msg + l, isar->clsb - l, 32,
-  1, isar->log, 256, 1);
+  1, isar->log, 256,
+  HEXDUMP_ASCII);
pr_debug("%s: %s %02x: %s\n", isar->name,
 __func__, l, isar->log);
l += 32;
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 4555d678fadd..23c3fbafdcb2 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -209,7 +209,7 @@ static ssize_t mbox_test_message_read(struct file *filp, 
char __user *userbuf,
hex_dump_to_buffer(ptr,
   MBOX_BYTES_PER_LINE,
   MBOX_BYTES_PER_LINE, 1, touser + l,
-  MBOX_HEXDUMP_LINE_LEN, true);
+  MBOX_HEXDUMP_LINE_LEN, HEXDUMP_ASCII);
 
ptr += MBOX_BYTES_PER_LINE;
l += MBOX_HEXDUMP_LINE_LEN;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 3dd0cecddba8..1e26410cf6c2 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -2992,7 +2992,7 @@ void xgbe_print_pkt(struct net_device *netdev, struct 
sk_buff *skb, bool tx_rx)
unsigned int len = min(skb->len - i, 32U);
 
hex_dump_to_buffer(>data[i], len, 32, 1,
-  buffer, sizeof(buffer), false);
+  buffer, sizeof(buffer), 0);
netdev_dbg(netdev, "  %#06x: %s\n", i, buffer);
}
 
diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c 
b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
index eb1c6b03c329..b80adfa1f890 100644
--- a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
+++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
@@ -349,7 +349,7 @@ void xlgmac_print_pkt(struct net_device *netdev,
unsigned int len = min(skb->len - i, 

[PATCH v3 1/7] lib/hexdump.c: Fix selftests

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

The overflow tests did not account for the situation where no
overflow occurs and len < rowsize.

This patch renames the cryptic variables and accounts for the
above case.

The selftests now pass.

Signed-off-by: Alastair D'Silva 
---
 lib/test_hexdump.c | 47 ++
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c
index 5144899d3c6b..d78ddd62ffd0 100644
--- a/lib/test_hexdump.c
+++ b/lib/test_hexdump.c
@@ -163,45 +163,52 @@ static void __init test_hexdump_overflow(size_t buflen, 
size_t len,
 {
char test[TEST_HEXDUMP_BUF_SIZE];
char buf[TEST_HEXDUMP_BUF_SIZE];
-   int rs = rowsize, gs = groupsize;
-   int ae, he, e, f, r;
-   bool a;
+   int ascii_len, hex_len, expected_len, fill_point, ngroups, rc;
+   bool match;
 
total_tests++;
 
memset(buf, FILL_CHAR, sizeof(buf));
 
-   r = hex_dump_to_buffer(data_b, len, rs, gs, buf, buflen, ascii);
+   rc = hex_dump_to_buffer(data_b, len, rowsize, groupsize, buf, buflen, 
ascii);
 
/*
 * Caller must provide the data length multiple of groupsize. The
 * calculations below are made with that assumption in mind.
 */
-   ae = rs * 2 /* hex */ + rs / gs /* spaces */ + 1 /* space */ + len /* 
ascii */;
-   he = (gs * 2 /* hex */ + 1 /* space */) * len / gs - 1 /* no trailing 
space */;
+   ngroups = rowsize / groupsize;
+   hex_len = (groupsize * 2 /* hex */ + 1 /* spaces */) * ngroups
+ - 1 /* no trailing space */;
+   ascii_len = hex_len + 2 /* space */ + len /* ascii */;
+
+   if (len < rowsize) {
+   ngroups = len / groupsize;
+   hex_len = (groupsize * 2 /* hex */ + 1 /* spaces */) * ngroups
+ - 1 /* no trailing space */;
+   }
 
-   if (ascii)
-   e = ae;
-   else
-   e = he;
+   expected_len = (ascii) ? ascii_len : hex_len;
 
-   f = min_t(int, e + 1, buflen);
+   fill_point = min_t(int, expected_len + 1, buflen);
if (buflen) {
-   test_hexdump_prepare_test(len, rs, gs, test, sizeof(test), 
ascii);
-   test[f - 1] = '\0';
+   test_hexdump_prepare_test(len, rowsize, groupsize, test,
+ sizeof(test), ascii);
+   test[fill_point - 1] = '\0';
}
-   memset(test + f, FILL_CHAR, sizeof(test) - f);
+   memset(test + fill_point, FILL_CHAR, sizeof(test) - fill_point);
 
-   a = r == e && !memcmp(test, buf, TEST_HEXDUMP_BUF_SIZE);
+   match = rc == expected_len && !memcmp(test, buf, TEST_HEXDUMP_BUF_SIZE);
 
buf[sizeof(buf) - 1] = '\0';
 
-   if (!a) {
-   pr_err("Len: %zu buflen: %zu strlen: %zu\n",
-   len, buflen, strnlen(buf, sizeof(buf)));
-   pr_err("Result: %d '%s'\n", r, buf);
-   pr_err("Expect: %d '%s'\n", e, test);
+   if (!match) {
+   pr_err("rowsize: %u groupsize: %u ascii: %d Len: %zu buflen: 
%zu strlen: %zu\n",
+   rowsize, groupsize, ascii, len, buflen,
+   strnlen(buf, sizeof(buf)));
+   pr_err("Result: %d '%-.*s'\n", rc, (int)buflen, buf);
+   pr_err("Expect: %d '%-.*s'\n", expected_len, (int)buflen, test);
failed_tests++;
+
}
 }
 
-- 
2.21.0

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


[PATCH v3 3/7] lib/hexdump.c: Optionally suppress lines of repeated bytes

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

Some buffers may only be partially filled with useful data, while the rest
is padded (typically with 0x00 or 0xff).

This patch introduces a flag to allow the supression of lines of repeated
bytes, which are replaced with '** Skipped %u bytes of value 0x%x **'

An inline wrapper function is provided for backwards compatibility with
existing code, which maintains the original behaviour.

Signed-off-by: Alastair D'Silva 
---
 include/linux/printk.h | 25 +---
 lib/hexdump.c  | 91 --
 2 files changed, 99 insertions(+), 17 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index cefd374c47b1..d7754799cfe0 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -481,13 +481,18 @@ enum {
DUMP_PREFIX_ADDRESS,
DUMP_PREFIX_OFFSET
 };
+
 extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
  int groupsize, char *linebuf, size_t linebuflen,
  bool ascii);
+
+#define HEXDUMP_ASCII  BIT(0)
+#define HEXDUMP_SUPPRESS_REPEATED  BIT(1)
+
 #ifdef CONFIG_PRINTK
-extern void print_hex_dump(const char *level, const char *prefix_str,
+extern void print_hex_dump_ext(const char *level, const char *prefix_str,
   int prefix_type, int rowsize, int groupsize,
-  const void *buf, size_t len, bool ascii);
+  const void *buf, size_t len, u32 flags);
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)\
dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
@@ -496,18 +501,28 @@ extern void print_hex_dump_bytes(const char *prefix_str, 
int prefix_type,
 const void *buf, size_t len);
 #endif /* defined(CONFIG_DYNAMIC_DEBUG) */
 #else
-static inline void print_hex_dump(const char *level, const char *prefix_str,
+static inline void print_hex_dump_ext(const char *level, const char 
*prefix_str,
  int prefix_type, int rowsize, int groupsize,
- const void *buf, size_t len, bool ascii)
+ const void *buf, size_t len, u32 flags)
 {
 }
 static inline void print_hex_dump_bytes(const char *prefix_str, int 
prefix_type,
const void *buf, size_t len)
 {
 }
-
 #endif
 
+static __always_inline void print_hex_dump(const char *level,
+  const char *prefix_str,
+  int prefix_type, int rowsize,
+  int groupsize, const void *buf,
+  size_t len, bool ascii)
+{
+   print_hex_dump_ext(level, prefix_str, prefix_type, rowsize, groupsize,
+   buf, len, ascii ? HEXDUMP_ASCII : 0);
+}
+
+
 #if defined(CONFIG_DYNAMIC_DEBUG)
 #define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
 groupsize, buf, len, ascii)\
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 3943507bc0e9..b781f84e 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -212,8 +212,44 @@ int hex_dump_to_buffer(const void *buf, size_t len, int 
rowsize, int groupsize,
 EXPORT_SYMBOL(hex_dump_to_buffer);
 
 #ifdef CONFIG_PRINTK
+
+/**
+ * buf_is_all - Check if a buffer contains only a single byte value
+ * @buf: pointer to the buffer
+ * @len: the size of the buffer in bytes
+ * @val: outputs the value if if the bytes are identical
+ */
+static bool buf_is_all(const u8 *buf, size_t len, u8 *val_out)
+{
+   size_t i;
+   u8 val;
+
+   if (len <= 1)
+   return false;
+
+   val = buf[0];
+
+   for (i = 1; i < len; i++) {
+   if (buf[i] != val)
+   return false;
+   }
+
+   *val_out = val;
+   return true;
+}
+
+static void announce_skipped(const char *level, const char *prefix_str,
+  u8 val, size_t count)
+{
+   if (count == 0)
+   return;
+
+   printk("%s%s ** Skipped %lu bytes of value 0x%x **\n",
+  level, prefix_str, count, val);
+}
+
 /**
- * print_hex_dump - print a text hex dump to syslog for a binary blob of data
+ * print_hex_dump_ext - dump a binary blob of data to syslog in hexadecimal
  * @level: kernel log level (e.g. KERN_DEBUG)
  * @prefix_str: string to prefix each line with;
  *  caller supplies trailing spaces for alignment if desired
@@ -224,6 +260,10 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
  * @buf: data blob to dump
  * @len: number of bytes in the @buf
  * @ascii: include ASCII after the hex output
+ * @flags: A bitwise OR of the following flags:
+ * HEXDUMP_ASCII:  include ASCII after the hex output
+ * HEXDUMP_SUPPRESS_REPEATED:  suppress repeated lines of identical

[PATCH v3 0/7] Hexdump Enhancements

2019-06-16 Thread Alastair D'Silva
From: Alastair D'Silva 

Apologies for the large CC list, it's a heads up for those responsible
for subsystems where a prototype change in generic code causes a change
in those subsystems.

This series enhances hexdump.

These improve the readability of the dumped data in certain situations
(eg. wide terminals are available, many lines of empty bytes exist, etc).

The default behaviour of hexdump is unchanged, however, the prototype
for hex_dump_to_buffer() has changed, and print_hex_dump() has been
renamed to print_hex_dump_ext(), with a wrapper replacing it for
compatibility with existing code, which would have been too invasive to
change.

Hexdump selftests have be run & confirmed passed.

Changelog:
V3:
 - Fix inline documention
 - use BIT macros
 - use u32 rather than u64 for flags
V2:
 - Fix failing selftests
 - Fix precedence bug in 'Replace ascii bool in hex_dump_to_buffer...'
 - Remove hardcoded new lengths & instead relax the checks in
   hex_dump_to_buffer, allocating the buffer from the heap instead of the
   stack.
 - Replace the skipping of lines of 0x00/0xff with skipping lines of
   repeated characters, announcing what has been skipped.
 - Add spaces as an optional N-group separator
 - Allow byte ordering to be maintained when HEXDUMP_RETAIN_BYTE_ORDERING
   is set.
 - Updated selftests to cover 'Relax rowsize checks' &
   'Optionally retain byte ordering'

Alastair D'Silva (7):
  lib/hexdump.c: Fix selftests
  lib/hexdump.c: Relax rowsize checks in hex_dump_to_buffer
  lib/hexdump.c: Optionally suppress lines of repeated bytes
  lib/hexdump.c: Replace ascii bool in hex_dump_to_buffer with flags
  lib/hexdump.c: Allow multiple groups to be separated by lines '|'
  lib/hexdump.c: Allow multiple groups to be separated by spaces
  lib/hexdump.c: Optionally retain byte ordering

 drivers/gpu/drm/i915/intel_engine_cs.c|   2 +-
 drivers/isdn/hardware/mISDN/mISDNisar.c   |   6 +-
 drivers/mailbox/mailbox-test.c|   2 +-
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c  |   2 +-
 .../net/ethernet/synopsys/dwc-xlgmac-common.c |   2 +-
 drivers/net/wireless/ath/ath10k/debug.c   |   3 +-
 .../net/wireless/intel/iwlegacy/3945-mac.c|   2 +-
 drivers/platform/chrome/wilco_ec/debugfs.c|   2 +-
 drivers/scsi/scsi_logging.c   |   8 +-
 drivers/staging/fbtft/fbtft-core.c|   2 +-
 fs/seq_file.c |   3 +-
 include/linux/printk.h|  34 ++-
 lib/hexdump.c | 260 +++---
 lib/test_hexdump.c| 146 +++---
 14 files changed, 372 insertions(+), 102 deletions(-)

-- 
2.21.0

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


Re: [PATCH] staging: iio: adt7316: Add missing include files

2019-06-16 Thread Yuehaibing
On 2019/6/16 21:11, Jonathan Cameron wrote:
> On Fri, 14 Jun 2019 23:28:46 +0800
> YueHaibing  wrote:
> 
>> Fix build error:
>>
>> drivers/staging/iio/addac/adt7316.c: In function adt7316_store_update_DAC:
>> drivers/staging/iio/addac/adt7316.c:949:3: error: implicit declaration of
>>  function gpiod_set_value; did you mean gpio_set_value? 
>> [-Werror=implicit-function-declaration]
>>gpiod_set_value(chip->ldac_pin, 0);
>>
>> drivers/staging/iio/addac/adt7316.c: In function adt7316_setup_irq:
>> drivers/staging/iio/addac/adt7316.c:1807:13: error: implicit declaration of
>>  function irqd_get_trigger_type; did you mean devm_iio_trigger_free? 
>> [-Werror=implicit-function-declaration]
>>   irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq));
>>
>> Reported-by: Hulk Robot 
>> Fixes: 7f6b6d553df7 ("Staging: iio: adt7316: Add all irq related code in 
>> adt7316_irq_setup()")
>> Fixes: c63460c4298f ("Staging: iio: adt7316: Use device tree data to set 
>> ldac_pin")
>> Signed-off-by: YueHaibing 
> Hi yuehaibing,
> 
> You were second to send a fix for this. I've had it in my
> fixes branch since last week, but not done a pull request quite yet.
> I'll probably send it out later today.

Sorry, our robot report this again and I forgot this ...

> 
> https://patchwork.kernel.org/patch/10978301/
> 
> Thanks,
> 
> Jonathan
> 
>> ---
>>  drivers/staging/iio/addac/adt7316.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/staging/iio/addac/adt7316.c 
>> b/drivers/staging/iio/addac/adt7316.c
>> index 37ce563..9d3d159 100644
>> --- a/drivers/staging/iio/addac/adt7316.c
>> +++ b/drivers/staging/iio/addac/adt7316.c
>> @@ -16,6 +16,8 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  
>>  #include 
>>  #include 
> 
> 
> .
> 

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


Re: [PATCH V3 10/15] scsi: aha152x: use sg helper to operate scatterlist

2019-06-16 Thread Ming Lei
On Fri, Jun 14, 2019 at 08:36:38PM +1000, Finn Thain wrote:
> On Fri, 14 Jun 2019, Ming Lei wrote:
> 
> > 
> > Follows the fixed version, could you review again?
> > 
> > From f03484d4bac083c39d70665cfbadb641093b63de Mon Sep 17 00:00:00 2001
> > From: Ming Lei 
> > Date: Wed, 12 Jun 2019 20:37:35 +0800
> > Subject: [PATCH] scsi: aha152x: use sg helper to operate scatterlist
> > 
> > Use the scatterlist iterators and remove direct indexing of the
> > scatterlist array.
> > 
> > This way allows us to pre-allocate one small scatterlist, which can be
> > chained with one runtime allocated scatterlist if the pre-allocated one
> > isn't enough for the whole request.
> > 
> > Signed-off-by: Ming Lei 
> > ---
> >  drivers/scsi/aha152x.c | 34 --
> >  1 file changed, 20 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
> > index 97872838b983..7faecdefda56 100644
> > --- a/drivers/scsi/aha152x.c
> > +++ b/drivers/scsi/aha152x.c
> > @@ -2033,7 +2033,7 @@ static void datai_run(struct Scsi_Host *shpnt)
> > CURRENT_SC->SCp.buffers_residual > 0) {
> > /* advance to next buffer */
> > CURRENT_SC->SCp.buffers_residual--;
> > -   CURRENT_SC->SCp.buffer++;
> > +   CURRENT_SC->SCp.buffer = 
> > sg_next(CURRENT_SC->SCp.buffer);
> > CURRENT_SC->SCp.ptr   = 
> > SG_ADDRESS(CURRENT_SC->SCp.buffer);
> > CURRENT_SC->SCp.this_residual = 
> > CURRENT_SC->SCp.buffer->length;
> > }
> > @@ -2139,7 +2139,7 @@ static void datao_run(struct Scsi_Host *shpnt)
> > if(CURRENT_SC->SCp.this_residual==0 && 
> > CURRENT_SC->SCp.buffers_residual>0) {
> > /* advance to next buffer */
> > CURRENT_SC->SCp.buffers_residual--;
> > -   CURRENT_SC->SCp.buffer++;
> > +   CURRENT_SC->SCp.buffer = 
> > sg_next(CURRENT_SC->SCp.buffer);
> > CURRENT_SC->SCp.ptr   = 
> > SG_ADDRESS(CURRENT_SC->SCp.buffer);
> > CURRENT_SC->SCp.this_residual = 
> > CURRENT_SC->SCp.buffer->length;
> > }
> > @@ -2158,22 +2158,28 @@ static void datao_run(struct Scsi_Host *shpnt)
> >  static void datao_end(struct Scsi_Host *shpnt)
> >  {
> > if(TESTLO(DMASTAT, DFIFOEMP)) {
> > -   int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
> > -   GETSTCNT();
> > +   int done = GETSTCNT();
> > +   int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) - done;
> 
> I think that's better than my suggestion.
> 
> > +   struct scatterlist *sg = scsi_sglist(CURRENT_SC);
> > +   int i;
> >  
> > CMD_INC_RESID(CURRENT_SC, data_count);
> >  
> > -   data_count -= CURRENT_SC->SCp.ptr -
> > -   SG_ADDRESS(CURRENT_SC->SCp.buffer);
> > -   while(data_count>0) {
> > -   CURRENT_SC->SCp.buffer--;
> > -   CURRENT_SC->SCp.buffers_residual++;
> > -   data_count -= CURRENT_SC->SCp.buffer->length;
> > +   /*
> > +* rewind where we have done, and we have to start from
> > +* the beginning
> > +*/
> 
> How about, "Locate the first SG entry not yet sent".

OK.

> 
> We could use sg_nents_for_len() but it returns a count of sg entries not a 
> scatterlist pointer so it's not very helpful here.
> 
> > +   for (i = 0; done > 0 && !sg_is_last(sg); i++, sg = sg_next(sg)) 
> > {
> > +   if (done < sg->length)
> > +   break;
> > +   done -= sg->length;
> > }
> > -   CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
> > -   data_count;
> > -   CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
> > -   data_count;
> > +
> > +   CURRENT_SC->SCp.buffers_residual = i;
> 
> Contradicting my previous email, that's still not right. I think it would 
> have to be,
> 
>   CURRENT_SC->SCp.buffers_residual = scsi_sg_count(CURRENT_SC) - 
> i;

Right, my fault.

> 
> But we could remove all references to SCp.buffers_residual, like I did in 
> patch 15/15 for NCR5380.c.
> 
> > +   CURRENT_SC->SCp.buffer = sg;
> > +   CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + done;
> > +   CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length -
> > +   done;
> > }
> >  
> > SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
> > 
> 
> What do you think of the revised patch below?

Looks fine, I will include it in V4.

Thanks,
Ming
___
devel mailing list
de...@linuxdriverproject.org

RE: BUSINESS/INVESTMENTS & LOAN.5

2019-06-16 Thread Micheal Kai
Good day,
I  am financial consultant based in Doha Qatar. I have a client from a ruling 
family Retired Qatari Government Official he is one of this people with 
floating free cash for major investments Or Loan and he is also into Jets Fuel, 
Oil, gold and diamond dealers

He wishes to invest in a stable economy outside Qatar and his interest is in 
companies with potentials for rapid growth in long terms. My client is 
interested in placing part of his funds into your company or private 
businesses, if your country's bi-laws allow foreign Investors/ investment.

Thanks for your kind cooperation expecting to hear from you soonest if 
interested.

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


Re: [PATCH v2] staging: rtl8723bs: Resolve checkpatch error "that open brace { should be on the previous line" in the rtl8723 driver

2019-06-16 Thread Joe Perches
On Sat, 2019-06-15 at 14:29 -0700, Shobhit Kukreti wrote:
> Cleaned up the code from the following files to get rid of
> check patch error "that open brace { should be on the previous line"

It's fine you are modifying brace styles, but:

> diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c 
> b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> index aa2499f..4631b68 100644
> --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> @@ -46,8 +46,7 @@ void rtw_os_indicate_connect(struct adapter *adapter)
>   struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
>  
>   if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
> - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
> - {
> + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
>   rtw_cfg80211_ibss_indicate_connect(adapter);
>   }
>   else

the else should be on the same line as the close brace

> @@ -106,8 +105,9 @@ void rtw_reset_securitypriv(struct adapter *adapter)
>   adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
>  
>   }
> - else /* reset values in securitypriv */
> - {
> + else {
> + /* reset values in securitypriv */
> +

and here.  etc.  Please change all instances appropriately.


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


RE: BUSINESS/INVESTMENTS & LOAN.5

2019-06-16 Thread Micheal Kai
Good day,
I  am financial consultant based in Doha Qatar. I have a client from a ruling 
family Retired Qatari Government Official he is one of this people with 
floating free cash for major investments Or Loan and he is also into Jets Fuel, 
Oil, gold and diamond dealers

He wishes to invest in a stable economy outside Qatar and his interest is in 
companies with potentials for rapid growth in long terms. My client is 
interested in placing part of his funds into your company or private 
businesses, if your country's bi-laws allow foreign Investors/ investment.

Thanks for your kind cooperation expecting to hear from you soonest if 
interested.

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


Re: [PATCH V3 09/15] s390: zfcp_fc: use sg helper to operate scatterlist

2019-06-16 Thread Benjamin Block
On Fri, Jun 14, 2019 at 10:53:10AM +0800, Ming Lei wrote:
> Use the scatterlist iterators and remove direct indexing of the
> scatterlist array.
> 
> This way allows us to pre-allocate one small scatterlist, which can be
> chained with one runtime allocated scatterlist if the pre-allocated one
> isn't enough for the whole request.
> 
> Cc: Steffen Maier 
> Cc: Benjamin Block 
> Cc: Martin Schwidefsky 
> Cc: Heiko Carstens 
> Cc: linux-s...@vger.kernel.org
> Signed-off-by: Ming Lei 
> ---
>  drivers/s390/scsi/zfcp_fc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
> index 33eddb02ee30..b018b61bd168 100644
> --- a/drivers/s390/scsi/zfcp_fc.c
> +++ b/drivers/s390/scsi/zfcp_fc.c
> @@ -620,7 +620,7 @@ static void zfcp_fc_sg_free_table(struct scatterlist *sg, 
> int count)
>  {
>   int i;
>  
> - for (i = 0; i < count; i++, sg++)
> + for (i = 0; i < count; i++, sg = sg_next(sg))
>   if (sg)
>   free_page((unsigned long) sg_virt(sg));
>   else
> @@ -641,7 +641,7 @@ static int zfcp_fc_sg_setup_table(struct scatterlist *sg, 
> int count)
>   int i;
>  
>   sg_init_table(sg, count);
> - for (i = 0; i < count; i++, sg++) {
> + for (i = 0; i < count; i++, sg = sg_next(sg)) {
>   addr = (void *) get_zeroed_page(GFP_KERNEL);
>   if (!addr) {
>   zfcp_fc_sg_free_table(sg, i);

Acked-by: Benjamin Block 

-- 
With Best Regards, Benjamin Block  /  Linux on IBM Z Kernel Development
IBM Systems & Technology Group   /  IBM Deutschland Research & Development GmbH
Vorsitz. AufsR.: Matthias Hartmann   /  Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

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


[PATCH v3 0/3] Resolve checkpatch if/else brace style errors

2019-06-16 Thread Shobhit Kukreti
This patchset fixes the following errors reported by checkpatch in the 
staging/rtl8723bs driver.

Patch[1/3]: Fix check patch error "that open brace { should be on the previous 
line"

Patch[2/3]: Fix the error else should follow close brace '}' 

Patch[3/3]: Fix Indentation Error

version 3 changes:
- Converted the patch to a patchset
- Resolve checkpatch errors:
else should follow  close brace '}'
Fixed Indentation Error to use tabs
- Compiles and builds, untested on real hardware.


version 2 changes:
- Removed Trailing whitespace introduced in the previous patch
- Moved comments to a new line in the else statement

Shobhit Kukreti (3):
  staging: rtl8723bs: Resolve checkpatch error "that open brace { should
be on the previous line" in the rtl8723 driver
  staging: rtl8723bs: Resolve the checkpatch error: else should follow  
  close brace '}'
  staging: rtl8723bs: Fix Indentation Error: code indent should use tabs
where possible

 drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 19 ++---
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 90 ---
 drivers/staging/rtl8723bs/os_dep/rtw_proc.c   |  6 +-
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  | 54 ++
 drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 24 ++
 5 files changed, 71 insertions(+), 122 deletions(-)

-- 
2.7.4

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


[PATCH v3 2/3] staging: rtl8723bs: Resolve the checkpatch error: else should follow close brace '}'

2019-06-16 Thread Shobhit Kukreti
Cleaned up the code to resolve the checkpatch error else should follow
close brace '}' from the following files:

mlme_linux.c
recv_linux.c
sdio_intf.c

Signed-off-by: Shobhit Kukreti 
---
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c |  6 ++
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 21 +++--
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  |  9 +++--
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c 
b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index 4631b68..6a5ab35 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -48,8 +48,7 @@ void rtw_os_indicate_connect(struct adapter *adapter)
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
rtw_cfg80211_ibss_indicate_connect(adapter);
-   }
-   else
+   } else
rtw_cfg80211_indicate_connect(adapter);
 
rtw_indicate_wx_assoc_event(adapter);
@@ -104,8 +103,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
 
-   }
-   else {
+   } else {
/* reset values in securitypriv */
 
/* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c 
b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index a2055f6..aab0195 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -62,15 +62,13 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 
nSubframe_Length, u8
if (sub_skb) {
skb_reserve(sub_skb, 12);
skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length);
-   }
-   else {
+   } else {
sub_skb = rtw_skb_clone(prframe->u.hdr.pkt);
if (sub_skb) {
sub_skb->data = pdata + ETH_HLEN;
sub_skb->len = nSubframe_Length;
skb_set_tail_pointer(sub_skb, nSubframe_Length);
-   }
-   else {
+   } else {
DBG_871X("%s(): rtw_skb_clone() Fail!!!\n", __func__);
return NULL;
}
@@ -142,8 +140,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, 
_pkt *pkt, struct rx_pkt
return;
}
}
-   }
-   else {
+   } else {
/*  to APself */
 
/* DBG_871X("to APSelf\n"); */
@@ -183,24 +180,21 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 
bgroup)
 
if (psecuritypriv->last_mic_err_time == 0) {
psecuritypriv->last_mic_err_time = jiffies;
-   }
-   else {
+   } else {
cur_time = jiffies;
 
if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) {
psecuritypriv->btkip_countermeasure = true;
psecuritypriv->last_mic_err_time = 0;
psecuritypriv->btkip_countermeasure_time = cur_time;
-   }
-   else {
+   } else {
psecuritypriv->last_mic_err_time = jiffies;
}
}
 
if (bgroup) {
key_type |= NL80211_KEYTYPE_GROUP;
-   }
-   else {
+   } else {
key_type |= NL80211_KEYTYPE_PAIRWISE;
}
 
@@ -210,8 +204,7 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 
bgroup)
memset(, 0x00, sizeof(ev));
if (bgroup) {
ev.flags |= IW_MICFAILURE_GROUP;
-   }
-   else {
+   } else {
ev.flags |= IW_MICFAILURE_PAIRWISE;
}
 
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index c60f13c..9c408d9 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -88,8 +88,7 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj)
if (err) {
dvobj->drv_dbg.dbg_sdio_alloc_irq_error_cnt++;
printk(KERN_CRIT "%s: sdio_claim_irq FAIL(%d)!\n", __func__, 
err);
-   }
-   else {
+   } else {
dvobj->drv_dbg.dbg_sdio_alloc_irq_cnt++;
dvobj->irq_alloc = 1;
}
@@ -115,8 +114,7 @@ static void sdio_free_irq(struct dvobj_priv *dvobj)
 if (err) {
dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++;

[PATCH v3 3/3] staging: rtl8723bs: Fix Indentation Error: code indent should use tabs where possible

2019-06-16 Thread Shobhit Kukreti
Resolve indentation errors which were caused by a mix of space and tabs
for indentation. Previous patch to fix if-else brace styles revealed
the indentation error

Signed-off-by: Shobhit Kukreti 
---
 drivers/staging/rtl8723bs/os_dep/recv_linux.c |  6 ++---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  | 36 +--
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c 
b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index aab0195..8695127 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -203,9 +203,9 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 
bgroup)
 
memset(, 0x00, sizeof(ev));
if (bgroup) {
-   ev.flags |= IW_MICFAILURE_GROUP;
+   ev.flags |= IW_MICFAILURE_GROUP;
} else {
-   ev.flags |= IW_MICFAILURE_PAIRWISE;
+   ev.flags |= IW_MICFAILURE_PAIRWISE;
}
 
ev.src_addr.sa_family = ARPHRD_ETHER;
@@ -298,7 +298,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union 
recv_frame *precv_frame
 
RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt 
:after rtw_os_recv_indicate_pkt\n"));
 
-return _SUCCESS;
+   return _SUCCESS;
 
 _recv_indicatepkt_drop:
 
diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c 
b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
index 9c408d9..540a7ee 100644
--- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
+++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
@@ -100,26 +100,26 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj)
 
 static void sdio_free_irq(struct dvobj_priv *dvobj)
 {
-struct sdio_data *psdio_data;
-struct sdio_func *func;
-int err;
-
-if (dvobj->irq_alloc) {
-psdio_data = >intf_data;
-func = psdio_data->func;
-
-if (func) {
-sdio_claim_host(func);
-err = sdio_release_irq(func);
-if (err) {
+   struct sdio_data *psdio_data;
+   struct sdio_func *func;
+   int err;
+
+   if (dvobj->irq_alloc) {
+   psdio_data = >intf_data;
+   func = psdio_data->func;
+
+   if (func) {
+   sdio_claim_host(func);
+   err = sdio_release_irq(func);
+   if (err) {
dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++;
DBG_871X_LEVEL(_drv_err_,"%s: sdio_release_irq 
FAIL(%d)!\n", __func__, err);
-} else
-   dvobj->drv_dbg.dbg_sdio_free_irq_cnt++;
-sdio_release_host(func);
-}
-dvobj->irq_alloc = 0;
-}
+   } else
+   dvobj->drv_dbg.dbg_sdio_free_irq_cnt++;
+   sdio_release_host(func);
+   }
+   dvobj->irq_alloc = 0;
+   }
 }
 
 #ifdef CONFIG_GPIO_WAKEUP
-- 
2.7.4

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


[PATCH v3 1/3] staging: rtl8723bs: Resolve checkpatch error "that open brace { should be on the previous line" in the rtl8723 driver

2019-06-16 Thread Shobhit Kukreti
Cleaned up the code from the following files to get rid of
check patch error "that open brace { should be on the previous line"

drivers/staging/rtl8723bs/os_dep/mlme_linux.c
drivers/staging/rtl8723bs/os_dep/recv_linux.c
drivers/staging/rtl8723bs/os_dep/rtw_proc.c
drivers/staging/rtl8723bs/os_dep/sdio_intf.c
drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c

Signed-off-by: Shobhit Kukreti 
---
 drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 15 +++--
 drivers/staging/rtl8723bs/os_dep/recv_linux.c | 77 ---
 drivers/staging/rtl8723bs/os_dep/rtw_proc.c   |  6 +-
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c  | 15 ++---
 drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 24 +++
 5 files changed, 49 insertions(+), 88 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c 
b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
index aa2499f..4631b68 100644
--- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
@@ -46,8 +46,7 @@ void rtw_os_indicate_connect(struct adapter *adapter)
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
 
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
-   (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
-   {
+   (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
rtw_cfg80211_ibss_indicate_connect(adapter);
}
else
@@ -77,8 +76,8 @@ void rtw_reset_securitypriv(struct adapter *adapter)
 
spin_lock_bh(>security_key_mutex);
 
-   if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)/* 
802.1x */
-   {
+   if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { 
/* 802.1x */
+
/*  Added by Albert 2009/02/18 */
/*  We have to backup the PMK information for WiFi PMK Caching 
test item. */
/*  */
@@ -106,8 +105,9 @@ void rtw_reset_securitypriv(struct adapter *adapter)
adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
 
}
-   else /* reset values in securitypriv */
-   {
+   else {
+   /* reset values in securitypriv */
+
/* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */
/*  */
struct security_priv *psec_priv = >securitypriv;
@@ -150,8 +150,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 
authmode, u8 *sec_ie)
RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, 
authmode =%d\n", authmode));
 
buff = NULL;
-   if (authmode == _WPA_IE_ID_)
-   {
+   if (authmode == _WPA_IE_ID_) {
RT_TRACE(_module_mlme_osdep_c_, _drv_info_, 
("rtw_report_sec_ie, authmode =%d\n", authmode));
 
buff = rtw_zmalloc(IW_CUSTOM_MAX);
diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c 
b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
index 3fe9c22..a2055f6 100644
--- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c
@@ -12,8 +12,7 @@
 
 void rtw_os_free_recvframe(union recv_frame *precvframe)
 {
-   if (precvframe->u.hdr.pkt)
-   {
+   if (precvframe->u.hdr.pkt) {
dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver 
*/
 
precvframe->u.hdr.pkt = NULL;
@@ -34,10 +33,8 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
 
precvframe = (union recv_frame*) precvpriv->precv_frame_buf;
 
-   for (i = 0; i < NR_RECVFRAME; i++)
-   {
-   if (precvframe->u.hdr.pkt)
-   {
+   for (i = 0; i < NR_RECVFRAME; i++) {
+   if (precvframe->u.hdr.pkt) {
dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by 
driver */
precvframe->u.hdr.pkt = NULL;
}
@@ -48,8 +45,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
 /* free os related resource in struct recv_buf */
 void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf 
*precvbuf)
 {
-   if (precvbuf->pskb)
-   {
+   if (precvbuf->pskb) {
dev_kfree_skb_any(precvbuf->pskb);
}
 }
@@ -63,22 +59,18 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 
nSubframe_Length, u8
pattrib = >u.hdr.attrib;
 
sub_skb = rtw_skb_alloc(nSubframe_Length + 12);
-   if (sub_skb)
-   {
+   if (sub_skb) {
skb_reserve(sub_skb, 12);
skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length);
}
-   else
-   {
+   else {
sub_skb = rtw_skb_clone(prframe->u.hdr.pkt);
-   if (sub_skb)
-   {
+   if (sub_skb) {
sub_skb->data = pdata + ETH_HLEN;
sub_skb->len = nSubframe_Length;

Re: [PATCH v2 1/2] dt-bindings: iio: adc: add adi,ad7780.yaml binding

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 13:43:02 -0600
Rob Herring  wrote:

> On Fri, 24 May 2019 22:26:30 -0300, Renato Lui Geh wrote:
> > This patch adds a YAML binding for the Analog Devices AD7780/1 and
> > AD7170/1 analog-to-digital converters.
> > 
> > Signed-off-by: Renato Lui Geh 
> > ---
> > Changes in v2:
> >  - vref-supply to avdd-supply
> >  - remove avdd-supply from required list
> >  - include adc block in an spi block
> > 
> >  .../bindings/iio/adc/adi,ad7780.txt   | 48 --
> >  .../bindings/iio/adc/adi,ad7780.yaml  | 87 +++
> >  2 files changed, 87 insertions(+), 48 deletions(-)
> >  delete mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt
> >  create mode 100644 
> > Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
> >   
> 
> Reviewed-by: Rob Herring 

Thanks. As I'd not yet pushed out as togreg (rather than testing)
I've rebased to add your RB.

Thanks,

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


Re: [PATCH] staging: iio: adt7316: Add missing include files

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 23:28:46 +0800
YueHaibing  wrote:

> Fix build error:
> 
> drivers/staging/iio/addac/adt7316.c: In function adt7316_store_update_DAC:
> drivers/staging/iio/addac/adt7316.c:949:3: error: implicit declaration of
>  function gpiod_set_value; did you mean gpio_set_value? 
> [-Werror=implicit-function-declaration]
>gpiod_set_value(chip->ldac_pin, 0);
> 
> drivers/staging/iio/addac/adt7316.c: In function adt7316_setup_irq:
> drivers/staging/iio/addac/adt7316.c:1807:13: error: implicit declaration of
>  function irqd_get_trigger_type; did you mean devm_iio_trigger_free? 
> [-Werror=implicit-function-declaration]
>   irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq));
> 
> Reported-by: Hulk Robot 
> Fixes: 7f6b6d553df7 ("Staging: iio: adt7316: Add all irq related code in 
> adt7316_irq_setup()")
> Fixes: c63460c4298f ("Staging: iio: adt7316: Use device tree data to set 
> ldac_pin")
> Signed-off-by: YueHaibing 
Hi yuehaibing,

You were second to send a fix for this. I've had it in my
fixes branch since last week, but not done a pull request quite yet.
I'll probably send it out later today.

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

Thanks,

Jonathan

> ---
>  drivers/staging/iio/addac/adt7316.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/iio/addac/adt7316.c 
> b/drivers/staging/iio/addac/adt7316.c
> index 37ce563..9d3d159 100644
> --- a/drivers/staging/iio/addac/adt7316.c
> +++ b/drivers/staging/iio/addac/adt7316.c
> @@ -16,6 +16,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #include 
>  #include 

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


Re: [PATCH v2] staging: rtl8723bs: Resolve checkpatch error "that open brace { should be on the previous line" in the rtl8723 driver

2019-06-16 Thread Shobhit Kukreti
On Sun, Jun 16, 2019 at 01:13:11AM -0700, Joe Perches wrote:
> On Sat, 2019-06-15 at 14:29 -0700, Shobhit Kukreti wrote:
> > Cleaned up the code from the following files to get rid of
> > check patch error "that open brace { should be on the previous line"
> 
> It's fine you are modifying brace styles, but:
> 
> > diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c 
> > b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> > index aa2499f..4631b68 100644
> > --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> > +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c
> > @@ -46,8 +46,7 @@ void rtw_os_indicate_connect(struct adapter *adapter)
> > struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
> >  
> > if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
> > -   (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
> > -   {
> > +   (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
> > rtw_cfg80211_ibss_indicate_connect(adapter);
> > }
> > else
> 
> the else should be on the same line as the close brace
> 
> > @@ -106,8 +105,9 @@ void rtw_reset_securitypriv(struct adapter *adapter)
> > adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
> >  
> > }
> > -   else /* reset values in securitypriv */
> > -   {
> > +   else {
> > +   /* reset values in securitypriv */
> > +
> 
> and here.  etc.  Please change all instances appropriately.
Thank you for the feedback. I intented to do one kind of change in a
patch. This probably would need a patch set. Will edit appropriately. 

Best,
Shobhit Kukreti
> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/3] staging: iio: ad7150: simplify i2c SMBus return treatment

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 13:32:54 -0300
Melissa Wen  wrote:

> Since i2c_smbus_write_byte_data returns no-positive value, this commit
> making the treatment of its return value less verbose.
> 
> Signed-off-by: Melissa Wen 
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/cdc/ad7150.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index 091aa33589d7..7d56f10a19ed 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -202,16 +202,11 @@ static int ad7150_write_event_params(struct iio_dev 
> *indio_dev,
>   ret = i2c_smbus_write_byte_data(chip->client,
>   ad7150_addresses[chan][4],
>   sens);
> - if (ret < 0)
> + if (ret)
>   return ret;
> -
> - ret = i2c_smbus_write_byte_data(chip->client,
> + return i2c_smbus_write_byte_data(chip->client,
>   ad7150_addresses[chan][5],
>   timeout);
> - if (ret < 0)
> - return ret;
> -
> - return 0;
>  }
>  
>  static int ad7150_write_event_config(struct iio_dev *indio_dev,

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


Re: [PATCH v2 3/3] staging: iio: ad7150: clean up of comments

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 13:33:19 -0300
Melissa Wen  wrote:

> General cleaning of comments to remove useless information or improve
> description.
> 
> Signed-off-by: Melissa Wen 
Applied,

Thanks,

Jonathan

> ---
>  drivers/staging/iio/cdc/ad7150.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index 7d56f10a19ed..51d6b52bce8b 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -163,7 +163,8 @@ static int ad7150_read_event_config(struct iio_dev 
> *indio_dev,
>   return -EINVAL;
>  }
>  
> -/* lock should be held */
> +/* state_lock should be held to ensure consistent state*/
> +
>  static int ad7150_write_event_params(struct iio_dev *indio_dev,
>unsigned int chan,
>enum iio_event_type type,
> @@ -479,10 +480,6 @@ static const struct iio_chan_spec ad7150_channels[] = {
>   AD7150_CAPACITANCE_CHAN(1)
>  };
>  
> -/*
> - * threshold events
> - */
> -
>  static irqreturn_t ad7150_event_handler(int irq, void *private)
>  {
>   struct iio_dev *indio_dev = private;
> @@ -571,10 +568,6 @@ static const struct iio_info ad7150_info = {
>   .write_event_value = _write_event_value,
>  };
>  
> -/*
> - * device probe and remove
> - */
> -
>  static int ad7150_probe(struct i2c_client *client,
>   const struct i2c_device_id *id)
>  {

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


Re: [PATCH v2 1/3] staging: iio: ad7150: use FIELD_GET and GENMASK

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 13:32:21 -0300
Melissa Wen  wrote:

> Use the bitfield macro FIELD_GET, and GENMASK to do the shift and mask in
> one go. This makes the code more readable than explicit masking followed
> by a shift.
> 
> Signed-off-by: Melissa Wen 
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to paly with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/cdc/ad7150.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index 8234da4b8c65..091aa33589d7 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -5,6 +5,7 @@
>   * Copyright 2010-2011 Analog Devices Inc.
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -45,6 +46,9 @@
>  #define AD7150_SN0 22
>  #define AD7150_ID  23
>  
> +/* AD7150 masks */
> +#define AD7150_THRESHTYPE_MSKGENMASK(6, 5)
> +
>  /**
>   * struct ad7150_chip_info - instance specific chip data
>   * @client: i2c client for this device
> @@ -137,7 +141,7 @@ static int ad7150_read_event_config(struct iio_dev 
> *indio_dev,
>   if (ret < 0)
>   return ret;
>  
> - threshtype = (ret >> 5) & 0x03;
> + threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret);
>   adaptive = !!(ret & 0x80);
>  
>   switch (type) {

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


Re: [PATCH] staging: iio: ad7150: use ternary operating to ensure 0/1 value

2019-06-16 Thread Jonathan Cameron
On Fri, 14 Jun 2019 13:50:59 -0300
Melissa Wen  wrote:

> Remove idiom and use ternary operator for consistently trigger 0/1 value
> on variable declaration.
> 
> Signed-off-by: Melissa Wen 
Hi Melissa,

In general I would consider this unnecessary churn as, whilst
it's no longer a favoured idiom, it is extremely common in the
kernel.  However, as this is a staging cleanup, fair enough to
make it as 'nice as possible'! 

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/cdc/ad7150.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index 8234da4b8c65..25598bf124fb 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -350,8 +350,8 @@ static ssize_t ad7150_show_timeout(struct device *dev,
>  
>   /* use the event code for consistency reasons */
>   int chan = IIO_EVENT_CODE_EXTRACT_CHAN(this_attr->address);
> - int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address)
> - == IIO_EV_DIR_RISING);
> + int rising = (IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address)
> +   == IIO_EV_DIR_RISING) ? 1 : 0;
>  
>   switch (IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address)) {
>   case IIO_EV_TYPE_MAG_ADAPTIVE:

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


Re: [PATCH v3 1/2] staging: erofs: add requirements field in superblock

2019-06-16 Thread Gao Xiang



On 2019/6/16 15:14, Greg Kroah-Hartman wrote:
> On Sun, Jun 16, 2019 at 03:00:38PM +0800, Gao Xiang wrote:
>> Hi Greg,
>>
>> Sorry for annoying... Could you help merge these two fixes? Thanks in 
>> advance...
> 
> It was only 3 days, please give me at the very least, a week or so for
> staging patches.
> 
>> decompression inplace optimization needs these two patches and I will 
>> integrate
>> erofs decompression inplace optimization later for linux-next 5.3, and try 
>> to start 
>> making effort on moving to fs/ directory on kernel 5.4...
> 
> You can always send follow-on patches, I apply them in the correct
> order.  I will get to these next week, thanks.

OK, I was actually just afraid of the appling order. I was thinking of merging
these two patches in advance since the new series has the dependency on these 
patches.

Thanks,
Gao Xiang

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


Re: [PATCH] staging: rtl8723bs: os_dep: ioctl_linux: Make use rtw_zmalloc

2019-06-16 Thread Dan Carpenter
On Sun, Jun 16, 2019 at 11:02:50AM +0530, Hariprasad Kelam wrote:
> rtw_malloc with memset can be replace with rtw_zmalloc.
> 
> Signed-off-by: Hariprasad Kelam 
> ---
>  drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
> b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> index fc3885d..c59e366 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
> @@ -478,14 +478,12 @@ static int wpa_set_encryption(struct net_device *dev, 
> struct ieee_param *param,
>   if (wep_key_len > 0) {
>   wep_key_len = wep_key_len <= 5 ? 5 : 13;
>   wep_total_len = wep_key_len + FIELD_OFFSET(struct 
> ndis_802_11_wep, KeyMaterial);
> - pwep = rtw_malloc(wep_total_len);
> + pwep = rtw_zmalloc(wep_total_len);

We should not introduce new uses of rtw_malloc() or rtw_zmalloc().  They
are buggy garbage.  Use normall kmalloc() and kzalloc().

regards,
dan carpenter

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


Re: [PATCH v3 1/2] staging: erofs: add requirements field in superblock

2019-06-16 Thread Greg Kroah-Hartman
On Sun, Jun 16, 2019 at 03:00:38PM +0800, Gao Xiang wrote:
> Hi Greg,
> 
> Sorry for annoying... Could you help merge these two fixes? Thanks in 
> advance...

It was only 3 days, please give me at the very least, a week or so for
staging patches.

> decompression inplace optimization needs these two patches and I will 
> integrate
> erofs decompression inplace optimization later for linux-next 5.3, and try to 
> start 
> making effort on moving to fs/ directory on kernel 5.4...

You can always send follow-on patches, I apply them in the correct
order.  I will get to these next week, thanks.

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


Re: [PATCH v3 1/2] staging: erofs: add requirements field in superblock

2019-06-16 Thread Gao Xiang
Hi Greg,

Sorry for annoying... Could you help merge these two fixes? Thanks in advance...
decompression inplace optimization needs these two patches and I will integrate
erofs decompression inplace optimization later for linux-next 5.3, and try to 
start 
making effort on moving to fs/ directory on kernel 5.4...

Thanks,
Gao Xiang

On 2019/6/13 16:35, Gao Xiang wrote:
> There are some backward incompatible features pending
> for months, mainly due to on-disk format expensions.
> 
> However, we should ensure that it cannot be mounted with
> old kernels. Otherwise, it will causes unexpected behaviors.
> 
> Fixes: ba2b77a82022 ("staging: erofs: add super block operations")
> Cc:  # 4.19+
> Reviewed-by: Chao Yu 
> Signed-off-by: Gao Xiang 
> ---
> change log v3:
>  - record requirements in erofs_sb_info for runtime use as well;
> 
> change log v2:
>  - update printed message
> 
>  drivers/staging/erofs/erofs_fs.h | 13 ++---
>  drivers/staging/erofs/internal.h |  2 ++
>  drivers/staging/erofs/super.c| 19 +++
>  3 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/erofs/erofs_fs.h 
> b/drivers/staging/erofs/erofs_fs.h
> index fa52898df006..8ddb2b3e7d39 100644
> --- a/drivers/staging/erofs/erofs_fs.h
> +++ b/drivers/staging/erofs/erofs_fs.h
> @@ -17,10 +17,16 @@
>  #define EROFS_SUPER_MAGIC_V10xE0F5E1E2
>  #define EROFS_SUPER_OFFSET  1024
>  
> +/*
> + * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be
> + * incompatible with this kernel version.
> + */
> +#define EROFS_ALL_REQUIREMENTS  0
> +
>  struct erofs_super_block {
>  /*  0 */__le32 magic;   /* in the little endian */
>  /*  4 */__le32 checksum;/* crc32c(super_block) */
> -/*  8 */__le32 features;
> +/*  8 */__le32 features;/* (aka. feature_compat) */
>  /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */
>  /* 13 */__u8 reserved;
>  
> @@ -34,9 +40,10 @@ struct erofs_super_block {
>  /* 44 */__le32 xattr_blkaddr;
>  /* 48 */__u8 uuid[16];  /* 128-bit uuid for volume */
>  /* 64 */__u8 volume_name[16];   /* volume name */
> +/* 80 */__le32 requirements;/* (aka. feature_incompat) */
>  
> -/* 80 */__u8 reserved2[48]; /* 128 bytes */
> -} __packed;
> +/* 84 */__u8 reserved2[44];
> +} __packed; /* 128 bytes */
>  
>  /*
>   * erofs inode data mapping:
> diff --git a/drivers/staging/erofs/internal.h 
> b/drivers/staging/erofs/internal.h
> index 911333cdeef4..fc732c86ecd8 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -115,6 +115,8 @@ struct erofs_sb_info {
>  
>   u8 uuid[16];/* 128-bit uuid for volume */
>   u8 volume_name[16]; /* volume name */
> + u32 requirements;
> +
>   char *dev_name;
>  
>   unsigned int mount_opt;
> diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> index f580d4ef77a1..cadbcc11702a 100644
> --- a/drivers/staging/erofs/super.c
> +++ b/drivers/staging/erofs/super.c
> @@ -71,6 +71,22 @@ static void free_inode(struct inode *inode)
>   kmem_cache_free(erofs_inode_cachep, vi);
>  }
>  
> +static bool check_layout_compatibility(struct super_block *sb,
> +struct erofs_super_block *layout)
> +{
> + const unsigned int requirements = le32_to_cpu(layout->requirements);
> +
> + EROFS_SB(sb)->requirements = requirements;
> +
> + /* check if current kernel meets all mandatory requirements */
> + if (requirements & (~EROFS_ALL_REQUIREMENTS)) {
> + errln("unidentified requirements %x, please upgrade kernel 
> version",
> +   requirements & ~EROFS_ALL_REQUIREMENTS);
> + return false;
> + }
> + return true;
> +}
> +
>  static int superblock_read(struct super_block *sb)
>  {
>   struct erofs_sb_info *sbi;
> @@ -104,6 +120,9 @@ static int superblock_read(struct super_block *sb)
>   goto out;
>   }
>  
> + if (!check_layout_compatibility(sb, layout))
> + goto out;
> +
>   sbi->blocks = le32_to_cpu(layout->blocks);
>   sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr);
>  #ifdef CONFIG_EROFS_FS_XATTR
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel