Re: [PATCH 05/22] drm/i915: Make use of the new sg_map helper function

2017-04-17 Thread Daniel Vetter
On Thu, Apr 13, 2017 at 04:05:18PM -0600, Logan Gunthorpe wrote:
> This is a single straightforward conversion from kmap to sg_map.
> 
> Signed-off-by: Logan Gunthorpe 

Acked-by: Daniel Vetter 

Probably makes sense to merge through some other tree, but please be aware
of the considerable churn rate in i915 (i.e. make sure your tree is in
linux-next before you send a pull request for this). Plane B would be to
get the prep patch in first and then merge the i915 conversion one kernel
release later.
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_gem.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 67b1fc5..1b1b91a 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2188,6 +2188,15 @@ static void __i915_gem_object_reset_page_iter(struct 
> drm_i915_gem_object *obj)
>   radix_tree_delete(&obj->mm.get_page.radix, iter.index);
>  }
>  
> +static void i915_gem_object_unmap(const struct drm_i915_gem_object *obj,
> +   void *ptr)
> +{
> + if (is_vmalloc_addr(ptr))
> + vunmap(ptr);
> + else
> + sg_unmap(obj->mm.pages->sgl, ptr, SG_KMAP);
> +}
> +
>  void __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
>enum i915_mm_subclass subclass)
>  {
> @@ -2215,10 +2224,7 @@ void __i915_gem_object_put_pages(struct 
> drm_i915_gem_object *obj,
>   void *ptr;
>  
>   ptr = ptr_mask_bits(obj->mm.mapping);
> - if (is_vmalloc_addr(ptr))
> - vunmap(ptr);
> - else
> - kunmap(kmap_to_page(ptr));
> + i915_gem_object_unmap(obj, ptr);
>  
>   obj->mm.mapping = NULL;
>   }
> @@ -2475,8 +2481,11 @@ static void *i915_gem_object_map(const struct 
> drm_i915_gem_object *obj,
>   void *addr;
>  
>   /* A single page can always be kmapped */
> - if (n_pages == 1 && type == I915_MAP_WB)
> - return kmap(sg_page(sgt->sgl));
> + if (n_pages == 1 && type == I915_MAP_WB) {
> + addr = sg_map(sgt->sgl, SG_KMAP);
> + if (IS_ERR(addr))
> + return NULL;
> + }
>  
>   if (n_pages > ARRAY_SIZE(stack_pages)) {
>   /* Too big for stack -- allocate temporary array instead */
> @@ -2543,11 +2552,7 @@ void *i915_gem_object_pin_map(struct 
> drm_i915_gem_object *obj,
>   goto err_unpin;
>   }
>  
> - if (is_vmalloc_addr(ptr))
> - vunmap(ptr);
> - else
> - kunmap(kmap_to_page(ptr));
> -
> + i915_gem_object_unmap(obj, ptr);
>   ptr = obj->mm.mapping = NULL;
>   }
>  
> -- 
> 2.1.4
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/1] drivers/staging/vt6656/main_usb.c: checkpatch warning

2017-04-17 Thread Chewie Lin
On Tue, Apr 18, 2017 at 06:14:11AM +0200, Greg KH wrote:
> On Mon, Apr 17, 2017 at 04:58:48PM -0700, Chewie Lin wrote:
> > Swap string in the dev_warn() call with __func__ argument, instead of
> > explicitly calling the function name in the string:
> > 
> > WARNING: Prefer using "%s", __func__ to embedded function names
> > #417: FILE: main_usb.c:417:
> > +"usb_device_reset fail status=%d\n", 
> > status);
> > 
> > total: 0 errors, 1 warnings, 1058 lines checked
> > 
> > And after fix:
> > 
> > main_usb.c has no obvious style problems and is ready for 
> > submission.
> > 
> > Signed-off-by: Chewie Lin 
> > ---
> >  drivers/staging/vt6656/main_usb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/vt6656/main_usb.c 
> > b/drivers/staging/vt6656/main_usb.c
> > index 9e074e9daf4e..71c4511b4cff 100644
> > --- a/drivers/staging/vt6656/main_usb.c
> > +++ b/drivers/staging/vt6656/main_usb.c
> > @@ -414,7 +414,7 @@ static void usb_device_reset(struct vnt_private *priv)
> > status = usb_reset_device(priv->usb);
> > if (status)
> > dev_warn(&priv->usb->dev,
> > -"usb_device_reset fail status=%d\n", status);
> > +"%s fail status=%d\n", __func__, status);
> 
> But the call that failed was called usb_device_reset(), right?  Why is
> this function even needed at all, have the caller call the correct
> function instead please, and then this whole function can be deleted.
> 

thanks greg. 
Yes, I think that's a good approach as well. I initially wanted to fix a 
coding style problem without touching the function calls, but I can 
definitely do that as well. 

linsh

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


Re: [PATCH 1/1] drivers/staging/vt6656/main_usb.c: checkpatch warning

2017-04-17 Thread Greg KH
On Mon, Apr 17, 2017 at 04:58:48PM -0700, Chewie Lin wrote:
> Swap string in the dev_warn() call with __func__ argument, instead of
> explicitly calling the function name in the string:
> 
> WARNING: Prefer using "%s", __func__ to embedded function names
> #417: FILE: main_usb.c:417:
> +"usb_device_reset fail status=%d\n", status);
> 
> total: 0 errors, 1 warnings, 1058 lines checked
> 
> And after fix:
> 
> main_usb.c has no obvious style problems and is ready for submission.
> 
> Signed-off-by: Chewie Lin 
> ---
>  drivers/staging/vt6656/main_usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/vt6656/main_usb.c 
> b/drivers/staging/vt6656/main_usb.c
> index 9e074e9daf4e..71c4511b4cff 100644
> --- a/drivers/staging/vt6656/main_usb.c
> +++ b/drivers/staging/vt6656/main_usb.c
> @@ -414,7 +414,7 @@ static void usb_device_reset(struct vnt_private *priv)
>   status = usb_reset_device(priv->usb);
>   if (status)
>   dev_warn(&priv->usb->dev,
> -  "usb_device_reset fail status=%d\n", status);
> +  "%s fail status=%d\n", __func__, status);

But the call that failed was called usb_device_reset(), right?  Why is
this function even needed at all, have the caller call the correct
function instead please, and then this whole function can be deleted.

thanks,

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


答复: Using ion memory for direct-io

2017-04-17 Thread Zengtao (B)
Hi Laura:

>-邮件原件-
>发件人: Laura Abbott [mailto:labb...@redhat.com]
>发送时间: 2017年4月18日 0:14
>收件人: Zengtao (B) ; sumit.sem...@linaro.org
>抄送: gre...@linuxfoundation.org; a...@android.com;
>riandr...@android.com; de...@driverdev.osuosl.org;
>linux-ker...@vger.kernel.org
>主题: Re: Using ion memory for direct-io
>
>On 04/14/2017 02:18 AM, Zengtao (B) wrote:
>> Hi
>>
>> Currently, the ion mapped to userspace will be forced with VM_IO and
>VM_PFNMAP flags.
>> When I use the ion memory to do the direct-io, it will fail when
>> reaching the get_user_pages,
>>
>> Back to the VM_IO and VM_PFNMAP flag, there two flags are introduced
>> by the remap_pfn_range called by the ion_heap_mmap_user.
>>
>> From my point of view, all ion memory(cma/vmalloc/system heap) are
>> managed by linux vm, it is not reasonable to have the VM_IO and
>> VM_PFNMAP flag, but I don't any suitable function to replace the
>remap_pfn_range, any suggestions?
>>
>> Thanks && Regards
>>
>> Zengtao
>>
>
>The carveout heap is omitted from your list of 'all ion memory'. At one
>time, carveout memory was not backed by struct pages so I suspect
>this is a holdover from then. This would probably be better served
Yes, you are right, I missed the carveout heap which needs the VM_IO and 
VM_PFNMAP,
and I think the carveout heap can implement its own map_user rather then using 
the common
ion_heap_map_user.

>by using vm_insert_page and handling higher order pages properly.
Your latest patch has remove the the page faulting support, I didn't deep into 
the reason,
but I think this conflicts with the vm_insert_page.

>
>Thanks,
>Laura

I tried to use the similar way as the dma framework do(split the page and 
map_vm_area), but
the split will break the ion sg design, maybe we need a new lowlevel map 
function instead of directly 
using the remap_pfn_range.

Thanks
Zengtao 

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


[PATCH 14/15] staging: ks7010: fix checkpatch SPLIT_STRING

2017-04-17 Thread Tobin C. Harding
Checkpatch emits WARNING: quoted string split across lines.

Concatenate string onto single line.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 4e62241..ec11799 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -871,8 +871,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 
sdio_set_drvdata(func, card);
 
-   DPRINTK(5, "class = 0x%X, vendor = 0x%X, "
-   "device = 0x%X\n", func->class, func->vendor, func->device);
+   DPRINTK(5, "class = 0x%X, vendor = 0x%X, device = 0x%X\n",
+   func->class, func->vendor, func->device);
 
/* private memory allocate */
netdev = alloc_etherdev(sizeof(*priv));
-- 
2.7.4

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


[PATCH 12/15] staging: ks7010: fix checkpatch LINE_SPACING

2017-04-17 Thread Tobin C. Harding
Checkpatch emits CHECK: Please don't use multiple blank lines.

Remove multiple blank lines.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 5cd7833..aca7205 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1025,7 +1025,6 @@ static int send_stop_request(struct sdio_func *func)
return 0;
 }
 
-
 static void ks7010_sdio_remove(struct sdio_func *func)
 {
int ret;
-- 
2.7.4

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


[PATCH 09/15] staging: ks7010: clean up SDIO source comments

2017-04-17 Thread Tobin C. Harding
SDIO code currently has a number of unneeded comments. Following
kernel coding style we do not need extraneous comments, especially on
code where it is clear what is being done. Spelling typos can be
fixed.

Remove unnecessary comments, fix typos in comments.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 32 +---
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index e3e2989..87d5519 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -32,8 +32,6 @@ static const struct sdio_device_id ks7010_sdio_ids[] = {
 };
 MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
 
-/* macro */
-
 #define inc_txqhead(priv) \
(priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE)
 #define inc_txqtail(priv) \
@@ -247,7 +245,6 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
}
 
if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
-   /* in case of buffer overflow */
DPRINTK(1, "tx buffer overflow\n");
ret = -EOVERFLOW;
goto err_complete;
@@ -389,7 +386,6 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
 
/* receive data */
if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
-   /* in case of buffer overflow */
DPRINTK(1, "rx buffer overflow\n");
return;
}
@@ -453,14 +449,14 @@ static void ks7010_rw_function(struct work_struct *work)
 
DPRINTK(4, "\n");
 
-   /* wiat after DOZE */
+   /* wait after DOZE */
if (time_after(priv->last_doze + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after DOZE\n");
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return;
}
 
-   /* wiat after WAKEUP */
+   /* wait after WAKEUP */
while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after WAKEUP\n");
dev_info(&priv->ks_sdio_card->func->dev,
@@ -588,15 +584,12 @@ static void ks_sdio_interrupt(struct sdio_func *func)
 
 static int trx_device_init(struct ks_wlan_private *priv)
 {
-   /* initialize values (tx) */
priv->tx_dev.qhead = 0;
priv->tx_dev.qtail = 0;
 
-   /* initialize values (rx) */
priv->rx_dev.qhead = 0;
priv->rx_dev.qtail = 0;
 
-   /* initialize spinLock (tx,rx) */
spin_lock_init(&priv->tx_dev.tx_dev_lock);
spin_lock_init(&priv->rx_dev.rx_dev_lock);
 
@@ -612,7 +605,7 @@ static void trx_device_exit(struct ks_wlan_private *priv)
/* tx buffer clear */
while (cnt_txqbody(priv) > 0) {
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
-   kfree(sp->sendp);   /* allocated memory free */
+   kfree(sp->sendp);
if (sp->complete_handler)   /* TX Complete */
(*sp->complete_handler)(priv, sp->skb);
inc_txqhead(priv);
@@ -686,7 +679,6 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
unsigned int length;
const struct firmware *fw_entry = NULL;
 
-   /* buffer allocate */
rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if (!rom_buf)
return -ENOMEM;
@@ -707,7 +699,6 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 
length = fw_entry->size;
 
-   /* Load Program */
n = 0;
do {
if (length >= ROM_BUFF_SIZE) {
@@ -721,18 +712,16 @@ static int ks7010_upload_firmware(struct ks_sdio_card 
*card)
if (size == 0)
break;
memcpy(rom_buf, fw_entry->data + n, size);
-   /* Update write index */
+
offset = n;
ret = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS + 
offset);
if (ret)
goto release_firmware;
 
-   /* Write data */
ret = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
if (ret)
goto release_firmware;
 
-   /* compare */
ret = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, 
size);
if (ret)
goto release_firmware;
@@ -741,7 +730,6 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 
} while (size);
 
-   /* Remap request */
rw_data = GCR_A_REMAP;
ret = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data));
if (ret)
@@ -781,7 +769,6 @@ static void ks7010_card_init(struct ks_wlan_private *priv)
 {
DPRINTK(5, "\ncard_init_task()\n");
 
-   /* init_waitqueue_head(&priv->confirm_wait); */
init_completion(&priv->confirm_wait);
 

[PATCH 08/15] staging: ks7010: add struct comment to ks_sdio_card

2017-04-17 Thread Tobin C. Harding
ks_sdio_card structure description does not have a kernel doc format
comment.

Add kernel doc format comment to struct ks_sdio_card.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 22c7ba7..e4f56a1 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -85,6 +85,14 @@ enum gen_com_reg_b {
 
 #define KS7010_IRAM_ADDRESS0x0600
 
+/**
+ * struct ks_sdio_card - SDIO device data.
+ *
+ * Structure is used as the &struct sdio_func private data.
+ *
+ * @func: Pointer to the SDIO function device.
+ * @priv: Pointer to the &struct net_device private data.
+ */
 struct ks_sdio_card {
struct sdio_func *func;
struct ks_wlan_private *priv;
-- 
2.7.4

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


[PATCH 15/15] staging: ks7010: rename SDIO files

2017-04-17 Thread Tobin C. Harding
Driver SDIO code is currently in files name ks7010_sdio.[ch]. These
names are not uniform with the rest of the files in this driver. This
driver only covers a single chipset, the file prefix does not add any
extra information. Other in-tree SDIO drivers typically call these
files sdio.[ch]. This is achieved using the following commands.

$ git mv ks7010_sdio.c sdio.c
$ git mv ks7010_sdio.h sdio.h

Rename 'ks7010_sdio.c' to 'sdio.c'
Rename 'ks7010_sdio.h' to 'sdio.h'

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/Makefile  |2 +-
 drivers/staging/ks7010/ks7010_sdio.c | 1079 --
 drivers/staging/ks7010/ks7010_sdio.h |  164 --
 drivers/staging/ks7010/ks_wlan.h |2 +-
 drivers/staging/ks7010/sdio.c| 1079 ++
 drivers/staging/ks7010/sdio.h|  164 ++
 6 files changed, 1245 insertions(+), 1245 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.c
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h
 create mode 100644 drivers/staging/ks7010/sdio.c
 create mode 100644 drivers/staging/ks7010/sdio.h

diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile
index 69fcf8d..d14f292 100644
--- a/drivers/staging/ks7010/Makefile
+++ b/drivers/staging/ks7010/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_KS7010) += ks7010.o
 
 ccflags-y   += -DKS_WLAN_DEBUG=0
-ks7010-y:= michael_mic.o ks_hostif.o ks_wlan_net.o ks7010_sdio.o
+ks7010-y:= michael_mic.o ks_hostif.o ks_wlan_net.o sdio.o
diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
deleted file mode 100644
index ec11799..000
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ /dev/null
@@ -1,1079 +0,0 @@
-/*
- *   Driver for KeyStream, KS7010 based SDIO cards.
- *
- *   Copyright (C) 2006-2008 KeyStream Corp.
- *   Copyright (C) 2009 Renesas Technology Corp.
- *   Copyright (C) 2016 Sang Engineering, Wolfram Sang
- *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2 as
- *   published by the Free Software Foundation.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "ks_wlan.h"
-#include "ks_wlan_ioctl.h"
-#include "ks_hostif.h"
-#include "ks7010_sdio.h"
-
-#define KS7010_FUNC_NUM 1
-#define KS7010_IO_BLOCK_SIZE 512
-#define KS7010_MAX_CLOCK 2500
-
-static const struct sdio_device_id ks7010_sdio_ids[] = {
-   {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)},
-   {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)},
-   { /* all zero */ }
-};
-MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
-
-#define inc_txqhead(priv) \
-   (priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE)
-#define inc_txqtail(priv) \
-   (priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE)
-#define cnt_txqbody(priv) \
-   (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - (priv->tx_dev.qhead)) % 
TX_DEVICE_BUFF_SIZE)
-
-#define inc_rxqhead(priv) \
-   (priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE)
-#define inc_rxqtail(priv) \
-   (priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE)
-#define cnt_rxqbody(priv) \
-   (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % 
RX_DEVICE_BUFF_SIZE)
-
-/* Read single byte from device address into byte (CMD52) */
-static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int 
address,
-unsigned char *byte)
-{
-   struct sdio_func *func = priv->ks_sdio_card->func;
-   int ret;
-
-   *byte = sdio_readb(func, address, &ret);
-
-   return ret;
-}
-
-/* Read length bytes from device address into buffer (CMD53) */
-static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
-   unsigned char *buffer, int length)
-{
-   struct sdio_func *func = priv->ks_sdio_card->func;
-
-   return sdio_memcpy_fromio(func, buffer, address, length);
-}
-
-/* Write single byte to device address (CMD52) */
-static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
- unsigned int address, unsigned char byte)
-{
-   struct sdio_func *func = priv->ks_sdio_card->func;
-   int ret;
-
-   sdio_writeb(func, byte, address, &ret);
-
-   return ret;
-}
-
-/* Write length bytes to device address from buffer (CMD53) */
-static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int 
address,
-unsigned char *buffer, int length)
-{
-   struct sdio_func *func = priv->ks_sdio_card->func;
-
-   return sdio_memcpy_toio(func, address, buffer, length);
-}
-
-static void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
-{
-   int ret;
-
-   DPRINTK(4, "\n");
-
-   /* clear request */
-   atomic_set(&priv->sleepstat

[PATCH 07/15] staging: ks7010: move hw info into dev private data

2017-04-17 Thread Tobin C. Harding
Currently driver uses a hardware information struct description to
group some SDIO related functionality (work, work queue, sdio private
data pointer). This structure is then embedded in the device private
data structure. Having nested structures described in different header
files means that to view the device private data programmers must open
two header files. This structure could be embedded anonymously in the
device private data and achieve the same result (grouping of function
specific to SDIO) without the need to open multiple headers. However,
the SDIO private data structure already has various different data and
pointers, adding the embedded structure adds little extra meaning and
lengthens all the dereferences throughout the driver, often meaning
addition line breaks and braces. We can increase readability and
reduce code complexity by moving the hardware information data and
pointers to directly be within the device private data structure
description.

While preparing for this refactoring it was noted that the identifier
currently used for the delayed work is 'rw_wq', this is confusing
since the 'wq' suffix typically means 'work queue'. This identifier
would be more meaningful if it used the suffix 'dwork' as does the
declaration of queue_delayed_work() (include/linux/workqueue.h).

The identifier for the work queue is currently 'ks7010sdio_wq'. This
identifier can be shortened without loss of meaning because there is
only one work queue within the driver. Identifier 'wq' is typical
within in-tree driver code and aptly describes the pointer.

Current pointer to the SDIO private data is identified by 'sdio_card',
this is sufficiently meaningful from within the hw_info structure but
once the hw_info_t structure is removed the pointer would be better to
have a prefix appended to it to retain the prior level of meaning.

Move members from struct hw_info_t to struct ks_wlan_private.

Rename identifiers;
struct delayed_work pointer 'rw_wq' to 'rw_dwork'.
struct workqueue_struct pointer 'ks7010sdio_wq' to 'wq'.
struct ks_sdio_card  pointer 'sdio_card' to 'ks_sdio_card'.

Remove structure description hw_info_t. Fix init/destroy calls. Fix
all call sites, SDIO private data access calls, and queuing calls.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 70 +++-
 drivers/staging/ks7010/ks7010_sdio.h |  6 
 drivers/staging/ks7010/ks_hostif.c   |  6 ++--
 drivers/staging/ks7010/ks_wlan.h |  5 ++-
 4 files changed, 34 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 2d73ebb..e3e2989 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -54,7 +54,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, 
unsigned int address,
struct ks_sdio_card *card;
int ret;
 
-   card = priv->ks_wlan_hw.sdio_card;
+   card = priv->ks_sdio_card;
 
if (length == 1)/* CMD52 */
*buffer = sdio_readb(card->func, address, &ret);
@@ -75,7 +75,7 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, 
unsigned int address,
struct ks_sdio_card *card;
int ret;
 
-   card = priv->ks_wlan_hw.sdio_card;
+   card = priv->ks_sdio_card;
 
if (length == 1)/* CMD52 */
sdio_writeb(card->func, *buffer, address, &ret);
@@ -198,8 +198,7 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private 
*priv)
if (atomic_read(&priv->psstatus.confirm_wait) ||
atomic_read(&priv->psstatus.snooze_guard) ||
cnt_txqbody(priv)) {
-   queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-  &priv->ks_wlan_hw.rw_wq, 0);
+   queue_delayed_work(priv->wq, &priv->rw_dwork, 0);
return;
}
 
@@ -224,14 +223,12 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private 
*priv)
return;
 
 queue_delayed_work:
-   queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-  &priv->ks_wlan_hw.rw_wq, 1);
+   queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
 }
 
 int ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 {
-   queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-  &priv->ks_wlan_hw.rw_wq, 1);
+   queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return 0;
 }
 
@@ -320,8 +317,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
ret = write_to_device(priv, sp->sendp, sp->size);
if (ret) {
DPRINTK(1, "write_to_device error !!(%d)\n", ret);
-   queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-  &priv->ks_wlan_hw.rw_wq, 1);
+   queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
return;
}

[PATCH 06/15] staging: ks7010: move tasklet_struct to ks_wlan_private

2017-04-17 Thread Tobin C. Harding
Currently a pointer to the tasklet_struct used for bottom half
processing on the receive path is within the hw_info_t structure. This
structure is then embedded in the device private data
structure. Having the tasklet_struct nested does not add meaning to
the device private data, device private data already (and typically)
has various data relating to the device, there is no real need to
separate the tasklet_struct to a SDIO specific structure. While not
adding allot of extra meaning having the nested structure means the
programmer must open two header files to read the description of the
device private data, the code would be easier to read if the device
private data struct description was not spread over two files.

Move tasklet_struct out of sdio header file and into the device
private data structure description.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 10 --
 drivers/staging/ks7010/ks7010_sdio.h |  1 -
 drivers/staging/ks7010/ks_wlan.h |  1 +
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 0f173c3..2d73ebb 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -380,7 +380,7 @@ static void rx_event_task(unsigned long dev)
inc_rxqhead(priv);
 
if (cnt_rxqbody(priv) > 0)
-   tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
+   tasklet_schedule(&priv->rx_bh_task);
}
 }
 
@@ -447,8 +447,7 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
}
}
 
-   /* rx_event_task((void *)priv); */
-   tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
+   tasklet_schedule(&priv->rx_bh_task);
 }
 
 static void ks7010_rw_function(struct work_struct *work)
@@ -614,8 +613,7 @@ static int trx_device_init(struct ks_wlan_private *priv)
spin_lock_init(&priv->tx_dev.tx_dev_lock);
spin_lock_init(&priv->rx_dev.rx_dev_lock);
 
-   tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task,
-(unsigned long)priv);
+   tasklet_init(&priv->rx_bh_task, rx_event_task, (unsigned long)priv);
 
return 0;
 }
@@ -633,7 +631,7 @@ static void trx_device_exit(struct ks_wlan_private *priv)
inc_txqhead(priv);
}
 
-   tasklet_kill(&priv->ks_wlan_hw.rx_bh_task);
+   tasklet_kill(&priv->rx_bh_task);
 }
 
 static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index d04fccc..76c6b102 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -89,7 +89,6 @@ struct hw_info_t {
struct ks_sdio_card *sdio_card;
struct workqueue_struct *ks7010sdio_wq;
struct delayed_work rw_wq;
-   struct tasklet_struct rx_bh_task;
 };
 
 struct ks_sdio_card {
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 7968470..b0bc7a8 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -414,6 +414,7 @@ struct wps_status_t {
 
 struct ks_wlan_private {
struct hw_info_t ks_wlan_hw;/* hardware information */
+   struct tasklet_struct rx_bh_task;
 
struct net_device *net_dev;
int reg_net;/* register_netdev */
-- 
2.7.4

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


[PATCH 10/15] staging: ks7010: remove err_ from non-error path label

2017-04-17 Thread Tobin C. Harding
goto label includes 'err_' suffix but is executed on non-error paths.

Remove err_ suffix from goto label.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 87d5519..13d5de9 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -474,18 +474,18 @@ static void ks7010_rw_function(struct work_struct *work)
ks_wlan_hw_wakeup_request(priv);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
}
-   goto err_release_host;
+   goto release_host;
}
 
/* sleep mode doze */
if (atomic_read(&priv->sleepstatus.doze_request) == 1) {
ks_wlan_hw_sleep_doze_request(priv);
-   goto err_release_host;
+   goto release_host;
}
/* sleep mode wakeup */
if (atomic_read(&priv->sleepstatus.wakeup_request) == 1) {
ks_wlan_hw_sleep_wakeup_request(priv);
-   goto err_release_host;
+   goto release_host;
}
 
/* read (WriteStatus/ReadDataSize FN1:00_0014) */
@@ -493,7 +493,7 @@ static void ks7010_rw_function(struct work_struct *work)
if (ret) {
DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,
atomic_read(&priv->psstatus.status));
-   goto err_release_host;
+   goto release_host;
}
DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
 
@@ -505,7 +505,7 @@ static void ks7010_rw_function(struct work_struct *work)
 
_ks_wlan_hw_power_save(priv);
 
-err_release_host:
+release_host:
sdio_release_host(priv->ks_sdio_card->func);
 }
 
-- 
2.7.4

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


[PATCH 03/15] staging: ks7010: fix complete_handler

2017-04-17 Thread Tobin C. Harding
complete_handler() takes void * types as parameters. void * parameters are then
cast to struct types. Call sites for this function either pass in NULL
or pointers to the struct types cast to void *. This casting is
unnecessary and can be removed.

Struct tx_device_buffer (which contains a pointer member to the
complete_handler() function) has as member 'ks_wlan_priv *priv' this is
unnecessary, we always have a pointer to this struct there is no need
to store it here.

The complete_handler can be more clearly defined by using struct
pointer types instead of void * types. The code is currently
unnecessarily complex, storing and passing extraneous pointer
parameters.

Remove unnecessary parameters, unnecessary casting to/from 'void
*'. Fix all call sites involving complete_handler().

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 21 +++--
 drivers/staging/ks7010/ks7010_sdio.h |  6 +++---
 drivers/staging/ks7010/ks_hostif.c   | 35 ---
 drivers/staging/ks7010/ks_hostif.h   |  7 ---
 drivers/staging/ks7010/ks_wlan_net.c | 12 
 5 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b103a20..0f173c3 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -237,8 +237,9 @@ int ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 
 static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
 unsigned long size,
-void (*complete_handler)(void *arg1, void *arg2),
-void *arg1, void *arg2)
+void (*complete_handler)(struct ks_wlan_private *priv,
+ struct sk_buff *skb),
+struct sk_buff *skb)
 {
struct tx_device_buffer *sp;
int ret;
@@ -259,8 +260,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
sp->sendp = p;
sp->size = size;
sp->complete_handler = complete_handler;
-   sp->arg1 = arg1;
-   sp->arg2 = arg2;
+   sp->skb = skb;
inc_txqtail(priv);
 
return 0;
@@ -268,7 +268,7 @@ static int enqueue_txdev(struct ks_wlan_private *priv, 
unsigned char *p,
 err_complete:
kfree(p);
if (complete_handler)
-   (*complete_handler) (arg1, arg2);
+   (*complete_handler)(priv, skb);
 
return ret;
 }
@@ -327,7 +327,7 @@ static void tx_device_task(struct ks_wlan_private *priv)
}
kfree(sp->sendp);
if (sp->complete_handler)   /* TX Complete */
-   (*sp->complete_handler) (sp->arg1, sp->arg2);
+   (*sp->complete_handler)(priv, sp->skb);
inc_txqhead(priv);
 
if (cnt_txqbody(priv) > 0) {
@@ -337,8 +337,9 @@ static void tx_device_task(struct ks_wlan_private *priv)
 }
 
 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
- void (*complete_handler)(void *arg1, void *arg2),
- void *arg1, void *arg2)
+ void (*complete_handler)(struct ks_wlan_private *priv,
+  struct sk_buff *skb),
+ struct sk_buff *skb)
 {
int result = 0;
struct hostif_hdr *hdr;
@@ -356,7 +357,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, 
unsigned long size,
 
DPRINTK(4, "event=%04X\n", hdr->event);
spin_lock(&priv->tx_dev.tx_dev_lock);
-   result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2);
+   result = enqueue_txdev(priv, p, size, complete_handler, skb);
spin_unlock(&priv->tx_dev.tx_dev_lock);
 
if (cnt_txqbody(priv) > 0) {
@@ -628,7 +629,7 @@ static void trx_device_exit(struct ks_wlan_private *priv)
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
kfree(sp->sendp);   /* allocated memory free */
if (sp->complete_handler)   /* TX Complete */
-   (*sp->complete_handler) (sp->arg1, sp->arg2);
+   (*sp->complete_handler)(priv, sp->skb);
inc_txqhead(priv);
}
 
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index e9b0ad9..5aa593a 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -108,9 +108,9 @@ struct ks_sdio_card {
 struct tx_device_buffer {
unsigned char *sendp;   /* pointer of send req data */
unsigned int size;
-   void (*complete_handler)(void *arg1, void *arg2);
-   void *arg1;
-   void *arg2;
+   void (*complete_handler)(struct ks_wlan_private *priv,
+struct sk_buff *skb);
+   struct sk_buff *skb;
 };
 
 struct tx_device {
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drive

[PATCH 02/15] staging: ks7010: replace defines with enum types

2017-04-17 Thread Tobin C. Harding
Header has multiple constants defined using preprocessor
directive. In the cases where these are an integer progression an
enumeration type can be used. Doing so adds documentation to the code
and makes the usage explicit. Maintain original constant value, this
value is returned by the device.

Replace (integer progression) preprocessor constants with enumeration
type.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.h | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 0b8b865..e9b0ad9 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -62,14 +62,18 @@ enum reg_status_type {
 
 /* General Communication Register A */
 #define GCR_A  0x28
-#define GCR_A_INIT 0
-#define GCR_A_REMAP1
-#define GCR_A_RUN  2
+enum gen_com_reg_a {
+   GCR_A_INIT,
+   GCR_A_REMAP,
+   GCR_A_RUN
+};
 
 /* General Communication Register B */
 #define GCR_B  0x2C
-#define GCR_B_ACTIVE   0
-#define GCR_B_DOZE 1
+enum gen_com_reg_b {
+   GCR_B_ACTIVE,
+   GCR_B_DOZE
+};
 
 /* Wakeup Register */
 /* #define WAKEUP  0x008104 */
-- 
2.7.4

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


[PATCH 11/15] staging: ks7010: fix checkpatch SPACE_BEFORE_TAB

2017-04-17 Thread Tobin C. Harding
Checkpatch emits WARNING: please, no space before tabs.

Remove space before tabs.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 13d5de9..5cd7833 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -562,7 +562,7 @@ static void ks_sdio_interrupt(struct sdio_func *func)
}
DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
rsize = rw_data & RSIZE_MASK;
-   if (rsize != 0) /* Read schedule */
+   if (rsize != 0) /* Read schedule */
ks_wlan_hw_rx(priv, (uint16_t)(rsize << 4));
 
if (rw_data & WSTATUS_MASK) {
-- 
2.7.4

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


[PATCH 13/15] staging: ks7010: refactor SDIO read/write helpers

2017-04-17 Thread Tobin C. Harding
Driver SDIO code uses helper functions to do IO to the SDIO
device. Current helpers handle IO of a single byte as well as
multi-byte. Driver predominately uses single byte IO. If the
common case is made simple it simplifies the whole driver. The common
case can be made simple by splitting the multi-byte and single byte
calls into separate functions, i.e 4 functions in total, read single
byte, read multi-byte, write single byte, write multi-byte.

Also, we need to handle the debug code. Currently debug calls after
read/write fail access the IO buffer. This buffer, at best, does not hold
useful data on the error path, at worst is uninitialized and holds
garbage.

Split read/write helper functions into two functions each, one for
single byte IO and one for multi-byte IO. Fix all call sites. Do not
change the program logic.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c | 187 +++
 1 file changed, 81 insertions(+), 106 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index aca7205..4e62241 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -46,51 +46,50 @@ MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
 #define cnt_rxqbody(priv) \
(((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % 
RX_DEVICE_BUFF_SIZE)
 
-static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
-   unsigned char *buffer, int length)
+/* Read single byte from device address into byte (CMD52) */
+static int ks7010_sdio_readb(struct ks_wlan_private *priv, unsigned int 
address,
+unsigned char *byte)
 {
-   struct ks_sdio_card *card;
+   struct sdio_func *func = priv->ks_sdio_card->func;
int ret;
 
-   card = priv->ks_sdio_card;
+   *byte = sdio_readb(func, address, &ret);
 
-   if (length == 1)/* CMD52 */
-   *buffer = sdio_readb(card->func, address, &ret);
-   else/* CMD53 multi-block transfer */
-   ret = sdio_memcpy_fromio(card->func, buffer, address, length);
+   return ret;
+}
 
-   if (ret) {
-   DPRINTK(1, "sdio error=%d size=%d\n", ret, length);
-   return ret;
-   }
+/* Read length bytes from device address into buffer (CMD53) */
+static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
+   unsigned char *buffer, int length)
+{
+   struct sdio_func *func = priv->ks_sdio_card->func;
 
-   return 0;
+   return sdio_memcpy_fromio(func, buffer, address, length);
 }
 
-static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int 
address,
-unsigned char *buffer, int length)
+/* Write single byte to device address (CMD52) */
+static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
+ unsigned int address, unsigned char byte)
 {
-   struct ks_sdio_card *card;
+   struct sdio_func *func = priv->ks_sdio_card->func;
int ret;
 
-   card = priv->ks_sdio_card;
+   sdio_writeb(func, byte, address, &ret);
 
-   if (length == 1)/* CMD52 */
-   sdio_writeb(card->func, *buffer, address, &ret);
-   else/* CMD53 */
-   ret = sdio_memcpy_toio(card->func, address, buffer, length);
+   return ret;
+}
 
-   if (ret) {
-   DPRINTK(1, "sdio error=%d size=%d\n", ret, length);
-   return ret;
-   }
+/* Write length bytes to device address from buffer (CMD53) */
+static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int 
address,
+unsigned char *buffer, int length)
+{
+   struct sdio_func *func = priv->ks_sdio_card->func;
 
-   return 0;
+   return sdio_memcpy_toio(func, address, buffer, length);
 }
 
 static void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
 {
-   unsigned char rw_data;
int ret;
 
DPRINTK(4, "\n");
@@ -99,13 +98,11 @@ static void ks_wlan_hw_sleep_doze_request(struct 
ks_wlan_private *priv)
atomic_set(&priv->sleepstatus.doze_request, 0);
 
if (atomic_read(&priv->sleepstatus.status) == 0) {
-   rw_data = GCR_B_DOZE;
-   ret = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data));
+   ret = ks7010_sdio_writeb(priv, GCR_B, GCR_B_DOZE);
if (ret) {
-   DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
+   DPRINTK(1, " error : GCR_B\n");
goto set_sleep_mode;
}
-   DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data);
DPRINTK(3, "sleep_mode=SLP_SLEEP\n");
atomic_set(&priv->sleepstatus.status, 1);
priv->last_doze = jiffies;
@@ -119,7 +116,6 @@ static void ks_wlan_hw_sleep_doze_request(

[PATCH 05/15] staging: ks7010: rename wakeup work struct

2017-04-17 Thread Tobin C. Harding
struct work_struct uses identifier ks_wlan_wakeup_task, this is
confusing because the 'task' suffix implies that this is a
tasklet_struct instead of a work struct. Suffix 'work' would be more
clear. The code would be easier to read if it followed the principle
of least surprise and used the 'work' suffix for a work_struct
identifier.

Rename work_struct structure 'ks_wlan_wakeup_task' to 'wakeup_work'.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks_hostif.c | 14 +++---
 drivers/staging/ks7010/ks_wlan.h   |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a04e4e3..2a54b4c 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -66,11 +66,13 @@ inline u32 get_DWORD(struct ks_wlan_private *priv)
 
 static void ks_wlan_hw_wakeup_task(struct work_struct *work)
 {
-   struct ks_wlan_private *priv =
-   container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task);
-   int ps_status = atomic_read(&priv->psstatus.status);
+   struct ks_wlan_private *priv;
+   int ps_status;
long time_left;
 
+   priv = container_of(work, struct ks_wlan_private, wakeup_work);
+   ps_status = atomic_read(&priv->psstatus.status);
+
if (ps_status == PS_SNOOZE) {
ks_wlan_hw_wakeup_request(priv);
time_left = wait_for_completion_interruptible_timeout(
@@ -78,7 +80,7 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work)
msecs_to_jiffies(20));
if (time_left <= 0) {
DPRINTK(1, "wake up timeout or interrupted !!!\n");
-   schedule_work(&priv->ks_wlan_wakeup_task);
+   schedule_work(&priv->wakeup_work);
return;
}
} else {
@@ -2656,10 +2658,8 @@ int hostif_init(struct ks_wlan_private *priv)
atomic_set(&priv->psstatus.status, PS_NONE);
atomic_set(&priv->psstatus.confirm_wait, 0);
atomic_set(&priv->psstatus.snooze_guard, 0);
-   /* init_waitqueue_head(&priv->psstatus.wakeup_wait); */
init_completion(&priv->psstatus.wakeup_wait);
-   //INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task, (void 
*)priv);
-   INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task);
+   INIT_WORK(&priv->wakeup_work, ks_wlan_hw_wakeup_task);
 
/* WPA */
memset(&priv->wpa, 0, sizeof(priv->wpa));
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index 7ba440a..7968470 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -429,7 +429,7 @@ struct ks_wlan_private {
u8 *rxp;
unsigned int rx_size;
struct tasklet_struct sme_task;
-   struct work_struct ks_wlan_wakeup_task;
+   struct work_struct wakeup_work;
int scan_ind_count;
 
unsigned char eth_addr[ETH_ALEN];
-- 
2.7.4

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


[PATCH 04/15] staging: ks7010: clean up SDIO header comments

2017-04-17 Thread Tobin C. Harding
SDIO header file does not use kernel doc format struct
comments. Adding them aids readability and enables documentation to be
built from the source code. Other comments may be tidied up as we do this.

Add kernel format struct comments. Tidy up comments.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.h | 46 ++--
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index 5aa593a..d04fccc 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -76,8 +76,6 @@ enum gen_com_reg_b {
 };
 
 /* Wakeup Register */
-/* #define WAKEUP  0x008104 */
-/* #define WAKEUP_REQ  0x00 */
 #define WAKEUP 0x008018
 #define WAKEUP_REQ 0x5a
 
@@ -87,9 +85,6 @@ enum gen_com_reg_b {
 
 #define KS7010_IRAM_ADDRESS0x0600
 
-/*
- * struct define
- */
 struct hw_info_t {
struct ks_sdio_card *sdio_card;
struct workqueue_struct *ks7010sdio_wq;
@@ -105,35 +100,62 @@ struct ks_sdio_card {
 /* Tx Device struct */
 #defineTX_DEVICE_BUFF_SIZE 1024
 
+/**
+ * struct tx_device_buffer - Queue item for the tx queue.
+ * @sendp: Pointer to the send request data.
+ * @size: Size of @sendp data.
+ * @complete_handler: Function called once data write to device is complete.
+ * @arg1: First argument to @complete_handler.
+ * @arg2: Second argument to @complete_handler.
+ */
 struct tx_device_buffer {
-   unsigned char *sendp;   /* pointer of send req data */
+   unsigned char *sendp;
unsigned int size;
void (*complete_handler)(struct ks_wlan_private *priv,
 struct sk_buff *skb);
struct sk_buff *skb;
 };
 
+/**
+ * struct tx_device - Tx buffer queue.
+ * @tx_device_buffer: Queue buffer.
+ * @qhead: Head of tx queue.
+ * @qtail: Tail of tx queue.
+ * @tx_dev_lock: Queue lock.
+ */
 struct tx_device {
struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE];
-   unsigned int qhead; /* tx buffer queue first pointer */
-   unsigned int qtail; /* tx buffer queue last pointer */
-   spinlock_t tx_dev_lock;
+   unsigned int qhead;
+   unsigned int qtail;
+   spinlock_t tx_dev_lock; /* protect access to the queue */
 };
 
 /* Rx Device struct */
 #defineRX_DATA_SIZE(2 + 2 + 2347 + 1)
 #defineRX_DEVICE_BUFF_SIZE 32
 
+/**
+ * struct rx_device_buffer - Queue item for the rx queue.
+ * @data: rx data.
+ * @size: Size of @data.
+ */
 struct rx_device_buffer {
unsigned char data[RX_DATA_SIZE];
unsigned int size;
 };
 
+/**
+ * struct rx_device - Rx buffer queue.
+ * @rx_device_buffer: Queue buffer.
+ * @qhead: Head of rx queue.
+ * @qtail: Tail of rx queue.
+ * @rx_dev_lock: Queue lock.
+ */
 struct rx_device {
struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE];
-   unsigned int qhead; /* rx buffer queue first pointer */
-   unsigned int qtail; /* rx buffer queue last pointer */
-   spinlock_t rx_dev_lock;
+   unsigned int qhead;
+   unsigned int qtail;
+   spinlock_t rx_dev_lock; /* protect access to the queue */
 };
 
 #defineROM_FILE "ks7010sd.rom"
-- 
2.7.4

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


[PATCH 01/15] staging: ks7010: create reg_status_type enum type

2017-04-17 Thread Tobin C. Harding
SDIO header currently defines unused constants READ_STATUS_BUSY and
WRITE_STATUS_IDLE. There are reciprocal constants that are used
READ_STATUS_IDLE and WRITE_STATUS_BUSY. We can roll these into a
single enumeration type and remove the two that are unused.

Add enumeration type containing IDLE/BUSY pair that are currently used
within the SDIO source. Change source to use new enum types.

Signed-off-by: Tobin C. Harding 
---
 drivers/staging/ks7010/ks7010_sdio.c |  6 +++---
 drivers/staging/ks7010/ks7010_sdio.h | 14 ++
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 59451f8..b103a20 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -295,7 +295,7 @@ static int write_to_device(struct ks_wlan_private *priv, 
unsigned char *buffer,
return ret;
}
 
-   rw_data = WRITE_STATUS_BUSY;
+   rw_data = REG_STATUS_BUSY;
ret = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data));
if (ret) {
DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data);
@@ -415,7 +415,7 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
 rx_buffer->data, 32);
 #endif
/* rx_status update */
-   read_status = READ_STATUS_IDLE;
+   read_status = REG_STATUS_IDLE;
ret = ks7010_sdio_write(priv, READ_STATUS, &read_status,
sizeof(read_status));
if (ret)
@@ -431,7 +431,7 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, 
uint16_t size)
inc_rxqtail(priv);
 
/* read status update */
-   read_status = READ_STATUS_IDLE;
+   read_status = REG_STATUS_IDLE;
ret = ks7010_sdio_write(priv, READ_STATUS, &read_status,
sizeof(read_status));
if (ret)
diff --git a/drivers/staging/ks7010/ks7010_sdio.h 
b/drivers/staging/ks7010/ks7010_sdio.h
index c01a020..0b8b865 100644
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ b/drivers/staging/ks7010/ks7010_sdio.h
@@ -22,10 +22,13 @@
 /* Older sources suggest earlier versions were named 7910 or 79xx */
 #define SDIO_DEVICE_ID_KS_7010 0x7910
 
-/* Read Status Register */
+/* Read/Write Status Register */
 #define READ_STATUS0x00
-#define READ_STATUS_BUSY   0
-#define READ_STATUS_IDLE   1
+#define WRITE_STATUS   0x0C
+enum reg_status_type {
+   REG_STATUS_BUSY,
+   REG_STATUS_IDLE
+};
 
 /* Read Index Register */
 #define READ_INDEX 0x04
@@ -33,11 +36,6 @@
 /* Read Data Size Register */
 #define READ_DATA_SIZE 0x08
 
-/* Write Status Register */
-#define WRITE_STATUS   0x0C
-#define WRITE_STATUS_BUSY  0
-#define WRITE_STATUS_IDLE  1
-
 /* Write Index Register */
 #define WRITE_INDEX0x10
 
-- 
2.7.4

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


[PATCH 00/15] staging: ks7010: refactor SDIO code

2017-04-17 Thread Tobin C. Harding
This is a rework of a partially applied series with the same subject
text (originally containing 18 patches). This is version 1 because the
subject is not identical.

The purpose of this patch set is to improve the readability of the
SDIO code within the driver. Refactorings only, there are no changes
to functionality introduced by this series.

The ks7010 driver currently implements the WEXT interface. Currently,
Wi-Fi kernel drivers are expected to use the CFG80211 interface. This
series is a step towards that conversion. It will be easier to do the
conversion if first the code is nice and clean.

Patch 01 combines 4 preprocessor defines into an enumeration type,
removing two which are unused.

Patch 02 replaces preprocessor defines with enumeration types.

Patch 03 fixes complete_handler() function prototype, this requires
modification to a struct description and fixing all call sites. The
prototype is included as a parameter in a number of functions, we fix
these at the same time.

Patch 04 cleans up header file comments, removes unneeded comments,
adds structure kernel doc format comments.

Patch 05 renames work_struct structure 'ks_wlan_wakeup_task' to
'wakeup_work'.

Patch 06 moves tasklet_struct pointer into device private data
structure.

Patch 07 moves SDIO related members from hw_info_t structure into
device private data structure.

Patch 08 adds kernel doc format struct comments to structure used as
SDIO func private data.

Patch 09 cleans up the SDIO source code comments, removes unneeded
comments and fixes comment typos.

Patch 10 renames a goto label, removing the err_ prefix.

Patch 11 fixes checkpatch space before tab warning.

Patch 12 fixes checkpatch warning caused by multiple new lines.

Patch 13 splits SDIO IO helper functions into two parts, simplifying
the common case. Updates all call sites, including debug print
statements.

Patch 14 fixes checkpatch split string warning caused by debug print
statement.

Patch 15 renames 'ks7010_sdio.c' to 'sdio.c' and 'ks7010_sdio.h' to
'sdio.h'. Patch is the result of running the following two commands.

$ git mv ks7010_sdio.c sdio.c
$ git mv ks7010_sdio.h sdio.h

Code is untested. Builds on x86_64 and PowerPC.

Tobin C. Harding (15):
  staging: ks7010: create reg_status_type enum type
  staging: ks7010: replace defines with enum types
  staging: ks7010: fix complete_handler
  staging: ks7010: clean up SDIO header comments
  staging: ks7010: rename wakeup work struct
  staging: ks7010: move tasklet_struct to ks_wlan_private
  staging: ks7010: move hw info into dev private data
  staging: ks7010: add struct comment to ks_sdio_card
  staging: ks7010: clean up SDIO source comments
  staging: ks7010: remove err_ from non-error path label
  staging: ks7010: fix checkpatch SPACE_BEFORE_TAB
  staging: ks7010: fix checkpatch LINE_SPACING
  staging: ks7010: refactor SDIO read/write helpers
  staging: ks7010: fix checkpatch SPLIT_STRING
  staging: ks7010: rename SDIO files

 drivers/staging/ks7010/Makefile  |2 +-
 drivers/staging/ks7010/ks7010_sdio.c | 1142 --
 drivers/staging/ks7010/ks7010_sdio.h |  139 -
 drivers/staging/ks7010/ks_hostif.c   |   55 +-
 drivers/staging/ks7010/ks_hostif.h   |7 +-
 drivers/staging/ks7010/ks_wlan.h |   10 +-
 drivers/staging/ks7010/ks_wlan_net.c |   12 +-
 drivers/staging/ks7010/sdio.c| 1079 
 drivers/staging/ks7010/sdio.h|  164 +
 9 files changed, 1284 insertions(+), 1326 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.c
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h
 create mode 100644 drivers/staging/ks7010/sdio.c
 create mode 100644 drivers/staging/ks7010/sdio.h

-- 
2.7.4

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


[PATCH 1/1] drivers/staging/vt6656/main_usb.c: checkpatch warning

2017-04-17 Thread Chewie Lin
Swap string in the dev_warn() call with __func__ argument, instead of
explicitly calling the function name in the string:

WARNING: Prefer using "%s", __func__ to embedded function names
#417: FILE: main_usb.c:417:
+"usb_device_reset fail status=%d\n", status);

total: 0 errors, 1 warnings, 1058 lines checked

And after fix:

main_usb.c has no obvious style problems and is ready for submission.

Signed-off-by: Chewie Lin 
---
 drivers/staging/vt6656/main_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 9e074e9daf4e..71c4511b4cff 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -414,7 +414,7 @@ static void usb_device_reset(struct vnt_private *priv)
status = usb_reset_device(priv->usb);
if (status)
dev_warn(&priv->usb->dev,
-"usb_device_reset fail status=%d\n", status);
+"%s fail status=%d\n", __func__, status);
 }
 
 static void vnt_free_int_bufs(struct vnt_private *priv)
-- 
2.12.2

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


[PATCH 0/1] drivers/staging/vt6656/main_usb.c: checkpatch warning

2017-04-17 Thread Chewie Lin
Hi All,

I'm submitting this patch as part of Eudyptula challenge to fix a
coding style problem.  Thanks for taking time on this trivial patch.

linsh

Chewie Lin (1):
  drivers/staging/vt6656/main_usb.c: checkpatch warning

 drivers/staging/vt6656/main_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.12.2

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


Re: [PATCH] scsi: storvsc: Allow only one remove lun work item to be issued per lun

2017-04-17 Thread Cathy Avery

On 04/15/2017 10:06 AM, Christoph Hellwig wrote:

Just add a singlethreaded workqueue for storvsc_handle_error and you'll
get serialization for all error handling for free.


The problem I am seeing is that many work items can be queued up for the 
same lun before it goes away. The single threaded queue would have to allow
for only a queue of one and no more. Either that or each work item for a 
particular lun must have the same memory address so it gets

rejected if it you try to queue a remove to the same lun twice.

Maybe I am not understanding your suggestion correctly.

Thanks,

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


[PATCH v3 2/2] scsi: storvsc: Add support for FC rport.

2017-04-17 Thread Cathy Avery
Included in the current storvsc driver for Hyper-V is the ability
to access luns on an FC fabric via a virtualized fiber channel
adapter exposed by the Hyper-V host. The driver also attaches to
the FC transport to allow host and port names to be published under
/sys/class/fc_host/hostX. Current customer tools running on the VM
require that these names be available in the well known standard
location under fc_host/hostX.

This patch stubs in an rport per fc_host and sets its rport role
as FC_PORT_ROLE_FCP_DUMMY_INITIATOR to indicate to the fc_transport
that it is a pseudo rport in order to scan the scsi stack via
echo "- - -" > /sys/class/scsi_host/hostX/scan.

Signed-off-by: Cathy Avery 
---
 drivers/scsi/storvsc_drv.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 016639d..1ec8579 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -476,6 +476,9 @@ struct storvsc_device {
 */
u64 node_name;
u64 port_name;
+#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
+   struct fc_rport *rport;
+#endif
 };
 
 struct hv_host_device {
@@ -1823,19 +1826,27 @@ static int storvsc_probe(struct hv_device *device,
target = (device->dev_instance.b[5] << 8 |
 device->dev_instance.b[4]);
ret = scsi_add_device(host, 0, target, 0);
-   if (ret) {
-   scsi_remove_host(host);
-   goto err_out2;
-   }
+   if (ret)
+   goto err_out3;
}
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
if (host->transportt == fc_transport_template) {
+   struct fc_rport_identifiers ids = {
+   .roles = FC_PORT_ROLE_FCP_DUMMY_INITIATOR,
+   };
+
fc_host_node_name(host) = stor_device->node_name;
fc_host_port_name(host) = stor_device->port_name;
+   stor_device->rport = fc_remote_port_add(host, 0, &ids);
+   if (!stor_device->rport)
+   goto err_out3;
}
 #endif
return 0;
 
+err_out3:
+   scsi_remove_host(host);
+
 err_out2:
/*
 * Once we have connected with the host, we would need to
@@ -1861,8 +1872,10 @@ static int storvsc_remove(struct hv_device *dev)
struct Scsi_Host *host = stor_device->host;
 
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
-   if (host->transportt == fc_transport_template)
+   if (host->transportt == fc_transport_template) {
+   fc_remote_port_delete(stor_device->rport);
fc_remove_host(host);
+   }
 #endif
scsi_remove_host(host);
storvsc_dev_remove(dev);
-- 
2.5.0

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


[PATCH v3 1/2] scsi: scsi_transport_fc: Add dummy initiator role to rport

2017-04-17 Thread Cathy Avery
This patch allows scsi drivers that expose virturalized fibre channel
devices but that do not expose rports to successfully rescan the scsi
bus via echo "- - -" > /sys/class/scsi_host/hostX/scan.
Drivers can create a pseudo rport and indicate
FC_PORT_ROLE_FCP_DUMMY_INITIATOR as the rport's role in
fc_rport_identifiers. This insures that a valid scsi_target_id
is assigned to the newly created rport and it can meet the
requirements of fc_user_scan_tgt calling scsi_scan_target.

Signed-off-by: Cathy Avery 
---
 drivers/scsi/scsi_transport_fc.c | 10 ++
 include/scsi/scsi_transport_fc.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2d753c9..de85602 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -289,9 +289,10 @@ static const struct {
u32 value;
char*name;
 } fc_port_role_names[] = {
-   { FC_PORT_ROLE_FCP_TARGET,  "FCP Target" },
-   { FC_PORT_ROLE_FCP_INITIATOR,   "FCP Initiator" },
-   { FC_PORT_ROLE_IP_PORT, "IP Port" },
+   { FC_PORT_ROLE_FCP_TARGET,  "FCP Target" },
+   { FC_PORT_ROLE_FCP_INITIATOR,   "FCP Initiator" },
+   { FC_PORT_ROLE_IP_PORT, "IP Port" },
+   { FC_PORT_ROLE_FCP_DUMMY_INITIATOR, "FCP Dummy Initiator" },
 };
 fc_bitfield_name_search(port_roles, fc_port_role_names)
 
@@ -2628,7 +2629,8 @@ fc_remote_port_create(struct Scsi_Host *shost, int 
channel,
spin_lock_irqsave(shost->host_lock, flags);
 
rport->number = fc_host->next_rport_number++;
-   if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
+   if ((rport->roles & FC_PORT_ROLE_FCP_TARGET) ||
+   (rport->roles & FC_PORT_ROLE_FCP_DUMMY_INITIATOR))
rport->scsi_target_id = fc_host->next_target_id++;
else
rport->scsi_target_id = -1;
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index b21b8aa5..6e208bb 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -162,6 +162,7 @@ enum fc_tgtid_binding_type  {
 #define FC_PORT_ROLE_FCP_TARGET0x01
 #define FC_PORT_ROLE_FCP_INITIATOR 0x02
 #define FC_PORT_ROLE_IP_PORT   0x04
+#define FC_PORT_ROLE_FCP_DUMMY_INITIATOR   0x08
 
 /* The following are for compatibility */
 #define FC_RPORT_ROLE_UNKNOWN  FC_PORT_ROLE_UNKNOWN
-- 
2.5.0

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


[PATCH v3 0/2] scsi: storvsc: Add support for FC rport

2017-04-17 Thread Cathy Avery
The updated patch set provides a way for drivers ( specifically
storvsc in this case ) that expose virturalized fc devices
but that do not expose rports to be manually scanned. This is
done via creating a pseudo rport in storvsc and a
corresponding dummy initiator rport role in the fc transport.

Changes since v2:
- Additional patch adding FC_PORT_ROLE_FCP_DUMMY_INITIATOR role
  to fc_transport
- Changed storvsc rport role to FC_PORT_ROLE_FCP_DUMMY_INITIATOR

Changes since v1:
- Fix fc_rport_identifiers init [Stephen Hemminger]
- Better error checking


Cathy Avery (2):
  scsi: scsi_transport_fc: Add dummy initiator role to rport
  scsi: storvsc: Add support for FC rport.

 drivers/scsi/scsi_transport_fc.c | 10 ++
 drivers/scsi/storvsc_drv.c   | 23 ++-
 include/scsi/scsi_transport_fc.h |  1 +
 3 files changed, 25 insertions(+), 9 deletions(-)

-- 
2.5.0

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


[PATCH] staging: rtl8192u: fix incorrect type in assignment in ieee80211_tx.c

2017-04-17 Thread Martin Karamihov
This patch fixes the following sparse warning:
ieee80211_tx.c:174:36: incorrect type in assignment (different base types)
ieee80211_tx.c:174:36: expected unsigned short [unsigned] [short] [usertype] 

ieee80211_tx.c:174:36: got restricted __be16 [usertype] 

by adding left side cast to __be16.

Signed-off-by: Martin Karamihov 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 7afdd05..bdb96a4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -171,7 +171,7 @@ static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
snap->oui[1] = oui[1];
snap->oui[2] = oui[2];
 
-   *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+   *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
 
return SNAP_SIZE + sizeof(u16);
 }
-- 
2.11.0

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


Re: Using ion memory for direct-io

2017-04-17 Thread Laura Abbott
On 04/14/2017 02:18 AM, Zengtao (B) wrote:
> Hi 
> 
> Currently, the ion mapped to userspace will be forced with VM_IO and 
> VM_PFNMAP flags.
> When I use the ion memory to do the direct-io, it will fail when reaching the 
> get_user_pages,
> 
> Back to the VM_IO and VM_PFNMAP flag, there two flags are introduced by the 
> remap_pfn_range called 
> by the ion_heap_mmap_user.
> 
> From my point of view, all ion memory(cma/vmalloc/system heap) are managed by 
> linux vm, it
> is not reasonable to have the VM_IO and VM_PFNMAP flag, but I don't any 
> suitable function
> to replace the remap_pfn_range, any suggestions?
> 
> Thanks && Regards
> 
> Zengtao 
> 

The carveout heap is omitted from your list of 'all ion memory'. At one
time, carveout memory was not backed by struct pages so I suspect
this is a holdover from then. This would probably be better served
by using vm_insert_page and handling higher order pages properly.

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


Re:staging:skein: skein_base.h, skein_block.h: move macros into appropriate header files

2017-04-17 Thread Karim Eshapa
On Mon, 17 Apr 2017 09:04:03 +0200, Greg KH wrote:
> On Mon, Apr 17, 2017 at 02:47:34AM +0200, Karim Eshapa wrote:
>>
>> Macros more related to BLK operations. 
>
> That doesn't make any sense to me, can you be more explicit?.

skein_block.h contains all fn's related to processing on 
different block size so , it's more finer to contain macros
that define block configuration, message,.. specially they
aren't even referenced in all files that include skein_base.h
but these macros I think still exist in driver files for future work as well.

> Moving stuff from one file to another doesn't seem like it is really
> worth it.
> And where is patch 1/2 in this series?

And, Moving stuff is what "TODO" see it is worth.
There is no patch1/2 sorry, but may be because I sent
the patch twice as one of the mails was witten wrong.

>> Signed-off-by: Karim Eshapa 
>> ---
>> drivers/staging/skein/skein_base.h  | 28 
>> drivers/staging/skein/skein_block.h | 28 
>>  2 files changed, 28 insertions(+), 28 deletions(-)

Thanks,
Karim

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


Re: [PATCH 2/2] staging:skein: skein_base.h, skein_block.h: move macros into appropriate header files

2017-04-17 Thread Greg KH
On Mon, Apr 17, 2017 at 02:47:34AM +0200, Karim Eshapa wrote:
> Macros more related to BLK operations.

That doesn't make any sense to me, can you be more explicit?

> Signed-off-by: Karim Eshapa 
> ---
>  drivers/staging/skein/skein_base.h  | 28 
>  drivers/staging/skein/skein_block.h | 28 
>  2 files changed, 28 insertions(+), 28 deletions(-)

Moving stuff from one file to another doesn't seem like it is really
worth it.

And where is patch 1/2 in this series?

thanks,

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