[PATCH v3 20/25] staging: ion: fix common struct sg_table related issues

2020-05-05 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the
numer of the created entries in the DMA address space. However the
subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be
called with the original number of the entries passed to dma_map_sg. The
sg_table->nents in turn holds the result of the dma_map_sg call as stated
in include/linux/scatterlist.h. A common mistake was to ignore a result
of the dma_map_sg function and don't use the sg_table->orig_nents at all.

To avoid such issues, lets use common dma-mapping wrappers operating
directly on the struct sg_table objects and adjust references to the
nents and orig_nents respectively.

Signed-off-by: Marek Szyprowski 
---
For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents
vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187
---
 drivers/staging/android/ion/ion.c | 25 +++--
 drivers/staging/android/ion/ion_heap.c|  6 +++---
 drivers/staging/android/ion/ion_system_heap.c |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 38b51ea..9274298 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -147,14 +147,14 @@ static struct sg_table *dup_sg_table(struct sg_table 
*table)
if (!new_table)
return ERR_PTR(-ENOMEM);
 
-   ret = sg_alloc_table(new_table, table->nents, GFP_KERNEL);
+   ret = sg_alloc_table(new_table, table->orig_nents, GFP_KERNEL);
if (ret) {
kfree(new_table);
return ERR_PTR(-ENOMEM);
}
 
new_sg = new_table->sgl;
-   for_each_sg(table->sgl, sg, table->nents, i) {
+   for_each_sg(table->sgl, sg, table->orig_nents, i) {
memcpy(new_sg, sg, sizeof(*sg));
new_sg->dma_address = 0;
new_sg = sg_next(new_sg);
@@ -224,12 +224,13 @@ static struct sg_table *ion_map_dma_buf(struct 
dma_buf_attachment *attachment,
 {
struct ion_dma_buf_attachment *a = attachment->priv;
struct sg_table *table;
+   int ret;
 
table = a->table;
 
-   if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
-   direction))
-   return ERR_PTR(-ENOMEM);
+   ret = dma_map_sgtable(attachment->dev, table, direction);
+   if (ret)
+   return ERR_PTR(ret);
 
return table;
 }
@@ -238,7 +239,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment 
*attachment,
  struct sg_table *table,
  enum dma_data_direction direction)
 {
-   dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
+   dma_unmap_sgtable(attachment->dev, table, direction);
 }
 
 static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
@@ -296,10 +297,8 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
}
 
mutex_lock(&buffer->lock);
-   list_for_each_entry(a, &buffer->attachments, list) {
-   dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
-   direction);
-   }
+   list_for_each_entry(a, &buffer->attachments, list)
+   dma_sync_sgtable_for_cpu(a->dev, a->table, direction);
 
 unlock:
mutex_unlock(&buffer->lock);
@@ -319,10 +318,8 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf 
*dmabuf,
}
 
mutex_lock(&buffer->lock);
-   list_for_each_entry(a, &buffer->attachments, list) {
-   dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
-  direction);
-   }
+   list_for_each_entry(a, &buffer->attachments, list)
+   dma_sync_sgtable_for_device(a->dev, a->table, direction);
mutex_unlock(&buffer->lock);
 
return 0;
diff --git a/drivers/staging/android/ion/ion_heap.c 
b/drivers/staging/android/ion/ion_heap.c
index 0755b11..f2f7ca7 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -38,7 +38,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
else
pgprot = pgprot_writecombine(PAGE_KERNEL);
 
-   for_each_sg(table->sgl, sg, table->nents, i) {
+   for_each_sg(table->sgl, sg, table->orig_nents, i) {
int npages_this_entry = PAGE_ALIGN(sg->length) / PAGE_SIZE;
struct page *page = sg_page(sg);
 
@@ -71,7 +71,7 @@ int ion_heap_map_user(struct ion_heap *heap, struct 
ion_buffer *buffer,
int i;
int ret;
 
-   for_each_sg(table->sgl, sg, table->nents, i) {
+   for_each_sg(table->sgl, sg, table->orig_nents, i) {
struct page *page = sg_page(sg);
unsigned long remainder = vma->vm_end - addr;
unsigned long len = sg->length;
@@ -142,7 +142,7 @@ int ion_heap_b

[PATCH v3 21/25] staging: tegra-vde: fix common struct sg_table related issues

2020-05-05 Thread Marek Szyprowski
The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the
numer of the created entries in the DMA address space. However the
subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be
called with the original number of the entries passed to dma_map_sg. The
sg_table->nents in turn holds the result of the dma_map_sg call as stated
in include/linux/scatterlist.h. A common mistake was to ignore a result
of the dma_map_sg function and don't use the sg_table->orig_nents at all.

To avoid such issues, lets use common dma-mapping wrappers operating
directly on the struct sg_table objects and adjust references to the
nents and orig_nents respectively.

Signed-off-by: Marek Szyprowski 
---
For more information, see '[PATCH v3 00/25] DRM: fix struct sg_table nents
vs. orig_nents misuse' thread: https://lkml.org/lkml/2020/5/5/187
---
 drivers/staging/media/tegra-vde/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/tegra-vde/iommu.c 
b/drivers/staging/media/tegra-vde/iommu.c
index 6af863d..adf8dc7 100644
--- a/drivers/staging/media/tegra-vde/iommu.c
+++ b/drivers/staging/media/tegra-vde/iommu.c
@@ -36,8 +36,8 @@ int tegra_vde_iommu_map(struct tegra_vde *vde,
 
addr = iova_dma_addr(&vde->iova, iova);
 
-   size = iommu_map_sg(vde->domain, addr, sgt->sgl, sgt->nents,
-   IOMMU_READ | IOMMU_WRITE);
+   size = iommu_map_sgtable(vde->domain, addr, sgt,
+IOMMU_READ | IOMMU_WRITE);
if (!size) {
__free_iova(&vde->iova, iova);
return -ENXIO;
-- 
1.9.1

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


[PATCH 1/4] staging: most: usb: remove overcautious parameter checking

2020-05-05 Thread Christian Gromm
The interface pointer passed to a core API function cannot be NULL. This
patch removes unnessecary the sanity check of the pointer.

Signed-off-by: Christian Gromm 
Reported-by: Greg Kroah-Hartman 
---
 drivers/staging/most/usb/usb.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index e8c5a8c..9527e31 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -233,10 +233,6 @@ static int hdm_poison_channel(struct most_interface 
*iface, int channel)
unsigned long flags;
spinlock_t *lock; /* temp. lock */
 
-   if (unlikely(!iface)) {
-   dev_warn(&mdev->usb_device->dev, "Poison: Bad interface.\n");
-   return -EIO;
-   }
if (unlikely(channel < 0 || channel >= iface->num_channels)) {
dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
return -ECHRNG;
@@ -559,7 +555,7 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
unsigned long length;
void *virt_address;
 
-   if (unlikely(!iface || !mbo))
+   if (unlikely(!mbo))
return -EIO;
if (unlikely(iface->num_channels <= channel || channel < 0))
return -ECHRNG;
@@ -674,8 +670,8 @@ static int hdm_configure_channel(struct most_interface 
*iface, int channel,
mdev->clear_work[channel].mdev = mdev;
INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
 
-   if (unlikely(!iface || !conf)) {
-   dev_err(dev, "Bad interface or config pointer.\n");
+   if (unlikely(!conf)) {
+   dev_err(dev, "Bad config pointer.\n");
return -EINVAL;
}
if (unlikely(channel < 0 || channel >= iface->num_channels)) {
@@ -747,7 +743,6 @@ static void hdm_request_netinfo(struct most_interface 
*iface, int channel,
 {
struct most_dev *mdev;
 
-   BUG_ON(!iface);
mdev = to_mdev(iface);
mdev->on_netinfo = on_netinfo;
if (!on_netinfo)
-- 
2.7.4

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


[PATCH 2/4] staging: most: usb: use EINVAL error code

2020-05-05 Thread Christian Gromm
This patch replaces the error code EIO with EINVAL, when there is no IO
happening.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index 9527e31..1087ad9 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -274,13 +274,13 @@ static int hdm_add_padding(struct most_dev *mdev, int 
channel, struct mbo *mbo)
unsigned int j, num_frames;
 
if (!frame_size)
-   return -EIO;
+   return -EINVAL;
num_frames = mbo->buffer_length / frame_size;
 
if (num_frames < 1) {
dev_err(&mdev->usb_device->dev,
"Missed minimal transfer unit.\n");
-   return -EIO;
+   return -EINVAL;
}
 
for (j = num_frames - 1; j > 0; j--)
@@ -308,7 +308,7 @@ static int hdm_remove_padding(struct most_dev *mdev, int 
channel,
unsigned int j, num_frames;
 
if (!frame_size)
-   return -EIO;
+   return -EINVAL;
num_frames = mbo->processed_length / USB_MTU;
 
for (j = 1; j < num_frames; j++)
@@ -556,7 +556,7 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
void *virt_address;
 
if (unlikely(!mbo))
-   return -EIO;
+   return -EINVAL;
if (unlikely(iface->num_channels <= channel || channel < 0))
return -ECHRNG;
 
@@ -577,7 +577,7 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
 
if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
hdm_add_padding(mdev, channel, mbo)) {
-   retval = -EIO;
+   retval = -EINVAL;
goto err_free_urb;
}
 
-- 
2.7.4

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


[PATCH 0/4] staging: most: usb: cleanup code

2020-05-05 Thread Christian Gromm
This patch set consolidates the source code appearance by rearranging or
removing unnecessary code and makes use of error codes that better signal
the exception.

Christian Gromm (4):
  staging: most: usb: remove overcautious parameter checking
  staging: most: usb: use EINVAL error code
  staging: most: usb: drop unlikely macros
  staging: most: usb: consolidate code

 drivers/staging/most/usb/usb.c | 33 +
 1 file changed, 13 insertions(+), 20 deletions(-)

-- 
2.7.4

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


[PATCH 4/4] staging: most: usb: consolidate code

2020-05-05 Thread Christian Gromm
This patch applies the same look and feel when assigning local variables.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index 62d773c..b31a49c 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -548,7 +548,7 @@ static void hdm_read_completion(struct urb *urb)
 static int hdm_enqueue(struct most_interface *iface, int channel,
   struct mbo *mbo)
 {
-   struct most_dev *mdev;
+   struct most_dev *mdev = to_mdev(iface);
struct most_channel_config *conf;
int retval = 0;
struct urb *urb;
@@ -560,7 +560,6 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
if (iface->num_channels <= channel || channel < 0)
return -ECHRNG;
 
-   mdev = to_mdev(iface);
conf = &mdev->conf[channel];
 
mutex_lock(&mdev->io_mutex);
@@ -741,9 +740,8 @@ static void hdm_request_netinfo(struct most_interface 
*iface, int channel,
   unsigned char,
   unsigned char *))
 {
-   struct most_dev *mdev;
+   struct most_dev *mdev = to_mdev(iface);
 
-   mdev = to_mdev(iface);
mdev->on_netinfo = on_netinfo;
if (!on_netinfo)
return;
-- 
2.7.4

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


[PATCH 3/4] staging: most: usb: drop unlikely macros

2020-05-05 Thread Christian Gromm
This patch removes the unlikely macros in the error patch of argument
checking, as it has no measurable performance adavantage.

Signed-off-by: Christian Gromm 
Reported-by: Greg Kroah-Hartman 
---
 drivers/staging/most/usb/usb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index 1087ad9..62d773c 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -233,7 +233,7 @@ static int hdm_poison_channel(struct most_interface *iface, 
int channel)
unsigned long flags;
spinlock_t *lock; /* temp. lock */
 
-   if (unlikely(channel < 0 || channel >= iface->num_channels)) {
+   if (channel < 0 || channel >= iface->num_channels) {
dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
return -ECHRNG;
}
@@ -555,9 +555,9 @@ static int hdm_enqueue(struct most_interface *iface, int 
channel,
unsigned long length;
void *virt_address;
 
-   if (unlikely(!mbo))
+   if (!mbo)
return -EINVAL;
-   if (unlikely(iface->num_channels <= channel || channel < 0))
+   if (iface->num_channels <= channel || channel < 0)
return -ECHRNG;
 
mdev = to_mdev(iface);
@@ -670,11 +670,11 @@ static int hdm_configure_channel(struct most_interface 
*iface, int channel,
mdev->clear_work[channel].mdev = mdev;
INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
 
-   if (unlikely(!conf)) {
+   if (!conf) {
dev_err(dev, "Bad config pointer.\n");
return -EINVAL;
}
-   if (unlikely(channel < 0 || channel >= iface->num_channels)) {
+   if (channel < 0 || channel >= iface->num_channels) {
dev_err(dev, "Channel ID out of range.\n");
return -EINVAL;
}
-- 
2.7.4

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


Re: KASAN: slab-out-of-bounds Read in hfa384x_usbin_callback

2020-05-05 Thread Oliver Neukum
Am Freitag, den 20.03.2020, 12:28 -0700 schrieb syzbot:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:e17994d1 usb: core: kcov: collect coverage from usb comple..
> git tree:   https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=11d74573e0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
> dashboard link: https://syzkaller.appspot.com/bug?extid=7d42d68643a35f71ac8a
> compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=15fa561de0
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15d74573e0
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+7d42d68643a35f71a...@syzkaller.appspotmail.com
> 
> ==
> BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:381 [inline]
> BUG: KASAN: slab-out-of-bounds in skb_put_data include/linux/skbuff.h:2284 
> [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_int_rxmonitor 
> drivers/staging/wlan-ng/hfa384x_usb.c:3412 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_rx 
> drivers/staging/wlan-ng/hfa384x_usb.c:3312 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_callback+0x1993/0x2360 
> drivers/staging/wlan-ng/hfa384x_usb.c:3026
> Read of size 19671 at addr 8881d226413c by task swapper/0/0

#syz test: https://github.com/google/kasan.git e17994d1From 6dbcac8c4b645600161feafc5576657905f15d65 Mon Sep 17 00:00:00 2001
From: Oliver Neukum 
Date: Tue, 5 May 2020 13:46:26 +0200
Subject: [PATCH] hfa384x_usb: fix buffer overflow

The driver trusts the data_len coming from the hardware
without verification. That means that this opens
a vector by which an attacker can smash 64K of the heap.

Signed-off-by: Oliver Neukum 
---
 drivers/staging/wlan-ng/hfa384x_usb.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index fa1bf8b069fd..5b6497d8c9e2 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3353,9 +3353,9 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
   struct hfa384x_usb_rxfrm *rxfrm)
 {
 	struct hfa384x_rx_frame *rxdesc = &rxfrm->desc;
-	unsigned int hdrlen = 0;
-	unsigned int datalen = 0;
-	unsigned int skblen = 0;
+	unsigned int hdrlen;
+	unsigned int datalen;
+	unsigned int skblen;
 	u8 *datap;
 	u16 fc;
 	struct sk_buff *skb;
@@ -3413,8 +3413,10 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
 	 */
 	skb_put_data(skb, &rxdesc->frame_control, hdrlen);
 
-	/* If any, copy the data from the card to the skb */
-	if (datalen > 0) {
+	/* If any, copy the data from the card to the skb,
+	 * as long as it fits, lest we smash a buffer
+	 */
+	if (datalen > 0 && datalen <= skblen - hdrlen) {
 		datap = skb_put_data(skb, rxfrm->data, datalen);
 
 		/* check for unencrypted stuff if WEP bit set. */
-- 
2.16.4

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


[PATCH] staging: most: usb: add PM functions

2020-05-05 Thread Christian Gromm
This patch adds the implementation of the PM functions resume and suspend.

Signed-off-by: Christian Gromm 
---
 drivers/staging/most/usb/usb.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index b31a49c..daa5e4b 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -1221,11 +1221,39 @@ static void hdm_disconnect(struct usb_interface 
*interface)
put_device(&mdev->dev);
 }
 
+static int hdm_suspend(struct usb_interface *interface, pm_message_t message)
+{
+   struct most_dev *mdev = usb_get_intfdata(interface);
+   int i;
+
+   mutex_lock(&mdev->io_mutex);
+   for (i = 0; i < mdev->iface.num_channels; i++) {
+   most_stop_enqueue(&mdev->iface, i);
+   usb_kill_anchored_urbs(&mdev->busy_urbs[i]);
+   }
+   mutex_unlock(&mdev->io_mutex);
+   return 0;
+}
+
+static int hdm_resume(struct usb_interface *interface)
+{
+   struct most_dev *mdev = usb_get_intfdata(interface);
+   int i;
+
+   mutex_lock(&mdev->io_mutex);
+   for (i = 0; i < mdev->iface.num_channels; i++)
+   most_resume_enqueue(&mdev->iface, i);
+   mutex_unlock(&mdev->io_mutex);
+   return 0;
+}
+
 static struct usb_driver hdm_usb = {
.name = "hdm_usb",
.id_table = usbid,
.probe = hdm_probe,
.disconnect = hdm_disconnect,
+   .resume = hdm_resume,
+   .suspend = hdm_suspend,
 };
 
 module_usb_driver(hdm_usb);
-- 
2.7.4

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


[PATCH 02/15] staging: wfx: reduce timeout for chip initial start up

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

The device take a few hundreds of milliseconds to start. However, the
current code wait up to 10 second for the chip. We can safely reduce
this value to 1 second. Thanks to that change, it is no more necessary
to use an interruptible timeout.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 742a286c9207..ba2e3a6b3549 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -370,8 +370,7 @@ int wfx_probe(struct wfx_dev *wdev)
if (err)
goto err1;
 
-   err = wait_for_completion_interruptible_timeout(&wdev->firmware_ready,
-   10 * HZ);
+   err = wait_for_completion_timeout(&wdev->firmware_ready, 1 * HZ);
if (err <= 0) {
if (err == 0) {
dev_err(wdev->dev, "timeout while waiting for startup 
indication. IRQ configuration error?\n");
-- 
2.26.1

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


[PATCH 01/15] staging: wfx: add support for hardware revision 2 and further

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

Currently, the driver explicitly exclude support for chip with version
number it does not know. However, it unlikely that any futur hardware
change would break the driver. Therefore, we prefer to invert the test
and only exclude the versions we know the driver does not support.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/fwio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c
index 9d61082c1e6c..e2f914296677 100644
--- a/drivers/staging/wfx/fwio.c
+++ b/drivers/staging/wfx/fwio.c
@@ -360,7 +360,7 @@ int wfx_init_device(struct wfx_dev *wdev)
dev_dbg(wdev->dev, "initial config register value: %08x\n", reg);
 
hw_revision = FIELD_GET(CFG_DEVICE_ID_MAJOR, reg);
-   if (hw_revision == 0 || hw_revision > 2) {
+   if (hw_revision == 0) {
dev_err(wdev->dev, "bad hardware revision number: %d\n",
hw_revision);
return -ENODEV;
-- 
2.26.1

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


[PATCH 04/15] staging: wfx: drop useless check

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

Currently, the ISR check if bus->core is not NULL. But, it is a useless
check. bus->core is initialiased before to request IRQ and it is not
assigned to NULL when it is released.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/bus_sdio.c | 9 +
 drivers/staging/wfx/bus_spi.c  | 4 
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c
index dedc3ff58d3e..9ac87178270f 100644
--- a/drivers/staging/wfx/bus_sdio.c
+++ b/drivers/staging/wfx/bus_sdio.c
@@ -91,20 +91,13 @@ static void wfx_sdio_irq_handler(struct sdio_func *func)
 {
struct wfx_sdio_priv *bus = sdio_get_drvdata(func);
 
-   if (bus->core)
-   wfx_bh_request_rx(bus->core);
-   else
-   WARN(!bus->core, "race condition in driver init/deinit");
+   wfx_bh_request_rx(bus->core);
 }
 
 static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv)
 {
struct wfx_sdio_priv *bus = priv;
 
-   if (!bus->core) {
-   WARN(!bus->core, "race condition in driver init/deinit");
-   return IRQ_NONE;
-   }
sdio_claim_host(bus->func);
wfx_bh_request_rx(bus->core);
sdio_release_host(bus->func);
diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
index 61e99b09decb..03f95e65d2f9 100644
--- a/drivers/staging/wfx/bus_spi.c
+++ b/drivers/staging/wfx/bus_spi.c
@@ -140,10 +140,6 @@ static irqreturn_t wfx_spi_irq_handler(int irq, void *priv)
 {
struct wfx_spi_priv *bus = priv;
 
-   if (!bus->core) {
-   WARN(!bus->core, "race condition in driver init/deinit");
-   return IRQ_NONE;
-   }
queue_work(system_highpri_wq, &bus->request_rx);
return IRQ_HANDLED;
 }
-- 
2.26.1

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


[PATCH 06/15] staging: wfx: use threaded IRQ with SPI

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

Currently, the SPI implementation use a workqueue to acknowledge IRQ
while the SDIO-OOB implementation use a threaded IRQ.

The threaded also offers the advantage to allow level triggered IRQs.

Uniformize the code and use threaded IRQ in both case. Therefore, prefer
level triggered IRQs if the user does not specify it in the DT.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/bus_spi.c | 34 --
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
index 03f95e65d2f9..00613d046c3f 100644
--- a/drivers/staging/wfx/bus_spi.c
+++ b/drivers/staging/wfx/bus_spi.c
@@ -39,7 +39,6 @@ struct wfx_spi_priv {
struct spi_device *func;
struct wfx_dev *core;
struct gpio_desc *gpio_reset;
-   struct work_struct request_rx;
bool need_swab;
 };
 
@@ -140,21 +139,21 @@ static irqreturn_t wfx_spi_irq_handler(int irq, void 
*priv)
 {
struct wfx_spi_priv *bus = priv;
 
-   queue_work(system_highpri_wq, &bus->request_rx);
-   return IRQ_HANDLED;
-}
-
-static void wfx_spi_request_rx(struct work_struct *work)
-{
-   struct wfx_spi_priv *bus =
-   container_of(work, struct wfx_spi_priv, request_rx);
-
wfx_bh_request_rx(bus->core);
+   return IRQ_HANDLED;
 }
 
-static void wfx_flush_irq_work(void *w)
+static int wfx_spi_irq_subscribe(struct wfx_spi_priv *bus)
 {
-   flush_work(w);
+   u32 flags;
+
+   flags = irq_get_trigger_type(bus->func->irq);
+   if (!flags)
+   flags = IRQF_TRIGGER_HIGH;
+   flags |= IRQF_ONESHOT;
+   return devm_request_threaded_irq(&bus->func->dev, bus->func->irq, NULL,
+wfx_spi_irq_handler, IRQF_ONESHOT,
+"wfx", bus);
 }
 
 static size_t wfx_spi_align_size(void *priv, size_t size)
@@ -212,21 +211,12 @@ static int wfx_spi_probe(struct spi_device *func)
usleep_range(2000, 2500);
}
 
-   INIT_WORK(&bus->request_rx, wfx_spi_request_rx);
bus->core = wfx_init_common(&func->dev, &wfx_spi_pdata,
&wfx_spi_hwbus_ops, bus);
if (!bus->core)
return -EIO;
 
-   ret = devm_add_action_or_reset(&func->dev, wfx_flush_irq_work,
-  &bus->request_rx);
-   if (ret)
-   return ret;
-
-   ret = devm_request_irq(&func->dev, func->irq, wfx_spi_irq_handler,
-  IRQF_TRIGGER_RISING, "wfx", bus);
-   if (ret)
-   return ret;
+   wfx_spi_irq_subscribe(bus);
 
return wfx_probe(bus->core);
 }
-- 
2.26.1

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


[PATCH 03/15] staging: wfx: fix double free

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

In case of error in wfx_probe(), wdev->hw is freed. Since an error
occurred, wfx_free_common() is called, then wdev->hw is freed again.

Cc: Michał Mirosław 
Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index ba2e3a6b3549..5d0754b55429 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -469,7 +469,6 @@ int wfx_probe(struct wfx_dev *wdev)
 
 err2:
ieee80211_unregister_hw(wdev->hw);
-   ieee80211_free_hw(wdev->hw);
 err1:
wfx_bh_unregister(wdev);
return err;
-- 
2.26.1

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


[PATCH 00/15] staging: wfx: fix Out-Of-Band IRQ

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

The WF200 can be used on SPI and SDIO. When using SDIO bus, the driver
normally use the in band IRQ provided by the SDIO bus. However, WF200
also provides support for a dedicated IRQ line. This feature is used
when in-band IRQ does not work or to allows some kind of Wake-On-Wlan.
There already was an implementation of Out-Of-Band (OOB) IRQ in the
driver. However, it did not work correctly. This series mainly aims to
fix that. It add, it allows to use edge or level IRQ and unify the IRQ
handling in SPI and SDIO.

The 6 last patches are cosmetic.

Jérôme Pouiller (15):
  staging: wfx: add support for hardware revision 2 and further
  staging: wfx: reduce timeout for chip initial start up
  staging: wfx: fix double free
  staging: wfx: drop useless check
  staging: wfx: repair external IRQ for SDIO
  staging: wfx: use threaded IRQ with SPI
  staging: wfx: introduce a way to poll IRQ
  staging: wfx: poll IRQ during init
  staging: wfx: fix missing 'static' statement
  staging: wfx: fix missing 'static' keyword
  staging: wfx: prefer ARRAY_SIZE instead of a magic number
  staging: wfx: remove useless header inclusions
  staging: wfx: fix alignements of function prototypes
  staging: wfx: remove spaces after cast operator
  staging: wfx: use kernel types instead of c99 ones

 drivers/staging/wfx/bh.c | 29 +++
 drivers/staging/wfx/bh.h |  1 +
 drivers/staging/wfx/bus.h|  2 +
 drivers/staging/wfx/bus_sdio.c   | 64 
 drivers/staging/wfx/bus_spi.c| 50 -
 drivers/staging/wfx/data_rx.h|  3 +-
 drivers/staging/wfx/data_tx.c| 11 +++---
 drivers/staging/wfx/fwio.c   |  6 +--
 drivers/staging/wfx/hif_rx.c |  2 +-
 drivers/staging/wfx/hif_tx.c | 30 ---
 drivers/staging/wfx/hif_tx.h |  7 ++--
 drivers/staging/wfx/hif_tx_mib.c |  2 +-
 drivers/staging/wfx/hif_tx_mib.h |  4 +-
 drivers/staging/wfx/hwio.c   | 16 
 drivers/staging/wfx/key.c|  2 +-
 drivers/staging/wfx/main.c   | 43 +
 drivers/staging/wfx/main.h   |  4 +-
 drivers/staging/wfx/queue.h  |  2 -
 drivers/staging/wfx/sta.c| 40 +---
 drivers/staging/wfx/sta.h|  2 -
 drivers/staging/wfx/wfx.h|  4 +-
 21 files changed, 175 insertions(+), 149 deletions(-)

-- 
2.26.1

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


[PATCH 07/15] staging: wfx: introduce a way to poll IRQ

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

It is possible to check if an IRQ is ending by polling the control
register. This function must used with care: if an IRQ fires while the
host reads control register, the IRQ can be lost. However, it could be
useful in some cases.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/bh.c | 28 
 drivers/staging/wfx/bh.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c
index ba7fa0a7cd9a..d3e7eed89c38 100644
--- a/drivers/staging/wfx/bh.c
+++ b/drivers/staging/wfx/bh.c
@@ -307,6 +307,34 @@ void wfx_bh_request_tx(struct wfx_dev *wdev)
queue_work(system_highpri_wq, &wdev->hif.bh);
 }
 
+/*
+ * If IRQ is not available, this function allow to manually poll the control
+ * register and simulate an IRQ ahen an event happened.
+ *
+ * Note that the device has a bug: If an IRQ raise while host read control
+ * register, the IRQ is lost. So, use this function carefully (only duing
+ * device initialisation).
+ */
+void wfx_bh_poll_irq(struct wfx_dev *wdev)
+{
+   ktime_t now, start;
+   u32 reg;
+
+   start = ktime_get();
+   for (;;) {
+   control_reg_read(wdev, ®);
+   now = ktime_get();
+   if (reg & 0xFFF)
+   break;
+   if (ktime_after(now, ktime_add_ms(start, 1000))) {
+   dev_err(wdev->dev, "time out while polling control 
register\n");
+   return;
+   }
+   udelay(200);
+   }
+   wfx_bh_request_rx(wdev);
+}
+
 void wfx_bh_register(struct wfx_dev *wdev)
 {
INIT_WORK(&wdev->hif.bh, bh_work);
diff --git a/drivers/staging/wfx/bh.h b/drivers/staging/wfx/bh.h
index 93ca98424e0b..4b73437869e1 100644
--- a/drivers/staging/wfx/bh.h
+++ b/drivers/staging/wfx/bh.h
@@ -28,5 +28,6 @@ void wfx_bh_register(struct wfx_dev *wdev);
 void wfx_bh_unregister(struct wfx_dev *wdev);
 void wfx_bh_request_rx(struct wfx_dev *wdev);
 void wfx_bh_request_tx(struct wfx_dev *wdev);
+void wfx_bh_poll_irq(struct wfx_dev *wdev);
 
 #endif /* WFX_BH_H */
-- 
2.26.1

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


[PATCH 08/15] staging: wfx: poll IRQ during init

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

When the chip starts in SDIO mode, the external IRQ (aka Out-Of-Band
IRQ) cannot be used before to configure it. Therefore, the first
exchanges with the chip have to be done without the OOB IRQ.

This patch allow to poll the data until the OOB IRQ is correctly setup.
In order to keep the code simpler, this patch also poll data even if OOB
IRQ is not used.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/bh.c   |  1 +
 drivers/staging/wfx/bus.h  |  2 ++
 drivers/staging/wfx/bus_sdio.c | 17 +++--
 drivers/staging/wfx/bus_spi.c  | 16 +---
 drivers/staging/wfx/hif_tx.c   |  3 +++
 drivers/staging/wfx/main.c | 28 
 drivers/staging/wfx/wfx.h  |  1 +
 7 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c
index d3e7eed89c38..2572fbcf1a33 100644
--- a/drivers/staging/wfx/bh.c
+++ b/drivers/staging/wfx/bh.c
@@ -320,6 +320,7 @@ void wfx_bh_poll_irq(struct wfx_dev *wdev)
ktime_t now, start;
u32 reg;
 
+   WARN(!wdev->poll_irq, "unexpected IRQ polling can mask IRQ");
start = ktime_get();
for (;;) {
control_reg_read(wdev, ®);
diff --git a/drivers/staging/wfx/bus.h b/drivers/staging/wfx/bus.h
index 62d6ecabe4cb..0370b6c59863 100644
--- a/drivers/staging/wfx/bus.h
+++ b/drivers/staging/wfx/bus.h
@@ -25,6 +25,8 @@ struct hwbus_ops {
void *dst, size_t count);
int (*copy_to_io)(void *bus_priv, unsigned int addr,
  const void *src, size_t count);
+   int (*irq_subscribe)(void *bus_priv);
+   int (*irq_unsubscribe)(void *bus_priv);
void (*lock)(void *bus_priv);
void (*unlock)(void *bus_priv);
size_t (*align_size)(void *bus_priv, size_t size);
diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c
index 2f782120e438..6afde2349289 100644
--- a/drivers/staging/wfx/bus_sdio.c
+++ b/drivers/staging/wfx/bus_sdio.c
@@ -106,8 +106,9 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void 
*priv)
return IRQ_HANDLED;
 }
 
-static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus)
+static int wfx_sdio_irq_subscribe(void *priv)
 {
+   struct wfx_sdio_priv *bus = priv;
u32 flags;
int ret;
u8 cccr;
@@ -134,8 +135,9 @@ static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus)
 "wfx", bus);
 }
 
-static int wfx_sdio_irq_unsubscribe(struct wfx_sdio_priv *bus)
+static int wfx_sdio_irq_unsubscribe(void *priv)
 {
+   struct wfx_sdio_priv *bus = priv;
int ret;
 
if (bus->of_irq)
@@ -156,6 +158,8 @@ static size_t wfx_sdio_align_size(void *priv, size_t size)
 static const struct hwbus_ops wfx_sdio_hwbus_ops = {
.copy_from_io = wfx_sdio_copy_from_io,
.copy_to_io = wfx_sdio_copy_to_io,
+   .irq_subscribe = wfx_sdio_irq_subscribe,
+   .irq_unsubscribe = wfx_sdio_irq_unsubscribe,
.lock   = wfx_sdio_lock,
.unlock = wfx_sdio_unlock,
.align_size = wfx_sdio_align_size,
@@ -212,18 +216,12 @@ static int wfx_sdio_probe(struct sdio_func *func,
goto err1;
}
 
-   ret = wfx_sdio_irq_subscribe(bus);
-   if (ret)
-   goto err1;
-
ret = wfx_probe(bus->core);
if (ret)
-   goto err2;
+   goto err1;
 
return 0;
 
-err2:
-   wfx_sdio_irq_unsubscribe(bus);
 err1:
sdio_claim_host(func);
sdio_disable_func(func);
@@ -237,7 +235,6 @@ static void wfx_sdio_remove(struct sdio_func *func)
struct wfx_sdio_priv *bus = sdio_get_drvdata(func);
 
wfx_release(bus->core);
-   wfx_sdio_irq_unsubscribe(bus);
sdio_claim_host(func);
sdio_disable_func(func);
sdio_release_host(func);
diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
index 00613d046c3f..e8da61fb096b 100644
--- a/drivers/staging/wfx/bus_spi.c
+++ b/drivers/staging/wfx/bus_spi.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "bus.h"
@@ -143,8 +144,9 @@ static irqreturn_t wfx_spi_irq_handler(int irq, void *priv)
return IRQ_HANDLED;
 }
 
-static int wfx_spi_irq_subscribe(struct wfx_spi_priv *bus)
+static int wfx_spi_irq_subscribe(void *priv)
 {
+   struct wfx_spi_priv *bus = priv;
u32 flags;
 
flags = irq_get_trigger_type(bus->func->irq);
@@ -156,6 +158,14 @@ static int wfx_spi_irq_subscribe(struct wfx_spi_priv *bus)
 "wfx", bus);
 }
 
+static int wfx_spi_irq_unsubscribe(void *priv)
+{
+   struct wfx_spi_priv *bus = priv;
+
+   devm_free_irq(&bus->func->dev, bus->func->irq, bus);
+   return 0;
+}
+
 static size_t wfx_spi_align_size(void *priv, size_t size)
 {
// Most of SPI controllers avoid DMA if buffer size

[PATCH 05/15] staging: wfx: repair external IRQ for SDIO

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

When used over SDIO bus, device is able to use an external line to
signal IRQs (also called Out-Of-Band IRQ). The current code have several
problems:
  1. The ISR cannot directly acknowledge IRQ since access to the bus is
 not atomic. This patch use a threaded IRQ to solve that issue.
  2. On certain platforms, it is necessary to keep SDIO interruption
 enabled (with register SDIO_CCCR_IENx) (this part has inspired from
 the brcmfmac driver).

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/bus_sdio.c | 38 ++
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c
index 9ac87178270f..2f782120e438 100644
--- a/drivers/staging/wfx/bus_sdio.c
+++ b/drivers/staging/wfx/bus_sdio.c
@@ -6,10 +6,12 @@
  * Copyright (c) 2010, ST-Ericsson
  */
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include "bus.h"
 #include "wfx.h"
@@ -106,31 +108,41 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void 
*priv)
 
 static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus)
 {
+   u32 flags;
int ret;
+   u8 cccr;
 
-   if (bus->of_irq) {
-   ret = request_irq(bus->of_irq, wfx_sdio_irq_handler_ext,
- IRQF_TRIGGER_RISING, "wfx", bus);
-   } else {
+   if (!bus->of_irq) {
sdio_claim_host(bus->func);
ret = sdio_claim_irq(bus->func, wfx_sdio_irq_handler);
sdio_release_host(bus->func);
+   return ret;
}
-   return ret;
+
+   sdio_claim_host(bus->func);
+   cccr = sdio_f0_readb(bus->func, SDIO_CCCR_IENx, NULL);
+   cccr |= BIT(0);
+   cccr |= BIT(bus->func->num);
+   sdio_f0_writeb(bus->func, cccr, SDIO_CCCR_IENx, NULL);
+   sdio_release_host(bus->func);
+   flags = irq_get_trigger_type(bus->of_irq);
+   if (!flags)
+   flags = IRQF_TRIGGER_HIGH;
+   flags |= IRQF_ONESHOT;
+   return devm_request_threaded_irq(&bus->func->dev, bus->of_irq, NULL,
+wfx_sdio_irq_handler_ext, flags,
+"wfx", bus);
 }
 
 static int wfx_sdio_irq_unsubscribe(struct wfx_sdio_priv *bus)
 {
int ret;
 
-   if (bus->of_irq) {
-   free_irq(bus->of_irq, bus);
-   ret = 0;
-   } else {
-   sdio_claim_host(bus->func);
-   ret = sdio_release_irq(bus->func);
-   sdio_release_host(bus->func);
-   }
+   if (bus->of_irq)
+   devm_free_irq(&bus->func->dev, bus->of_irq, bus);
+   sdio_claim_host(bus->func);
+   ret = sdio_release_irq(bus->func);
+   sdio_release_host(bus->func);
return ret;
 }
 
-- 
2.26.1

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


[PATCH 12/15] staging: wfx: remove useless header inclusions

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

In order to keep the compilation times reasonable, we try to only
include the necessary headers (especially header included from other
headers).

This patch clean up unnecessary headers inclusions.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/data_rx.h| 3 +--
 drivers/staging/wfx/hif_tx.h | 3 +--
 drivers/staging/wfx/hif_tx_mib.h | 2 --
 drivers/staging/wfx/main.c   | 1 +
 drivers/staging/wfx/main.h   | 2 +-
 drivers/staging/wfx/queue.h  | 2 --
 drivers/staging/wfx/sta.h| 2 --
 drivers/staging/wfx/wfx.h| 3 ---
 8 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wfx/data_rx.h b/drivers/staging/wfx/data_rx.h
index 61c28bfd2a37..125dbfc1f875 100644
--- a/drivers/staging/wfx/data_rx.h
+++ b/drivers/staging/wfx/data_rx.h
@@ -8,10 +8,9 @@
 #ifndef WFX_DATA_RX_H
 #define WFX_DATA_RX_H
 
-#include "hif_api_cmd.h"
-
 struct wfx_vif;
 struct sk_buff;
+struct hif_ind_rx;
 
 void wfx_rx_cb(struct wfx_vif *wvif,
   const struct hif_ind_rx *arg, struct sk_buff *skb);
diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h
index 038ea54e2574..826851a7e950 100644
--- a/drivers/staging/wfx/hif_tx.h
+++ b/drivers/staging/wfx/hif_tx.h
@@ -10,12 +10,11 @@
 #ifndef WFX_HIF_TX_H
 #define WFX_HIF_TX_H
 
-#include "hif_api_cmd.h"
-
 struct ieee80211_channel;
 struct ieee80211_bss_conf;
 struct ieee80211_tx_queue_params;
 struct cfg80211_scan_request;
+struct hif_req_add_key;
 struct wfx_dev;
 struct wfx_vif;
 
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index b72770a4ba12..bce35eb7eaa0 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -9,8 +9,6 @@
 #ifndef WFX_HIF_TX_MIB_H
 #define WFX_HIF_TX_MIB_H
 
-#include "hif_api_mib.h"
-
 struct wfx_vif;
 struct sk_buff;
 
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 623a9fc31153..d3d86c8c92c8 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -28,6 +28,7 @@
 #include "bh.h"
 #include "sta.h"
 #include "key.h"
+#include "scan.h"
 #include "debug.h"
 #include "data_tx.h"
 #include "secure_link.h"
diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h
index 9c9410072def..a0f37c8ce3df 100644
--- a/drivers/staging/wfx/main.h
+++ b/drivers/staging/wfx/main.h
@@ -13,10 +13,10 @@
 #include 
 #include 
 
-#include "bus.h"
 #include "hif_api_general.h"
 
 struct wfx_dev;
+struct hwbus_ops;
 
 struct wfx_platform_data {
/* Keyset and ".sec" extention will appended to this string */
diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h
index 1020dfde399b..0cbe5f4b06f2 100644
--- a/drivers/staging/wfx/queue.h
+++ b/drivers/staging/wfx/queue.h
@@ -11,8 +11,6 @@
 #include 
 #include 
 
-#include "hif_api_cmd.h"
-
 struct wfx_dev;
 struct wfx_vif;
 
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index a0e025c18341..c84c3749ec4f 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -10,8 +10,6 @@
 
 #include 
 
-#include "hif_api_cmd.h"
-
 struct wfx_dev;
 struct wfx_vif;
 
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index 4eb7762142fc..09a24561f092 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -21,10 +21,7 @@
 #include "main.h"
 #include "queue.h"
 #include "secure_link.h"
-#include "sta.h"
-#include "scan.h"
 #include "hif_tx.h"
-#include "hif_api_general.h"
 
 #define USEC_PER_TXOP 32 // see struct ieee80211_tx_queue_params
 #define USEC_PER_TU 1024
-- 
2.26.1

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


[PATCH 14/15] staging: wfx: remove spaces after cast operator

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

The kernel coding style expects no space after cast operator. This patch
make the wfx driver compliant with this rule.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/hif_rx.c |  2 +-
 drivers/staging/wfx/hif_tx.c |  4 ++--
 drivers/staging/wfx/hwio.c   |  4 ++--
 drivers/staging/wfx/key.c|  2 +-
 drivers/staging/wfx/main.c   |  2 +-
 drivers/staging/wfx/sta.c| 23 +++
 6 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c
index b786714a8755..ac4ec4f30496 100644
--- a/drivers/staging/wfx/hif_rx.c
+++ b/drivers/staging/wfx/hif_rx.c
@@ -263,7 +263,7 @@ static int hif_generic_indication(struct wfx_dev *wdev,
return 0;
case HIF_GENERIC_INDICATION_TYPE_STRING:
dev_info(wdev->dev, "firmware says: %s\n",
-(char *) body->indication_data.raw_data);
+(char *)body->indication_data.raw_data);
return 0;
case HIF_GENERIC_INDICATION_TYPE_RX_STATS:
mutex_lock(&wdev->rx_stats_lock);
diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
index 96f13d9c8c98..b083fcace303 100644
--- a/drivers/staging/wfx/hif_tx.c
+++ b/drivers/staging/wfx/hif_tx.c
@@ -106,7 +106,7 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg 
*request,
 
if (ret &&
(cmd == HIF_REQ_ID_READ_MIB || cmd == HIF_REQ_ID_WRITE_MIB)) {
-   mib_name = get_mib_name(((u16 *) request)[2]);
+   mib_name = get_mib_name(((u16 *)request)[2]);
mib_sep = "/";
}
if (ret < 0)
@@ -470,7 +470,7 @@ int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int 
flags, int sta_id)
 
if (mac_addr)
ether_addr_copy(body->mac_addr, mac_addr);
-   body->map_link_flags = *(struct hif_map_link_flags *) &flags;
+   body->map_link_flags = *(struct hif_map_link_flags *)&flags;
body->peer_sta_id = sta_id;
wfx_fill_header(hif, wvif->id, HIF_REQ_ID_MAP_LINK, sizeof(*body));
ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false);
diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c
index 051d4b233b47..d878cb3e84fc 100644
--- a/drivers/staging/wfx/hwio.c
+++ b/drivers/staging/wfx/hwio.c
@@ -233,7 +233,7 @@ int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t 
len)
 {
int ret;
 
-   WARN((long) buf & 3, "%s: unaligned buffer", __func__);
+   WARN((long)buf & 3, "%s: unaligned buffer", __func__);
wdev->hwbus_ops->lock(wdev->hwbus_priv);
ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv,
WFX_REG_IN_OUT_QUEUE, buf, len);
@@ -249,7 +249,7 @@ int wfx_data_write(struct wfx_dev *wdev, const void *buf, 
size_t len)
 {
int ret;
 
-   WARN((long) buf & 3, "%s: unaligned buffer", __func__);
+   WARN((long)buf & 3, "%s: unaligned buffer", __func__);
wdev->hwbus_ops->lock(wdev->hwbus_priv);
ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv,
  WFX_REG_IN_OUT_QUEUE, buf, len);
diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c
index ceb57cbdfefd..5ee2ffc5f935 100644
--- a/drivers/staging/wfx/key.c
+++ b/drivers/staging/wfx/key.c
@@ -228,7 +228,7 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd 
cmd,
struct ieee80211_key_conf *key)
 {
int ret = -EOPNOTSUPP;
-   struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+   struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
mutex_lock(&wvif->wdev->conf_mutex);
if (cmd == SET_KEY)
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index de41f1671433..18c96b82c66e 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -390,7 +390,7 @@ int wfx_probe(struct wfx_dev *wdev)
 wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label,
 wdev->hw_caps.api_version_major,
 wdev->hw_caps.api_version_minor,
-wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities));
+wdev->keyset, *((u32 *)&wdev->hw_caps.capabilities));
snprintf(wdev->hw->wiphy->fw_version,
 sizeof(wdev->hw->wiphy->fw_version),
 "%d.%d.%d",
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 999e0f0e19af..1a876a0faaf5 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -251,7 +251,7 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
   u16 queue, const struct ieee80211_tx_queue_params *params)
 {
struct wfx_dev *wdev = hw->priv;
-   struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+   struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
int old_uapsd = wvif->uapsd_mask;
 
WARN_ON(queue

[PATCH 09/15] staging: wfx: fix missing 'static' statement

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

The function get_firmware() is only used from fwio.c. It can be declared
static.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/fwio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c
index e2f914296677..85b6a916a7d0 100644
--- a/drivers/staging/wfx/fwio.c
+++ b/drivers/staging/wfx/fwio.c
@@ -99,8 +99,8 @@ static int sram_write_dma_safe(struct wfx_dev *wdev, u32 
addr, const u8 *buf,
return ret;
 }
 
-int get_firmware(struct wfx_dev *wdev, u32 keyset_chip,
-const struct firmware **fw, int *file_offset)
+static int get_firmware(struct wfx_dev *wdev, u32 keyset_chip,
+   const struct firmware **fw, int *file_offset)
 {
int keyset_file;
char filename[256];
-- 
2.26.1

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


[PATCH 11/15] staging: wfx: prefer ARRAY_SIZE instead of a magic number

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

When possible, we prefer to use the macro ARRAY_SIZE rather than hard
coding the number of elements.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/data_tx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index 30aa8c267cd0..83a9256f09bf 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -166,13 +166,13 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif)
 
do {
spin_lock_bh(&wvif->tx_policy_cache.lock);
-   for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) {
+   for (i = 0; i < ARRAY_SIZE(wvif->tx_policy_cache.cache); ++i) {
is_used = memzcmp(policies[i].rates,
  sizeof(policies[i].rates));
if (!policies[i].uploaded && is_used)
break;
}
-   if (i < HIF_TX_RETRY_POLICY_MAX) {
+   if (i < ARRAY_SIZE(wvif->tx_policy_cache.cache)) {
policies[i].uploaded = true;
memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates));
spin_unlock_bh(&wvif->tx_policy_cache.lock);
@@ -180,7 +180,7 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif)
} else {
spin_unlock_bh(&wvif->tx_policy_cache.lock);
}
-   } while (i < HIF_TX_RETRY_POLICY_MAX);
+   } while (i < ARRAY_SIZE(wvif->tx_policy_cache.cache));
return 0;
 }
 
@@ -204,7 +204,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif)
INIT_LIST_HEAD(&cache->used);
INIT_LIST_HEAD(&cache->free);
 
-   for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i)
+   for (i = 0; i < ARRAY_SIZE(cache->cache); ++i)
list_add(&cache->cache[i].link, &cache->free);
 }
 
-- 
2.26.1

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


[PATCH 15/15] staging: wfx: use kernel types instead of c99 ones

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

The kernel coding style promotes the use of kernel types (u8, u16, u32,
etc...) instead of the C99 ones.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/hif_tx.c | 5 ++---
 drivers/staging/wfx/hif_tx_mib.c | 2 +-
 drivers/staging/wfx/hif_tx_mib.h | 2 +-
 drivers/staging/wfx/main.c   | 4 ++--
 drivers/staging/wfx/main.h   | 2 +-
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
index b083fcace303..58013c019192 100644
--- a/drivers/staging/wfx/hif_tx.c
+++ b/drivers/staging/wfx/hif_tx.c
@@ -495,7 +495,7 @@ int hif_update_ie_beacon(struct wfx_vif *wvif, const u8 
*ies, size_t ies_len)
 }
 
 int hif_sl_send_pub_keys(struct wfx_dev *wdev,
-const uint8_t *pubkey, const uint8_t *pubkey_hmac)
+const u8 *pubkey, const u8 *pubkey_hmac)
 {
int ret;
struct hif_msg *hif;
@@ -529,8 +529,7 @@ int hif_sl_config(struct wfx_dev *wdev, const unsigned long 
*bitmap)
return ret;
 }
 
-int hif_sl_set_mac_key(struct wfx_dev *wdev,
-  const uint8_t *slk_key, int destination)
+int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key, int 
destination)
 {
int ret;
struct hif_msg *hif;
diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c
index 6fdde5a4c9a1..65381b22437e 100644
--- a/drivers/staging/wfx/hif_tx_mib.c
+++ b/drivers/staging/wfx/hif_tx_mib.c
@@ -215,7 +215,7 @@ int hif_set_association_mode(struct wfx_vif *wvif,
 }
 
 int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif,
-int policy_index, uint8_t *rates)
+int policy_index, u8 *rates)
 {
struct hif_mib_set_tx_rate_retry_policy *arg;
size_t size = struct_size(arg, tx_rate_retry_policy, 1);
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index bce35eb7eaa0..86683de7de7c 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -36,7 +36,7 @@ int hif_set_block_ack_policy(struct wfx_vif *wvif,
 int hif_set_association_mode(struct wfx_vif *wvif,
 struct ieee80211_bss_conf *info);
 int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif,
-int policy_index, uint8_t *rates);
+int policy_index, u8 *rates);
 int hif_set_mac_addr_condition(struct wfx_vif *wvif,
   int idx, const u8 *mac_addr);
 int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif,
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 18c96b82c66e..25d70ebe9933 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -203,7 +203,7 @@ struct gpio_desc *wfx_get_gpio(struct device *dev,
 }
 
 /* NOTE: wfx_send_pds() destroy buf */
-int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len)
+int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len)
 {
int ret;
int start, brace_level, i;
@@ -252,7 +252,7 @@ static int wfx_send_pdata_pds(struct wfx_dev *wdev)
 {
int ret = 0;
const struct firmware *pds;
-   unsigned char *tmp_buf;
+   u8 *tmp_buf;
 
ret = request_firmware(&pds, wdev->pdata.file_pds, wdev->dev);
if (ret) {
diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h
index a0f37c8ce3df..f832ce409fda 100644
--- a/drivers/staging/wfx/main.h
+++ b/drivers/staging/wfx/main.h
@@ -41,6 +41,6 @@ void wfx_release(struct wfx_dev *wdev);
 struct gpio_desc *wfx_get_gpio(struct device *dev, int override,
   const char *label);
 bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor);
-int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len);
+int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len);
 
 #endif
-- 
2.26.1

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


[PATCH 13/15] staging: wfx: fix alignements of function prototypes

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

Some function prototypes were not correctly aligned and/or exceed 80
columns.

In some other cases, the prototypes were written on more lines than
necessary.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/data_tx.c |  3 +--
 drivers/staging/wfx/hif_tx.c  | 24 
 drivers/staging/wfx/hif_tx.h  |  4 ++--
 drivers/staging/wfx/hwio.c| 12 ++--
 drivers/staging/wfx/main.c|  4 ++--
 drivers/staging/wfx/sta.c | 15 +--
 6 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index 83a9256f09bf..f64149ab0484 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -106,8 +106,7 @@ static int wfx_tx_policy_release(struct tx_policy_cache 
*cache,
 }
 
 static int wfx_tx_policy_get(struct wfx_vif *wvif,
-struct ieee80211_tx_rate *rates,
-bool *renew)
+struct ieee80211_tx_rate *rates, bool *renew)
 {
int idx;
struct tx_policy_cache *cache = &wvif->tx_policy_cache;
diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
index 511ef874a6d9..96f13d9c8c98 100644
--- a/drivers/staging/wfx/hif_tx.c
+++ b/drivers/staging/wfx/hif_tx.c
@@ -23,8 +23,8 @@ void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd)
mutex_init(&hif_cmd->key_renew_lock);
 }
 
-static void wfx_fill_header(struct hif_msg *hif, int if_id, unsigned int cmd,
-   size_t size)
+static void wfx_fill_header(struct hif_msg *hif, int if_id,
+   unsigned int cmd, size_t size)
 {
if (if_id == -1)
if_id = 2;
@@ -47,8 +47,8 @@ static void *wfx_alloc_hif(size_t body_len, struct hif_msg 
**hif)
return NULL;
 }
 
-int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply,
-size_t reply_len, bool async)
+int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request,
+void *reply, size_t reply_len, bool async)
 {
const char *mib_name = "";
const char *mib_sep = "";
@@ -176,8 +176,8 @@ int hif_reset(struct wfx_vif *wvif, bool reset_stat)
return ret;
 }
 
-int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val,
-size_t val_len)
+int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id,
+void *val, size_t val_len)
 {
int ret;
struct hif_msg *hif;
@@ -207,8 +207,8 @@ int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 
mib_id, void *val,
return ret;
 }
 
-int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val,
- size_t val_len)
+int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id,
+ void *val, size_t val_len)
 {
int ret;
struct hif_msg *hif;
@@ -494,8 +494,8 @@ int hif_update_ie_beacon(struct wfx_vif *wvif, const u8 
*ies, size_t ies_len)
return ret;
 }
 
-int hif_sl_send_pub_keys(struct wfx_dev *wdev, const uint8_t *pubkey,
-const uint8_t *pubkey_hmac)
+int hif_sl_send_pub_keys(struct wfx_dev *wdev,
+const uint8_t *pubkey, const uint8_t *pubkey_hmac)
 {
int ret;
struct hif_msg *hif;
@@ -529,8 +529,8 @@ int hif_sl_config(struct wfx_dev *wdev, const unsigned long 
*bitmap)
return ret;
 }
 
-int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key,
-  int destination)
+int hif_sl_set_mac_key(struct wfx_dev *wdev,
+  const uint8_t *slk_key, int destination)
 {
int ret;
struct hif_msg *hif;
diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h
index 826851a7e950..e9eca9330178 100644
--- a/drivers/staging/wfx/hif_tx.h
+++ b/drivers/staging/wfx/hif_tx.h
@@ -57,8 +57,8 @@ int hif_start(struct wfx_vif *wvif, const struct 
ieee80211_bss_conf *conf,
 int hif_beacon_transmit(struct wfx_vif *wvif, bool enable);
 int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int flags, int sta_id);
 int hif_update_ie_beacon(struct wfx_vif *wvif, const u8 *ies, size_t ies_len);
-int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key,
-  int destination);
+int hif_sl_set_mac_key(struct wfx_dev *wdev,
+  const u8 *slk_key, int destination);
 int hif_sl_config(struct wfx_dev *wdev, const unsigned long *bitmap);
 int hif_sl_send_pub_keys(struct wfx_dev *wdev,
 const u8 *pubkey, const u8 *pubkey_hmac);
diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c
index d3a141d95a0e..051d4b233b47 100644
--- a/drivers/staging/wfx/hwio.c
+++ b/drivers/staging/wfx/hwio.c
@@ -106,8 +106,8 @@ static int write32_bits_locked(struct wfx_dev *wdev, int 
reg, u32 mask, u32 val)
return ret;
 }
 
-static int indirect_read(struct wfx_dev *wdev, int reg, u32 add

[PATCH 10/15] staging: wfx: fix missing 'static' keyword

2020-05-05 Thread Jerome Pouiller
From: Jérôme Pouiller 

Sparse tool noticed that wfx_enable_beacon() is never used outside of
sta.c. Therefore, it can be declared static.

Signed-off-by: Jérôme Pouiller 
---
 drivers/staging/wfx/sta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 74ec0b604085..3ad0b67a7dca 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -519,7 +519,7 @@ void wfx_leave_ibss(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif)
wfx_do_unjoin(wvif);
 }
 
-void wfx_enable_beacon(struct wfx_vif *wvif, bool enable)
+static void wfx_enable_beacon(struct wfx_vif *wvif, bool enable)
 {
// Driver has Content After DTIM Beacon in queue. Driver is waiting for
// a signal from the firmware. Since we are going to stop to send
-- 
2.26.1

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


Re: KASAN: slab-out-of-bounds Read in hfa384x_usbin_callback

2020-05-05 Thread Oliver Neukum
Am Freitag, den 20.03.2020, 12:28 -0700 schrieb syzbot:
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:e17994d1 usb: core: kcov: collect coverage from usb comple..
> git tree:   https://github.com/google/kasan.git usb-fuzzer
> console output: https://syzkaller.appspot.com/x/log.txt?x=11d74573e0
> kernel config:  https://syzkaller.appspot.com/x/.config?x=5d64370c438bc60
> dashboard link: https://syzkaller.appspot.com/bug?extid=7d42d68643a35f71ac8a
> compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=15fa561de0
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15d74573e0
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+7d42d68643a35f71a...@syzkaller.appspotmail.com
> 
> ==
> BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:381 [inline]
> BUG: KASAN: slab-out-of-bounds in skb_put_data include/linux/skbuff.h:2284 
> [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_int_rxmonitor 
> drivers/staging/wlan-ng/hfa384x_usb.c:3412 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_rx 
> drivers/staging/wlan-ng/hfa384x_usb.c:3312 [inline]
> BUG: KASAN: slab-out-of-bounds in hfa384x_usbin_callback+0x1993/0x2360 
> drivers/staging/wlan-ng/hfa384x_usb.c:3026
> Read of size 19671 at addr 8881d226413c by task swapper/0/0

#syz test: https://github.com/google/kasan.git e17994d1
From 6dbcac8c4b645600161feafc5576657905f15d65 Mon Sep 17 00:00:00 2001
From: Oliver Neukum 
Date: Tue, 5 May 2020 13:46:26 +0200
Subject: [PATCH] hfa384x_usb: fix buffer overflow

The driver trusts the data_len coming from the hardware
without verification. That means that this opens
a vector by which an attacker can smash 64K of the heap.

Signed-off-by: Oliver Neukum 
---
 drivers/staging/wlan-ng/hfa384x_usb.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index fa1bf8b069fd..5b6497d8c9e2 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3353,9 +3353,9 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
   struct hfa384x_usb_rxfrm *rxfrm)
 {
 	struct hfa384x_rx_frame *rxdesc = &rxfrm->desc;
-	unsigned int hdrlen = 0;
-	unsigned int datalen = 0;
-	unsigned int skblen = 0;
+	unsigned int hdrlen;
+	unsigned int datalen;
+	unsigned int skblen;
 	u8 *datap;
 	u16 fc;
 	struct sk_buff *skb;
@@ -3413,8 +3413,10 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
 	 */
 	skb_put_data(skb, &rxdesc->frame_control, hdrlen);
 
-	/* If any, copy the data from the card to the skb */
-	if (datalen > 0) {
+	/* If any, copy the data from the card to the skb,
+	 * as long as it fits, lest we smash a buffer
+	 */
+	if (datalen > 0 && datalen <= skblen - hdrlen) {
 		datap = skb_put_data(skb, rxfrm->data, datalen);
 
 		/* check for unencrypted stuff if WEP bit set. */
-- 
2.16.4

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


Re: [PATCH 03/15] staging: wfx: fix double free

2020-05-05 Thread Michał Mirosław
On Tue, May 05, 2020 at 02:37:45PM +0200, Jerome Pouiller wrote:
> From: Jérôme Pouiller 
> 
> In case of error in wfx_probe(), wdev->hw is freed. Since an error
> occurred, wfx_free_common() is called, then wdev->hw is freed again.
> 
> Cc: Michał Mirosław 
> Signed-off-by: Jérôme Pouiller 
> ---
>  drivers/staging/wfx/main.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
> index ba2e3a6b3549..5d0754b55429 100644
> --- a/drivers/staging/wfx/main.c
> +++ b/drivers/staging/wfx/main.c
> @@ -469,7 +469,6 @@ int wfx_probe(struct wfx_dev *wdev)
>  
>  err2:
>   ieee80211_unregister_hw(wdev->hw);
> - ieee80211_free_hw(wdev->hw);
>  err1:
>   wfx_bh_unregister(wdev);
>   return err;

Reviewed-by: Michał Mirosław 
Fixes: 4033714d6cbe ("staging: wfx: fix init/remove vs IRQ race")
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[git:media_tree/master] media: staging: media: imx: no need to check return value of debugfs_create functions

2020-05-05 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: staging: media: imx: no need to check return value of 
debugfs_create functions
Author:  Greg Kroah-Hartman 
Date:Tue Apr 28 19:04:05 2020 +0200

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Steve Longerbeam 
Cc: Philipp Zabel 
Cc: Shawn Guo 
Cc: Sascha Hauer 
Cc: Pengutronix Kernel Team 
Cc: Fabio Estevam 
Cc: NXP Linux Team 
Cc: de...@driverdev.osuosl.org
Signed-off-by: Greg Kroah-Hartman 
Reviewed-by: Rui Miguel Silva 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/staging/media/imx/imx7-mipi-csis.c | 29 +
 1 file changed, 5 insertions(+), 24 deletions(-)

---

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
index e2403b448b6d..ca20f5da9ac6 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -1017,33 +1017,14 @@ static int mipi_csis_dump_regs_show(struct seq_file *m, 
void *private)
 }
 DEFINE_SHOW_ATTRIBUTE(mipi_csis_dump_regs);
 
-static int mipi_csis_debugfs_init(struct csi_state *state)
+static void mipi_csis_debugfs_init(struct csi_state *state)
 {
-   struct dentry *d;
-
-   if (!debugfs_initialized())
-   return -ENODEV;
-
state->debugfs_root = debugfs_create_dir(dev_name(state->dev), NULL);
-   if (!state->debugfs_root)
-   return -ENOMEM;
-
-   d = debugfs_create_bool("debug_enable", 0600, state->debugfs_root,
-   &state->debug);
-   if (!d)
-   goto remove_debugfs;
-
-   d = debugfs_create_file("dump_regs", 0600, state->debugfs_root,
-   state, &mipi_csis_dump_regs_fops);
-   if (!d)
-   goto remove_debugfs;
-
-   return 0;
-
-remove_debugfs:
-   debugfs_remove_recursive(state->debugfs_root);
 
-   return -ENOMEM;
+   debugfs_create_bool("debug_enable", 0600, state->debugfs_root,
+   &state->debug);
+   debugfs_create_file("dump_regs", 0600, state->debugfs_root, state,
+   &mipi_csis_dump_regs_fops);
 }
 
 static void mipi_csis_debugfs_exit(struct csi_state *state)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast()

2020-05-05 Thread Souptick Joarder
Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno
and no of pinned pages. The only case where these two functions will
return 0, is for nr_pages <= 0, which doesn't find a valid use case.
But if at all any, then a -ERRNO will be returned instead of 0, which
means {get|pin}_user_pages_fast() will have 2 return values -errno &
no of pinned pages.

Update all the callers which deals with return value 0 accordingly.

Signed-off-by: Souptick Joarder 
---
 arch/ia64/kernel/err_inject.c  | 2 +-
 drivers/platform/goldfish/goldfish_pipe.c  | 2 +-
 drivers/staging/gasket/gasket_page_table.c | 4 ++--
 drivers/tee/tee_shm.c  | 2 +-
 mm/gup.c   | 6 +++---
 net/rds/rdma.c | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 8b5b8e6b..fd72218 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -143,7 +143,7 @@ static DEVICE_ATTR(name, 0644, show_##name, store_##name)
int ret;
 
ret = get_user_pages_fast(virt_addr, 1, FOLL_WRITE, NULL);
-   if (ret<=0) {
+   if (ret < 0) {
 #ifdef ERR_INJ_DEBUG
printk("Virtual address %lx is not existing.\n",virt_addr);
 #endif
diff --git a/drivers/platform/goldfish/goldfish_pipe.c 
b/drivers/platform/goldfish/goldfish_pipe.c
index 1ab207e..831449d 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -277,7 +277,7 @@ static int goldfish_pin_pages(unsigned long first_page,
ret = pin_user_pages_fast(first_page, requested_pages,
  !is_write ? FOLL_WRITE : 0,
  pages);
-   if (ret <= 0)
+   if (ret < 0)
return -EFAULT;
if (ret < requested_pages)
*iter_last_page_size = PAGE_SIZE;
diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index f6d7157..1d08e1d 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -489,11 +489,11 @@ static int gasket_perform_mapping(struct 
gasket_page_table *pg_tbl,
ret = get_user_pages_fast(page_addr - offset, 1,
  FOLL_WRITE, &page);
 
-   if (ret <= 0) {
+   if (ret < 0) {
dev_err(pg_tbl->device,
"get user pages failed for addr=0x%lx, 
offset=0x%lx [ret=%d]\n",
page_addr, offset, ret);
-   return ret ? ret : -ENOMEM;
+   return ret;
}
++pg_tbl->num_active_pages;
 
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index bd679b7..2706a1f 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -230,7 +230,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, 
unsigned long addr,
if (rc > 0)
shm->num_pages = rc;
if (rc != num_pages) {
-   if (rc >= 0)
+   if (rc > 0)
rc = -ENOMEM;
ret = ERR_PTR(rc);
goto err;
diff --git a/mm/gup.c b/mm/gup.c
index 50681f0..8d293ed 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2760,7 +2760,7 @@ static int internal_get_user_pages_fast(unsigned long 
start, int nr_pages,
end = start + len;
 
if (end <= start)
-   return 0;
+   return -EINVAL;
if (unlikely(!access_ok((void __user *)start, len)))
return -EFAULT;
 
@@ -2805,8 +2805,8 @@ static int internal_get_user_pages_fast(unsigned long 
start, int nr_pages,
  * calling get_user_pages().
  *
  * Returns number of pages pinned. This may be fewer than the number requested.
- * If nr_pages is 0 or negative, returns 0. If no pages were pinned, returns
- * -errno.
+ * If nr_pages is 0 or negative, returns -errno. If no pages were pinned,
+ * returns -errno.
  */
 int get_user_pages_fast(unsigned long start, int nr_pages,
unsigned int gup_flags, struct page **pages)
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index a7ae118..44b96e6 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -161,7 +161,7 @@ static int rds_pin_pages(unsigned long user_addr, unsigned 
int nr_pages,
gup_flags |= FOLL_WRITE;
 
ret = pin_user_pages_fast(user_addr, nr_pages, gup_flags, pages);
-   if (ret >= 0 && ret < nr_pages) {
+   if (ret > 0 && ret < nr_pages) {
unpin_user_pages(pages, ret);
ret = -EFAULT;
}
-- 
1.9.1

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

Re: [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast()

2020-05-05 Thread John Hubbard

On 2020-05-05 12:14, Souptick Joarder wrote:

Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno
and no of pinned pages. The only case where these two functions will
return 0, is for nr_pages <= 0, which doesn't find a valid use case.
But if at all any, then a -ERRNO will be returned instead of 0, which
means {get|pin}_user_pages_fast() will have 2 return values -errno &
no of pinned pages.

Update all the callers which deals with return value 0 accordingly.


Hmmm, seems a little shaky. In order to do this safely, I'd recommend
first changing gup_fast/pup_fast so so that they return -EINVAL if
the caller specified nr_pages==0, and of course auditing all callers,
to ensure that this won't cause problems.

The gup.c documentation would also need updating in a couple of comment
blocks, above get_user_pages_remote(), and __get_user_pages(), because
those talk about a zero return value.

This might be practical without slowing down the existing code, because
there is already a check in place, so just tweaking it like this (untested)
won't change performance at all:

diff --git a/mm/gup.c b/mm/gup.c
index 11fda538c9d9..708eed79ae29 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2787,7 +2787,7 @@ static int internal_get_user_pages_fast(unsigned long start, 
int nr_pages,

end = start + len;

if (end <= start)
-   return 0;
+   return -EINVAL;
if (unlikely(!access_ok((void __user *)start, len)))
return -EFAULT;

...although I might be missing some other things that need a similar change,
so you should look carefully for yourself.


Once that change (and anything I missed) is in place, then you could go
ahead and stop handling ret==0 cases at the call sites.


thanks,
--
John Hubbard
NVIDIA



Signed-off-by: Souptick Joarder 
---
  arch/ia64/kernel/err_inject.c  | 2 +-
  drivers/platform/goldfish/goldfish_pipe.c  | 2 +-
  drivers/staging/gasket/gasket_page_table.c | 4 ++--
  drivers/tee/tee_shm.c  | 2 +-
  mm/gup.c   | 6 +++---
  net/rds/rdma.c | 2 +-
  6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 8b5b8e6b..fd72218 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -143,7 +143,7 @@ static DEVICE_ATTR(name, 0644, show_##name, store_##name)
int ret;
  
  	ret = get_user_pages_fast(virt_addr, 1, FOLL_WRITE, NULL);

-   if (ret<=0) {
+   if (ret < 0) {
  #ifdef ERR_INJ_DEBUG
printk("Virtual address %lx is not existing.\n",virt_addr);
  #endif
diff --git a/drivers/platform/goldfish/goldfish_pipe.c 
b/drivers/platform/goldfish/goldfish_pipe.c
index 1ab207e..831449d 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -277,7 +277,7 @@ static int goldfish_pin_pages(unsigned long first_page,
ret = pin_user_pages_fast(first_page, requested_pages,
  !is_write ? FOLL_WRITE : 0,
  pages);
-   if (ret <= 0)
+   if (ret < 0)
return -EFAULT;
if (ret < requested_pages)
*iter_last_page_size = PAGE_SIZE;
diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index f6d7157..1d08e1d 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -489,11 +489,11 @@ static int gasket_perform_mapping(struct 
gasket_page_table *pg_tbl,
ret = get_user_pages_fast(page_addr - offset, 1,
  FOLL_WRITE, &page);
  
-			if (ret <= 0) {

+   if (ret < 0) {
dev_err(pg_tbl->device,
"get user pages failed for addr=0x%lx, 
offset=0x%lx [ret=%d]\n",
page_addr, offset, ret);
-   return ret ? ret : -ENOMEM;
+   return ret;
}
++pg_tbl->num_active_pages;
  
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c

index bd679b7..2706a1f 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -230,7 +230,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, 
unsigned long addr,
if (rc > 0)
shm->num_pages = rc;
if (rc != num_pages) {
-   if (rc >= 0)
+   if (rc > 0)
rc = -ENOMEM;
ret = ERR_PTR(rc);
goto err;
diff --git a/mm/gup.c b/mm/gup.c
index 50681f0..8d293ed 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2760,7 +2760,7 @@ static int internal_get_user_pages_fast(unsigned long 
start, int nr_pages,
end = start + len;
  
  	if (end <= start)

-

Re: [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast()

2020-05-05 Thread Souptick Joarder
On Wed, May 6, 2020 at 1:08 AM John Hubbard  wrote:
>
> On 2020-05-05 12:14, Souptick Joarder wrote:
> > Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno
> > and no of pinned pages. The only case where these two functions will
> > return 0, is for nr_pages <= 0, which doesn't find a valid use case.
> > But if at all any, then a -ERRNO will be returned instead of 0, which
> > means {get|pin}_user_pages_fast() will have 2 return values -errno &
> > no of pinned pages.
> >
> > Update all the callers which deals with return value 0 accordingly.
>
> Hmmm, seems a little shaky. In order to do this safely, I'd recommend
> first changing gup_fast/pup_fast so so that they return -EINVAL if
> the caller specified nr_pages==0, and of course auditing all callers,
> to ensure that this won't cause problems.

While auditing it was figured out, there are 5 callers which cares for
return value
0 of gup_fast/pup_fast. What problem it might cause if we change
gup_fast/pup_fast
to return -EINVAL and update all the callers in a single commit ?

>
> The gup.c documentation would also need updating in a couple of comment
> blocks, above get_user_pages_remote(), and __get_user_pages(), because
> those talk about a zero return value.

OK.

>
> This might be practical without slowing down the existing code, because
> there is already a check in place, so just tweaking it like this (untested)
> won't change performance at all:
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 11fda538c9d9..708eed79ae29 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2787,7 +2787,7 @@ static int internal_get_user_pages_fast(unsigned long 
> start,
> int nr_pages,
>  end = start + len;
>
>  if (end <= start)
> -   return 0;
> +   return -EINVAL;
>  if (unlikely(!access_ok((void __user *)start, len)))
>  return -EFAULT;
>
> ...although I might be missing some other things that need a similar change,
> so you should look carefully for yourself.

Do you refer to other gup APIs similar to gup_fast/pup_fast ?

>
>
> Once that change (and anything I missed) is in place, then you could go
> ahead and stop handling ret==0 cases at the call sites.
>
>
> thanks,
> --
> John Hubbard
> NVIDIA
>
> >
> > Signed-off-by: Souptick Joarder 
> > ---
> >   arch/ia64/kernel/err_inject.c  | 2 +-
> >   drivers/platform/goldfish/goldfish_pipe.c  | 2 +-
> >   drivers/staging/gasket/gasket_page_table.c | 4 ++--
> >   drivers/tee/tee_shm.c  | 2 +-
> >   mm/gup.c   | 6 +++---
> >   net/rds/rdma.c | 2 +-
> >   6 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
> > index 8b5b8e6b..fd72218 100644
> > --- a/arch/ia64/kernel/err_inject.c
> > +++ b/arch/ia64/kernel/err_inject.c
> > @@ -143,7 +143,7 @@ static DEVICE_ATTR(name, 0644, show_##name, 
> > store_##name)
> >   int ret;
> >
> >   ret = get_user_pages_fast(virt_addr, 1, FOLL_WRITE, NULL);
> > - if (ret<=0) {
> > + if (ret < 0) {
> >   #ifdef ERR_INJ_DEBUG
> >   printk("Virtual address %lx is not existing.\n",virt_addr);
> >   #endif
> > diff --git a/drivers/platform/goldfish/goldfish_pipe.c 
> > b/drivers/platform/goldfish/goldfish_pipe.c
> > index 1ab207e..831449d 100644
> > --- a/drivers/platform/goldfish/goldfish_pipe.c
> > +++ b/drivers/platform/goldfish/goldfish_pipe.c
> > @@ -277,7 +277,7 @@ static int goldfish_pin_pages(unsigned long first_page,
> >   ret = pin_user_pages_fast(first_page, requested_pages,
> > !is_write ? FOLL_WRITE : 0,
> > pages);
> > - if (ret <= 0)
> > + if (ret < 0)
> >   return -EFAULT;
> >   if (ret < requested_pages)
> >   *iter_last_page_size = PAGE_SIZE;
> > diff --git a/drivers/staging/gasket/gasket_page_table.c 
> > b/drivers/staging/gasket/gasket_page_table.c
> > index f6d7157..1d08e1d 100644
> > --- a/drivers/staging/gasket/gasket_page_table.c
> > +++ b/drivers/staging/gasket/gasket_page_table.c
> > @@ -489,11 +489,11 @@ static int gasket_perform_mapping(struct 
> > gasket_page_table *pg_tbl,
> >   ret = get_user_pages_fast(page_addr - offset, 1,
> > FOLL_WRITE, &page);
> >
> > - if (ret <= 0) {
> > + if (ret < 0) {
> >   dev_err(pg_tbl->device,
> >   "get user pages failed for 
> > addr=0x%lx, offset=0x%lx [ret=%d]\n",
> >   page_addr, offset, ret);
> > - return ret ? ret : -ENOMEM;
> > + return ret;
> >   }
> >   ++pg_tbl->num_active_pages;
> >
> > diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
> > index

Re: [RFC] mm/gup.c: Updated return value of {get|pin}_user_pages_fast()

2020-05-05 Thread John Hubbard

On 2020-05-05 13:36, Souptick Joarder wrote:

On Wed, May 6, 2020 at 1:08 AM John Hubbard  wrote:


On 2020-05-05 12:14, Souptick Joarder wrote:

Currently {get|pin}_user_pages_fast() have 3 return value 0, -errno
and no of pinned pages. The only case where these two functions will
return 0, is for nr_pages <= 0, which doesn't find a valid use case.
But if at all any, then a -ERRNO will be returned instead of 0, which
means {get|pin}_user_pages_fast() will have 2 return values -errno &
no of pinned pages.

Update all the callers which deals with return value 0 accordingly.


Hmmm, seems a little shaky. In order to do this safely, I'd recommend
first changing gup_fast/pup_fast so so that they return -EINVAL if
the caller specified nr_pages==0, and of course auditing all callers,
to ensure that this won't cause problems.


While auditing it was figured out, there are 5 callers which cares for
return value
0 of gup_fast/pup_fast. What problem it might cause if we change
gup_fast/pup_fast
to return -EINVAL and update all the callers in a single commit ?



If you change the semantics of a core API, it's critical to do it
in steps that are safe even against other code changes that may be
merged in. There are other people potentially editing the callers. And
those might very well be in different git trees, and on different mailing
lists.

Even within a tree, it's possible to either overlook a call site during
an audit, or for someone else (who overlooked your change's review
discussions) to commit a change that doesn't follow the same assumptions.
So API assumptions often need to be backed up by things like -errno return
values, or sometimes even WARN*() statements.

For a recent example: gup() assumes that no one passes in a "bare"
FOLL_PIN flag to it. Therfore, it returns -errno and also WARN's in that
case--for precisely the same reasons: other people are editing the code
base. It's not static.





The gup.c documentation would also need updating in a couple of comment
blocks, above get_user_pages_remote(), and __get_user_pages(), because
those talk about a zero return value.


OK.



This might be practical without slowing down the existing code, because
there is already a check in place, so just tweaking it like this (untested)
won't change performance at all:

diff --git a/mm/gup.c b/mm/gup.c
index 11fda538c9d9..708eed79ae29 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2787,7 +2787,7 @@ static int internal_get_user_pages_fast(unsigned long 
start,
int nr_pages,
  end = start + len;

  if (end <= start)
-   return 0;
+   return -EINVAL;
  if (unlikely(!access_ok((void __user *)start, len)))
  return -EFAULT;

...although I might be missing some other things that need a similar change,
so you should look carefully for yourself.


Do you refer to other gup APIs similar to gup_fast/pup_fast ?



Yes, like all the gup/pup variants.


thanks,
--
John Hubbard
NVIDIA
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/6] staging: vt6656: vnt_rxtx_rsvtime_le16 to use ieee80211_generic_frame_duration.

2020-05-05 Thread Malcolm Priestley
ieee80211_generic_frame_duration is the mac80211 equivalent to
vnt_get_rsvtime use this to get our frame time.

There is a change where there is rrv_time_a and rrv_time_b
the frame duration is always the same so both are equal.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 68be0fa7b201..6724b213a723 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -216,11 +216,16 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 
pkt_type,
return data_time;
 }
 
-static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
-   u32 frame_length, u16 rate, int need_ack)
+static __le16 vnt_rxtx_rsvtime_le16(struct vnt_usb_send_context *context)
 {
-   return cpu_to_le16((u16)vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack));
+   struct vnt_private *priv = context->priv;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
+   struct ieee80211_rate *rate = ieee80211_get_tx_rate(priv->hw, info);
+
+   return ieee80211_generic_frame_duration(priv->hw,
+info->control.vif, info->band,
+context->frame_len,
+rate);
 }
 
 static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv, u8 rsv_type,
@@ -465,7 +470,6 @@ static void vnt_rxtx_rts(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = &tx_head->tx_rts.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
buf->rts_rrv_time_aa = vnt_get_rtscts_rsvtime_le(priv, 2,
tx_context->pkt_type, frame_len, current_rate);
@@ -474,11 +478,8 @@ static void vnt_rxtx_rts(struct vnt_usb_send_context 
*tx_context,
buf->rts_rrv_time_bb = vnt_get_rtscts_rsvtime_le(priv, 0,
tx_context->pkt_type, frame_len, current_rate);
 
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
-   frame_len, current_rate,
-   need_ack);
-   buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B, frame_len,
-   priv->top_cck_basic_rate, need_ack);
+   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
+   buf->rrv_time_b = buf->rrv_time_a;
 
if (need_mic)
head = &tx_head->tx_rts.tx.mic.head;
@@ -494,12 +495,9 @@ static void vnt_rxtx_cts(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = &tx_head->tx_cts.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
-   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
-   frame_len, current_rate, need_ack);
-   buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B,
-   frame_len, priv->top_cck_basic_rate, need_ack);
+   buf->rrv_time_a = vnt_rxtx_rsvtime_le16(tx_context);
+   buf->rrv_time_b = buf->rrv_time_a;
 
buf->cts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 3,
tx_context->pkt_type, frame_len, current_rate);
@@ -519,10 +517,8 @@ static void vnt_rxtx_ab(struct vnt_usb_send_context 
*tx_context,
union vnt_tx_data_head *head = &tx_head->tx_ab.tx.head;
u32 frame_len = tx_context->frame_len;
u16 current_rate = tx_context->tx_rate;
-   u8 need_ack = tx_context->need_ack;
 
-   buf->rrv_time = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
- frame_len, current_rate, 
need_ack);
+   buf->rrv_time = vnt_rxtx_rsvtime_le16(tx_context);
 
if (need_mic)
head = &tx_head->tx_ab.tx.mic.head;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] staging: vt6656: vnt_get_rtscts_duration_le use ieee80211_rts_duration

2020-05-05 Thread Malcolm Priestley
use the mac80211 ieee80211_rts_duration for RTS frames.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 6724b213a723..48fe16c27d3f 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -285,28 +285,18 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
 u8 dur_type, u8 pkt_type, u16 rate)
 {
struct vnt_private *priv = context->priv;
-   u32 cts_time = 0, dur_time = 0;
+   u32 dur_time = 0;
u32 frame_length = context->frame_len;
u8 need_ack = context->need_ack;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
switch (dur_type) {
+   /* fall through */
case RTSDUR_BB:
case RTSDUR_BA:
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   dur_time = cts_time + 2 * priv->sifs +
-   vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack);
-   break;
-
case RTSDUR_AA:
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-   dur_time = cts_time + 2 * priv->sifs +
-   vnt_get_rsvtime(priv, pkt_type,
-   frame_length, rate, need_ack);
-   break;
-
+   return ieee80211_rts_duration(priv->hw, priv->vif,
+ context->frame_len, info);
case CTSDUR_BA:
dur_time = priv->sifs + vnt_get_rsvtime(priv,
pkt_type, frame_length, rate, need_ack);
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] staging: vt6656: vnt_get_rtscts_duration_le use ieee80211_ctstoself_duration

2020-05-05 Thread Malcolm Priestley
use the mac80211 ieee80211_ctstoself_duration for CTS to self frames.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 32 +++-
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 48fe16c27d3f..27069ac60b15 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -195,27 +195,6 @@ static __le16 vnt_time_stamp_off(struct vnt_private *priv, 
u16 rate)
[rate % MAX_RATE]);
 }
 
-static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type,
-  u32 frame_length, u16 rate, int need_ack)
-{
-   u32 data_time, ack_time;
-
-   data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
-  frame_length, rate);
-
-   if (pkt_type == PK_TYPE_11B)
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14,
- (u16)priv->top_cck_basic_rate);
-   else
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14,
- (u16)priv->top_ofdm_basic_rate);
-
-   if (need_ack)
-   return data_time + priv->sifs + ack_time;
-
-   return data_time;
-}
-
 static __le16 vnt_rxtx_rsvtime_le16(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
@@ -285,9 +264,6 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
 u8 dur_type, u8 pkt_type, u16 rate)
 {
struct vnt_private *priv = context->priv;
-   u32 dur_time = 0;
-   u32 frame_length = context->frame_len;
-   u8 need_ack = context->need_ack;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
switch (dur_type) {
@@ -298,15 +274,13 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
return ieee80211_rts_duration(priv->hw, priv->vif,
  context->frame_len, info);
case CTSDUR_BA:
-   dur_time = priv->sifs + vnt_get_rsvtime(priv,
-   pkt_type, frame_length, rate, need_ack);
-   break;
-
+   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
+   context->frame_len, info);
default:
break;
}
 
-   return cpu_to_le16((u16)dur_time);
+   return cpu_to_le16(0);
 }
 
 static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/6] staging: vt6656: Split RTS and CTS Duration functions

2020-05-05 Thread Malcolm Priestley
split vnt_get_rtscts_duration_le into vnt_get_rts_duration and
vnt_get_cts_duration.

The duration's are all the same in vnt_rxtx_rts_g_head.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 56 ++-
 1 file changed, 16 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 27069ac60b15..47da9dabb133 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -13,7 +13,6 @@
  *
  * Functions:
  *  vnt_generate_tx_parameter - Generate tx dma required parameter.
- *  vnt_get_rtscts_duration_le- get rtx/cts required duration
  *  vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
  *  vnt_get_rsvtime- get frame reserved time
  *  vnt_fill_cts_head- fulfill CTS ctl header
@@ -38,10 +37,6 @@ static const u16 vnt_time_stampoff[2][MAX_RATE] = {
{384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
 };
 
-#define RTSDUR_BB   0
-#define RTSDUR_BA   1
-#define RTSDUR_AA   2
-#define CTSDUR_BA   3
 #define DATADUR_B   10
 #define DATADUR_A   11
 
@@ -260,27 +255,22 @@ static __le16 vnt_get_rtscts_rsvtime_le(struct 
vnt_private *priv, u8 rsv_type,
return cpu_to_le16((u16)rrv_time);
 }
 
-static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
-u8 dur_type, u8 pkt_type, u16 rate)
+static __le16 vnt_get_rts_duration(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
 
-   switch (dur_type) {
-   /* fall through */
-   case RTSDUR_BB:
-   case RTSDUR_BA:
-   case RTSDUR_AA:
-   return ieee80211_rts_duration(priv->hw, priv->vif,
- context->frame_len, info);
-   case CTSDUR_BA:
-   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
-   context->frame_len, info);
-   default:
-   break;
-   }
+   return ieee80211_rts_duration(priv->hw, priv->vif,
+ context->frame_len, info);
+}
 
-   return cpu_to_le16(0);
+static __le16 vnt_get_cts_duration(struct vnt_usb_send_context *context)
+{
+   struct vnt_private *priv = context->priv;
+   struct ieee80211_tx_info *info = IEEE80211_SKB_CB(context->skb);
+
+   return ieee80211_ctstoself_duration(priv->hw, priv->vif,
+   context->frame_len, info);
 }
 
 static u16 vnt_mac_hdr_pos(struct vnt_usb_send_context *tx_context,
@@ -359,22 +349,15 @@ static void vnt_rxtx_rts_g_head(struct 
vnt_usb_send_context *tx_context,
 {
struct vnt_private *priv = tx_context->priv;
u16 rts_frame_len = 20;
-   u16 current_rate = tx_context->tx_rate;
 
vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
  PK_TYPE_11B, &buf->b);
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
  tx_context->pkt_type, &buf->a);
 
-   buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
- PK_TYPE_11B,
- priv->top_cck_basic_rate);
-   buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
- tx_context->pkt_type,
- current_rate);
-   buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
- tx_context->pkt_type,
- current_rate);
+   buf->duration_bb = vnt_get_rts_duration(tx_context);
+   buf->duration_aa = buf->duration_bb;
+   buf->duration_ba = buf->duration_bb;
 
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration_aa);
 
@@ -385,15 +368,12 @@ static void vnt_rxtx_rts_ab_head(struct 
vnt_usb_send_context *tx_context,
 struct vnt_rts_ab *buf)
 {
struct vnt_private *priv = tx_context->priv;
-   u16 current_rate = tx_context->tx_rate;
u16 rts_frame_len = 20;
 
vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
  tx_context->pkt_type, &buf->ab);
 
-   buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
-  tx_context->pkt_type,
-  current_rate);
+   buf->duration = vnt_get_rts_duration(tx_context);
 
vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration);
 
@@ -406,16 +386,12 @@ static void vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
struct vnt_private *priv 

[PATCH 5/6] staging: vt6656: vnt_get_rtscts_rsvtime_le replace with rts/cts duration.

2020-05-05 Thread Malcolm Priestley
rsvtime is the time needed in firmware to process the received
frame time in firmware so they can be the same as vnt_get_rts_duration
or vnt_get_cts_duration where appropriate.

The rts_rrv_time are now all the same timing in vnt_rxtx_rts.

So vnt_get_rtscts_rsvtime_le and and vnt_get_frame_time are no longer
required.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/rxtx.c | 113 ++
 1 file changed, 5 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 47da9dabb133..8348ffe6ebfa 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -13,7 +13,6 @@
  *
  * Functions:
  *  vnt_generate_tx_parameter - Generate tx dma required parameter.
- *  vnt_get_rtscts_rsvtime_le- get rts/cts reserved time
  *  vnt_get_rsvtime- get frame reserved time
  *  vnt_fill_cts_head- fulfill CTS ctl header
  *
@@ -92,37 +91,6 @@ static struct vnt_usb_send_context
return NULL;
 }
 
-/* Frame time for Tx */
-static unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
-  unsigned int frame_length, u16 tx_rate)
-{
-   unsigned int frame_time;
-   unsigned int preamble;
-   unsigned int rate;
-
-   if (tx_rate > RATE_54M)
-   return 0;
-
-   rate = (unsigned int)vnt_frame_time[tx_rate];
-
-   if (tx_rate <= RATE_11M) {
-   if (preamble_type == PREAMBLE_SHORT)
-   preamble = 96;
-   else
-   preamble = 192;
-
-   frame_time = DIV_ROUND_UP(frame_length * 80, rate);
-   return preamble + frame_time;
-   }
-
-   frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
-   frame_time = frame_time * 4;
-
-   if (pkt_type != PK_TYPE_11A)
-   frame_time += 6;
-   return 20 + frame_time;
-}
-
 /* Get Length, Service, and Signal fields of Phy for Tx */
 static void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
  u16 tx_rate, u8 pkt_type,
@@ -202,59 +170,6 @@ static __le16 vnt_rxtx_rsvtime_le16(struct 
vnt_usb_send_context *context)
 rate);
 }
 
-static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv, u8 rsv_type,
-   u8 pkt_type, u32 frame_length,
-   u16 current_rate)
-{
-   u32 rrv_time, rts_time, cts_time, ack_time, data_time;
-
-   rrv_time = 0;
-   rts_time = 0;
-   cts_time = 0;
-   ack_time = 0;
-
-   data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
-  frame_length, current_rate);
-
-   if (rsv_type == 0) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- priv->top_cck_basic_rate);
-   cts_time = ack_time;
-
-   } else if (rsv_type == 1) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_cck_basic_rate);
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-   } else if (rsv_type == 2) {
-   rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_ofdm_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14,
- priv->top_ofdm_basic_rate);
-   cts_time = ack_time;
-
-   } else if (rsv_type == 3) {
-   cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
-   ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
-
-   rrv_time = cts_time + ack_time + data_time + 2 * priv->sifs;
-
-   return cpu_to_le16((u16)rrv_time);
-   }
-
-   rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->sifs;
-
-   return cpu_to_le16((u16)rrv_time);
-}
-
 static __le16 vnt_get_rts_duration(struct vnt_usb_send_context *context)
 {
struct vnt_private *priv = context->priv;
@@ -405,18 +320,12 @@ static void vnt_fill_cts_head(struct vnt_usb_send_context 
*tx_context,
 static voi

[PATCH 6/6] staging: vt6656: remove difs / sifs adjustments.

2020-05-05 Thread Malcolm Priestley
Now mac89211 is doing frame timing in rxtx these vendor adjustments need
to be removed.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 32 
 1 file changed, 32 deletions(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 3cb97c4daeb8..10f3dfda83b5 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -149,38 +149,6 @@ int vnt_update_ifs(struct vnt_private *priv)
 
priv->eifs = C_EIFS;
 
-   switch (priv->rf_type) {
-   case RF_VT3226D0:
-   if (priv->bb_type != BB_TYPE_11B) {
-   priv->sifs -= 1;
-   priv->difs -= 1;
-   break;
-   }
-   /* fall through */
-   case RF_AIROHA7230:
-   case RF_AL2230:
-   case RF_AL2230S:
-   if (priv->bb_type != BB_TYPE_11B)
-   break;
-   /* fall through */
-   case RF_RFMD2959:
-   case RF_VT3226:
-   case RF_VT3342A0:
-   priv->sifs -= 3;
-   priv->difs -= 3;
-   break;
-   case RF_MAXIM2829:
-   if (priv->bb_type == BB_TYPE_11A) {
-   priv->sifs -= 5;
-   priv->difs -= 5;
-   } else {
-   priv->sifs -= 2;
-   priv->difs -= 2;
-   }
-
-   break;
-   }
-
data[0] = (u8)priv->sifs;
data[1] = (u8)priv->difs;
data[2] = (u8)priv->eifs;
-- 
2.25.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:staging-linus] BUILD SUCCESS 769acc3656d93aaacada814939743361d284fd87

2020-05-05 Thread kbuild test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
 staging-linus
branch HEAD: 769acc3656d93aaacada814939743361d284fd87  staging: gasket: Check 
the return value of gasket_get_bar_index()

elapsed time: 482m

configs tested: 229
configs skipped: 0

The following configs have been built successfully.
More configs may be tested in the coming days.

arm64allyesconfig
arm  allyesconfig
arm64allmodconfig
arm  allmodconfig
arm64 allnoconfig
arm   allnoconfig
arm   efm32_defconfig
arm at91_dt_defconfig
armshmobile_defconfig
arm64   defconfig
arm  exynos_defconfig
armmulti_v5_defconfig
arm   sunxi_defconfig
armmulti_v7_defconfig
sparcallyesconfig
mips allmodconfig
s390 allyesconfig
h8300   h8s-sim_defconfig
um   x86_64_defconfig
m68k   sun3_defconfig
mips  loongson3_defconfig
i386  allnoconfig
i386 allyesconfig
i386 alldefconfig
i386defconfig
i386  debian-10.3
ia64 allmodconfig
ia64defconfig
ia64  allnoconfig
ia64generic_defconfig
ia64  tiger_defconfig
ia64 bigsur_defconfig
ia64 allyesconfig
ia64 alldefconfig
m68k   m5475evb_defconfig
m68k allmodconfig
m68k   bvme6000_defconfig
m68k  multi_defconfig
nios2 3c120_defconfig
nios2 10m50_defconfig
c6xevmc6678_defconfig
c6x  allyesconfig
openrisc simple_smp_defconfig
openriscor1ksim_defconfig
nds32   defconfig
nds32 allnoconfig
cskydefconfig
alpha   defconfig
h8300 edosk2674_defconfig
xtensa  iss_defconfig
h8300h8300h-sim_defconfig
xtensa   common_defconfig
arc defconfig
arc  allyesconfig
microblaze  mmu_defconfig
microblazenommu_defconfig
mips  fuloong2e_defconfig
mips  malta_kvm_defconfig
mipsar7_defconfig
mips allyesconfig
mips 64r6el_defconfig
mips  allnoconfig
mips   32r2_defconfig
mipsmalta_kvm_guest_defconfig
mips tb0287_defconfig
mips   capcella_defconfig
mips   ip32_defconfig
mips  decstation_64_defconfig
mips  ath79_defconfig
mipsbcm63xx_defconfig
pariscallnoconfig
pariscgeneric-64bit_defconfig
pariscgeneric-32bit_defconfig
parisc   allyesconfig
parisc   allmodconfig
powerpc  chrp32_defconfig
powerpc defconfig
powerpc   holly_defconfig
powerpc   ppc64_defconfig
powerpc  rhel-kconfig
powerpc   allnoconfig
powerpc  mpc866_ads_defconfig
powerpcamigaone_defconfig
powerpcadder875_defconfig
powerpc ep8248e_defconfig
powerpc  g5_defconfig
powerpc mpc512x_defconfig
m68k randconfig-a001-20200505
mips randconfig-a001-20200505
nds32randconfig-a001-20200505
parisc   randconfig-a001-20200505
alpharandconfig-a001-20200505
riscvrandconfig-a001-20200505
m68k randconfig-a001-20200503
mips randconfig-a001-20200503
nds32randconfig-a001-20200503
alpharandconfig-a001-20200503
parisc   randconfig-a001-20200503
riscvrandconfig-a001-20200503
h8300randconfig-a001-20200503
nios2

We bieden financiering tegen een laag tarief.

2020-05-05 Thread Genovese Capital partners
Welkom bij Genovese Capital Partners.

We hebben een enorme kredietportefeuille voor het financieren van projecten en 
bedrijven met een groot volume. De procedures zijn als volgt: -

1-De klant moet een korte samenvatting van het project sturen. Dit moet het 
totale bedrag bevatten dat nodig is voor het project, geschat rendement op 
investering, terugbetalingsperiode voor leningen, dit mag niet meer zijn dan 15 
jaar.

2- De klant moet het genoemde project verzekeren bij een 
verzekeringsmaatschappij van het totale leenbedrag om de lening als onderpand 
te garanderen (afhankelijk van het leningsbedrag).

3- Het rentepercentage zal jaarlijks 2% bedragen.

4-Terugbetalingsduur is maximaal 15 jaar

5 Financiering duurt ongeveer 10 bankwerkdagen vanaf de dag dat u het 
verzekeringscertificaat overlegt of de Neceessary Paper Works heeft voltooid.

 
Als u tevreden bent met de bovenstaande procedures, stuur mij dan een 
intentieverklaring die op het briefhoofd van uw bedrijf staat.

Voor meer informatie over het verkrijgen van een lening van: Reageer 
alstublieft onmiddellijk op deze e-mail:


Met vriendelijke groet, in afwachting van uw reactie.

Vriendelijke groeten
Caio Pinto

Genovese Capital Partners.
Tel. 07537 121915
WhatsApp: +44 7537166769
Kings Ride, Ascot, SL5 7JR



Welcome to Genovese Capital Partners.

We have a huge Portfolio of Credit, for financing projects and Business of 
large volume. The procedures are as follows:- 

1-The client needs to send a brief summary of the project. This must include 
the total amount required for the project, estimated return on investment, loan 
repayment period this must not be more than 15years. 

2- The client will need to insure the said project with an insurance company of 
the total loan sum to guarantee the loan as collateral.(Dependent on Loan 
Amount).

3- The interest rate will be 2% annually. 

4-Repayment duration will be a Maximum of  15 Years 

5 Funding will take approximately 10 banking days from the day you present the 
insurance certificate or have completed the Neceessary Paper works. 

 
If you are satisfied with the above procedures send me a letter of intent 
writing on your company letterhead. 

For further details to go about procuring a loan from: Kindly respond 
immediately to this email: 


Regards, as we await your response. 

Best Regards 
Caio Pinto

Genovese Capital Partners.
Tel. 07537 121 915
WhatsApp : +44 7537 166 769
Kings Ride, Ascot, SL5 7JR
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:staging-testing] BUILD SUCCESS 2e11cc1ab790ccbc7c7f6ed74c0f40b85c561dc7

2020-05-05 Thread kbuild test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
 staging-testing
branch HEAD: 2e11cc1ab790ccbc7c7f6ed74c0f40b85c561dc7  staging: vt6656: Use 
const for read only data

elapsed time: 692m

configs tested: 198
configs skipped: 0

The following configs have been built successfully.
More configs may be tested in the coming days.

arm   efm32_defconfig
arm at91_dt_defconfig
armshmobile_defconfig
arm64   defconfig
arm  exynos_defconfig
armmulti_v5_defconfig
arm   sunxi_defconfig
armmulti_v7_defconfig
arm64allyesconfig
arm  allyesconfig
arm64allmodconfig
arm  allmodconfig
arm64 allnoconfig
arm   allnoconfig
sparcallyesconfig
mips allmodconfig
h8300   h8s-sim_defconfig
um   x86_64_defconfig
m68k   sun3_defconfig
microblazenommu_defconfig
powerpcadder875_defconfig
shtitan_defconfig
i386defconfig
mips  loongson3_defconfig
i386  allnoconfig
i386 allyesconfig
i386 alldefconfig
i386  debian-10.3
ia64 allmodconfig
ia64defconfig
ia64  allnoconfig
ia64generic_defconfig
ia64  tiger_defconfig
ia64 bigsur_defconfig
ia64 allyesconfig
ia64 alldefconfig
m68k   m5475evb_defconfig
m68k allmodconfig
m68k   bvme6000_defconfig
m68k  multi_defconfig
nios2 3c120_defconfig
nios2 10m50_defconfig
c6xevmc6678_defconfig
c6x  allyesconfig
openrisc simple_smp_defconfig
openriscor1ksim_defconfig
nds32   defconfig
nds32 allnoconfig
cskydefconfig
alpha   defconfig
h8300 edosk2674_defconfig
xtensa  iss_defconfig
h8300h8300h-sim_defconfig
xtensa   common_defconfig
arc defconfig
arc  allyesconfig
microblaze  mmu_defconfig
mipsmalta_kvm_guest_defconfig
mips tb0287_defconfig
mips   capcella_defconfig
mips   ip32_defconfig
mips  decstation_64_defconfig
mips  ath79_defconfig
mipsbcm63xx_defconfig
mips  fuloong2e_defconfig
mips  malta_kvm_defconfig
mipsar7_defconfig
mips allyesconfig
mips 64r6el_defconfig
mips  allnoconfig
mips   32r2_defconfig
pariscallnoconfig
pariscgeneric-64bit_defconfig
pariscgeneric-32bit_defconfig
parisc   allyesconfig
parisc   allmodconfig
powerpc  chrp32_defconfig
powerpc defconfig
powerpc   holly_defconfig
powerpc   ppc64_defconfig
powerpc  rhel-kconfig
powerpc   allnoconfig
powerpc  mpc866_ads_defconfig
powerpcamigaone_defconfig
powerpc ep8248e_defconfig
powerpc  g5_defconfig
powerpc mpc512x_defconfig
m68k randconfig-a001-20200505
mips randconfig-a001-20200505
nds32randconfig-a001-20200505
parisc   randconfig-a001-20200505
alpharandconfig-a001-20200505
riscvrandconfig-a001-20200505
m68k randconfig-a001-20200503
mips randconfig-a001-20200503
nds32randconfig-a001-20200503
alpharandconfig-a001-20200503
parisc   randconfig-a001-20200503
riscvrandconfig-a001-20200503
h8300randconfig-a001-20200503
nios2randconfig-a001

[driver-core:driver-core-testing] BUILD SUCCESS c78c31b374a68be79cb4a03ef5b6c187f034e903

2020-05-05 Thread kbuild test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git  
driver-core-testing
branch HEAD: c78c31b374a68be79cb4a03ef5b6c187f034e903  Revert "Revert "driver 
core: Set fw_devlink to "permissive" behavior by default""

elapsed time: 671m

configs tested: 203
configs skipped: 0

The following configs have been built successfully.
More configs may be tested in the coming days.

arm   efm32_defconfig
arm at91_dt_defconfig
armshmobile_defconfig
arm64   defconfig
arm  exynos_defconfig
armmulti_v5_defconfig
arm   sunxi_defconfig
armmulti_v7_defconfig
arm64allyesconfig
arm  allyesconfig
arm64allmodconfig
arm  allmodconfig
arm64 allnoconfig
arm   allnoconfig
sparcallyesconfig
pariscallnoconfig
powerpc defconfig
powerpc   defconfig-4
powerpc   defconfig-5
powerpc   defconfig-3
microblazenommu_defconfig
i386defconfig
i386  allnoconfig
i386 allyesconfig
i386 alldefconfig
i386  debian-10.3
ia64 allmodconfig
ia64defconfig
ia64  allnoconfig
ia64generic_defconfig
ia64  tiger_defconfig
ia64 bigsur_defconfig
ia64 allyesconfig
ia64 alldefconfig
m68k   m5475evb_defconfig
m68k allmodconfig
m68k   bvme6000_defconfig
m68k   sun3_defconfig
m68k  multi_defconfig
nios2 3c120_defconfig
nios2 10m50_defconfig
c6xevmc6678_defconfig
c6x  allyesconfig
openrisc simple_smp_defconfig
openriscor1ksim_defconfig
nds32   defconfig
nds32 allnoconfig
cskydefconfig
alpha   defconfig
h8300   h8s-sim_defconfig
h8300 edosk2674_defconfig
xtensa  iss_defconfig
h8300h8300h-sim_defconfig
xtensa   common_defconfig
arc defconfig
arc  allyesconfig
microblaze  mmu_defconfig
mips  fuloong2e_defconfig
mips  malta_kvm_defconfig
mipsar7_defconfig
mips allyesconfig
mips 64r6el_defconfig
mips  allnoconfig
mips   32r2_defconfig
mipsmalta_kvm_guest_defconfig
mips tb0287_defconfig
mips   capcella_defconfig
mips   ip32_defconfig
mips  decstation_64_defconfig
mips  loongson3_defconfig
mips  ath79_defconfig
mipsbcm63xx_defconfig
mips allmodconfig
pariscgeneric-64bit_defconfig
pariscgeneric-32bit_defconfig
parisc   allyesconfig
parisc   allmodconfig
powerpc  chrp32_defconfig
powerpc   holly_defconfig
powerpc   ppc64_defconfig
powerpc  rhel-kconfig
powerpc   allnoconfig
powerpc  mpc866_ads_defconfig
powerpcamigaone_defconfig
powerpcadder875_defconfig
powerpc ep8248e_defconfig
powerpc  g5_defconfig
powerpc mpc512x_defconfig
m68k     randconfig-a001-20200505
mips     randconfig-a001-20200505
m68k randconfig-a001-20200503
mips randconfig-a001-20200503
nds32randconfig-a001-20200503
alpharandconfig-a001-20200503
parisc   randconfig-a001-20200503
riscvrandconfig-a001-20200503
nds32    randconfig-a001-20200505
parisc   randconfig-a001-20200505
alpha    randconfig-a001-20200505
riscv