[PATCH v8 2/5] gpu: ipu-v3: ipu-ic: Fully describe colorspace conversions

2019-05-21 Thread Steve Longerbeam
Only providing the input and output RGB/YUV space to the IC task init
functions is not sufficient. To fully characterize a colorspace
conversion, the Y'CbCr encoding standard, and quantization also
need to be specified.

Define a 'struct ipu_ic_colorspace' that includes all the above.

This allows to actually enforce the fact that the IC:

- can only encode to/from YUV and RGB full range. A follow-up patch will
  remove this restriction.
- can only encode using BT.601 standard. A follow-up patch will add
  Rec.709 encoding support.

The determination of the CSC coefficients based on the input/output
'struct ipu_ic_colorspace' are moved to a new exported function
ipu_ic_calc_csc(), and 'struct ic_csc_params' is exported as
'struct ipu_ic_csc_params'. ipu_ic_calc_csc() fills a 'struct ipu_ic_csc'
with the input/output 'struct ipu_ic_colorspace' and the calculated
'struct ic_csc_params' from those input/output colorspaces.

The functions ipu_ic_task_init(_rsc)() now take a filled 'struct
ipu_ic_csc'.

The existing CSC coefficient tables and ipu_ic_calc_csc() are moved
to a new module ipu-ic-csc.c. This is in preparation for adding more
coefficient tables for limited range quantization and more encoding
standards.

The existing ycbcr2rgb and inverse rgb2ycbcr tables defined the BT.601
Y'CbCr encoding coefficients. The rgb2ycbcr table specifically described
the BT.601 encoding from full range RGB to full range YUV. Table
comments have been added in ipu-ic-csc.c to make this more clear.

The ycbcr2rgb inverse table described encoding YUV limited range to RGB
full range. To be consistent with the rgb2ycbcr table, this table is
converted to YUV full range to RGB full range, and the comments are
expanded in ipu-ic-csc.c.

The ic_csc_rgb2rgb table was just an identity matrix, so it is renamed
'identity' in ipu-ic-csc.c.

Signed-off-by: Steve Longerbeam 
---
Changes in v8:
- remove Fixes: and cc: stable. This patch is too difficult to backport
  to stable trees.
Changes in v7:
- squashed with "gpu: ipu-v3: ipu-ic: Fix BT.601 coefficients".
- moved the coefficient tables and calc_csc_coeffs() to a new
  module ipu-ic-csc.c, and added exported ipu_ic_calc_csc() to it.
- drop v4l2_colorspace (chromaticities) from 'struct ipu_ic_colorspace'.
  It's implied that xfer_func (gamma function) must be the same for input
  and output, so make that implicit for chromaticities too.
- drop passing priv to calc_csc_coeffs(), was only used to print error
  messages.
- removed the inverse_encode boolean in calc_csc_coeffs().
- express negative coefficients as true signed int's, for better
  readability.
- tweak inverse coeff in comments, no change to rounded table values.
---
 drivers/gpu/ipu-v3/Makefile |   4 +-
 drivers/gpu/ipu-v3/ipu-ic-csc.c | 129 ++
 drivers/gpu/ipu-v3/ipu-ic.c | 138 +++-
 drivers/gpu/ipu-v3/ipu-image-convert.c  |  28 ++--
 drivers/staging/media/imx/imx-ic-prpencvf.c |  34 -
 include/video/imx-ipu-v3.h  |  56 +++-
 6 files changed, 271 insertions(+), 118 deletions(-)
 create mode 100644 drivers/gpu/ipu-v3/ipu-ic-csc.c

diff --git a/drivers/gpu/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile
index 7cc8b47e488b..5fe5ef20701a 100644
--- a/drivers/gpu/ipu-v3/Makefile
+++ b/drivers/gpu/ipu-v3/Makefile
@@ -2,8 +2,8 @@
 obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
 imx-ipu-v3-objs := ipu-common.o ipu-cpmem.o ipu-csi.o ipu-dc.o ipu-di.o \
-   ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-image-convert.o \
-   ipu-smfc.o ipu-vdi.o
+   ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-ic-csc.o \
+   ipu-image-convert.o ipu-smfc.o ipu-vdi.o
 
 ifdef CONFIG_DRM
imx-ipu-v3-objs += ipu-pre.o ipu-prg.o
diff --git a/drivers/gpu/ipu-v3/ipu-ic-csc.c b/drivers/gpu/ipu-v3/ipu-ic-csc.c
new file mode 100644
index ..5fb469cd64fe
--- /dev/null
+++ b/drivers/gpu/ipu-v3/ipu-ic-csc.c
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Mentor Graphics Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ipu-prv.h"
+
+/* identity matrix */
+static const struct ipu_ic_csc_params identity = {
+   .coeff = {
+   {  128,0,0, },
+   {0,  128,0, },
+   {0,0,  128, },
+   },
+   .offset = { 0, 0, 0, },
+   .scale = 2,
+};
+
+static const struct ipu_ic_csc_params *rgb2rgb[] = {
+   ,
+};
+
+static const struct ipu_ic_csc_params *yuv2yuv[] = {
+   ,
+};
+
+/*
+ * BT.601 RGB full-range to YUV full-range
+ *
+ * Y =  .2990 * R + .5870 * G + .1140 * B
+ * U = -.1687 * R - .3313 * G + .5000 * B + 128
+ * V =  .5000 * R - .4187 * G - .0813 * B + 128
+ */
+static const struct ipu_ic_csc_params rgbf2yuvf_601 = {
+   .coeff = {
+   {   77,  150,   29, },
+   {  -43,  -85,  128, },
+   {  128, -107,  -21, },
+   },
+   .offset = { 0, 

[PATCH v8 5/5] media: imx: Try colorimetry at both sink and source pads

2019-05-21 Thread Steve Longerbeam
Retask imx_media_fill_default_mbus_fields() to try colorimetry parameters,
renaming it to to imx_media_try_colorimetry(), and call it at both sink and
source pad try_fmt's. The unrelated check for uninitialized field value is
moved out to appropriate places in each subdev try_fmt.

The IC now supports Rec.709 and BT.601 Y'CbCr encoding, and both limited
and full range quantization for both YUV and RGB space, so allow those
for pipelines that route through the IC.

Signed-off-by: Steve Longerbeam 
---
Changes in v7:
- squashed with "media: imx: Allow Rec.709 encoding for IC routes".
- remove the RGB full-range quantization restriction for IC routes.
---
 drivers/staging/media/imx/imx-ic-prp.c  |  6 +-
 drivers/staging/media/imx/imx-ic-prpencvf.c |  8 +--
 drivers/staging/media/imx/imx-media-csi.c   | 19 +++---
 drivers/staging/media/imx/imx-media-utils.c | 73 ++---
 drivers/staging/media/imx/imx-media-vdic.c  |  5 +-
 drivers/staging/media/imx/imx-media.h   |  5 +-
 drivers/staging/media/imx/imx7-media-csi.c  |  8 +--
 7 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/media/imx/imx-ic-prp.c 
b/drivers/staging/media/imx/imx-ic-prp.c
index 10ffe00f1a54..f87fe0203720 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -193,8 +193,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
sdformat->format.code = cc->codes[0];
}
 
-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
break;
case PRP_SRC_PAD_PRPENC:
case PRP_SRC_PAD_PRPVF:
@@ -203,6 +203,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd,
break;
}
 
+   imx_media_try_colorimetry(>format, true);
+
fmt = __prp_get_fmt(priv, cfg, sdformat->pad, sdformat->which);
*fmt = sdformat->format;
 out:
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c 
b/drivers/staging/media/imx/imx-ic-prpencvf.c
index e8b36a181ccc..f2fe3c11c70e 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -907,8 +907,6 @@ static void prp_try_fmt(struct prp_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
} else {
v4l_bound_align_image(>format.width,
  MIN_W_SINK, MAX_W_SINK, W_ALIGN_SINK,
@@ -916,9 +914,11 @@ static void prp_try_fmt(struct prp_priv *priv,
  MIN_H_SINK, MAX_H_SINK, H_ALIGN_SINK,
  S_ALIGN);
 
-   imx_media_fill_default_mbus_fields(>format, infmt,
-  true);
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
}
+
+   imx_media_try_colorimetry(>format, true);
 }
 
 static int prp_set_fmt(struct v4l2_subdev *sd,
diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 1d248aca40a9..dce4addadff4 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1375,9 +1375,15 @@ static void csi_try_field(struct csi_priv *priv,
struct v4l2_mbus_framefmt *infmt =
__csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which);
 
-   /* no restrictions on sink pad field type */
-   if (sdformat->pad == CSI_SINK_PAD)
+   /*
+* no restrictions on sink pad field type except must
+* be initialized.
+*/
+   if (sdformat->pad == CSI_SINK_PAD) {
+   if (sdformat->format.field == V4L2_FIELD_ANY)
+   sdformat->format.field = V4L2_FIELD_NONE;
return;
+   }
 
switch (infmt->field) {
case V4L2_FIELD_SEQ_TB:
@@ -1455,8 +1461,6 @@ static void csi_try_fmt(struct csi_priv *priv,
/* propagate colorimetry from sink */
sdformat->format.colorspace = infmt->colorspace;
sdformat->format.xfer_func = infmt->xfer_func;
-   sdformat->format.quantization = infmt->quantization;
-   sdformat->format.ycbcr_enc = infmt->ycbcr_enc;
 
break;
case CSI_SINK_PAD:
@@ -1476,10 +1480,6 @@ static void csi_try_fmt(struct csi_priv *priv,
 
csi_try_field(priv, cfg, sdformat);
 
-   imx_media_fill_default_mbus_fields(
-   >format, infmt,
-

[PATCH] staging: rtl8723bs: Add missing blank lines

2019-05-21 Thread Fabio Lima
This patch resolves the following warning from checkpatch.pl
WARNING: Missing a blank line after declarations

Signed-off-by: Fabio Lima 
---
 drivers/staging/rtl8723bs/core/rtw_debug.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c 
b/drivers/staging/rtl8723bs/core/rtw_debug.c
index 9f8446ccf..853362381 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -382,6 +382,7 @@ ssize_t proc_set_roam_tgt_addr(struct file *file, const 
char __user *buffer, siz
if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
 
int num = sscanf(tmp, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", addr, 
addr+1, addr+2, addr+3, addr+4, addr+5);
+
if (num == 6)
memcpy(adapter->mlmepriv.roam_tgt_addr, addr, ETH_ALEN);
 
@@ -1348,6 +1349,7 @@ int proc_get_btcoex_dbg(struct seq_file *m, void *v)
struct net_device *dev = m->private;
struct adapter *padapter;
char buf[512] = {0};
+
padapter = (struct adapter *)rtw_netdev_priv(dev);
 
rtw_btcoex_GetDBG(padapter, buf, 512);
-- 
2.11.0

___
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-05-21 Thread Greg Ungerer

Hi Sergio,

Thanks for the quick response.

On 21/5/19 6:14 pm, Sergio Paracuellos wrote:

On Tue, May 21, 2019 at 8:44 AM Greg Ungerer  wrote:

I am working on a couple of different MedaiTek MT7621 based platforms
and am having problems with the PCI bus on those.

Big picture is that the PCI bus on my boards worked in linux-4.20
(with the obvious compilation breakage fixed), and it does not work
in linux-5.0 or linux-5.1.

On linux-4.20 the PCI bus probe at kernel boot looks like this:

* Xtal 40MHz *
PCIE1 no card, disable it(RST)
PCIE2 no card, disable it(RST)
PCIE0 enabled
PCI coherence region base: 0x6000, mask/settings: 0xf002
mt7621-pci 1e14.pcie: PCI host bridge to bus :00
pci_bus :00: root bus resource [io  0x]
pci_bus :00: root bus resource [mem 0x6000-0x6fff]
pci_bus :00: root bus resource [bus 00-ff]
pci :00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci :00:00.0: PCI bridge to [bus 01-ff]
pci :00:00.0: BAR 0: no space for [mem size 0x8000]
pci :00:00.0: BAR 0: failed to assign [mem size 0x8000]
pci :00:00.0: BAR 8: assigned [mem 0x6000-0x601f]
pci :00:00.0: BAR 9: assigned [mem 0x6020-0x602f pref]
pci :00:00.0: BAR 1: assigned [mem 0x6030-0x6030]
pci :00:00.0: BAR 7: no space for [io  size 0x1000]
pci :00:00.0: BAR 7: failed to assign [io  size 0x1000]
pci :01:00.0: BAR 0: assigned [mem 0x6000-0x601f 64bit]
pci :01:00.0: BAR 6: assigned [mem 0x6020-0x6020 pref]
pci :00:00.0: PCI bridge to [bus 01]
pci :00:00.0:   bridge window [mem 0x6000-0x601f]
pci :00:00.0:   bridge window [mem 0x6020-0x602f pref]

The PCI bus works, and devices on it are found and work as expected.

On linux-5.1 the PCI initialization and probe fails, with the kernel
locking up:

...
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 0 failed
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 1 failed
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)

The lockup is in mt7621_pci_phy_power_off(), at the phy_read() call.
If I modify that code and return immediately in that mt7621_pci_phy_power_off()
the systemboots - but obviously from the above you can see that the PCI bus
and no devices were detected.


There are two changes with this two commits:

commit 36d657b011ef49b549aae44d0fe49ce845beb975
Author: Sergio Paracuellos 
Date:   Wed Apr 17 13:58:38 2019 +0200

 staging: mt7621-pci-phy: convert driver to use kernel regmap API's

 Instead of using writel and readl use regmap API which makes
 the driver maintainability easier.

 Signed-off-by: Sergio Paracuellos 
 Signed-off-by: Greg Kroah-Hartman 

commit 9445ccb3714c78c26a3a25fafed4d9d965080431
Author: Sergio Paracuellos 
Date:   Wed Apr 17 13:58:37 2019 +0200

 staging: mt7621-pci-phy: add quirks for 'E2' revision using
'soc_device_attribute'

 Depending on revision of the chip, 'mt7621_bypass_pipe_rst' function
 must be executed. Add better support for this using 'soc_device_match'
 in driver probe function.

 Signed-off-by: Sergio Paracuellos 
 Signed-off-by: Greg Kroah-Hartman 

So, I added a quirk for E2 revision of the board as I was suggested to
do by the phy
tree maintainer, and this is the only place I can think the problem could be.


I took the pci-mt7621.c and pci-mt7621-phy.c from a linux-5.2-rc1,
which has both those commits. Same behavior, PCI probing locks up
kernel in mt7621_pci_phy_power_off().



I think all te changes before this was properly tested by Neil and
results in a working
PCI.


Not sure what board Neil is using.
I am using a Digi/EX15 and I also tried a Digi/TX54 (very different
boards, very different designs).



Copying in the working linux-4.20 pci-mt7621.c into place on
linux-5.1 results in a working PCI bus also. I have 2 very different
MT7621 based boards, and they both exhibit this same problem.

I tried bisecting that back to find the problem commit.
It was not at all easy with quite a few of the mt7621 PCI related
patches not building in isolation while bisecting. But ultimately
I got to commit 745eeeac68d7 ("staging: mt7621-pci: factor out
'mt7621_pcie_enable_port' function").


Sorry for your time in this and for the problems with isolation patches. I'll


FWIW, I do like your changes, they really clean up that code a lot.



do my best from now to this don't happen again. The problem commit
you are pointing out here had problems at first because depending on the
revision of the chip 

Re: [PATCH 10/10] docs: fix broken documentation links

2019-05-21 Thread Federico Vaga
On Monday, May 20, 2019 4:47:39 PM CEST Mauro Carvalho Chehab wrote:
> Mostly due to x86 and acpi conversion, several documentation
> links are still pointing to the old file. Fix them.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> ---
>  Documentation/acpi/dsd/leds.txt  |  2 +-
>  Documentation/admin-guide/kernel-parameters.rst  |  6 +++---
>  Documentation/admin-guide/kernel-parameters.txt  | 16 
>  Documentation/admin-guide/ras.rst|  2 +-
>  .../devicetree/bindings/net/fsl-enetc.txt|  7 +++
>  .../bindings/pci/amlogic,meson-pcie.txt  |  2 +-
>  .../bindings/regulator/qcom,rpmh-regulator.txt   |  2 +-
>  Documentation/devicetree/booting-without-of.txt  |  2 +-
>  Documentation/driver-api/gpio/board.rst  |  2 +-
>  Documentation/driver-api/gpio/consumer.rst   |  2 +-
>  .../firmware-guide/acpi/enumeration.rst  |  2 +-
>  .../firmware-guide/acpi/method-tracing.rst   |  2 +-
>  Documentation/i2c/instantiating-devices  |  2 +-
>  Documentation/sysctl/kernel.txt  |  4 ++--
>  .../translations/it_IT/process/4.Coding.rst  |  2 +-
>  .../translations/it_IT/process/howto.rst |  2 +-
>  .../it_IT/process/stable-kernel-rules.rst|  4 ++--
>  .../translations/zh_CN/process/4.Coding.rst  |  2 +-
>  Documentation/x86/x86_64/5level-paging.rst   |  2 +-
>  Documentation/x86/x86_64/boot-options.rst|  4 ++--
>  .../x86/x86_64/fake-numa-for-cpusets.rst |  2 +-
>  MAINTAINERS  |  6 +++---
>  arch/arm/Kconfig |  2 +-
>  arch/arm64/kernel/kexec_image.c  |  2 +-
>  arch/powerpc/Kconfig |  2 +-
>  arch/x86/Kconfig | 16 
>  arch/x86/Kconfig.debug   |  2 +-
>  arch/x86/boot/header.S   |  2 +-
>  arch/x86/entry/entry_64.S|  2 +-
>  arch/x86/include/asm/bootparam_utils.h   |  2 +-
>  arch/x86/include/asm/page_64_types.h |  2 +-
>  arch/x86/include/asm/pgtable_64_types.h  |  2 +-
>  arch/x86/kernel/cpu/microcode/amd.c  |  2 +-
>  arch/x86/kernel/kexec-bzimage64.c|  2 +-
>  arch/x86/kernel/pci-dma.c|  2 +-
>  arch/x86/mm/tlb.c|  2 +-
>  arch/x86/platform/pvh/enlighten.c|  2 +-
>  drivers/acpi/Kconfig | 10 +-
>  drivers/net/ethernet/faraday/ftgmac100.c |  2 +-
>  .../fieldbus/Documentation/fieldbus_dev.txt  |  4 ++--
>  drivers/vhost/vhost.c|  2 +-
>  include/acpi/acpi_drivers.h  |  2 +-
>  include/linux/fs_context.h   |  2 +-
>  include/linux/lsm_hooks.h|  2 +-
>  mm/Kconfig   |  2 +-
>  security/Kconfig |  2 +-
>  tools/include/linux/err.h|  2 +-
>  tools/objtool/Documentation/stack-validation.txt |  4 ++--
>  tools/testing/selftests/x86/protection_keys.c|  2 +-
>  49 files changed, 78 insertions(+), 79 deletions(-)
> 
> diff --git a/Documentation/acpi/dsd/leds.txt
> b/Documentation/acpi/dsd/leds.txt index 81a63af42ed2..cc58b1a574c5 100644
> --- a/Documentation/acpi/dsd/leds.txt
> +++ b/Documentation/acpi/dsd/leds.txt
> @@ -96,4 +96,4 @@ where
> 
> http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-da
> ta-extension-UUID-v1.1.pdf>, referenced 2019-02-21.
> 
> -[7] Documentation/acpi/dsd/data-node-reference.txt
> +[7] Documentation/firmware-guide/acpi/dsd/data-node-references.rst
> diff --git a/Documentation/admin-guide/kernel-parameters.rst
> b/Documentation/admin-guide/kernel-parameters.rst index
> 0124980dca2d..8d3273e32eb1 100644
> --- a/Documentation/admin-guide/kernel-parameters.rst
> +++ b/Documentation/admin-guide/kernel-parameters.rst
> @@ -167,7 +167,7 @@ parameter is applicable::
>   X86-32  X86-32, aka i386 architecture is enabled.
>   X86-64  X86-64 architecture is enabled.
>   More X86-64 boot options can be found in
> - Documentation/x86/x86_64/boot-options.txt 
.
> + Documentation/x86/x86_64/boot-options.rst.
>   X86 Either 32-bit or 64-bit x86 (same as X86-32+X86-64)
>   X86_UV  SGI UV support is enabled.
>   XEN Xen support is enabled
> @@ -181,10 +181,10 @@ In addition, the following text indicates that the
> option:: Parameters denoted with BOOT are actually interpreted by the boot
> loader, and have no meaning to the kernel directly.
>  Do not modify the syntax of boot loader parameters without extreme
> -need or coordination with .
> +need or coordination with .
> 
>  There are also arch-specific kernel-parameters not documented here.
> -See for example .
> +See 

Re: [PATCH] staging: rtl8192u: Remove an unnecessary NULL check

2019-05-21 Thread Nick Desaulniers
On Tue, May 21, 2019 at 10:42 AM Nathan Chancellor
 wrote:
>
> Clang warns:
>
> drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:47: warning:
> address of array 'param->u.wpa_ie.data' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
> (param->u.wpa_ie.len && !param->u.wpa_ie.data))
> ~^~~~
>
> This was exposed by commit deabe03523a7 ("Staging: rtl8192u: ieee80211:
> Use !x in place of NULL comparisons") because we disable the warning
> that would have pointed out the comparison against NULL is also false:
>
> drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:46: warning:
> comparison of array 'param->u.wpa_ie.data' equal to a null pointer is
> always false [-Wtautological-pointer-compare]
> (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
> ^~~~
>
> Remove it so clang no longer warns.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/487
> Signed-off-by: Nathan Chancellor 
> ---
>  drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c 
> b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> index f38f9d8b78bb..e0da0900a4f7 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> @@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct 
> ieee80211_device *ieee,
>  {
> u8 *buf;
>
> -   if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
> -   (param->u.wpa_ie.len && !param->u.wpa_ie.data))

Right so, the types in this expression:

param: struct ieee_param*
param->u: *anonymous union*
param->u.wpa_ie: *anonymous struct*
param->u.wpa_ie.len: u32
param->u.wpa_ie.data: u8 [0]
as defined in drivers/staging/rtl8192u/ieee80211/ieee80211.h#L295
https://github.com/ClangBuiltLinux/linux/blob/9c7db5004280767566e91a33445bf93aa479ef02/drivers/staging/rtl8192u/ieee80211/ieee80211.h#L295-L322

so this is a tricky case, because in general array members can never
themselves be NULL, and usually I trust -Wpointer-bool-conversion, but
this is a special case because of the flexible array member:
https://en.wikipedia.org/wiki/Flexible_array_member. (It seems that
having the 0 in the length explicitly was pre-c99 GNU extension:
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html). I wonder if
-Wtautological-pointer-compare applies to Flexible Array Members or
not (Richard, do you know)?  In general, you'd be setting
param->u.wpa_ie to the return value of a dynamic memory allocation,
not param->u.wpa_ie.data, so this check is fishy to me.

> +   if (param->u.wpa_ie.len > MAX_WPA_IE_LEN)
> return -EINVAL;
>
> if (param->u.wpa_ie.len) {
> --
> 2.22.0.rc1
>


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


[PATCH] staging: rtl8723bs: Fix Coverity warning in rtw_dbg_port()

2019-05-21 Thread Hans de Goede
Fix the following Coverity warning:

File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function
rtw_dbg_port():

CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true.

if ((extra_arg & 0x07) > 0x07)
padapter->driver_ampdu_spacing = 0xFF;
else
padapter->driver_ampdu_spacing = extra_arg;

Reported-by: Colin Ian King 
Signed-off-by: Hans de Goede 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 8fb03efd588b..5c70c17aee19 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -3101,7 +3101,7 @@ static int rtw_dbg_port(struct net_device *dev,
 
DBG_871X("enable driver 
ctrl ampdu density = %d\n", extra_arg);
 
-   if ((extra_arg & 0x07) 
> 0x07)
+   if (extra_arg > 0x07)

padapter->driver_ampdu_spacing = 0xFF;
else

padapter->driver_ampdu_spacing = extra_arg;
-- 
2.21.0

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


[Patch v2] staging: rtl8723bs: core: rtw_ap: fix Unneeded variable: "ret". Return "0

2019-05-21 Thread Hariprasad Kelam
Function "rtw_sta_flush" always returns 0 value.
So change return type of rtw_sta_flush from int to void.

Same thing applies for rtw_hostapd_sta_flush

Signed-off-by: Hariprasad Kelam 
--
Changes v2 -
change return type of rtw_sta_flush

-
 drivers/staging/rtl8723bs/core/rtw_ap.c   | 7 ++-
 drivers/staging/rtl8723bs/include/rtw_ap.h| 2 +-
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 ++--
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c| 7 +++
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c 
b/drivers/staging/rtl8723bs/core/rtw_ap.c
index bc02306..19418ea 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -2189,10 +2189,9 @@ u8 ap_free_sta(
return beacon_updated;
 }
 
-int rtw_sta_flush(struct adapter *padapter)
+void rtw_sta_flush(struct adapter *padapter)
 {
struct list_head*phead, *plist;
-   int ret = 0;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
@@ -2202,7 +2201,7 @@ int rtw_sta_flush(struct adapter *padapter)
DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
 
if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
-   return ret;
+   return ;
 
spin_lock_bh(>asoc_list_lock);
phead = >asoc_list;
@@ -2226,8 +2225,6 @@ int rtw_sta_flush(struct adapter *padapter)
issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING);
 
associated_clients_update(padapter, true);
-
-   return ret;
 }
 
 /* called > TSR LEVEL for USB or SDIO Interface*/
diff --git a/drivers/staging/rtl8723bs/include/rtw_ap.h 
b/drivers/staging/rtl8723bs/include/rtw_ap.h
index fd56c9db..d6f3a3a 100644
--- a/drivers/staging/rtl8723bs/include/rtw_ap.h
+++ b/drivers/staging/rtl8723bs/include/rtw_ap.h
@@ -31,7 +31,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, 
struct sta_info *psta);
 void sta_info_update(struct adapter *padapter, struct sta_info *psta);
 void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta);
 u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, bool active, 
u16 reason);
-int rtw_sta_flush(struct adapter *padapter);
+void rtw_sta_flush(struct adapter *padapter);
 void start_ap_mode(struct adapter *padapter);
 void stop_ap_mode(struct adapter *padapter);
 
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index db553f2..ce57e0e 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -2896,9 +2896,9 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, 
struct net_device *ndev
 
flush_all_cam_entry(padapter);  /* clear CAM */
 
-   ret = rtw_sta_flush(padapter);
+   rtw_sta_flush(padapter);
 
-   return ret;
+   return 0;
}
 
 
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index e3d3569..a4d05f2 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -3754,7 +3754,7 @@ static int rtw_set_beacon(struct net_device *dev, struct 
ieee_param *param, int
 
 }
 
-static int rtw_hostapd_sta_flush(struct net_device *dev)
+static void rtw_hostapd_sta_flush(struct net_device *dev)
 {
/* _irqL irqL; */
/* struct list_head *phead, *plist; */
@@ -3766,8 +3766,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev)
 
flush_all_cam_entry(padapter);  /* clear CAM */
 
-   return rtw_sta_flush(padapter);
-
+   rtw_sta_flush(padapter);
 }
 
 static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
@@ -4254,7 +4253,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, 
struct iw_point *p)
switch (param->cmd) {
case RTL871X_HOSTAPD_FLUSH:
 
-   ret = rtw_hostapd_sta_flush(dev);
+   rtw_hostapd_sta_flush(dev);
 
break;
 
-- 
2.7.4

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


Re: [PATCH] staging: wilc1000: remove redundant masking of pkt_offset

2019-05-21 Thread Adham.Abozaeid


On 5/21/19 6:17 AM, Colin King wrote:
> External E-Mail
>
>
> From: Colin Ian King 
>
> The masking update of pkg_offset is redundant as the updated
> value is never read and pkg_offset is re-assigned on the next
> iteration of the loop.  Clean this up by removing the redundant
> assignment.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King 

Reviewed-by: Adham Abozaeid 


Thanks,

Adham

> ---
>  drivers/staging/wilc1000/wilc_wlan.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
> b/drivers/staging/wilc1000/wilc_wlan.c
> index 95eaf8fdf4f2..dcd728557958 100644
> --- a/drivers/staging/wilc1000/wilc_wlan.c
> +++ b/drivers/staging/wilc1000/wilc_wlan.c
> @@ -709,9 +709,6 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, 
> u8 *buffer, int size)
>   break;
>  
>   if (pkt_offset & IS_MANAGMEMENT) {
> - pkt_offset &= ~(IS_MANAGMEMENT |
> - IS_MANAGMEMENT_CALLBACK |
> - IS_MGMT_STATUS_SUCCES);
>   buff_ptr += HOST_HDR_OFFSET;
>   wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len);
>   } else {
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fieldbus: arcx-anybus: change custom -> mmio regmap

2019-05-21 Thread Sven Van Asbroeck
The arcx-anybus's registers are accessed via a memory-mapped
IO region. A regmap associated with this region is created
using custom reg_read() / reg_write() callbacks.

However, an abstraction which creates a memory-mapped IO
region backed regmap already exists: devm_regmap_init_mmio().

Replace the custom regmap with the existing kernel abstraction.
As a pleasant side-effect, sparse warnings now disappear.

Signed-off-by: Sven Van Asbroeck 
---
 .../staging/fieldbus/anybuss/arcx-anybus.c| 44 ++-
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c 
b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
index a167fb68e355..2ecffa42e561 100644
--- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c
+++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
@@ -111,49 +111,31 @@ static void export_reset_1(struct device *dev, bool 
assert)
  * at a time for now.
  */
 
-static int read_reg_bus(void *context, unsigned int reg,
-   unsigned int *val)
-{
-   void __iomem *base = context;
-
-   *val = readb(base + reg);
-   return 0;
-}
-
-static int write_reg_bus(void *context, unsigned int reg,
-unsigned int val)
-{
-   void __iomem *base = context;
-
-   writeb(val, base + reg);
-   return 0;
-}
+static const struct regmap_config arcx_regmap_cfg = {
+   .reg_bits = 16,
+   .val_bits = 8,
+   .max_register = 0x7ff,
+   .use_single_read = true,
+   .use_single_write = true,
+   /*
+* single-byte parallel bus accesses are atomic, so don't
+* require any synchronization.
+*/
+   .disable_locking = true,
+};
 
 static struct regmap *create_parallel_regmap(struct platform_device *pdev,
 int idx)
 {
-   struct regmap_config regmap_cfg = {
-   .reg_bits = 11,
-   .val_bits = 8,
-   /*
-* single-byte parallel bus accesses are atomic, so don't
-* require any synchronization.
-*/
-   .disable_locking = true,
-   .reg_read = read_reg_bus,
-   .reg_write = write_reg_bus,
-   };
struct resource *res;
void __iomem *base;
struct device *dev = >dev;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1);
-   if (resource_size(res) < (1 << regmap_cfg.reg_bits))
-   return ERR_PTR(-EINVAL);
base = devm_ioremap_resource(dev, res);
if (IS_ERR(base))
return ERR_CAST(base);
-   return devm_regmap_init(dev, NULL, base, _cfg);
+   return devm_regmap_init_mmio(dev, base, _regmap_cfg);
 }
 
 static struct anybuss_host *
-- 
2.17.1

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


[PATCH] staging: rtl8192u: Remove an unnecessary NULL check

2019-05-21 Thread Nathan Chancellor
Clang warns:

drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:47: warning:
address of array 'param->u.wpa_ie.data' will always evaluate to 'true'
[-Wpointer-bool-conversion]
(param->u.wpa_ie.len && !param->u.wpa_ie.data))
~^~~~

This was exposed by commit deabe03523a7 ("Staging: rtl8192u: ieee80211:
Use !x in place of NULL comparisons") because we disable the warning
that would have pointed out the comparison against NULL is also false:

drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:46: warning:
comparison of array 'param->u.wpa_ie.data' equal to a null pointer is
always false [-Wtautological-pointer-compare]
(param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
^~~~

Remove it so clang no longer warns.

Link: https://github.com/ClangBuiltLinux/linux/issues/487
Signed-off-by: Nathan Chancellor 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index f38f9d8b78bb..e0da0900a4f7 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct 
ieee80211_device *ieee,
 {
u8 *buf;
 
-   if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
-   (param->u.wpa_ie.len && !param->u.wpa_ie.data))
+   if (param->u.wpa_ie.len > MAX_WPA_IE_LEN)
return -EINVAL;
 
if (param->u.wpa_ie.len) {
-- 
2.22.0.rc1

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


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 12:53 PM Sven Van Asbroeck  wrote:
>
> On Tue, May 21, 2019 at 12:24 PM Greg KH  wrote:
> >
> > what is so odd about this code that makes you have to jump through
> > strange hoops that no other driver has to?
> >
>
> Basically because it creates a regmap which accesses __iomem memory,
> instead of i2c/spi.
>

Wait a second... doesn't devm_regmap_init_mmio() do exactly that ?!
How could I overlook this :( :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: Add rtl8723bs sdio wifi driver

2019-05-21 Thread Hans de Goede

Hi,

On 5/21/19 3:49 PM, Colin Ian King wrote:

Hi,

static analysis with Coverity has detected an issues in the rtl8723bs
wifi driver:

File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function
rtw_dbg_port():

CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true.

 if ((extra_arg & 0x07) > 0x07)
 padapter->driver_ampdu_spacing = 0xFF;
 else
 padapter->driver_ampdu_spacing = extra_arg;


I'm not sure if the mask is (in)correct or the value it is being
compared to 0x07 is (in)correct (or both!)


Hmm, after looking at the rest of the code, it is clear that valid
values for driver_ampdu_spacing or 0 - 7, otherwise it should
be set to 0xff which means use the driver default.

I will send a patch fixing this.

Regards,

Hans

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


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 12:24 PM Greg KH  wrote:
>
> what is so odd about this code that makes you have to jump through
> strange hoops that no other driver has to?
>

Basically because it creates a regmap which accesses __iomem memory,
instead of i2c/spi.

This was done because future hardware in the company's pipeline will access
device register space through spi, instead of through a parallel memory bus.

The lower driver just has to create the appropriate regmap, __iomem or
spi, and pass it to the
upper driver, which does not have to know about the exact way the h/w
gets accessed.
So regmap is used as a hw abstraction layer.

The issue here is that a regmap context is a 'void *' yet the parallel
memory base pointer
is 'void __iomem *'. And so the two are incompatible.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Greg KH
On Tue, May 21, 2019 at 11:53:15AM -0400, Sven Van Asbroeck wrote:
> On Tue, May 21, 2019 at 11:42 AM Greg KH  wrote:
> >
> > Ick, if you are using __force, almost always something is wrong.
> >
> 
> What if I create a separate structure for the regmap context ?
> 
> struct anybus_regmap_context {
> void __iomem *base;
> };
> 
> Then just store the base pointer inside the struct, and pass the struct
> as the regmap context:
> 
> ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> ctx->base = base;
> devm_regmap_init(..., ctx);
> 
> static int write_reg_bus(void *context, unsigned int reg,
>   unsigned int val)
> {
> struct anybus_regmap_context *ctx = context;
> base>
> }

Ick, no.

> Penalty is an additional dynamic pointer-size
> allocation. Pro: it'll be formally correct ?

what is so odd about this code that makes you have to jump through
strange hoops that no other driver has to?

Just set your pointer types up properly to start with, and all should be
fine.  Why are you trying to cast anything here?

thanks,

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


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 11:42 AM Greg KH  wrote:
>
> Ick, if you are using __force, almost always something is wrong.
>

What if I create a separate structure for the regmap context ?

struct anybus_regmap_context {
void __iomem *base;
};

Then just store the base pointer inside the struct, and pass the struct
as the regmap context:

ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
ctx->base = base;
devm_regmap_init(..., ctx);

static int write_reg_bus(void *context, unsigned int reg,
  unsigned int val)
{
struct anybus_regmap_context *ctx = context;
base>
}

Penalty is an additional dynamic pointer-size
allocation. Pro: it'll be formally correct ?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Greg KH
On Tue, May 21, 2019 at 11:19:59AM -0400, Sven Van Asbroeck wrote:
> On Tue, May 21, 2019 at 11:13 AM Dan Carpenter  
> wrote:
> >
> > There is no need to use __force.  Just:
> >
> > void __iomem *base = (void __iomem *)context;
> >
> > For the rest as well.
> 
> Yes, that appears to work for 'void *' -> __iomem, but not the other way 
> around:
> 
> +   return devm_regmap_init(dev, NULL, (void *)base, _cfg);
> 
> sparse generates:
> drivers/staging/fieldbus/anybuss/arcx-anybus.c:156:16: warning: cast
> removes address space of expression
> 
> Would it be a ok solution to use __force in this instance only?

Ick, if you are using __force, almost always something is wrong.

thanks

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


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 11:13 AM Dan Carpenter  wrote:
>
> There is no need to use __force.  Just:
>
> void __iomem *base = (void __iomem *)context;
>
> For the rest as well.

Yes, that appears to work for 'void *' -> __iomem, but not the other way around:

+   return devm_regmap_init(dev, NULL, (void *)base, _cfg);

sparse generates:
drivers/staging/fieldbus/anybuss/arcx-anybus.c:156:16: warning: cast
removes address space of expression

Would it be a ok solution to use __force in this instance only?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/gasket: Fix string split

2019-05-21 Thread Dan Carpenter
On Tue, May 21, 2019 at 05:07:28PM +0200, Tianzheng Li wrote:
> This patch removes unnecessary quoted string splits.
> 
> Signed-off-by: Tianzheng Li 
> Signed-off-by: Jie Zhang 

What do the two sign off mean here?  What did Jie Zhang do?  Who wrote
this patch?

Co-developed-by?  Reviewed-by?

regards,
dan carpenter

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


Re: [PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Dan Carpenter
On Tue, May 21, 2019 at 10:51:16AM -0400, Sven Van Asbroeck wrote:
> The regmap's context (stored as 'void *') consists of a pointer to
> __iomem. Mixing __iomem and non-__iomem addresses generates
> sparse warnings.
> 
> Fix by using __force when converting to/from 'void __iomem *' and
> the regmap's context.
> 
> Signed-off-by: Sven Van Asbroeck 
> ---
>  drivers/staging/fieldbus/anybuss/arcx-anybus.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c 
> b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
> index a167fb68e355..8126e5535ada 100644
> --- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c
> +++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
> @@ -114,7 +114,7 @@ static void export_reset_1(struct device *dev, bool 
> assert)
>  static int read_reg_bus(void *context, unsigned int reg,
>   unsigned int *val)
>  {
> - void __iomem *base = context;
> + void __iomem *base = (__force void __iomem *)context;


There is no need to use __force.  Just:

void __iomem *base = (void __iomem *)context;

For the rest as well.

regards,
dan carpenter

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


[PATCH] staging/gasket: Fix string split

2019-05-21 Thread Tianzheng Li
This patch removes unnecessary quoted string splits.

Signed-off-by: Tianzheng Li 
Signed-off-by: Jie Zhang 
---
 drivers/staging/gasket/gasket_core.c   |  6 ++
 drivers/staging/gasket/gasket_ioctl.c  |  3 +--
 drivers/staging/gasket/gasket_page_table.c | 14 ++
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index a445d58fb399..13179f063a61 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -702,8 +702,7 @@ static bool gasket_mmap_has_permissions(struct gasket_dev 
*gasket_dev,
if ((vma->vm_flags & VM_WRITE) &&
!gasket_owned_by_current_tgid(_dev->dev_info)) {
dev_dbg(gasket_dev->dev,
-   "Attempting to mmap a region for write without owning "
-   "device.\n");
+   "Attempting to mmap a region for write without owning 
device.\n");
return false;
}
 
@@ -1054,8 +1053,7 @@ static int gasket_mmap(struct file *filp, struct 
vm_area_struct *vma)
}
if (bar_index > 0 && is_coherent_region) {
dev_err(gasket_dev->dev,
-   "double matching bar and coherent buffers for address "
-   "0x%lx\n",
+   "double matching bar and coherent buffers for address 
0x%lx\n",
raw_offset);
trace_gasket_mmap_exit(bar_index);
return -EINVAL;
diff --git a/drivers/staging/gasket/gasket_ioctl.c 
b/drivers/staging/gasket/gasket_ioctl.c
index 0ca48e688818..7ecfba4f2b06 100644
--- a/drivers/staging/gasket/gasket_ioctl.c
+++ b/drivers/staging/gasket/gasket_ioctl.c
@@ -353,8 +353,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void 
__user *argp)
 */
trace_gasket_ioctl_integer_data(arg);
dev_dbg(gasket_dev->dev,
-   "Unknown ioctl cmd=0x%x not caught by "
-   "gasket_is_supported_ioctl\n",
+   "Unknown ioctl cmd=0x%x not caught by 
gasket_is_supported_ioctl\n",
cmd);
retval = -EINVAL;
break;
diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index d35c4fb19e28..f6d715787da8 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -237,8 +237,8 @@ int gasket_page_table_init(struct gasket_page_table 
**ppg_tbl,
 * hardware register that contains the page table size.
 */
if (total_entries == ULONG_MAX) {
-   dev_dbg(device, "Error reading page table size. "
-   "Initializing page table with size 0\n");
+   dev_dbg(device,
+   "Error reading page table size. Initializing page table 
with size 0\n");
total_entries = 0;
}
 
@@ -491,8 +491,7 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
 
if (ret <= 0) {
dev_err(pg_tbl->device,
-   "get user pages failed for addr=0x%lx, "
-   "offset=0x%lx [ret=%d]\n",
+   "get user pages failed for addr=0x%lx, 
offset=0x%lx [ret=%d]\n",
page_addr, offset, ret);
return ret ? ret : -ENOMEM;
}
@@ -779,8 +778,8 @@ static bool gasket_is_extended_dev_addr_bad(struct 
gasket_page_table *pg_tbl,
 
if (page_lvl0_idx >= pg_tbl->num_extended_entries) {
dev_err(pg_tbl->device,
-   "starting level 0 slot at %lu is too large, max is < "
-   "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries);
+   "starting level 0 slot at %lu is too large, max is < 
%u\n",
+   page_lvl0_idx, pg_tbl->num_extended_entries);
return true;
}
 
@@ -965,8 +964,7 @@ static int gasket_map_extended_pages(struct 
gasket_page_table *pg_tbl,
if (ret) {
dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1;
dev_err(pg_tbl->device,
-   "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are "
-   "not available\n",
+   "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are 
not available\n",
gasket_extended_lvl0_page_idx(pg_tbl, dev_addr),
dev_addr,
gasket_extended_lvl1_page_idx(pg_tbl, dev_addr),
-- 
2.17.1

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


Re: [PATCH] staging: fieldbus: solve warning incorrect type dev_core.c

2019-05-21 Thread Oscar Gomez Fuente
Ok, perfect!

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


[PATCH] staging: fieldbus: anybuss: force address space conversion

2019-05-21 Thread Sven Van Asbroeck
The regmap's context (stored as 'void *') consists of a pointer to
__iomem. Mixing __iomem and non-__iomem addresses generates
sparse warnings.

Fix by using __force when converting to/from 'void __iomem *' and
the regmap's context.

Signed-off-by: Sven Van Asbroeck 
---
 drivers/staging/fieldbus/anybuss/arcx-anybus.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c 
b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
index a167fb68e355..8126e5535ada 100644
--- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c
+++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
@@ -114,7 +114,7 @@ static void export_reset_1(struct device *dev, bool assert)
 static int read_reg_bus(void *context, unsigned int reg,
unsigned int *val)
 {
-   void __iomem *base = context;
+   void __iomem *base = (__force void __iomem *)context;
 
*val = readb(base + reg);
return 0;
@@ -123,7 +123,7 @@ static int read_reg_bus(void *context, unsigned int reg,
 static int write_reg_bus(void *context, unsigned int reg,
 unsigned int val)
 {
-   void __iomem *base = context;
+   void __iomem *base = (__force void __iomem *)context;
 
writeb(val, base + reg);
return 0;
@@ -153,7 +153,7 @@ static struct regmap *create_parallel_regmap(struct 
platform_device *pdev,
base = devm_ioremap_resource(dev, res);
if (IS_ERR(base))
return ERR_CAST(base);
-   return devm_regmap_init(dev, NULL, base, _cfg);
+   return devm_regmap_init(dev, NULL, (__force void *)base, _cfg);
 }
 
 static struct anybuss_host *
-- 
2.17.1

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


Re: [PATCH v3] staging: fieldbus: core: fix ->poll() annotation

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 10:37 AM Dan Carpenter  wrote:
>
>
> If you're resending someone's patch, you have to add your own Signed off
> by line as well.  Everyone who touches a patch has to sign that they
> didn't add any of SCO's all powerful UnixWare source code into the
> patch.
>

Thank you Dan, that's very useful to know !

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


Re: [PATCH v3] staging: fieldbus: core: fix ->poll() annotation

2019-05-21 Thread Dan Carpenter
On Tue, May 21, 2019 at 10:20:09AM -0400, Sven Van Asbroeck wrote:
> From: Oscar Gomez Fuente 
> 
> ->poll() functions should return __poll_t, but the fieldbus
> core's poll() does not. This generates a sparse warning.
> 
> Fix the ->poll() return value, and use recommended __poll_t
> constants (EPOLLxxx).
> 
> Signed-off-by: Oscar Gomez Fuente 
> ---

If you're resending someone's patch, you have to add your own Signed off
by line as well.  Everyone who touches a patch has to sign that they
didn't add any of SCO's all powerful UnixWare source code into the
patch.

regards,
dan carpenter


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


[PATCH] Staging: rtl8188eu: core: Use !x in place of NULL comparisons

2019-05-21 Thread Puranjay Mohan
Change (x == NULL) to !x and (x != NULL) to x, to fix
following checkpatch.pl warnings:
CHECK: Comparison to NULL could be written "!x".

Signed-off-by: Puranjay Mohan 
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 087f6c9a5826..9caf7041ad60 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -450,7 +450,7 @@ static struct recv_frame *portctrl(struct adapter *adapter,
memcpy(_tmp, ptr, 2);
ether_type = ntohs(be_tmp);
 
-   if ((psta != NULL) && (psta->ieee8021x_blocked)) {
+   if (psta && (psta->ieee8021x_blocked)) {
/* blocked */
/* only accept EAPOL frame */
RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, 
("%s:psta->ieee8021x_blocked==1\n", __func__));
@@ -700,7 +700,7 @@ static int sta2sta_data_frame(struct adapter *adapter,
else
*psta = rtw_get_stainfo(pstapriv, sta_addr); /*  get ap_info */
 
-   if (*psta == NULL) {
+   if (!*psta) {
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta 
under %s ; drop pkt\n", __func__));
ret = _FAIL;
goto exit;
@@ -764,7 +764,7 @@ static int ap2sta_data_frame(
else
*psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /*  
get ap_info */
 
-   if (*psta == NULL) {
+   if (!*psta) {
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: 
can't get psta under STATION_MODE ; drop pkt\n"));
ret = _FAIL;
goto exit;
@@ -786,7 +786,7 @@ static int ap2sta_data_frame(
} else {
if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && !mcast) {
*psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /*  
get sta_info */
-   if (*psta == NULL) {
+   if (!*psta) {
DBG_88E("issue_deauth to the ap =%pM for the 
reason(7)\n", (pattrib->bssid));
 
issue_deauth(adapter, pattrib->bssid, 
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
@@ -820,7 +820,7 @@ static int sta2ap_data_frame(struct adapter *adapter,
}
 
*psta = rtw_get_stainfo(pstapriv, pattrib->src);
-   if (*psta == NULL) {
+   if (!*psta) {
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't 
get psta under AP_MODE; drop pkt\n"));
DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", 
(pattrib->src));
 
@@ -883,7 +883,7 @@ static int validate_recv_ctrl_frame(struct adapter 
*padapter,
aid = GetAid(pframe);
psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
 
-   if ((psta == NULL) || (psta->aid != aid))
+   if ((!psta) || (psta->aid != aid))
return _FAIL;
 
/* for rx pkt statistics */
@@ -1479,7 +1479,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter 
*padapter,
}
}
 
-   if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) {
+   if (prtnframe && (prtnframe->attrib.privacy)) {
/* after defrag we must check tkip mic code */
if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("recvframe_chkmic(padapter,  prtnframe)==_FAIL\n"));
-- 
2.21.0

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


Re: [PATCH v3] staging: fieldbus: core: fix ->poll() annotation

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 10:20 AM Sven Van Asbroeck  wrote:
>
> From: Oscar Gomez Fuente 
>
> ->poll() functions should return __poll_t, but the fieldbus
> core's poll() does not. This generates a sparse warning.
>
> Fix the ->poll() return value, and use recommended __poll_t
> constants (EPOLLxxx).
>
> Signed-off-by: Oscar Gomez Fuente 

Please ignore this patch.
> /dev/null :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fieldbus: solve warning incorrect type dev_core.c

2019-05-21 Thread Sven Van Asbroeck
On Tue, May 21, 2019 at 10:17 AM Greg KH  wrote:
>
>
> Greg already took this patch a while ago :)
>

Thanks for bringing that up Greg, I'll double-check your tree next time.

Oscar, please ignore the v3 patch I posted.

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


[PATCH v3] staging: fieldbus: core: fix ->poll() annotation

2019-05-21 Thread Sven Van Asbroeck
From: Oscar Gomez Fuente 

->poll() functions should return __poll_t, but the fieldbus
core's poll() does not. This generates a sparse warning.

Fix the ->poll() return value, and use recommended __poll_t
constants (EPOLLxxx).

Signed-off-by: Oscar Gomez Fuente 
---
 drivers/staging/fieldbus/dev_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fieldbus/dev_core.c 
b/drivers/staging/fieldbus/dev_core.c
index 60b85140675a..f6f5b92ba914 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -211,16 +211,16 @@ static ssize_t fieldbus_write(struct file *filp, const 
char __user *buf,
return fbdev->write_area(fbdev, buf, size, offset);
 }
 
-static unsigned int fieldbus_poll(struct file *filp, poll_table *wait)
+static __poll_t fieldbus_poll(struct file *filp, poll_table *wait)
 {
struct fb_open_file *of = filp->private_data;
struct fieldbus_dev *fbdev = of->fbdev;
-   unsigned int mask = POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM;
+   __poll_t mask = EPOLLIN | EPOLLRDNORM | EPOLLOUT | EPOLLWRNORM;
 
poll_wait(filp, >dc_wq, wait);
/* data changed ? */
if (fbdev->dc_event != of->dc_event)
-   mask |= POLLPRI | POLLERR;
+   mask |= EPOLLPRI | EPOLLERR;
return mask;
 }
 
-- 
2.17.1

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


Re: [PATCH] staging: fieldbus: solve warning incorrect type dev_core.c

2019-05-21 Thread Greg KH
On Tue, May 21, 2019 at 10:13:58AM -0400, Sven Van Asbroeck wrote:
> On Fri, May 17, 2019 at 1:50 PM Oscar Gomez Fuente
>  wrote:
> >
> > These changes solve a warning realated to an incorrect type inilizer in the 
> > function
> > fieldbus_poll.
> >
> > Signed-off-by: Oscar Gomez Fuente 
> > ---
> 
> I've reviewed your patch and tested it on a live system. Everything looks 
> good.
> However, I believe that your commit message could be improved.
> 
> I am going to re-post this patch as v3 (keeping you as the author) but with
> a (hopefully) improved commit message. If you provide positive feedback,
> and nobody else has any comments, I will tag it with my Reviewed-by,
> which will hopefully be Greg's cue to take the patch.

Greg already took this patch a while ago :)

thanks,

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


[PATCH] Staging: rtl8188eu: os_dep: Replace comparison with zero to !x

2019-05-21 Thread Puranjay Mohan
Change comparison to zero to !x.
Replace (x == 0) to !x.

Signed-off-by: Puranjay Mohan 
---
 drivers/staging/rtl8188eu/os_dep/rtw_android.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c 
b/drivers/staging/rtl8188eu/os_dep/rtw_android.c
index 7a090615dcbc..daf6db354982 100644
--- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c
+++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c
@@ -67,7 +67,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr)
int cmd_num;
 
for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++)
-   if (0 == strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num],
+   if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num],
  strlen(android_wifi_cmd_str[cmd_num])))
break;
return cmd_num;
-- 
2.21.0

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


Re: [PATCH] staging: fieldbus: solve warning incorrect type dev_core.c

2019-05-21 Thread Sven Van Asbroeck
On Fri, May 17, 2019 at 1:50 PM Oscar Gomez Fuente
 wrote:
>
> These changes solve a warning realated to an incorrect type inilizer in the 
> function
> fieldbus_poll.
>
> Signed-off-by: Oscar Gomez Fuente 
> ---

I've reviewed your patch and tested it on a live system. Everything looks good.
However, I believe that your commit message could be improved.

I am going to re-post this patch as v3 (keeping you as the author) but with
a (hopefully) improved commit message. If you provide positive feedback,
and nobody else has any comments, I will tag it with my Reviewed-by,
which will hopefully be Greg's cue to take the patch.

In the future you could perhaps run your patch through ./scripts/checkpatch.pl
before you post it? This should pick up missing commit messages, lines in the
commit msg that are too long, etc.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging/gasket: Fix string split

2019-05-21 Thread Greg KH
On Tue, May 21, 2019 at 03:50:12PM +0200, Tianzheng Li wrote:
> This patch removes unnecessary quoted string splits.
> Signed-off-by: Tianzheng Li 
> Signed-off-by: Jie Zhang 

We need a blank line before the signed-off-by line.

Care to fix this up and resend?

thanks,

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


[PATCH] Staging: rtl8192u: ieee80211: Replace function names in strings with "%s", __func__

2019-05-21 Thread Puranjay Mohan
Use "%s", __func__ in place of strings which contain function names.

Signed-off-by: Puranjay Mohan 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 7cac668bfb0b..59d179ae7ad2 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -51,7 +51,7 @@ static void RxPktPendingTimeout(struct timer_list *t)
if (SN_EQUAL(pReorderEntry->SeqNum, 
pRxTs->rx_indicate_seq))
pRxTs->rx_indicate_seq = 
(pRxTs->rx_indicate_seq + 1) % 4096;
 
-   IEEE80211_DEBUG(IEEE80211_DL_REORDER, 
"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum);
+   IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s: 
IndicateSeq: %d\n", __func__, pReorderEntry->SeqNum);
ieee->stats_IndicateArray[index] = 
pReorderEntry->prxb;
index++;
 
@@ -97,7 +97,7 @@ static void TsAddBaProcess(struct timer_list *t)
struct ieee80211_device *ieee = container_of(pTxTs, struct 
ieee80211_device, TxTsRecord[num]);
 
TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
-   IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is 
started!! \n");
+   IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: ADDBA Req is started!! \n", 
__func__);
 }
 
 
@@ -456,7 +456,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr)
 {
struct ts_common_info   *pTS, *pTmpTS;
 
-   printk("===>RemovePeerTS,%pM\n", Addr);
+   printk("===>%s,%pM\n", __func__, Addr);
list_for_each_entry_safe(pTS, pTmpTS, >Tx_TS_Pending_List, list) {
if (memcmp(pTS->addr, Addr, 6) == 0) {
RemoveTsEntry(ieee, pTS, TX_DIR);
@@ -525,11 +525,11 @@ void TsStartAddBaProcess(struct ieee80211_device *ieee, 
struct tx_ts_record *pTx
if (!pTxTS->add_ba_req_in_progress) {
pTxTS->add_ba_req_in_progress = true;
if (pTxTS->add_ba_req_delayed)  {
-   IEEE80211_DEBUG(IEEE80211_DL_BA, 
"TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
+   IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: Delayed Start 
ADDBA after 60 sec!!\n", __func__);
mod_timer(>ts_add_ba_timer,
  jiffies + msecs_to_jiffies(TS_ADDBA_DELAY));
} else {
-   IEEE80211_DEBUG(IEEE80211_DL_BA, 
"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
+   IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: Immediately Start 
ADDBA now!!\n", __func__);
mod_timer(>ts_add_ba_timer, jiffies+10); //set 
10 ticks
}
} else {
-- 
2.21.0

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


[PATCH] staging/gasket: Fix string split

2019-05-21 Thread Tianzheng Li
This patch removes unnecessary quoted string splits.
Signed-off-by: Tianzheng Li 
Signed-off-by: Jie Zhang 
---
 drivers/staging/gasket/gasket_core.c   |  6 ++
 drivers/staging/gasket/gasket_ioctl.c  |  3 +--
 drivers/staging/gasket/gasket_page_table.c | 14 ++
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index a445d58fb399..13179f063a61 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -702,8 +702,7 @@ static bool gasket_mmap_has_permissions(struct gasket_dev 
*gasket_dev,
if ((vma->vm_flags & VM_WRITE) &&
!gasket_owned_by_current_tgid(_dev->dev_info)) {
dev_dbg(gasket_dev->dev,
-   "Attempting to mmap a region for write without owning "
-   "device.\n");
+   "Attempting to mmap a region for write without owning 
device.\n");
return false;
}
 
@@ -1054,8 +1053,7 @@ static int gasket_mmap(struct file *filp, struct 
vm_area_struct *vma)
}
if (bar_index > 0 && is_coherent_region) {
dev_err(gasket_dev->dev,
-   "double matching bar and coherent buffers for address "
-   "0x%lx\n",
+   "double matching bar and coherent buffers for address 
0x%lx\n",
raw_offset);
trace_gasket_mmap_exit(bar_index);
return -EINVAL;
diff --git a/drivers/staging/gasket/gasket_ioctl.c 
b/drivers/staging/gasket/gasket_ioctl.c
index 0ca48e688818..7ecfba4f2b06 100644
--- a/drivers/staging/gasket/gasket_ioctl.c
+++ b/drivers/staging/gasket/gasket_ioctl.c
@@ -353,8 +353,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void 
__user *argp)
 */
trace_gasket_ioctl_integer_data(arg);
dev_dbg(gasket_dev->dev,
-   "Unknown ioctl cmd=0x%x not caught by "
-   "gasket_is_supported_ioctl\n",
+   "Unknown ioctl cmd=0x%x not caught by 
gasket_is_supported_ioctl\n",
cmd);
retval = -EINVAL;
break;
diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index d35c4fb19e28..f6d715787da8 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -237,8 +237,8 @@ int gasket_page_table_init(struct gasket_page_table 
**ppg_tbl,
 * hardware register that contains the page table size.
 */
if (total_entries == ULONG_MAX) {
-   dev_dbg(device, "Error reading page table size. "
-   "Initializing page table with size 0\n");
+   dev_dbg(device,
+   "Error reading page table size. Initializing page table 
with size 0\n");
total_entries = 0;
}
 
@@ -491,8 +491,7 @@ static int gasket_perform_mapping(struct gasket_page_table 
*pg_tbl,
 
if (ret <= 0) {
dev_err(pg_tbl->device,
-   "get user pages failed for addr=0x%lx, "
-   "offset=0x%lx [ret=%d]\n",
+   "get user pages failed for addr=0x%lx, 
offset=0x%lx [ret=%d]\n",
page_addr, offset, ret);
return ret ? ret : -ENOMEM;
}
@@ -779,8 +778,8 @@ static bool gasket_is_extended_dev_addr_bad(struct 
gasket_page_table *pg_tbl,
 
if (page_lvl0_idx >= pg_tbl->num_extended_entries) {
dev_err(pg_tbl->device,
-   "starting level 0 slot at %lu is too large, max is < "
-   "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries);
+   "starting level 0 slot at %lu is too large, max is < 
%u\n",
+   page_lvl0_idx, pg_tbl->num_extended_entries);
return true;
}
 
@@ -965,8 +964,7 @@ static int gasket_map_extended_pages(struct 
gasket_page_table *pg_tbl,
if (ret) {
dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1;
dev_err(pg_tbl->device,
-   "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are "
-   "not available\n",
+   "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are 
not available\n",
gasket_extended_lvl0_page_idx(pg_tbl, dev_addr),
dev_addr,
gasket_extended_lvl1_page_idx(pg_tbl, dev_addr),
-- 
2.17.1

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


staging: Add rtl8723bs sdio wifi driver

2019-05-21 Thread Colin Ian King
Hi,

static analysis with Coverity has detected an issues in the rtl8723bs
wifi driver:

File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function
rtw_dbg_port():

CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true.

if ((extra_arg & 0x07) > 0x07)
padapter->driver_ampdu_spacing = 0xFF;
else
padapter->driver_ampdu_spacing = extra_arg;


I'm not sure if the mask is (in)correct or the value it is being
compared to 0x07 is (in)correct (or both!)

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


[PATCH] Staging: rtl8723bs: os_dep: Remove functions that don't do anything.

2019-05-21 Thread Puranjay Mohan
Remove functions which just print the name of function and return 0,
These functions fake the network core to say that they support these
options.

Signed-off-by: Puranjay Mohan 
---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 28 +--
 1 file changed, 1 insertion(+), 27 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 12f8e3e6b1b6..996bd1a674cc 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -2439,23 +2439,7 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter 
*padapter, unsigned char
cfg80211_del_sta(ndev, da, GFP_ATOMIC);
 }
 
-static int rtw_cfg80211_monitor_if_open(struct net_device *ndev)
-{
-   int ret = 0;
-
-   DBG_8192C("%s\n", __func__);
-
-   return ret;
-}
-
-static int rtw_cfg80211_monitor_if_close(struct net_device *ndev)
-{
-   int ret = 0;
 
-   DBG_8192C("%s\n", __func__);
-
-   return ret;
-}
 
 static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, 
struct net_device *ndev)
 {
@@ -2604,20 +2588,10 @@ static netdev_tx_t 
rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc
 
 }
 
-static int rtw_cfg80211_monitor_if_set_mac_address(struct net_device *ndev, 
void *addr)
-{
-   int ret = 0;
-
-   DBG_8192C("%s\n", __func__);
 
-   return ret;
-}
 
 static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
-   .ndo_open = rtw_cfg80211_monitor_if_open,
-   .ndo_stop = rtw_cfg80211_monitor_if_close,
-   .ndo_start_xmit = rtw_cfg80211_monitor_if_xmit_entry,
-   .ndo_set_mac_address = rtw_cfg80211_monitor_if_set_mac_address,
+   .ndo_start_xmit = rtw_cfg80211_monitor_if_xmit_entry,
 };
 
 static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, 
struct net_device **ndev)
-- 
2.21.0

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


[PATCH] staging: wilc1000: remove redundant masking of pkt_offset

2019-05-21 Thread Colin King
From: Colin Ian King 

The masking update of pkg_offset is redundant as the updated
value is never read and pkg_offset is re-assigned on the next
iteration of the loop.  Clean this up by removing the redundant
assignment.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King 
---
 drivers/staging/wilc1000/wilc_wlan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 95eaf8fdf4f2..dcd728557958 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -709,9 +709,6 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 
*buffer, int size)
break;
 
if (pkt_offset & IS_MANAGMEMENT) {
-   pkt_offset &= ~(IS_MANAGMEMENT |
-   IS_MANAGMEMENT_CALLBACK |
-   IS_MGMT_STATUS_SUCCES);
buff_ptr += HOST_HDR_OFFSET;
wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len);
} else {
-- 
2.20.1

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


Re: [PATCH v3 3/6] staging: kpc2000: simplified kp2000_device retrieval in device attributes call-backs.

2019-05-21 Thread Dan Carpenter
On Fri, May 17, 2019 at 01:54:51PM +0200, Greg KH wrote:
> On Fri, May 17, 2019 at 12:03:12PM +0100, Jeremy Sowden wrote:
> >  static ssize_t  show_attr(struct device *dev, struct device_attribute 
> > *attr, char *buf)
> >  {
> > -struct pci_dev *pdev = to_pci_dev(dev);
> > -struct kp2000_device *pcard;
> > -
> > -if (!pdev)  return -ENXIO;
> > -pcard = pci_get_drvdata(pdev);
> > -if (!pcard)  return -ENXIO;
> > +struct kp2000_device *pcard = dev_get_drvdata(dev);
> 
> Wait, dev_get_drvdata() is not returning you the same pointer that
> pci_get_drvdata() does.  So I think this is now broken :(
> 

It looks sort of weird but it's fine.

> What this should look like is this:
>   struct pci_dev *pdev = to_pci_dev(dev);
>   struct kp200_device *pcard = pci_get_drvdata(pdev);
> 
>   if (!pcard)
>   return -ENODEV;
> 
> that is IF the driver really is setting the pci dev data to NULL when
> the device is removed from the driver.  Is it?

Yes.  The pci_get_drvdata() is only set to NULL after we remove the
sysfs files so pci_get_drvdata() always returns a valid pointer.

regards,
dan carpenter

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


[PATCH v6 3/6] staging: kpc2000: added separate show functions for readable kp device attributes, defined them as read-only, and declared them static.

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

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

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

The definitions are only used to populate the kp_attr_list attribute
array, so declared them as static.

Fixes the following sparse warnings:

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

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index e58bddec87ee..6b56ddcc03fa 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -39,7 +39,7 @@ static struct kp2000_device *get_pcard(struct device *dev)
return pci_get_drvdata(pdev);
 }
 
-static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
struct kp2000_device *pcard = get_pcard(dev);
@@ -47,36 +47,84 @@ static ssize_t show_attr(struct device *dev, struct 
device_attribute *attr,
if (!pcard)
return -ENXIO;
 
-   if (strcmp("ssid", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid);
+   return sprintf(buf, "%016llx\n", pcard->ssid);
+}
+static DEVICE_ATTR_RO(ssid);
 
-   if (strcmp("ddna", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna);
+static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("card_id", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id);
+   if (!pcard)
+   return -ENXIO;
+
+   return sprintf(buf, "%016llx\n", pcard->ddna);
+}
+static DEVICE_ATTR_RO(ddna);
+
+static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("hw_rev", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->hardware_revision);
+   if (!pcard)
+   return -ENXIO;
 
-   if (strcmp("build", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_version);
+   return sprintf(buf, "%08x\n", pcard->card_id);
+}
+static DEVICE_ATTR_RO(card_id);
 
-   if (strcmp("build_date", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_datestamp);
+static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("build_time", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_timestamp);
+   if (!pcard)
+   return -ENXIO;
 
-   return -ENXIO;
+   return sprintf(buf, "%08x\n", pcard->hardware_revision);
 }
+static DEVICE_ATTR_RO(hw_rev);
 
-static ssize_t show_cpld_config_reg(struct device *dev,
-   struct device_attribute *attr, char *buf)
+static ssize_t build_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
+
+   if (!pcard)
+   return -ENXIO;
+
+   return sprintf(buf, 

[PATCH v6 2/6] staging: kpc2000: added a helper to get struct kp2000_device from struct device.

2019-05-21 Thread Jeremy Sowden
The attribute call-backs all use the same formula to get the pcard from
dev:

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

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

Added a function to reduce the duplicated code.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index f1735237cfb6..e58bddec87ee 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -29,15 +29,21 @@
  * SysFS Attributes
  **/
 
-static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
-char *buf)
+static struct kp2000_device *get_pcard(struct device *dev)
 {
struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
 
if (!pdev)
-   return -ENXIO;
-   pcard = pci_get_drvdata(pdev);
+   return NULL;
+
+   return pci_get_drvdata(pdev);
+}
+
+static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
+
if (!pcard)
return -ENXIO;
 
@@ -72,14 +78,9 @@ static ssize_t show_attr(struct device *dev, struct 
device_attribute *attr,
 static ssize_t show_cpld_config_reg(struct device *dev,
struct device_attribute *attr, char *buf)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
+   struct kp2000_device *pcard = get_pcard(dev);
u64 val;
 
-   if (!pdev)
-   return -ENXIO;
-
-   pcard = pci_get_drvdata(pdev);
if (!pcard)
return -ENXIO;
 
@@ -91,14 +92,10 @@ static ssize_t cpld_reconfigure(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
+   struct kp2000_device *pcard = get_pcard(dev);
long wr_val;
-   struct kp2000_device *pcard;
int rv;
 
-   if (!pdev)
-   return -ENXIO;
-   pcard = pci_get_drvdata(pdev);
if (!pcard)
return -ENXIO;
 
-- 
2.20.1

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


[PATCH v6 1/6] staging: kpc2000: improved formatting of core.c.

2019-05-21 Thread Jeremy Sowden
  * Indented with tabs.
  * Broke lines over 80 columns where possible.
  * Removed braces from one-statement blocks.
  * Tidied up some comments.
  * Removed multiple blank lines.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 8e6db806f260..f1735237cfb6 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -26,28 +26,51 @@
 #include "uapi.h"
 
 /***
-  * SysFS Attributes
-  **/
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+ * SysFS Attributes
+ **/
+
+static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+char *buf)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct kp2000_device *pcard;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
-if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
-if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
-if (strcmp("card_id", attr->attr.name) == 0){  return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->card_id);  } else
-if (strcmp("hw_rev", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->hardware_revision);  } else
-if (strcmp("build", attr->attr.name) == 0){return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_version);  } else
-if (strcmp("build_date", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_datestamp);  } else
-if (strcmp("build_time", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_timestamp);  } else
-{ return -ENXIO; }
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct kp2000_device *pcard;
+
+   if (!pdev)
+   return -ENXIO;
+   pcard = pci_get_drvdata(pdev);
+   if (!pcard)
+   return -ENXIO;
+
+   if (strcmp("ssid", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid);
+
+   if (strcmp("ddna", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna);
+
+   if (strcmp("card_id", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id);
+
+   if (strcmp("hw_rev", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->hardware_revision);
+
+   if (strcmp("build", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_version);
+
+   if (strcmp("build_date", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_datestamp);
+
+   if (strcmp("build_time", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_timestamp);
+
+   return -ENXIO;
 }
 
-static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t show_cpld_config_reg(struct device *dev,
+   struct device_attribute *attr, char *buf)
 {
struct pci_dev *pdev = to_pci_dev(dev);
struct kp2000_device *pcard;
@@ -63,27 +86,33 @@ static ssize_t  show_cpld_config_reg(struct device *dev, 
struct device_attribute
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
-static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
+
+static ssize_t cpld_reconfigure(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-long wr_val;
-struct kp2000_device *pcard;
-int rv;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
-rv = kstrtol(buf, 0, _val);
-if (rv < 0)  return rv;
-if (wr_val > 7)  return -EINVAL;
-
-wr_val = wr_val << 8;
-wr_val |= 0x1; // Set the "Configure Go" bit
-writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
-return count;
-}
+   struct pci_dev *pdev = to_pci_dev(dev);
+   long wr_val;
+   struct kp2000_device *pcard;
+   int rv;
+
+   if (!pdev)
+   return -ENXIO;
+  

[PATCH v6 0/6] staging: kpc2000: another batch of fixes

2019-05-21 Thread Jeremy Sowden
There are a number relating to device attributes, one formatting patch,
and another that changes how card numbers are assigned.

Greg reckoned that the changes to the code in the attribute call-backs
that gets the struct kpc2000 object from the struct device object were
broken.  I've reviewed them and split them into two patches because I
was doing two different things in the previous patch.  I *think* they
are correct, but I've moved them to the end of the series in case I
really have just got the wrong end of the stick, so they can easily be
dropped.

Jeremy Sowden (6):
  staging: kpc2000: improved formatting of core.c.
  staging: kpc2000: added a helper to get struct kp2000_device from
struct device.
  staging: kpc2000: added separate show functions for readable kp device
attributes, defined them as read-only, and declared them static.
  staging: kpc2000: use IDA to assign card numbers.
  staging: kpc2000: simplified kp2000_device retrieval in device
attribute call-backs.
  staging: kpc2000: removed superfluous NULL checks from device
attribute call-backs.

 drivers/staging/kpc2000/TODO   |   1 -
 drivers/staging/kpc2000/kpc2000/core.c | 818 ++---
 2 files changed, 452 insertions(+), 367 deletions(-)

Since v5:

  * dropped two patches that Greg has applied;
  * rebased on to staging-testing.

Since v4:

  * rebased on to staging-next to pick up Greg's most recent changes.
  * made a few changes to some commit messages.
  * sent out the right versions of the patches.

Since v3:

  * added the formatting patch for core.c and folded the kp device
attribute formatting fixes into it;
  * added the patch that introduces get_pcard();
  * added missing clean-up of IDA and reworded the commit message;
  * split the patch that simplified the retrieval of struct
kp2000_device from struct dev in the show call-backs into two, and
moved them to the end of the series.

Since v2:

  * dropped the white-space patch since Greg has applied it;
  * added a reported-by tag to patch that drops two attributes;
  * merged the patches that declared attributes static with the ones
that split up the show call-backs;
  * moved the attribute definitions next to their call-backs;
  * moved the patch that fixed the card-number race to the end of the
  * series;
  * use an IDA to fix the card-number race, not an atomic_t.

Since v1:

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

-- 
2.20.1

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


[PATCH v6 5/6] staging: kpc2000: simplified kp2000_device retrieval in device attribute call-backs.

2019-05-21 Thread Jeremy Sowden
All the call-backs used the same formula to retrieve the pcard from dev:

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

  if (!pdev)
return NULL;

  pcard = pci_get_drvdata(pdev);

Since to_pci_dev is a wrapper for container_of, it will not return NULL,
and since pci_get_drvdata just calls dev_get_drvdata on the dev member
of pdev, this is equivalent to:

  struct kp2000_device *pcard = dev_get_drvdata(&(container_of(dev, struct 
pci_dev, dev)->dev));

and we can simplify it to:

  struct kp2000_device *pcard = dev_get_drvdata(dev);

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 7d6b99fcd2bd..2af4170a0d68 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -32,20 +32,10 @@ static DEFINE_IDA(card_num_ida);
  * SysFS Attributes
  **/
 
-static struct kp2000_device *get_pcard(struct device *dev)
-{
-   struct pci_dev *pdev = to_pci_dev(dev);
-
-   if (!pdev)
-   return NULL;
-
-   return pci_get_drvdata(pdev);
-}
-
 static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -57,7 +47,7 @@ static DEVICE_ATTR_RO(ssid);
 static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -69,7 +59,7 @@ static DEVICE_ATTR_RO(ddna);
 static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -81,7 +71,7 @@ static DEVICE_ATTR_RO(card_id);
 static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
   char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -93,7 +83,7 @@ static DEVICE_ATTR_RO(hw_rev);
 static ssize_t build_show(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -105,7 +95,7 @@ static DEVICE_ATTR_RO(build);
 static ssize_t build_date_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -117,7 +107,7 @@ static DEVICE_ATTR_RO(build_date);
 static ssize_t build_time_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -129,7 +119,7 @@ static DEVICE_ATTR_RO(build_time);
 static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
if (!pcard)
@@ -144,7 +134,7 @@ static ssize_t cpld_reconfigure(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
long wr_val;
int rv;
 
-- 
2.20.1

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


[PATCH v6 4/6] staging: kpc2000: use IDA to assign card numbers.

2019-05-21 Thread Jeremy Sowden
Previously the next card number was assigned from a static int local
variable.  Replaced it with an IDA.  Avoids the assignment of ever-
increasing card-numbers by allowing them to be reused.

Updated TODO.

Corrected format-specifier for unsigned pcard->card_num.

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

diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO
index 669fe5bf9637..47530e23e940 100644
--- a/drivers/staging/kpc2000/TODO
+++ b/drivers/staging/kpc2000/TODO
@@ -1,6 +1,5 @@
 - the kpc_spi driver doesn't seem to let multiple transactions (to different 
instances of the core) happen in parallel...
 - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton.  
It functions against current hardware though.
-- pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic 
/ locking / something better.
 - would be nice if the AIO fileops in kpc_dma could be made to work
 - probably want to add a CONFIG_ option to control compilation of the AIO 
functions
 - if the AIO fileops in kpc_dma start working, next would be making iov_count 
> 1 work too
diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 6b56ddcc03fa..7d6b99fcd2bd 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +26,8 @@
 #include "pcie.h"
 #include "uapi.h"
 
+static DEFINE_IDA(card_num_ida);
+
 /***
  * SysFS Attributes
  **/
@@ -388,7 +391,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 {
int err = 0;
struct kp2000_device *pcard;
-   static int card_count = 1;
int rv;
unsigned long reg_bar_phys_addr;
unsigned long reg_bar_phys_len;
@@ -414,9 +416,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
/*
 * Step 2: Initialize trivial pcard elements
 */
-   pcard->card_num = card_count;
-   card_count++;
-   scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num);
+   err = ida_simple_get(_num_ida, 1, INT_MAX, GFP_KERNEL);
+   if (err < 0) {
+   dev_err(>dev, "probe: failed to get card number (%d)\n",
+   err);
+   goto out2;
+   }
+   pcard->card_num = err;
+   scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num);
 
mutex_init(>sem);
mutex_lock(>sem);
@@ -630,6 +637,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pci_disable_device(pcard->pdev);
 out3:
mutex_unlock(>sem);
+   ida_simple_remove(_num_ida, pcard->card_num);
+out2:
kfree(pcard);
return err;
 }
@@ -663,6 +672,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
pci_disable_device(pcard->pdev);
pci_set_drvdata(pdev, NULL);
mutex_unlock(>sem);
+   ida_simple_remove(_num_ida, pcard->card_num);
kfree(pcard);
 }
 
@@ -698,6 +708,7 @@ static void __exit  kp2000_pcie_exit(void)
 {
pci_unregister_driver(_driver_inst);
class_destroy(kpc_uio_class);
+   ida_destroy(_num_ida);
 }
 module_exit(kp2000_pcie_exit);
 
-- 
2.20.1

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


[PATCH v6 6/6] staging: kpc2000: removed superfluous NULL checks from device attribute call-backs.

2019-05-21 Thread Jeremy Sowden
All the attribute show call-backs check whether pcard is NULL.  However,
pci_set_drvdata(pdev, pcard) is called before the sysfs files are
created during probe, and pci_set_drvdata(pdev, NULL) is not called
until after they are destroyed during remove; therefore, pcard will not
be NULL, and we can drop the checks.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 2af4170a0d68..4110032d0cbb 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -37,9 +37,6 @@ static ssize_t ssid_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%016llx\n", pcard->ssid);
 }
 static DEVICE_ATTR_RO(ssid);
@@ -49,9 +46,6 @@ static ssize_t ddna_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%016llx\n", pcard->ddna);
 }
 static DEVICE_ATTR_RO(ddna);
@@ -61,9 +55,6 @@ static ssize_t card_id_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->card_id);
 }
 static DEVICE_ATTR_RO(card_id);
@@ -73,9 +64,6 @@ static ssize_t hw_rev_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->hardware_revision);
 }
 static DEVICE_ATTR_RO(hw_rev);
@@ -85,9 +73,6 @@ static ssize_t build_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_version);
 }
 static DEVICE_ATTR_RO(build);
@@ -97,9 +82,6 @@ static ssize_t build_date_show(struct device *dev,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_datestamp);
 }
 static DEVICE_ATTR_RO(build_date);
@@ -109,9 +91,6 @@ static ssize_t build_time_show(struct device *dev,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_timestamp);
 }
 static DEVICE_ATTR_RO(build_time);
@@ -122,9 +101,6 @@ static ssize_t cpld_reg_show(struct device *dev, struct 
device_attribute *attr,
struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
-   if (!pcard)
-   return -ENXIO;
-
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return sprintf(buf, "%016llx\n", val);
 }
@@ -138,9 +114,6 @@ static ssize_t cpld_reconfigure(struct device *dev,
long wr_val;
int rv;
 
-   if (!pcard)
-   return -ENXIO;
-
rv = kstrtol(buf, 0, _val);
if (rv < 0)
return rv;
-- 
2.20.1

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


Re: [PATCH 0/5] Updates to staging driver: kpc_i2c

2019-05-21 Thread Greg Kroah-Hartman
On Tue, May 21, 2019 at 08:15:52AM +, Geordan Neukum wrote:
> On Mon, May 20, 2019 at 10:30:26AM +0200, Greg Kroah-Hartman wrote:
> > On Sat, May 18, 2019 at 02:29:55AM +, Geordan Neukum wrote:
> > > Attached are an assortment of updates to the kpc_i2c driver in the
> > > staging subtree.
> >
> > All now queued up.  I'll rebase my patches that move this file on top of
> > yours, as kbuild found some problems with mine, and I'll resend them to
> > the list.
> >
> Thanks.
> 
> Additionally, I plan on trying to clean up that driver a bit more. Should I
> base my future patches off of the staging tree so that I'll have the
> "latest" driver as my basepoint? I don't want to cause any headaches
> for anyone in the future.

Yes, please do so.  Please work off of either the staging-next or even
better, staging-testing as that contains the latest patches.  I apply
patches to the -testing branch first, and if that passes the 0-day bot,
I then merge them to -next.

Given that there are a lot of people working on this codebase right now
(as it needs so much obvious work), I would recommend using -next and
getting used to rebasing your changes :)

I take patches as they are submitted, so sometimes people do step on
each other's toes, that's normal.  But I think you are the only one
touching the i2c driver at the moment so it shouldn't be that bad.

> Apologies, if I missed something obvious on the newbies wiki.
> Assuming that I did not, I will certainly go ahead and try to document
> this case either on or as a link from the "sending your first patch"
> page.

This is beyond the "first patch" work, this is now in the "being an
active developer" workflow :)

thanks,

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


Re: [PATCH 0/5] Updates to staging driver: kpc_i2c

2019-05-21 Thread Geordan Neukum
> On Mon, May 20, 2019 at 10:30:26AM +0200, Greg Kroah-Hartman wrote:
>
> All now queued up.  I'll rebase my patches that move this file on top of
> yours, as kbuild found some problems with mine, and I'll resend them to
> the list.
>
> Thanks.

** Same content as last reply, just realized that I had configured my
** email client to do something wrong. Resend for readability's sake.

Additionally, I plan on trying to clean up that driver a bit more. Should I
base my future patches off of the staging tree so that I'll have the
"latest" driver as my basepoint? I don't want to cause any headaches
for anyone in the future.

Apologies, if I missed something obvious on the newbies wiki.
Assuming that I did not, I will certainly go ahead and try to document
this case either on or as a link from the "sending your first patch"
page.

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


Re: [PATCH v5 3/8] staging: kpc2000: improved formatting of core.c.

2019-05-21 Thread Jeremy Sowden


Re: [PATCH v5 3/8] staging: kpc2000: improved formatting of core.c.

2019-05-21 Thread Greg KH
On Tue, May 21, 2019 at 08:56:30AM +0100, Jeremy Sowden wrote:
>   * Indented with tabs.
>   * Broke lines over 80 columns where possible.
>   * Removed braces from one-statement blocks.
>   * Tidied up some comments.
>   * Removed multiple blank lines.
> 
> Signed-off-by: Jeremy Sowden 
> ---
>  drivers/staging/kpc2000/kpc2000/core.c | 788 ++---
>  1 file changed, 434 insertions(+), 354 deletions(-)

This patch fails to apply to my tree.  Can you rebase your series on my
staging-testing branch and resend?  I've applied the first two already.

thanks,

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


Re: [PATCH 0/5] Updates to staging driver: kpc_i2c

2019-05-21 Thread Geordan Neukum
On Mon, May 20, 2019 at 10:30:26AM +0200, Greg Kroah-Hartman wrote:
> On Sat, May 18, 2019 at 02:29:55AM +, Geordan Neukum wrote:
> > Attached are an assortment of updates to the kpc_i2c driver in the
> > staging subtree.
>
> All now queued up.  I'll rebase my patches that move this file on top of
> yours, as kbuild found some problems with mine, and I'll resend them to
> the list.
>
Thanks.

Additionally, I plan on trying to clean up that driver a bit more. Should I
base my future patches off of the staging tree so that I'll have the
"latest" driver as my basepoint? I don't want to cause any headaches
for anyone in the future.

Apologies, if I missed something obvious on the newbies wiki.
Assuming that I did not, I will certainly go ahead and try to document
this case either on or as a link from the "sending your first patch"
page.

Cheers,
Geordan

On Mon, May 20, 2019 at 8:30 AM Greg Kroah-Hartman
 wrote:
>
> On Sat, May 18, 2019 at 02:29:55AM +, Geordan Neukum wrote:
> > Attached are an assortment of updates to the kpc_i2c driver in the
> > staging subtree.
>
> All now queued up.  I'll rebase my patches that move this file on top of
> yours, as kbuild found some problems with mine, and I'll resend them to
> the list.
>
> thanks,
>
> greg k-h
___
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-05-21 Thread Sergio Paracuellos
Hi Greg,

On Tue, May 21, 2019 at 8:44 AM Greg Ungerer  wrote:
>
>
> Hi Sergio,
>
> I am working on a couple of different MedaiTek MT7621 based platforms
> and am having problems with the PCI bus on those.
>
> Big picture is that the PCI bus on my boards worked in linux-4.20
> (with the obvious compilation breakage fixed), and it does not work
> in linux-5.0 or linux-5.1.
>
> On linux-4.20 the PCI bus probe at kernel boot looks like this:
>
> * Xtal 40MHz *
> PCIE1 no card, disable it(RST)
> PCIE2 no card, disable it(RST)
> PCIE0 enabled
> PCI coherence region base: 0x6000, mask/settings: 0xf002
> mt7621-pci 1e14.pcie: PCI host bridge to bus :00
> pci_bus :00: root bus resource [io  0x]
> pci_bus :00: root bus resource [mem 0x6000-0x6fff]
> pci_bus :00: root bus resource [bus 00-ff]
> pci :00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
> pci :00:00.0: PCI bridge to [bus 01-ff]
> pci :00:00.0: BAR 0: no space for [mem size 0x8000]
> pci :00:00.0: BAR 0: failed to assign [mem size 0x8000]
> pci :00:00.0: BAR 8: assigned [mem 0x6000-0x601f]
> pci :00:00.0: BAR 9: assigned [mem 0x6020-0x602f pref]
> pci :00:00.0: BAR 1: assigned [mem 0x6030-0x6030]
> pci :00:00.0: BAR 7: no space for [io  size 0x1000]
> pci :00:00.0: BAR 7: failed to assign [io  size 0x1000]
> pci :01:00.0: BAR 0: assigned [mem 0x6000-0x601f 64bit]
> pci :01:00.0: BAR 6: assigned [mem 0x6020-0x6020 pref]
> pci :00:00.0: PCI bridge to [bus 01]
> pci :00:00.0:   bridge window [mem 0x6000-0x601f]
> pci :00:00.0:   bridge window [mem 0x6020-0x602f pref]
>
> The PCI bus works, and devices on it are found and work as expected.
>
> On linux-5.1 the PCI initialization and probe fails, with the kernel
> locking up:
>
> ...
> mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
> mt7621-pci 1e14.pcie: Initiating port 0 failed
> mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
> mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
> mt7621-pci 1e14.pcie: Initiating port 1 failed
> mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
> mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
> mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)
>
> The lockup is in mt7621_pci_phy_power_off(), at the phy_read() call.
> If I modify that code and return immediately in that 
> mt7621_pci_phy_power_off()
> the systemboots - but obviously from the above you can see that the PCI bus
> and no devices were detected.

There are two changes with this two commits:

commit 36d657b011ef49b549aae44d0fe49ce845beb975
Author: Sergio Paracuellos 
Date:   Wed Apr 17 13:58:38 2019 +0200

staging: mt7621-pci-phy: convert driver to use kernel regmap API's

Instead of using writel and readl use regmap API which makes
the driver maintainability easier.

Signed-off-by: Sergio Paracuellos 
Signed-off-by: Greg Kroah-Hartman 

commit 9445ccb3714c78c26a3a25fafed4d9d965080431
Author: Sergio Paracuellos 
Date:   Wed Apr 17 13:58:37 2019 +0200

staging: mt7621-pci-phy: add quirks for 'E2' revision using
'soc_device_attribute'

Depending on revision of the chip, 'mt7621_bypass_pipe_rst' function
must be executed. Add better support for this using 'soc_device_match'
in driver probe function.

Signed-off-by: Sergio Paracuellos 
Signed-off-by: Greg Kroah-Hartman 

So, I added a quirk for E2 revision of the board as I was suggested to
do by the phy
tree maintainer, and this is the only place I can think the problem could be.

I think all te changes before this was properly tested by Neil and
results in a working
PCI.

>
> Copying in the working linux-4.20 pci-mt7621.c into place on
> linux-5.1 results in a working PCI bus also. I have 2 very different
> MT7621 based boards, and they both exhibit this same problem.
>
> I tried bisecting that back to find the problem commit.
> It was not at all easy with quite a few of the mt7621 PCI related
> patches not building in isolation while bisecting. But ultimately
> I got to commit 745eeeac68d7 ("staging: mt7621-pci: factor out
> 'mt7621_pcie_enable_port' function").

Sorry for your time in this and for the problems with isolation patches. I'll
do my best from now to this don't happen again. The problem commit
you are pointing out here had problems at first because depending on the
revision of the chip the reset lines are inverted but this was properly fixed in
this other commit:

commit e51844bf825169024e0c743a92cf264e27f2366f
Author: Sergio Paracuellos 
Date:   Sat Nov 24 18:54:54 2018 +0100

staging: mt7621-pci: fix reset lines for each pcie port

Depending of chip revision reset lines are inverted. It is also
necessary 

Re: TODO advice for octeon-usb?

2019-05-21 Thread Greg Kroah-Hartman
On Tue, May 21, 2019 at 02:05:32AM +0300, Aaro Koskinen wrote:
> Hi,
> 
> I'm looking for input what should be done next to get
> drivers/staging/octeon-usb out of staging.
> 
> Thousands of checkpatch errors/warnings have been fixed (starting point
> was ),
> also the size of the driver has shrunken considerably.
> 
> If there are still some other bigger issues with this driver, please
> let me know.

Submit it as a patch that just adds the files to the drivers/usb/host/
directory so we can review it on linux-usb@vger and if it gets accepted,
I can then drop it from the staging directory, or just move it over if
no changes are needed.

thanks,

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


[PATCH v5 2/8] staging: kpc2000: removed two kpc_uio_class device attributes.

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

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

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 3796f034312a..0181b0a8ff82 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -172,20 +172,6 @@ static ssize_t type_show(struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR_RO(type);
 
-static ssize_t s2c_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-static DEVICE_ATTR_RO(s2c_dma_ch);
-
-static ssize_t c2s_dma_ch_show(struct device *dev,
-  struct device_attribute *attr, char *buf)
-{
-   return 0;
-}
-static DEVICE_ATTR_RO(c2s_dma_ch);
-
 static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr,
char *buf)
 {
@@ -241,8 +227,6 @@ struct attribute *kpc_uio_class_attrs[] = {
_attr_offset.attr,
_attr_size.attr,
_attr_type.attr,
-   _attr_s2c_dma_ch.attr,
-   _attr_c2s_dma_ch.attr,
_attr_s2c_dma.attr,
_attr_c2s_dma.attr,
_attr_irq_count.attr,
-- 
2.20.1

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


[PATCH v5 5/8] staging: kpc2000: added separate show functions for readable kp device attributes, defined them as read-only, and declared them static.

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

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

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

The definitions are only used to populate the kp_attr_list attribute
array, so declared them as static.

Fixes the following sparse warnings:

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

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 1d10e252c8da..2f4000f53740 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -32,7 +32,7 @@ static struct kp2000_device *get_pcard(struct device *dev)
return pci_get_drvdata(pdev);
 }
 
-static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
struct kp2000_device *pcard = get_pcard(dev);
@@ -40,36 +40,84 @@ static ssize_t show_attr(struct device *dev, struct 
device_attribute *attr,
if (!pcard)
return -ENXIO;
 
-   if (strcmp("ssid", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid);
+   return sprintf(buf, "%016llx\n", pcard->ssid);
+}
+static DEVICE_ATTR_RO(ssid);
 
-   if (strcmp("ddna", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna);
+static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("card_id", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id);
+   if (!pcard)
+   return -ENXIO;
+
+   return sprintf(buf, "%016llx\n", pcard->ddna);
+}
+static DEVICE_ATTR_RO(ddna);
+
+static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("hw_rev", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->hardware_revision);
+   if (!pcard)
+   return -ENXIO;
 
-   if (strcmp("build", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_version);
+   return sprintf(buf, "%08x\n", pcard->card_id);
+}
+static DEVICE_ATTR_RO(card_id);
 
-   if (strcmp("build_date", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_datestamp);
+static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
 
-   if (strcmp("build_time", attr->attr.name) == 0)
-   return scnprintf(buf, PAGE_SIZE, "%08x\n",
-pcard->build_timestamp);
+   if (!pcard)
+   return -ENXIO;
 
-   return -ENXIO;
+   return sprintf(buf, "%08x\n", pcard->hardware_revision);
 }
+static DEVICE_ATTR_RO(hw_rev);
 
-static ssize_t show_cpld_config_reg(struct device *dev,
-   struct device_attribute *attr, char *buf)
+static ssize_t build_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
+
+   if (!pcard)
+   return -ENXIO;
+
+   return sprintf(buf, 

[PATCH v5 1/8] staging: kpc2000: added separate show functions for kpc_uio_class device attributes, defined them as read-only and declared them static.

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

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

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

The definitions are only used to populate the kpc_uio_class_attrs
attribute array, so declared them as static.

Fixes the following sparse warnings:

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

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

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

[PATCH v5 7/8] staging: kpc2000: simplified kp2000_device retrieval in device attribute call-backs.

2019-05-21 Thread Jeremy Sowden
All the call-backs used the same formula to retrieve the pcard from dev:

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

  if (!pdev)
return NULL;

  pcard = pci_get_drvdata(pdev);

Since to_pci_dev is a wrapper for container_of, it will not return NULL,
and since pci_get_drvdata just calls dev_get_drvdata on the dev member
of pdev, this is equivalent to:

  struct kp2000_device *pcard = dev_get_drvdata(&(container_of(dev, struct 
pci_dev, dev)->dev));

and we can simplify it to:

  struct kp2000_device *pcard = dev_get_drvdata(dev);

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 35e54e494fa3..f5ad90b17959 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -25,20 +25,10 @@ static DEFINE_IDA(card_num_ida);
  * SysFS Attributes
  **/
 
-static struct kp2000_device *get_pcard(struct device *dev)
-{
-   struct pci_dev *pdev = to_pci_dev(dev);
-
-   if (!pdev)
-   return NULL;
-
-   return pci_get_drvdata(pdev);
-}
-
 static ssize_t ssid_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -50,7 +40,7 @@ static DEVICE_ATTR_RO(ssid);
 static ssize_t ddna_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -62,7 +52,7 @@ static DEVICE_ATTR_RO(ddna);
 static ssize_t card_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -74,7 +64,7 @@ static DEVICE_ATTR_RO(card_id);
 static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr,
   char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -86,7 +76,7 @@ static DEVICE_ATTR_RO(hw_rev);
 static ssize_t build_show(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -98,7 +88,7 @@ static DEVICE_ATTR_RO(build);
 static ssize_t build_date_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -110,7 +100,7 @@ static DEVICE_ATTR_RO(build_date);
 static ssize_t build_time_show(struct device *dev,
   struct device_attribute *attr, char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
 
if (!pcard)
return -ENXIO;
@@ -122,7 +112,7 @@ static DEVICE_ATTR_RO(build_time);
 static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr,
 char *buf)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
if (!pcard)
@@ -137,7 +127,7 @@ static ssize_t cpld_reconfigure(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct kp2000_device *pcard = get_pcard(dev);
+   struct kp2000_device *pcard = dev_get_drvdata(dev);
long wr_val;
int rv;
 
-- 
2.20.1

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


[PATCH v5 6/8] staging: kpc2000: use IDA to assign card numbers.

2019-05-21 Thread Jeremy Sowden
Previously the next card number was assigned from a static int local
variable.  Replaced it with an IDA.  Avoids the assignment of ever-
increasing card-numbers by allowing them to be reused.

Updated TODO.

Corrected format-specifier for unsigned pcard->card_num.

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

diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO
index 669fe5bf9637..47530e23e940 100644
--- a/drivers/staging/kpc2000/TODO
+++ b/drivers/staging/kpc2000/TODO
@@ -1,6 +1,5 @@
 - the kpc_spi driver doesn't seem to let multiple transactions (to different 
instances of the core) happen in parallel...
 - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton.  
It functions against current hardware though.
-- pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic 
/ locking / something better.
 - would be nice if the AIO fileops in kpc_dma could be made to work
 - probably want to add a CONFIG_ option to control compilation of the AIO 
functions
 - if the AIO fileops in kpc_dma start working, next would be making iov_count 
> 1 work too
diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 2f4000f53740..35e54e494fa3 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include 
 #include 
 #include 
 #include 
@@ -18,6 +19,8 @@
 #include 
 #include "pcie.h"
 
+static DEFINE_IDA(card_num_ida);
+
 /***
  * SysFS Attributes
  **/
@@ -275,7 +278,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 {
int err = 0;
struct kp2000_device *pcard;
-   static int card_count = 1;
int rv;
unsigned long reg_bar_phys_addr;
unsigned long reg_bar_phys_len;
@@ -301,9 +303,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
/*
 * Step 2: Initialize trivial pcard elements
 */
-   pcard->card_num = card_count;
-   card_count++;
-   scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num);
+   err = ida_simple_get(_num_ida, 1, INT_MAX, GFP_KERNEL);
+   if (err < 0) {
+   dev_err(>dev, "probe: failed to get card number (%d)\n",
+   err);
+   goto out2;
+   }
+   pcard->card_num = err;
+   scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num);
 
mutex_init(>sem);
mutex_lock(>sem);
@@ -518,6 +525,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pci_disable_device(pcard->pdev);
 out3:
mutex_unlock(>sem);
+   ida_simple_remove(_num_ida, pcard->card_num);
+out2:
kfree(pcard);
return err;
 }
@@ -551,6 +560,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
pci_disable_device(pcard->pdev);
pci_set_drvdata(pdev, NULL);
mutex_unlock(>sem);
+   ida_simple_remove(_num_ida, pcard->card_num);
kfree(pcard);
 }
 
@@ -586,6 +596,7 @@ static void __exit  kp2000_pcie_exit(void)
 {
pci_unregister_driver(_driver_inst);
class_destroy(kpc_uio_class);
+   ida_destroy(_num_ida);
 }
 module_exit(kp2000_pcie_exit);
 
-- 
2.20.1

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


[PATCH v5 8/8] staging: kpc2000: removed superfluous NULL checks from device attribute call-backs.

2019-05-21 Thread Jeremy Sowden
All the attribute show call-backs check whether pcard is NULL.  However,
pci_set_drvdata(pdev, pcard) is called before the sysfs files are
created during probe, and pci_set_drvdata(pdev, NULL) is not called
until after they are destroyed during remove; therefore, pcard will not
be NULL, and we can drop the checks.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index f5ad90b17959..3a4773183cab 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -30,9 +30,6 @@ static ssize_t ssid_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%016llx\n", pcard->ssid);
 }
 static DEVICE_ATTR_RO(ssid);
@@ -42,9 +39,6 @@ static ssize_t ddna_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%016llx\n", pcard->ddna);
 }
 static DEVICE_ATTR_RO(ddna);
@@ -54,9 +48,6 @@ static ssize_t card_id_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->card_id);
 }
 static DEVICE_ATTR_RO(card_id);
@@ -66,9 +57,6 @@ static ssize_t hw_rev_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->hardware_revision);
 }
 static DEVICE_ATTR_RO(hw_rev);
@@ -78,9 +66,6 @@ static ssize_t build_show(struct device *dev, struct 
device_attribute *attr,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_version);
 }
 static DEVICE_ATTR_RO(build);
@@ -90,9 +75,6 @@ static ssize_t build_date_show(struct device *dev,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_datestamp);
 }
 static DEVICE_ATTR_RO(build_date);
@@ -102,9 +84,6 @@ static ssize_t build_time_show(struct device *dev,
 {
struct kp2000_device *pcard = dev_get_drvdata(dev);
 
-   if (!pcard)
-   return -ENXIO;
-
return sprintf(buf, "%08x\n", pcard->build_timestamp);
 }
 static DEVICE_ATTR_RO(build_time);
@@ -115,9 +94,6 @@ static ssize_t cpld_reg_show(struct device *dev, struct 
device_attribute *attr,
struct kp2000_device *pcard = dev_get_drvdata(dev);
u64 val;
 
-   if (!pcard)
-   return -ENXIO;
-
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return sprintf(buf, "%016llx\n", val);
 }
@@ -131,9 +107,6 @@ static ssize_t cpld_reconfigure(struct device *dev,
long wr_val;
int rv;
 
-   if (!pcard)
-   return -ENXIO;
-
rv = kstrtol(buf, 0, _val);
if (rv < 0)
return rv;
-- 
2.20.1

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


[PATCH v5 3/8] staging: kpc2000: improved formatting of core.c.

2019-05-21 Thread Jeremy Sowden
  * Indented with tabs.
  * Broke lines over 80 columns where possible.
  * Removed braces from one-statement blocks.
  * Tidied up some comments.
  * Removed multiple blank lines.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index d8c44cc59ed7..65e31bf01227 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -18,30 +18,52 @@
 #include 
 #include "pcie.h"
 
-
 /***
-  * SysFS Attributes
-  **/
-static ssize_t  show_attr(struct device *dev, struct device_attribute *attr, 
char *buf)
+ * SysFS Attributes
+ **/
+
+static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+char *buf)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-struct kp2000_device *pcard;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
-if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ssid);  } else
-if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, 
PAGE_SIZE, "%016llx\n", pcard->ddna);  } else
-if (strcmp("card_id", attr->attr.name) == 0){  return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->card_id);  } else
-if (strcmp("hw_rev", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->hardware_revision);  } else
-if (strcmp("build", attr->attr.name) == 0){return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_version);  } else
-if (strcmp("build_date", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_datestamp);  } else
-if (strcmp("build_time", attr->attr.name) == 0){   return scnprintf(buf, 
PAGE_SIZE, "%08x\n", pcard->build_timestamp);  } else
-{ return -ENXIO; }
+   struct pci_dev *pdev = to_pci_dev(dev);
+   struct kp2000_device *pcard;
+
+   if (!pdev)
+   return -ENXIO;
+   pcard = pci_get_drvdata(pdev);
+   if (!pcard)
+   return -ENXIO;
+
+   if (strcmp("ssid", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid);
+
+   if (strcmp("ddna", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna);
+
+   if (strcmp("card_id", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id);
+
+   if (strcmp("hw_rev", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->hardware_revision);
+
+   if (strcmp("build", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_version);
+
+   if (strcmp("build_date", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_datestamp);
+
+   if (strcmp("build_time", attr->attr.name) == 0)
+   return scnprintf(buf, PAGE_SIZE, "%08x\n",
+pcard->build_timestamp);
+
+   return -ENXIO;
 }
 
-static ssize_t  show_cpld_config_reg(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t show_cpld_config_reg(struct device *dev,
+   struct device_attribute *attr, char *buf)
 {
struct pci_dev *pdev = to_pci_dev(dev);
struct kp2000_device *pcard;
@@ -57,27 +79,33 @@ static ssize_t  show_cpld_config_reg(struct device *dev, 
struct device_attribute
val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
return scnprintf(buf, PAGE_SIZE, "%016llx\n", val);
 }
-static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute 
*attr, const char *buf, size_t count)
+
+static ssize_t cpld_reconfigure(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
-struct pci_dev *pdev = to_pci_dev(dev);
-long wr_val;
-struct kp2000_device *pcard;
-int rv;
-
-if (!pdev)  return -ENXIO;
-pcard = pci_get_drvdata(pdev);
-if (!pcard)  return -ENXIO;
-
-rv = kstrtol(buf, 0, _val);
-if (rv < 0)  return rv;
-if (wr_val > 7)  return -EINVAL;
-
-wr_val = wr_val << 8;
-wr_val |= 0x1; // Set the "Configure Go" bit
-writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
-return count;
-}
+   struct pci_dev *pdev = to_pci_dev(dev);
+   long wr_val;
+   struct kp2000_device *pcard;
+   int rv;
 
+   if (!pdev)
+   return 

[PATCH v5 4/8] staging: kpc2000: added a helper to get struct kp2000_device from struct device.

2019-05-21 Thread Jeremy Sowden
The attribute call-backs all use the same formula to get the pcard from
dev:

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

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

Added a function to reduce the duplicated code.

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

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 65e31bf01227..1d10e252c8da 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -22,15 +22,21 @@
  * SysFS Attributes
  **/
 
-static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
-char *buf)
+static struct kp2000_device *get_pcard(struct device *dev)
 {
struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
 
if (!pdev)
-   return -ENXIO;
-   pcard = pci_get_drvdata(pdev);
+   return NULL;
+
+   return pci_get_drvdata(pdev);
+}
+
+static ssize_t show_attr(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct kp2000_device *pcard = get_pcard(dev);
+
if (!pcard)
return -ENXIO;
 
@@ -65,14 +71,9 @@ static ssize_t show_attr(struct device *dev, struct 
device_attribute *attr,
 static ssize_t show_cpld_config_reg(struct device *dev,
struct device_attribute *attr, char *buf)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct kp2000_device *pcard;
+   struct kp2000_device *pcard = get_pcard(dev);
u64 val;
 
-   if (!pdev)
-   return -ENXIO;
-
-   pcard = pci_get_drvdata(pdev);
if (!pcard)
return -ENXIO;
 
@@ -84,14 +85,10 @@ static ssize_t cpld_reconfigure(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
+   struct kp2000_device *pcard = get_pcard(dev);
long wr_val;
-   struct kp2000_device *pcard;
int rv;
 
-   if (!pdev)
-   return -ENXIO;
-   pcard = pci_get_drvdata(pdev);
if (!pcard)
return -ENXIO;
 
-- 
2.20.1

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


[PATCH v5 0/8] staging: kpc2000: another batch of fixes

2019-05-21 Thread Jeremy Sowden
There are a number relating to device attributes, one formatting patch,
and another that changes how card numbers are assigned.

Greg reckoned that the changes to the code in the attribute call-backs
that gets the struct kpc2000 object from the struct device object were
broken.  I've reviewed them and split them into two patches because I
was doing two different things in the previous patch.  I *think* they
are correct, but I've moved them to the end of the series in case I
really have just got the wrong end of the stick, so they can easily be
dropped.

Jeremy Sowden (8):
  staging: kpc2000: added separate show functions for kpc_uio_class
device attributes, defined them as read-only and declared them
static.
  staging: kpc2000: removed two kpc_uio_class device attributes.
  staging: kpc2000: improved formatting of core.c.
  staging: kpc2000: added a helper to get struct kp2000_device from
struct device.
  staging: kpc2000: added separate show functions for readable kp device
attributes, defined them as read-only, and declared them static.
  staging: kpc2000: use IDA to assign card numbers.
  staging: kpc2000: simplified kp2000_device retrieval in device
attribute call-backs.
  staging: kpc2000: removed superfluous NULL checks from device
attribute call-backs.

 drivers/staging/kpc2000/TODO  |   1 -
 drivers/staging/kpc2000/kpc2000/cell_probe.c  | 123 ++-
 drivers/staging/kpc2000/kpc2000/core.c| 859 ++
 .../staging/kpc2000/kpc2000/kp2000_module.c   |   1 +
 drivers/staging/kpc2000/kpc2000/pcie.h|   9 +-
 5 files changed, 558 insertions(+), 435 deletions(-)

Since v4:

  * rebased on to staging-next to pick up Greg's most recent changes.
  * made a few changes to some commit messages.
  * sent out the right versions of the patches.

Since v3:

  * added the formatting patch for core.c and folded the kp device
attribute formatting fixes into it;
  * added the patch that introduces get_pcard();
  * added missing clean-up of IDA and reworded the commit message;
  * split the patch that simplified the retrieval of struct
kp2000_device from struct dev in the show call-backs into two, and
moved them to the end of the series.

Since v2:

  * dropped the white-space patch since Greg has applied it;
  * added a reported-by tag to patch that drops two attributes;
  * merged the patches that declared attributes static with the ones
that split up the show call-backs;
  * moved the attribute definitions next to their call-backs;
  * moved the patch that fixed the card-number race to the end of the
  * series;
  * use an IDA to fix the card-number race, not an atomic_t.

Since v1:

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

-- 
2.20.1

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


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

2019-05-21 Thread Greg Ungerer



Hi Sergio,

I am working on a couple of different MedaiTek MT7621 based platforms
and am having problems with the PCI bus on those.

Big picture is that the PCI bus on my boards worked in linux-4.20
(with the obvious compilation breakage fixed), and it does not work
in linux-5.0 or linux-5.1.

On linux-4.20 the PCI bus probe at kernel boot looks like this:

* Xtal 40MHz *
PCIE1 no card, disable it(RST)
PCIE2 no card, disable it(RST)
PCIE0 enabled
PCI coherence region base: 0x6000, mask/settings: 0xf002
mt7621-pci 1e14.pcie: PCI host bridge to bus :00
pci_bus :00: root bus resource [io  0x]
pci_bus :00: root bus resource [mem 0x6000-0x6fff]
pci_bus :00: root bus resource [bus 00-ff]
pci :00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci :00:00.0: PCI bridge to [bus 01-ff]
pci :00:00.0: BAR 0: no space for [mem size 0x8000]
pci :00:00.0: BAR 0: failed to assign [mem size 0x8000]
pci :00:00.0: BAR 8: assigned [mem 0x6000-0x601f]
pci :00:00.0: BAR 9: assigned [mem 0x6020-0x602f pref]
pci :00:00.0: BAR 1: assigned [mem 0x6030-0x6030]
pci :00:00.0: BAR 7: no space for [io  size 0x1000]
pci :00:00.0: BAR 7: failed to assign [io  size 0x1000]
pci :01:00.0: BAR 0: assigned [mem 0x6000-0x601f 64bit]
pci :01:00.0: BAR 6: assigned [mem 0x6020-0x6020 pref]
pci :00:00.0: PCI bridge to [bus 01]
pci :00:00.0:   bridge window [mem 0x6000-0x601f]
pci :00:00.0:   bridge window [mem 0x6020-0x602f pref]

The PCI bus works, and devices on it are found and work as expected.

On linux-5.1 the PCI initialization and probe fails, with the kernel
locking up:

...
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 0
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie0 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 0 failed
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 1
mt7621-pci-phy 1e149000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie1 no card, disable it (RST & CLK)
mt7621-pci 1e14.pcie: Initiating port 1 failed
mt7621-pci 1e14.pcie: Port 454043648 N_FTS = 2
mt7621-pci-phy 1e14a000.pcie-phy: Xtal is 40MHz
mt7621-pci 1e14.pcie: pcie2 no card, disable it (RST & CLK)

The lockup is in mt7621_pci_phy_power_off(), at the phy_read() call.
If I modify that code and return immediately in that mt7621_pci_phy_power_off()
the systemboots - but obviously from the above you can see that the PCI bus
and no devices were detected.

Copying in the working linux-4.20 pci-mt7621.c into place on
linux-5.1 results in a working PCI bus also. I have 2 very different
MT7621 based boards, and they both exhibit this same problem.

I tried bisecting that back to find the problem commit.
It was not at all easy with quite a few of the mt7621 PCI related
patches not building in isolation while bisecting. But ultimately
I got to commit 745eeeac68d7 ("staging: mt7621-pci: factor out
'mt7621_pcie_enable_port' function").

Any idea what might be going wrong here?

Regards
Greg


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


Re: [PATCH 6/7] staging: vt6656: clean-up registers initialization error path

2019-05-21 Thread Greg Kroah-Hartman
On Mon, May 20, 2019 at 04:39:04PM +, Quentin Deslandes wrote:
> Avoid discarding function's return code during register initialization.
> Handle it instead and return 0 on success or a negative errno value on
> error.
> 
> Signed-off-by: Quentin Deslandes 
> ---
>  drivers/staging/vt6656/main_usb.c | 163 ++
>  1 file changed, 96 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/staging/vt6656/main_usb.c 
> b/drivers/staging/vt6656/main_usb.c
> index 5fd845cbdd52..8ed96e8eedbe 100644
> --- a/drivers/staging/vt6656/main_usb.c
> +++ b/drivers/staging/vt6656/main_usb.c
> @@ -109,33 +109,38 @@ static void vnt_set_options(struct vnt_private *priv)
>   */
>  static int vnt_init_registers(struct vnt_private *priv)
>  {
> + int ret = 0;

Minor nit here, no need to set this to 0 as you instantly set it with
this call:

>   struct vnt_cmd_card_init *init_cmd = >init_command;
>   struct vnt_rsp_card_init *init_rsp = >init_response;
>   u8 antenna;
>   int ii;
> - int status = STATUS_SUCCESS;
>   u8 tmp;
>   u8 calib_tx_iq = 0, calib_tx_dc = 0, calib_rx_iq = 0;
>  
>   dev_dbg(>usb->dev, ">INIbInitAdapter. [%d][%d]\n",
>   DEVICE_INIT_COLD, priv->packet_type);
>  
> - if (!vnt_check_firmware_version(priv)) {
> - if (vnt_download_firmware(priv) == true) {
> - if (vnt_firmware_branch_to_sram(priv) == false) {
> - dev_dbg(>usb->dev,
> - " vnt_firmware_branch_to_sram fail\n");
> - return false;
> - }
> - } else {
> - dev_dbg(>usb->dev, "FIRMWAREbDownload fail\n");
> - return false;
> + ret = vnt_check_firmware_version(priv);

You can fix that up in a later patch :)

At first glance, these all look really good, thanks for doing this work.

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


Re: TODO advice for octeon-usb?

2019-05-21 Thread Felipe Balbi

Hi,

Aaro Koskinen  writes:
> I'm looking for input what should be done next to get
> drivers/staging/octeon-usb out of staging.
>
> Thousands of checkpatch errors/warnings have been fixed (starting point
> was ),
> also the size of the driver has shrunken considerably.
>
> If there are still some other bigger issues with this driver, please
> let me know.

Looks pretty clean to me. I would simply break that single file into
smaller files if possible (see xhci/ehci for example).

my 2 cents

-- 
balbi


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