[PATCH v2]: staging: vc04_services: fix checkpatch error

2017-03-28 Thread Haim Daniel
 >From c840c64e0e662eee04b7d0403040be81eaa34c25 Mon Sep 17 00:00:00 2001
From: Haim Daniel 
Date: Wed, 29 Mar 2017 08:43:46 +0300
Subject: [PATCH] staging: vc04_services: add parenthesis to macros

vchi_cfg.h:

fix checkpatch ERROR: Macros with complex values should be enclosed in parenthesis
---
 drivers/staging/vc04_services/interface/vchi/vchi_cfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
index 26bc2d3..b6f42b8 100644
--- a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
+++ b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
@@ -173,7 +173,7 @@
  * under the carpet. */
 #if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS
 #  undef VCHI_RX_MSG_QUEUE_SIZE
-#  define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS
+#  define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS)
 #endif
 
 /* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit
-- 
1.9.1

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


[PATCH]: staging: media: css2400: fix checkpatch error

2017-03-28 Thread Haim Daniel
 >From 41d35b455f8eb139912909639e914469ef5e06fb Mon Sep 17 00:00:00 2001
From: Haim Daniel 
Date: Tue, 28 Mar 2017 19:27:57 +0300
Subject: [PATCH] [media] staging: css2400: fix checkpatch error

isp_capture_defs.h:

enclose macro with complex values in parentheses.

Signed-off-by: Haim Daniel 
---
 .../pci/atomisp2/css2400/css_2401_csi2p_system/hrt/isp_capture_defs.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hrt/isp_capture_defs.h b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hrt/isp_capture_defs.h
index aa413df..78cbbf6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hrt/isp_capture_defs.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2401_csi2p_system/hrt/isp_capture_defs.h
@@ -19,7 +19,7 @@
 #define _ISP_CAPTURE_BITS_PER_ELEM32  /* only for data, not SOP */		   
 #define _ISP_CAPTURE_BYTES_PER_ELEM   (_ISP_CAPTURE_BITS_PER_ELEM/8	)   
 #define _ISP_CAPTURE_BYTES_PER_WORD   32		/* 256/8 */	
-#define _ISP_CAPTURE_ELEM_PER_WORD_ISP_CAPTURE_BYTES_PER_WORD / _ISP_CAPTURE_BYTES_PER_ELEM		   
+#define _ISP_CAPTURE_ELEM_PER_WORD(_ISP_CAPTURE_BYTES_PER_WORD / _ISP_CAPTURE_BYTES_PER_ELEM) 
 
 //#define CAPT_RCV_ACK  1
 //#define CAPT_WRT_ACK  2   
-- 
1.9.1

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


[PATCH] staging: iio: Use devm functions

2017-03-28 Thread Arushi Singhal
Use managed resource functions devm_request_irq instead of request_irq.
Remove corresponding calls to free_irq in the probe.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c 
b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index 4e0b4eedb53d..42473d095911 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -211,8 +211,9 @@ static int iio_bfin_tmr_trigger_probe(struct 
platform_device *pdev)
if (ret)
goto out;
 
-   ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
- 0, st->trig->name, st);
+   ret = devm_request_irq(>dev,
+  st->irq, iio_bfin_tmr_trigger_isr,
+  0, st->trig->name, st);
if (ret) {
dev_err(>dev,
"request IRQ-%d failed", st->irq);
@@ -256,7 +257,6 @@ static int iio_bfin_tmr_trigger_probe(struct 
platform_device *pdev)
 
return 0;
 out_free_irq:
-   free_irq(st->irq, st);
 out1:
iio_trigger_unregister(st->trig);
 out:
@@ -271,7 +271,6 @@ static int iio_bfin_tmr_trigger_remove(struct 
platform_device *pdev)
disable_gptimers(st->t->bit);
if (st->output_enable)
peripheral_free(st->t->pin);
-   free_irq(st->irq, st);
iio_trigger_unregister(st->trig);
iio_trigger_free(st->trig);
 
-- 
2.11.0

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


Re: [PATCH] Remove sparse warnings in mdc_request.c

2017-03-28 Thread Dilger, Andreas
On Mar 27, 2017, at 23:40, Skanda Guruanand  wrote:
> 
> I have tried to fix the endian issues in the mdc_request.c in the
> lustre file system drivers in the staging area. Your feedback is
> welcome.

Sorry, but this patch is totally wrong.  This would break the handling of this 
structure
on big-endian systems.

The right fix would be to change the declaration of ldp_hash_start and 
ldp_hash_end from
__u64 to __le64, along with ldp_flags and ldp_pad0 (though it should be unused).

Cheers, Andreas

> CHECK   drivers/staging/lustre/lustre/mdc/mdc_request.c
> drivers/staging/lustre/lustre/mdc/mdc_request.c:958:42: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:959:42: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:962:42: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:963:42: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:985:50: warning: cast
> to restricted __le32
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1193:24: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1328:25: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1329:23: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1332:25: warning: cast
> to restricted __le64
> drivers/staging/lustre/lustre/mdc/mdc_request.c:1333:23: warning: cast
> to restricted __le64
> 
> ---
> drivers/staging/lustre/lustre/mdc/mdc_request.c | 20 ++--
> 1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c 
> b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index 6bc2fb8..aa8837c 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -955,12 +955,12 @@ static struct page *mdc_page_locate(struct 
> address_space *mapping, __u64 *hash,
>   if (PageUptodate(page)) {
>   dp = kmap(page);
>   if (BITS_PER_LONG == 32 && hash64) {
> - *start = le64_to_cpu(dp->ldp_hash_start) >> 32;
> - *end   = le64_to_cpu(dp->ldp_hash_end) >> 32;
> + *start = dp->ldp_hash_start >> 32;
> + *end   = dp->ldp_hash_end >> 32;
>   *hash  = *hash >> 32;
>   } else {
> - *start = le64_to_cpu(dp->ldp_hash_start);
> - *end   = le64_to_cpu(dp->ldp_hash_end);
> + *start = dp->ldp_hash_start;
> + *end   = dp->ldp_hash_end;
>   }
>   if (unlikely(*start == 1 && *hash == 0))
>   *hash = *start;
> @@ -982,7 +982,7 @@ static struct page *mdc_page_locate(struct address_space 
> *mapping, __u64 *hash,
>*/
>   kunmap(page);
>   mdc_release_page(page,
> -  le32_to_cpu(dp->ldp_flags) & 
> LDF_COLLIDE);
> +  dp->ldp_flags & LDF_COLLIDE);

Note that it would also be acceptable to use "cpu_to_le32(LDF_COLLIDE)" here, 
since swabbing
a constant is a compile-time operation, while swabbing a variable adds runtime 
overhead on
big-endian systems.

>   page = NULL;
>   }
>   } else {
> @@ -1190,7 +1190,7 @@ static int mdc_read_page_remote(void *data, struct page 
> *page0)
>   SetPageUptodate(page);
> 
>   dp = kmap(page);
> - hash = le64_to_cpu(dp->ldp_hash_start);
> + hash = dp->ldp_hash_start;
>   kunmap(page);
> 
>   offset = hash_x_index(hash, rp->rp_hash64);
> @@ -1325,12 +1325,12 @@ static int mdc_read_page(struct obd_export *exp, 
> struct md_op_data *op_data,
> hash_collision:
>   dp = page_address(page);
>   if (BITS_PER_LONG == 32 && rp_param.rp_hash64) {
> - start = le64_to_cpu(dp->ldp_hash_start) >> 32;
> - end = le64_to_cpu(dp->ldp_hash_end) >> 32;
> + start = dp->ldp_hash_start >> 32;
> + end = dp->ldp_hash_end >> 32;
>   rp_param.rp_off = hash_offset >> 32;
>   } else {
> - start = le64_to_cpu(dp->ldp_hash_start);
> - end = le64_to_cpu(dp->ldp_hash_end);
> + start = dp->ldp_hash_start;
> + end = dp->ldp_hash_end;
>   rp_param.rp_off = hash_offset;
>   }
>   if (end == start) {
> -- 
> 1.9.1
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation







___
devel 

Re: [PATCH 1/1] staging: rtl8188eu: Macros with complex values should be enclosed in parentheses

2017-03-28 Thread Ivan Safonov

On 03/28/2017 11:56 PM, Alfonso Lima Astor wrote:

Fix coding style issue

Signed-off-by: Alfonso Lima Astor 
---
 drivers/staging/rtl8188eu/include/rtw_ioctl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h 
b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
index a6b1c85..0c022a5 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
@@ -59,10 +59,10 @@
 #define OID_MP_SEG40xFF011100

 #define DEBUG_OID(dbg, str)\
-   if ((!dbg)) {   \
+   (if ((!dbg)) {  \
RT_TRACE(_module_rtl871x_ioctl_c_, _drv_info_,  \
 ("%s(%d): %s", __func__, __line__, str));\
-   }
+   })

 enum oid_type {
QUERY_OID,



Probably, DEBUG_OID macro does not used, so you can remove it.

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


Re: [PATCH] staging: media: atomisp: i2c: removed unnecessary white space before comma in memset()

2017-03-28 Thread vk

Corrected all comments.


Thanks,

Vaibhav

On Tuesday 28 March 2017 10:53 AM, Greg KH wrote:

On Tue, Mar 28, 2017 at 10:44:44AM +0530, vaibhavd...@gmail.com wrote:

gc2235.c

Why is this file name here?


  Removed extra space before comma in memset() as a part of
  checkpatch.pl fix-up.

Why the extra space at the beginning of the line?


Signed-off-by: Vaibhav Kothari 

This doesn't match your "From:" line above :(

Please fix up.

thanks,

greg k-h


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


[PATCH 1/2] staging: media: atomisp: i2c: removed unnecessary white space before comma in memset()

2017-03-28 Thread vaibhavddit
From: Vaibhav Kothari 

Removed extra space before comma in memset() as a part of
checkpatch.pl fix-up.

Signed-off-by: Vaibhav Kothari 
---
 drivers/staging/media/atomisp/i2c/gc2235.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c 
b/drivers/staging/media/atomisp/i2c/gc2235.c
index 9b41023..50f4317 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/gc2235.c
@@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client,
return -EINVAL;
}
 
-   memset(msg, 0 , sizeof(msg));
+   memset(msg, 0, sizeof(msg));
 
msg[0].addr = client->addr;
msg[0].flags = 0;
-- 
1.9.1

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


[PATCH] Remove atomisp/i2c style errors.

2017-03-28 Thread Daniel Cashman
From: Dan Cashman 

Remove two ' , ' issues and change spaces to tabs found by poking around in
drivers/staging/. Warnings left untouched.

Test: Run checkpatch script in drivers/staging/media/atomisp/i2c before and
after change.  Errors go from 3 to 0.

Signed-off-by: Dan Cashman 
---
 drivers/staging/media/atomisp/i2c/ap1302.c | 4 ++--
 drivers/staging/media/atomisp/i2c/gc0310.c | 2 +-
 drivers/staging/media/atomisp/i2c/gc2235.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/ap1302.c 
b/drivers/staging/media/atomisp/i2c/ap1302.c
index bacffbe..8432ee9 100644
--- a/drivers/staging/media/atomisp/i2c/ap1302.c
+++ b/drivers/staging/media/atomisp/i2c/ap1302.c
@@ -606,8 +606,8 @@ static s32 ap1302_try_mbus_fmt_locked(struct v4l2_subdev 
*sd,
 
 
 static int ap1302_get_fmt(struct v4l2_subdev *sd,
-struct v4l2_subdev_pad_config *cfg,
-struct v4l2_subdev_format *format)
+ struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_format *format)
 
 {
 struct v4l2_mbus_framefmt *fmt = >format;
diff --git a/drivers/staging/media/atomisp/i2c/gc0310.c 
b/drivers/staging/media/atomisp/i2c/gc0310.c
index add8b90..1ec616a 100644
--- a/drivers/staging/media/atomisp/i2c/gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/gc0310.c
@@ -54,7 +54,7 @@ static int gc0310_read_reg(struct i2c_client *client,
return -EINVAL;
}
 
-   memset(msg, 0 , sizeof(msg));
+   memset(msg, 0, sizeof(msg));
 
msg[0].addr = client->addr;
msg[0].flags = 0;
diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c 
b/drivers/staging/media/atomisp/i2c/gc2235.c
index 9b41023..50f4317 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/gc2235.c
@@ -55,7 +55,7 @@ static int gc2235_read_reg(struct i2c_client *client,
return -EINVAL;
}
 
-   memset(msg, 0 , sizeof(msg));
+   memset(msg, 0, sizeof(msg));
 
msg[0].addr = client->addr;
msg[0].flags = 0;
-- 
2.7.4

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


Re: [PATCH 1/1] Staging: lustre: lnet: libcfs: Fixed checkpatch.pl coding style errors

2017-03-28 Thread Oleg Drokin

On Mar 28, 2017, at 6:10 AM,   
wrote:

> From: Vaibhav Kothari 
> 
> Shifted open brace { to previous line for 8 functions as indicated by
> checkpatch.pl
> 
> Signed-off-by: Vaibhav Kothari 
> ---
> drivers/staging/lustre/lnet/libcfs/hash.c | 43 +++
> 1 file changed, 15 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c 
> b/drivers/staging/lustre/lnet/libcfs/hash.c
> index 5c2ce2e..bb966e2 100644
> --- a/drivers/staging/lustre/lnet/libcfs/hash.c
> +++ b/drivers/staging/lustre/lnet/libcfs/hash.c
> @@ -1348,8 +1348,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
> EXPORT_SYMBOL(cfs_hash_lookup);
> 
> static void
> -cfs_hash_for_each_enter(struct cfs_hash *hs)
> -{
> +cfs_hash_for_each_enter(struct cfs_hash *hs) {

Ugh, no.
This is obviously a false positive in checkpatch.


>   LASSERT(!cfs_hash_is_exiting(hs));
> 
>   if (!cfs_hash_with_rehash(hs))
> @@ -1375,8 +1374,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
> }
> 
> static void
> -cfs_hash_for_each_exit(struct cfs_hash *hs)
> -{
> +cfs_hash_for_each_exit(struct cfs_hash *hs) {
>   int remained;
>   int bits;
> 
> @@ -1407,8 +1405,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
>  */
> static u64
> cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> - void *data, int remove_safe)
> -{
> + void *data, int remove_safe) {
>   struct hlist_node *hnode;
>   struct hlist_node *pos;
>   struct cfs_hash_bd bd;
> @@ -1465,8 +1462,7 @@ struct cfs_hash_cond_arg {
> 
> static int
> cfs_hash_cond_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
> -  struct hlist_node *hnode, void *data)
> -{
> +  struct hlist_node *hnode, void *data) {
>   struct cfs_hash_cond_arg *cond = data;
> 
>   if (cond->func(cfs_hash_object(hs, hnode), cond->arg))
> @@ -1480,8 +1476,8 @@ struct cfs_hash_cond_arg {
>  * any object be reference.
>  */
> void
> -cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func, void 
> *data)
> -{
> +cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func,
> + void *data) {
>   struct cfs_hash_cond_arg arg = {
>   .func   = func,
>   .arg= data,
> @@ -1493,31 +1489,27 @@ struct cfs_hash_cond_arg {
> 
> void
> cfs_hash_for_each(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> -   void *data)
> -{
> +   void *data) {
>   cfs_hash_for_each_tight(hs, func, data, 0);
> }
> EXPORT_SYMBOL(cfs_hash_for_each);
> 
> void
> cfs_hash_for_each_safe(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> -void *data)
> -{
> +void *data) {
>   cfs_hash_for_each_tight(hs, func, data, 1);
> }
> EXPORT_SYMBOL(cfs_hash_for_each_safe);
> 
> static int
> cfs_hash_peek(struct cfs_hash *hs, struct cfs_hash_bd *bd,
> -   struct hlist_node *hnode, void *data)
> -{
> +   struct hlist_node *hnode, void *data) {
>   *(int *)data = 0;
>   return 1; /* return 1 to break the loop */
> }
> 
> int
> -cfs_hash_is_empty(struct cfs_hash *hs)
> -{
> +cfs_hash_is_empty(struct cfs_hash *hs) {
>   int empty = 1;
> 
>   cfs_hash_for_each_tight(hs, cfs_hash_peek, , 0);
> @@ -1526,8 +1518,7 @@ struct cfs_hash_cond_arg {
> EXPORT_SYMBOL(cfs_hash_is_empty);
> 
> u64
> -cfs_hash_size_get(struct cfs_hash *hs)
> -{
> +cfs_hash_size_get(struct cfs_hash *hs) {
>   return cfs_hash_with_counter(hs) ?
>  atomic_read(>hs_count) :
>  cfs_hash_for_each_tight(hs, NULL, NULL, 0);
> @@ -1551,8 +1542,7 @@ struct cfs_hash_cond_arg {
>  */
> static int
> cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> - void *data, int start)
> -{
> + void *data, int start) {
>   struct hlist_node *hnode;
>   struct hlist_node *tmp;
>   struct cfs_hash_bd bd;
> @@ -1629,8 +1619,7 @@ struct cfs_hash_cond_arg {
> 
> int
> cfs_hash_for_each_nolock(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> -  void *data, int start)
> -{
> +  void *data, int start) {
>   if (cfs_hash_with_no_lock(hs) ||
>   cfs_hash_with_rehash_key(hs) ||
>   !cfs_hash_with_no_itemref(hs))
> @@ -1661,8 +1650,7 @@ struct cfs_hash_cond_arg {
>  */
> int
> cfs_hash_for_each_empty(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
> - void *data)
> -{
> + void *data) {
>   unsigned int i = 0;
> 
>   if (cfs_hash_with_no_lock(hs))
> @@ -1718,8 +1706,7 @@ struct cfs_hash_cond_arg {
>  */
> void
> cfs_hash_for_each_key(struct cfs_hash *hs, const void *key,
> -   cfs_hash_for_each_cb_t func, void *data)
> -{
> +   cfs_hash_for_each_cb_t func, void *data) 

[PATCH] staging: lusten: conrpc.c: fix different address space sparse warning

2017-03-28 Thread Marcos Paulo de Souza
head_up parameter is marked with __user attribute, tmp is filled
by a copy_from_user from next, that is also marked as __user, so
tmp.next needs to be "casted" as __user to make sparse happy.

Signed-off-by: Marcos Paulo de Souza 
---

 this is mt first patch addressing an issue of sparse, so let me know
 if I misunderstood the error message

 drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c 
b/drivers/staging/lustre/lnet/selftest/conrpc.c
index c6a683b..fb7ad74 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -487,7 +487,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
   sizeof(struct list_head)))
return -EFAULT;
 
-   if (tmp.next == head_up)
+   if ((struct list_head __user *)tmp.next == head_up)
return 0;
 
next = tmp.next;
-- 
2.9.3

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


Re: [PATCH v6 02/39] [media] dt-bindings: Add bindings for i.MX media driver

2017-03-28 Thread Steve Longerbeam



On 03/28/2017 05:21 PM, Rob Herring wrote:

On Mon, Mar 27, 2017 at 7:40 PM, Steve Longerbeam  wrote:

Add bindings documentation for the i.MX media driver.


+
+mipi_csi2 node
+--
+
+This is the device node for the MIPI CSI-2 Receiver, required for MIPI
+CSI-2 sensors.
+
+Required properties:
+- compatible   : "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";


As I mentioned in v5, there's a DW CSI2 binding in progress. This
needs to be based on that.


Hi Rob, I'm not sure what you are asking me to do.

I assume if there's another binding doc in progress, it means
someone is working on another Synopsys DW CSI-2 subdevice driver.

Unfortunately I don't have the time to contribute and switch to
this other subdevice, and do test/debug.

For now I would prefer if this patchset is merged as is, and
then contribute/switch to another CSI-2 subdev later. It is
also getting very difficult managing all these patches (39 as
of this version), and I'd prefer not to spam the lists with
such large patchsets for too much longer.


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


Re: [PATCH v6 02/39] [media] dt-bindings: Add bindings for i.MX media driver

2017-03-28 Thread Rob Herring
On Mon, Mar 27, 2017 at 7:40 PM, Steve Longerbeam  wrote:
> Add bindings documentation for the i.MX media driver.
>
> Signed-off-by: Steve Longerbeam 
> ---
>  Documentation/devicetree/bindings/media/imx.txt | 74 
> +
>  1 file changed, 74 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/imx.txt
>
> diff --git a/Documentation/devicetree/bindings/media/imx.txt 
> b/Documentation/devicetree/bindings/media/imx.txt
> new file mode 100644
> index 000..3059c06
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/imx.txt
> @@ -0,0 +1,74 @@
> +Freescale i.MX Media Video Device
> +=
> +
> +Video Media Controller node
> +---
> +
> +This is the media controller node for video capture support. It is a
> +virtual device that lists the camera serial interface nodes that the
> +media device will control.
> +
> +Required properties:
> +- compatible : "fsl,imx-capture-subsystem";
> +- ports  : Should contain a list of phandles pointing to camera
> +   sensor interface ports of IPU devices
> +
> +example:
> +
> +capture-subsystem {
> +   compatible = "fsl,imx-capture-subsystem";
> +   ports = <_csi0>, <_csi1>;
> +};
> +
> +fim child node
> +--
> +
> +This is an optional child node of the ipu_csi port nodes. If present and
> +available, it enables the Frame Interval Monitor. Its properties can be
> +used to modify the method in which the FIM measures frame intervals.
> +Refer to Documentation/media/v4l-drivers/imx.rst for more info on the
> +Frame Interval Monitor.
> +
> +Optional properties:
> +- fsl,input-capture-channel: an input capture channel and channel flags,
> +specified as . The channel number
> +must be 0 or 1. The flags can be
> +IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or
> +IRQ_TYPE_EDGE_BOTH, and specify which input
> +capture signal edge will trigger the input
> +capture event. If an input capture channel is
> +specified, the FIM will use this method to
> +measure frame intervals instead of via the EOF
> +interrupt. The input capture method is much
> +preferred over EOF as it is not subject to
> +interrupt latency errors. However it requires
> +routing the VSYNC or FIELD output signals of
> +the camera sensor to one of the i.MX input
> +capture pads (SD1_DAT0, SD1_DAT1), which also
> +gives up support for SD1.
> +
> +
> +mipi_csi2 node
> +--
> +
> +This is the device node for the MIPI CSI-2 Receiver, required for MIPI
> +CSI-2 sensors.
> +
> +Required properties:
> +- compatible   : "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";

As I mentioned in v5, there's a DW CSI2 binding in progress. This
needs to be based on that.

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


[PATCH 1/1] Drivers: hv: Issue explicit EOI when autoeoi is not enabled

2017-03-28 Thread kys
From: K. Y. Srinivasan 

When auto EOI is not enabled; issue an explicit EOI for hyper-v
interrupts.

Fixes: 6c248aad81c8 ("Drivers: hv: Base autoeoi enablement based on hypervisor 
hints")

Signed-off-by: K. Y. Srinivasan 
---
 arch/x86/kernel/cpu/mshyperv.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index b5375b9..04cb8d3 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -49,6 +49,9 @@ void hyperv_vector_handler(struct pt_regs *regs)
if (vmbus_handler)
vmbus_handler();
 
+   if (ms_hyperv.hints & HV_X64_DEPRECATING_AEOI_RECOMMENDED)
+   ack_APIC_irq();
+
exiting_irq();
set_irq_regs(old_regs);
 }
-- 
1.7.1

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


Re: [PATCH 1/1] staging: rtl8188eu: Macros with complex values should be enclosed in parentheses

2017-03-28 Thread Tobin C. Harding
On Tue, Mar 28, 2017 at 09:56:19PM +0100, Alfonso Lima Astor wrote:
> Fix coding style issue
> 
> Signed-off-by: Alfonso Lima Astor 
> ---

Hi Alfonso,

You don't need to put 1/1 in the subject of a single patch. You may
like to limit your git log summary to 50 characters (and the main body
to about 72 characters). 

Also you may like to add a little more detail to your git log message, for
example how you found this issue, why it needs fixing etc

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


[PATCH 1/1] staging: rtl8188eu: Macros with complex values should be enclosed in parentheses

2017-03-28 Thread Alfonso Lima Astor
Fix coding style issue

Signed-off-by: Alfonso Lima Astor 
---
 drivers/staging/rtl8188eu/include/rtw_ioctl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h 
b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
index a6b1c85..0c022a5 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
@@ -59,10 +59,10 @@
 #define OID_MP_SEG40xFF011100
 
 #define DEBUG_OID(dbg, str)\
-   if ((!dbg)) {   \
+   (if ((!dbg)) {  \
RT_TRACE(_module_rtl871x_ioctl_c_, _drv_info_,  \
 ("%s(%d): %s", __func__, __line__, str));  \
-   }
+   })
 
 enum oid_type {
QUERY_OID,
-- 
2.7.4

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


Re: [PATCH] staging: atomisp: avoid false-positive maybe-uninitialized warning

2017-03-28 Thread Arnd Bergmann
On Tue, Mar 28, 2017 at 10:10 PM, kbuild test robot <l...@intel.com> wrote:
> Hi Arnd,
>
> [auto build test ERROR on staging/staging-testing]
> [also build test ERROR on next-20170328]
> [cannot apply to linuxtv-media/master v4.11-rc4]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
>
> url:
> https://github.com/0day-ci/linux/commits/Arnd-Bergmann/staging-atomisp-avoid-false-positive-maybe-uninitialized-warning/20170329-023715
> config: i386-allmodconfig (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
>drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_get_fmt':
>>> drivers/staging/media/atomisp/i2c/mt9m114.c:818:25: error: unused variable 
>>> 'dev' [-Werror=unused-variable]
>  struct mt9m114_device *dev = to_mt9m114_sensor(sd);
> ^~~
>drivers/staging/media/atomisp/i2c/mt9m114.c: In function 
> 'mt9m114_s_exposure_selection':
>drivers/staging/media/atomisp/i2c/mt9m114.c:1179:25: error: unused 
> variable 'dev' [-Werror=unused-variable]
>  struct mt9m114_device *dev = to_mt9m114_sensor(sd);
> ^~~
>cc1: all warnings being treated as errors
>

Very odd, I should obviouly have run into these when verifying my patch.
I guess

I'm preparing an v2 patch and will send that once I've built some more
randconfigs on top of recreating the bug and fix.

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


Re: [PATCH] staging: atomisp: avoid false-positive maybe-uninitialized warning

2017-03-28 Thread kbuild test robot
Hi Arnd,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on next-20170328]
[cannot apply to linuxtv-media/master v4.11-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Arnd-Bergmann/staging-atomisp-avoid-false-positive-maybe-uninitialized-warning/20170329-023715
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_get_fmt':
>> drivers/staging/media/atomisp/i2c/mt9m114.c:818:25: error: unused variable 
>> 'dev' [-Werror=unused-variable]
 struct mt9m114_device *dev = to_mt9m114_sensor(sd);
^~~
   drivers/staging/media/atomisp/i2c/mt9m114.c: In function 
'mt9m114_s_exposure_selection':
   drivers/staging/media/atomisp/i2c/mt9m114.c:1179:25: error: unused variable 
'dev' [-Werror=unused-variable]
 struct mt9m114_device *dev = to_mt9m114_sensor(sd);
^~~
   cc1: all warnings being treated as errors

vim +/dev +818 drivers/staging/media/atomisp/i2c/mt9m114.c

a49d2536 Alan Cox 2017-02-17  812  
a49d2536 Alan Cox 2017-02-17  813  static int mt9m114_get_fmt(struct 
v4l2_subdev *sd,
a49d2536 Alan Cox 2017-02-17  814   struct 
v4l2_subdev_pad_config *cfg,
a49d2536 Alan Cox 2017-02-17  815   struct 
v4l2_subdev_format *format)
a49d2536 Alan Cox 2017-02-17  816  {
a49d2536 Alan Cox 2017-02-17  817  struct v4l2_mbus_framefmt *fmt = 
>format;
a49d2536 Alan Cox 2017-02-17 @818   struct mt9m114_device *dev = 
to_mt9m114_sensor(sd);
a49d2536 Alan Cox 2017-02-17  819   int width, height;
a49d2536 Alan Cox 2017-02-17  820   int ret;
a49d2536 Alan Cox 2017-02-17  821   if (format->pad)

:: The code at line 818 was first introduced by commit
:: a49d25364dfb9f8a64037488a39ab1f56c5fa419 staging/atomisp: Add support 
for the Intel IPU v2

:: TO: Alan Cox <a...@linux.intel.com>
:: CC: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RFC PATCH v2 16/32] x86: kvm: Provide support to create Guest and HV shared per-CPU variables

2017-03-28 Thread Borislav Petkov
On Thu, Mar 02, 2017 at 10:15:36AM -0500, Brijesh Singh wrote:
> Some KVM specific MSR's (steal-time, asyncpf, avic_eio) allocates per-CPU
> variable at compile time and share its physical address with hypervisor.
> It presents a challege when SEV is active in guest OS. When SEV is active,
> guest memory is encrypted with guest key and hypervisor will no longer able
> to modify the guest memory. When SEV is active, we need to clear the
> encryption attribute of shared physical addresses so that both guest and
> hypervisor can access the data.
> 
> To solve this problem, I have tried these three options:
> 
> 1) Convert the static per-CPU to dynamic per-CPU allocation. When SEV is
> detected then clear the encryption attribute. But while doing so I found
> that per-CPU dynamic allocator was not ready when kvm_guest_cpu_init was
> called.
> 
> 2) Since the encryption attributes works on PAGE_SIZE hence add some extra
> padding to 'struct kvm-steal-time' to make it PAGE_SIZE and then at runtime
> clear the encryption attribute of the full PAGE. The downside of this was
> now we need to modify structure which may break the compatibility.

From SEV-ES whitepaper:

"To facilitate this communication, the SEV-ES architecture defines
a Guest Hypervisor Communication Block (GHCB). The GHCB resides in
page of shared memory so it is accessible to both the guest VM and the
hypervisor."

So this is kinda begging to be implemented with a shared page between
guest and host. And then put steal-time, ... etc in there too. Provided
there's enough room in the single page for the GHCB *and* our stuff.

> 
> 3) Define a new per-CPU section (.data..percpu.hv_shared) which will be
> used to hold the compile time shared per-CPU variables. When SEV is
> detected we map this section with encryption attribute cleared.
> 
> This patch implements #3. It introduces a new DEFINE_PER_CPU_HV_SHAHRED
> macro to create a compile time per-CPU variable. When SEV is detected we
> map the per-CPU variable as decrypted (i.e with encryption attribute cleared).
> 
> Signed-off-by: Brijesh Singh 
> ---
>  arch/x86/kernel/kvm.c |   43 
> +++--
>  include/asm-generic/vmlinux.lds.h |3 +++
>  include/linux/percpu-defs.h   |9 
>  3 files changed, 48 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 099fcba..706a08e 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -75,8 +75,8 @@ static int parse_no_kvmclock_vsyscall(char *arg)
>  
>  early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall);
>  
> -static DEFINE_PER_CPU(struct kvm_vcpu_pv_apf_data, apf_reason) __aligned(64);
> -static DEFINE_PER_CPU(struct kvm_steal_time, steal_time) __aligned(64);
> +static DEFINE_PER_CPU_HV_SHARED(struct kvm_vcpu_pv_apf_data, apf_reason) 
> __aligned(64);
> +static DEFINE_PER_CPU_HV_SHARED(struct kvm_steal_time, steal_time) 
> __aligned(64);
>  static int has_steal_clock = 0;
>  
>  /*
> @@ -290,6 +290,22 @@ static void __init paravirt_ops_setup(void)
>  #endif
>  }
>  
> +static int kvm_map_percpu_hv_shared(void *addr, unsigned long size)
> +{
> + /* When SEV is active, the percpu static variables initialized
> +  * in data section will contain the encrypted data so we first
> +  * need to decrypt it and then map it as decrypted.
> +  */

Kernel comments style is:

/*
 * A sentence ending with a full-stop.
 * Another sentence. ...
 * More sentences. ...
 */

But you get the idea. Please check your whole patchset for this.

> + if (sev_active()) {
> + unsigned long pa = slow_virt_to_phys(addr);
> +
> + sme_early_decrypt(pa, size);
> + return early_set_memory_decrypted(addr, size);
> + }
> +
> + return 0;
> +}
> +
>  static void kvm_register_steal_time(void)
>  {
>   int cpu = smp_processor_id();
> @@ -298,12 +314,17 @@ static void kvm_register_steal_time(void)
>   if (!has_steal_clock)
>   return;
>  
> + if (kvm_map_percpu_hv_shared(st, sizeof(*st))) {
> + pr_err("kvm-stealtime: failed to map hv_shared percpu\n");
> + return;
> + }
> +
>   wrmsrl(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED));
>   pr_info("kvm-stealtime: cpu %d, msr %llx\n",
>   cpu, (unsigned long long) slow_virt_to_phys(st));
>  }
>  
> -static DEFINE_PER_CPU(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED;
> +static DEFINE_PER_CPU_HV_SHARED(unsigned long, kvm_apic_eoi) = 
> KVM_PV_EOI_DISABLED;
>  
>  static notrace void kvm_guest_apic_eoi_write(u32 reg, u32 val)
>  {
> @@ -327,25 +348,33 @@ static void kvm_guest_cpu_init(void)
>   if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF) && kvmapf) {
>   u64 pa = slow_virt_to_phys(this_cpu_ptr(_reason));
>  
> + if (kvm_map_percpu_hv_shared(this_cpu_ptr(_reason),
> + 

Re: [Outreachy kernel] [PATCH v4] staging: iio: ade7753: Replace mlock with driver private lock

2017-03-28 Thread Alison Schofield
On Tue, Mar 28, 2017 at 10:55:17PM +0530, SIMRAN SINGHAL wrote:
> On Fri, Mar 24, 2017 at 12:51 AM, Alison Schofield  
> wrote:
> > On Fri, Mar 24, 2017 at 12:05:20AM +0530, simran singhal wrote:
> >> The IIO subsystem is redefining iio_dev->mlock to be used by
> >> the IIO core only for protecting device operating mode changes.
> >> ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.
> >>
> >> In this driver, mlock was being used to protect hardware state
> >> changes.  Replace it with a lock in the devices global data.
> >
> > Hi Simran,
> >
> > Please post all revision histories below the --- not just the most
> > recent.
> >
> Sorry, will not repeat this.
> 
> > Does this lock enforce the needed "atomicity" in the write_frequency
> > function? I read Jonathans comment on a previous revision about
> > "ensuring the spi bus frequency and sampling frequency of the device
> > are changed in an atomic fashion"
> >
> 
> By introducing another lock I am protecting read_modify_write and
> in this way also protecting the designated register that we are about
> to write.

I see it protecting this path from being re-entered.  My uncertainty
is about other paths to read/write.

> 
> > Is it possible for another spi bus transaction (read or write) to
> > occur between the read and write in write_frequency?
> >
> 
> Gargi has also come up with a solution.
> https://groups.google.com/forum/#!topic/outreachy-kernel/kzE9CrI5Bd8
> 
> Should I do like her as her's also seem correct or go ahead with this.

My suggestion would be to wait for feedback on Gargi's patch. 
(See the Outreachy log about creating similar solutions.)

We will not be able to close on this set of patches during the
Outreachy application window.  You can continue to push for closure
beyond the March 30th date as your time allows :)

Thanks,
alisons

> 
> > alisons
> >>
> >> Signed-off-by: simran singhal 
> >> ---
> >>
> >>  v4:
> >>-Add mutex_init
> >>
> >>  drivers/staging/iio/meter/ade7753.c | 7 +--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/staging/iio/meter/ade7753.c 
> >> b/drivers/staging/iio/meter/ade7753.c
> >> index b71fbd3..30aebaf 100644
> >> --- a/drivers/staging/iio/meter/ade7753.c
> >> +++ b/drivers/staging/iio/meter/ade7753.c
> >> @@ -80,11 +80,13 @@
> >>   * @us: actual spi_device
> >>   * @tx: transmit buffer
> >>   * @rx: receive buffer
> >> + * @lock:   protect sensor state
> >>   * @buf_lock:   mutex to protect tx and rx
> >>   **/
> >>  struct ade7753_state {
> >>   struct spi_device   *us;
> >>   struct mutexbuf_lock;
> >> + struct mutexlock;  /* protect sensor state */
> >>   u8  tx[ADE7753_MAX_TX] cacheline_aligned;
> >>   u8  rx[ADE7753_MAX_RX];
> >>  };
> >> @@ -484,7 +486,7 @@ static ssize_t ade7753_write_frequency(struct device 
> >> *dev,
> >>   if (!val)
> >>   return -EINVAL;
> >>
> >> - mutex_lock(_dev->mlock);
> >> + mutex_lock(>lock);
> >>
> >>   t = 27900 / val;
> >>   if (t > 0)
> >> @@ -505,7 +507,7 @@ static ssize_t ade7753_write_frequency(struct device 
> >> *dev,
> >>   ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
> >>
> >>  out:
> >> - mutex_unlock(_dev->mlock);
> >> + mutex_unlock(>lock);
> >>
> >>   return ret ? ret : len;
> >>  }
> >> @@ -581,6 +583,7 @@ static int ade7753_probe(struct spi_device *spi)
> >>   st = iio_priv(indio_dev);
> >>   st->us = spi;
> >>   mutex_init(>buf_lock);
> >> + mutex_init(>lock);
> >>
> >>   indio_dev->name = spi->dev.driver->name;
> >>   indio_dev->dev.parent = >dev;
> >> --
> >> 2.7.4
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "outreachy-kernel" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an 
> >> email to outreachy-kernel+unsubscr...@googlegroups.com.
> >> To post to this group, send email to outreachy-ker...@googlegroups.com.
> >> To view this discussion on the web visit 
> >> https://groups.google.com/d/msgid/outreachy-kernel/20170323183520.GA9871%40singhal-Inspiron-5558.
> >> For more options, visit https://groups.google.com/d/optout.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RFC] staging: iio: ad7759: Replace mlock with driver private buf_lock

2017-03-28 Thread Arushi Singhal
The IIO subsystem is redefining iio_dev->mlock to be used by
the IIO core only for protecting device operating mode changes.
ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.

In this driver, mlock was being used to protect hardware state
changes.  Replace it with a buf_lock in the devices global data.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/iio/meter/ade7759.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7759.c 
b/drivers/staging/iio/meter/ade7759.c
index 0b65f1847510..514a4f6bb8f9 100644
--- a/drivers/staging/iio/meter/ade7759.c
+++ b/drivers/staging/iio/meter/ade7759.c
@@ -429,7 +429,7 @@ static ssize_t ade7759_write_frequency(struct device *dev,
if (!val)
return -EINVAL;
 
-   mutex_lock(_dev->mlock);
+   mutex_lock(>buf_lock);
 
t = 27900 / val;
if (t > 0)
@@ -447,10 +447,13 @@ static ssize_t ade7759_write_frequency(struct device *dev,
reg &= ~(3 << 13);
reg |= t << 13;
 
-   ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
+   st->tx[0] = ADE7754_WRITE_REG(ADE7754_WAVMODE);
+   st->tx[1] = reg;
+
+   ret = spi_write(st->us, st->tx, 2);
 
 out:
-   mutex_unlock(_dev->mlock);
+   mutex_unlock(>buf_lock);
 
return ret ? ret : len;
 }
-- 
2.11.0

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


Re: [Outreachy kernel] [PATCH v4] staging: iio: ade7753: Replace mlock with driver private lock

2017-03-28 Thread SIMRAN SINGHAL
On Fri, Mar 24, 2017 at 12:51 AM, Alison Schofield  wrote:
> On Fri, Mar 24, 2017 at 12:05:20AM +0530, simran singhal wrote:
>> The IIO subsystem is redefining iio_dev->mlock to be used by
>> the IIO core only for protecting device operating mode changes.
>> ie. Changes between INDIO_DIRECT_MODE, INDIO_BUFFER_* modes.
>>
>> In this driver, mlock was being used to protect hardware state
>> changes.  Replace it with a lock in the devices global data.
>
> Hi Simran,
>
> Please post all revision histories below the --- not just the most
> recent.
>
Sorry, will not repeat this.

> Does this lock enforce the needed "atomicity" in the write_frequency
> function? I read Jonathans comment on a previous revision about
> "ensuring the spi bus frequency and sampling frequency of the device
> are changed in an atomic fashion"
>

By introducing another lock I am protecting read_modify_write and
in this way also protecting the designated register that we are about
to write.

> Is it possible for another spi bus transaction (read or write) to
> occur between the read and write in write_frequency?
>

Gargi has also come up with a solution.
https://groups.google.com/forum/#!topic/outreachy-kernel/kzE9CrI5Bd8

Should I do like her as her's also seem correct or go ahead with this.

> alisons
>>
>> Signed-off-by: simran singhal 
>> ---
>>
>>  v4:
>>-Add mutex_init
>>
>>  drivers/staging/iio/meter/ade7753.c | 7 +--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/iio/meter/ade7753.c 
>> b/drivers/staging/iio/meter/ade7753.c
>> index b71fbd3..30aebaf 100644
>> --- a/drivers/staging/iio/meter/ade7753.c
>> +++ b/drivers/staging/iio/meter/ade7753.c
>> @@ -80,11 +80,13 @@
>>   * @us: actual spi_device
>>   * @tx: transmit buffer
>>   * @rx: receive buffer
>> + * @lock:   protect sensor state
>>   * @buf_lock:   mutex to protect tx and rx
>>   **/
>>  struct ade7753_state {
>>   struct spi_device   *us;
>>   struct mutexbuf_lock;
>> + struct mutexlock;  /* protect sensor state */
>>   u8  tx[ADE7753_MAX_TX] cacheline_aligned;
>>   u8  rx[ADE7753_MAX_RX];
>>  };
>> @@ -484,7 +486,7 @@ static ssize_t ade7753_write_frequency(struct device 
>> *dev,
>>   if (!val)
>>   return -EINVAL;
>>
>> - mutex_lock(_dev->mlock);
>> + mutex_lock(>lock);
>>
>>   t = 27900 / val;
>>   if (t > 0)
>> @@ -505,7 +507,7 @@ static ssize_t ade7753_write_frequency(struct device 
>> *dev,
>>   ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg);
>>
>>  out:
>> - mutex_unlock(_dev->mlock);
>> + mutex_unlock(>lock);
>>
>>   return ret ? ret : len;
>>  }
>> @@ -581,6 +583,7 @@ static int ade7753_probe(struct spi_device *spi)
>>   st = iio_priv(indio_dev);
>>   st->us = spi;
>>   mutex_init(>buf_lock);
>> + mutex_init(>lock);
>>
>>   indio_dev->name = spi->dev.driver->name;
>>   indio_dev->dev.parent = >dev;
>> --
>> 2.7.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/20170323183520.GA9871%40singhal-Inspiron-5558.
>> For more options, visit https://groups.google.com/d/optout.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: media: atomisp: compress return logic

2017-03-28 Thread Arushi Singhal
Simplify function returns by merging assignment and return.

Signed-off-by: Arushi Singhal 
---
changes in v2
 *correct the error.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c  |  8 ++--
 .../media/atomisp/pci/atomisp2/css2400/runtime/bufq/src/bufq.c | 10 --
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
index b1f685a841ba..a04cd3ba7e68 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
@@ -519,9 +519,7 @@ int atomisp_runtime_suspend(struct device *dev)
if (ret)
return ret;
pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
-   ret = atomisp_mrfld_power_down(isp);
-
-   return ret;
+   return atomisp_mrfld_power_down(isp);
 }
 
 int atomisp_runtime_resume(struct device *dev)
@@ -587,9 +585,7 @@ static int atomisp_suspend(struct device *dev)
return ret;
}
pm_qos_update_request(>pm_qos, PM_QOS_DEFAULT_VALUE);
-   ret = atomisp_mrfld_power_down(isp);
-
-   return ret;
+   return atomisp_mrfld_power_down(isp);
 }
 
 static int atomisp_resume(struct device *dev)
diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/bufq/src/bufq.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/bufq/src/bufq.c
index 737ad66da900..ed33d4c4c84a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/bufq/src/bufq.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/bufq/src/bufq.c
@@ -440,7 +440,7 @@ enum ia_css_err ia_css_bufq_enqueue_psys_event(
 enum  ia_css_err ia_css_bufq_dequeue_psys_event(
uint8_t item[BUFQ_EVENT_SIZE])
 {
-   enum ia_css_err return_err;
+   enum ia_css_err;
int error = 0;
ia_css_queue_t *q;
 
@@ -457,8 +457,7 @@ enum  ia_css_err ia_css_bufq_dequeue_psys_event(
}
error = ia_css_eventq_recv(q, item);
 
-   return_err = ia_css_convert_errno(error);
-   return return_err;
+   return ia_css_convert_errno(error);
 
 }
 
@@ -466,7 +465,7 @@ enum  ia_css_err ia_css_bufq_dequeue_isys_event(
uint8_t item[BUFQ_EVENT_SIZE])
 {
 #if !defined(HAS_NO_INPUT_SYSTEM)
-   enum ia_css_err return_err;
+   enum ia_css_err;
int error = 0;
ia_css_queue_t *q;
 
@@ -482,8 +481,7 @@ enum  ia_css_err ia_css_bufq_dequeue_isys_event(
return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
}
error = ia_css_eventq_recv(q, item);
-   return_err = ia_css_convert_errno(error);
-   return return_err;
+   return ia_css_convert_errno(error);
 #else
(void)item;
return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
-- 
2.11.0

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


RE: [REGRESSION][Stable][v3.12.y][v4.4.y][v4.9.y][v4.10.y][v4.11-rc1] scsi: storvsc: properly set residual data length on errors

2017-03-28 Thread Stephen Hemminger
I decided not to send it to stable since problem was only observed on 4.11 but 
it is probably endemic to all GEN2 VM's

-Original Message-
From: Joseph Salisbury [mailto:joseph.salisb...@canonical.com] 
Sent: Tuesday, March 28, 2017 7:29 AM
To: Stephen Hemminger ; Long Li 
Cc: KY Srinivasan ; Martin K. Petersen 
; Haiyang Zhang ; 
j...@linux.vnet.ibm.com; de...@linuxdriverproject.org; linux-scsi 
; LKML ; 
sta...@vger.kernel.org; Greg KH 
Subject: Re: [REGRESSION][Stable][v3.12.y][v4.4.y][v4.9.y][v4.10.y][v4.11-rc1] 
scsi: storvsc: properly set residual data length on errors

On 03/27/2017 06:14 PM, Stephen Hemminger wrote:
> Are you sure the real problem is not the one fixed by this commit?
>
> commit f1c635b439a5c01776fe3a25b1e2dc546ea82e6f
> Author: Stephen Hemminger 
> Date:   Tue Mar 7 09:15:53 2017 -0800
>
> scsi: storvsc: Workaround for virtual DVD SCSI version
> 
> Hyper-V host emulation of SCSI for virtual DVD device reports SCSI
> version 0 (UNKNOWN) but is still capable of supporting REPORTLUN.
> 
> Without this patch, a GEN2 Linux guest on Hyper-V will not boot 4.11
> successfully with virtual DVD ROM device. What happens is that the SCSI
> scan process falls back to doing sequential probing by INQUIRY.  But the
> storvsc driver has a previous workaround that masks/blocks all errors
> reports from INQUIRY (or MODE_SENSE) commands.  This workaround causes
> the scan to then populate a full set of bogus LUN's on the target and
> then sends kernel spinning off into a death spiral doing block reads on
> the non-existent LUNs.
> 
> By setting the correct blacklist flags, the target with the DVD device
> is scanned with REPORTLUN and that works correctly.
> 
> Patch needs to go in current 4.11, it is safe but not necessary in older
> kernels.
> 
> Signed-off-by: Stephen Hemminger 
> Reviewed-by: K. Y. Srinivasan 
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Martin K. Petersen 
>
> -Original Message-
> From: Joseph Salisbury [mailto:joseph.salisb...@canonical.com] 
> Sent: Monday, March 27, 2017 1:22 PM
> To: Long Li 
> Cc: KY Srinivasan ; Martin K. Petersen 
> ; Haiyang Zhang ; Stephen 
> Hemminger ; j...@linux.vnet.ibm.com; 
> de...@linuxdriverproject.org; linux-scsi ; LKML 
> ; sta...@vger.kernel.org; Greg KH 
> 
> Subject: [REGRESSION][Stable][v3.12.y][v4.4.y][v4.9.y][v4.10.y][v4.11-rc1] 
> scsi: storvsc: properly set residual data length on errors
>
> Hi Long Li,
>
> A kernel bug report was opened against Ubuntu [0].  After a kernel
> bisect, it was found that reverting the following commit resolved this bug:
>
> commit 40630f462824ee24bc00d692865c86c3828094e0
> Author: Long Li 
> Date:   Wed Dec 14 18:46:03 2016 -0800
>
> scsi: storvsc: properly set residual data length on errors
>
>
> The regression was introduced in mainline as of v4.11-rc1.  It was also
> cc'd to stable and has landed in v3.12.y, v4.4.y, v4.9.y and v4.10.y.
>
>
> This regression seems pretty severe since it's preventing virtual
> machines from booting.  It's affecting a couple of users so far.  I was
> hoping to get your feedback, since you are the patch author.  Do you
> think gathering any additional data will help diagnose this issue, or
> would it be best to submit a revert request?
>
>
> Thanks,
>
> Joe
>
>
> [0] http://pad.lv/1674635
>
>
Hi Stephen,


Thanks again for pointing out commit
f1c635b439a5c01776fe3a25b1e2dc546ea82e6f.  It does indeed fix the bug. 
I noticed the commit was not cc'd to stable.  Would it be possible to do
that?


Thanks,


Joe


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


Re: [REGRESSION][Stable][v3.12.y][v4.4.y][v4.9.y][v4.10.y][v4.11-rc1] scsi: storvsc: properly set residual data length on errors

2017-03-28 Thread Joseph Salisbury
On 03/27/2017 06:14 PM, Stephen Hemminger wrote:
> Are you sure the real problem is not the one fixed by this commit?
>
> commit f1c635b439a5c01776fe3a25b1e2dc546ea82e6f
> Author: Stephen Hemminger 
> Date:   Tue Mar 7 09:15:53 2017 -0800
>
> scsi: storvsc: Workaround for virtual DVD SCSI version
> 
> Hyper-V host emulation of SCSI for virtual DVD device reports SCSI
> version 0 (UNKNOWN) but is still capable of supporting REPORTLUN.
> 
> Without this patch, a GEN2 Linux guest on Hyper-V will not boot 4.11
> successfully with virtual DVD ROM device. What happens is that the SCSI
> scan process falls back to doing sequential probing by INQUIRY.  But the
> storvsc driver has a previous workaround that masks/blocks all errors
> reports from INQUIRY (or MODE_SENSE) commands.  This workaround causes
> the scan to then populate a full set of bogus LUN's on the target and
> then sends kernel spinning off into a death spiral doing block reads on
> the non-existent LUNs.
> 
> By setting the correct blacklist flags, the target with the DVD device
> is scanned with REPORTLUN and that works correctly.
> 
> Patch needs to go in current 4.11, it is safe but not necessary in older
> kernels.
> 
> Signed-off-by: Stephen Hemminger 
> Reviewed-by: K. Y. Srinivasan 
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Martin K. Petersen 
>
> -Original Message-
> From: Joseph Salisbury [mailto:joseph.salisb...@canonical.com] 
> Sent: Monday, March 27, 2017 1:22 PM
> To: Long Li 
> Cc: KY Srinivasan ; Martin K. Petersen 
> ; Haiyang Zhang ; Stephen 
> Hemminger ; j...@linux.vnet.ibm.com; 
> de...@linuxdriverproject.org; linux-scsi ; LKML 
> ; sta...@vger.kernel.org; Greg KH 
> 
> Subject: [REGRESSION][Stable][v3.12.y][v4.4.y][v4.9.y][v4.10.y][v4.11-rc1] 
> scsi: storvsc: properly set residual data length on errors
>
> Hi Long Li,
>
> A kernel bug report was opened against Ubuntu [0].  After a kernel
> bisect, it was found that reverting the following commit resolved this bug:
>
> commit 40630f462824ee24bc00d692865c86c3828094e0
> Author: Long Li 
> Date:   Wed Dec 14 18:46:03 2016 -0800
>
> scsi: storvsc: properly set residual data length on errors
>
>
> The regression was introduced in mainline as of v4.11-rc1.  It was also
> cc'd to stable and has landed in v3.12.y, v4.4.y, v4.9.y and v4.10.y.
>
>
> This regression seems pretty severe since it's preventing virtual
> machines from booting.  It's affecting a couple of users so far.  I was
> hoping to get your feedback, since you are the patch author.  Do you
> think gathering any additional data will help diagnose this issue, or
> would it be best to submit a revert request?
>
>
> Thanks,
>
> Joe
>
>
> [0] http://pad.lv/1674635
>
>
Hi Stephen,


Thanks again for pointing out commit
f1c635b439a5c01776fe3a25b1e2dc546ea82e6f.  It does indeed fix the bug. 
I noticed the commit was not cc'd to stable.  Would it be possible to do
that?


Thanks,


Joe


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


Re: [PATCH v6 17/39] platform: add video-multiplexer subdevice driver

2017-03-28 Thread Vladimir Zapolskiy
Hi Steve,

On 03/28/2017 03:40 AM, Steve Longerbeam wrote:
> From: Philipp Zabel 
> 
> This driver can handle SoC internal and external video bus multiplexers,
> controlled either by register bit fields or by a GPIO. The subdevice
> passes through frame interval and mbus configuration of the active input
> to the output side.
> 
> Signed-off-by: Sascha Hauer 
> Signed-off-by: Philipp Zabel 
> 
> - fixed a cut error in vidsw_remove(): v4l2_async_register_subdev()
>   should be unregister.
> 
> - added media_entity_cleanup() to vidsw_remove().
> 
> - added missing MODULE_DEVICE_TABLE().
>   Suggested-by: Javier Martinez Canillas 
> 
> - there was a line left over from a previous iteration that negated
>   the new way of determining the pad count just before it which
>   has been removed (num_pads = of_get_child_count(np)).
> 
> - removed [gs]_frame_interval ops. timeperframe is not used anywhwere
>   in this subdev, and currently it has no control over frame rate.
> 
> - add link_validate to media_entity_operations.
> 
> - moved devicetree binding doc to a separate commit.
> 
> - Philipp Zabel has developed a set of patches that allow adding
>   to the subdev async notifier waiting list using a chaining method
>   from the async registered callbacks (v4l2_of_subdev_registered()
>   and the prep patches for that). For now, I've removed the use of
>   v4l2_of_subdev_registered() for the vidmux driver's registered
>   callback. This doesn't affect the functionality of this driver,
>   but allows for it to be merged now, before adding the chaining
>   support.
> 
> Signed-off-by: Steve Longerbeam 
> ---
>  drivers/media/platform/Kconfig |   8 +
>  drivers/media/platform/Makefile|   2 +
>  drivers/media/platform/video-multiplexer.c | 451 
> +
>  3 files changed, 461 insertions(+)
>  create mode 100644 drivers/media/platform/video-multiplexer.c
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index ab0bb48..c9b8d9c 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -74,6 +74,14 @@ config VIDEO_M32R_AR_M64278
> To compile this driver as a module, choose M here: the
> module will be called arv.
>  
> +config VIDEO_MULTIPLEXER
> + tristate "Video Multiplexer"
> + depends on VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER

+ depends on OF

> + help
> +   This driver provides support for SoC internal N:1 video bus
> +   multiplexers controlled by register bitfields as well as external
> +   2:1 video multiplexers controlled by a single GPIO.
> +

[snip]

> +static int vidsw_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct of_endpoint endpoint;
> + struct device_node *ep;
> + struct reg_field field;
> + struct vidsw *vidsw;
> + struct regmap *map;
> + unsigned int num_pads;
> + int ret;
> +
> + vidsw = devm_kzalloc(>dev, sizeof(*vidsw), GFP_KERNEL);
> + if (!vidsw)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, vidsw);
> +
> + v4l2_subdev_init(>subdev, _subdev_ops);
> + snprintf(vidsw->subdev.name, sizeof(vidsw->subdev.name), "%s",
> + np->name);

 or oops here   ^.

> + vidsw->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> + vidsw->subdev.dev = >dev;
> +
> + /*
> +  * The largest numbered port is the output port. It determines
> +  * total number of pads
> +  */
> + num_pads = 0;
> + for_each_endpoint_of_node(np, ep) {
> + of_graph_parse_endpoint(ep, );
> + num_pads = max(num_pads, endpoint.port + 1);
> + }
> +
> + if (num_pads < 2) {
> + dev_err(>dev, "Not enough ports %d\n", num_pads);
> + return -EINVAL;
> + }

This unveils another runtime dependency on OF.

> +
> + ret = of_get_reg_field(np, );
> + if (ret == 0) {
> + map = syscon_node_to_regmap(np->parent);
> + if (!map) {
> + dev_err(>dev, "Failed to get syscon register 
> map\n");
> + return PTR_ERR(map);
> + }
> +
> + vidsw->field = devm_regmap_field_alloc(>dev, map, field);
> + if (IS_ERR(vidsw->field)) {
> + dev_err(>dev, "Failed to allocate regmap 
> field\n");
> + return PTR_ERR(vidsw->field);
> + }
> +
> + regmap_field_read(vidsw->field, >active);
> + } else {
> + if (num_pads > 3) {
> + dev_err(>dev, "Too many ports %d\n", num_pads);
> + return -EINVAL;
> + }
> +
> + vidsw->gpio = devm_gpiod_get(>dev, NULL, GPIOD_OUT_LOW);
> + if (IS_ERR(vidsw->gpio)) {
> +  

[PATCH 36/44] staging: unisys: visorbus: add error handling to initiate_chipset_device_pause_resume

2017-03-28 Thread David Kershner
Clean up the function to remove some if statments that should be done
in the calling function.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 74 +++---
 1 file changed, 32 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 0aa731d..58e4009 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1199,62 +1199,38 @@ resume_state_change_complete(struct visor_device *dev, 
int status)
  * via a callback function; see pause_state_change_complete() and
  * resume_state_change_complete().
  */
-static void
+static int
 initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause)
 {
-   int rc;
+   int err;
struct visor_driver *drv = NULL;
-   void (*notify_func)(struct visor_device *dev, int response) = NULL;
-
-   if (is_pause)
-   notify_func = device_pause_response;
-   else
-   notify_func = device_resume_response;
-   if (!notify_func)
-   return;
 
drv = to_visor_driver(dev->device.driver);
-   if (!drv) {
-   (*notify_func)(dev, -ENODEV);
-   return;
-   }
+   if (!drv)
+   return -ENODEV;
 
-   if (dev->pausing || dev->resuming) {
-   (*notify_func)(dev, -EBUSY);
-   return;
-   }
+   if (dev->pausing || dev->resuming)
+   return -EBUSY;
 
if (is_pause) {
-   if (!drv->pause) {
-   (*notify_func)(dev, -EINVAL);
-   return;
-   }
+   if (!drv->pause)
+   return -EINVAL;
 
dev->pausing = true;
-   rc = drv->pause(dev, pause_state_change_complete);
+   err = drv->pause(dev, pause_state_change_complete);
} else {
-   /* This should be done at BUS resume time, but an
-* existing problem prevents us from ever getting a bus
-* resume...  This hack would fail to work should we
-* ever have a bus that contains NO devices, since we
-* would never even get here in that case.
+   /* The vbus_dev_info structure in the channel was been
+* cleared, make sure it is valid.
 */
fix_vbus_dev_info(dev);
-   if (!drv->resume) {
-   (*notify_func)(dev, -EINVAL);
-   return;
-   }
+   if (!drv->resume)
+   return -EINVAL;
 
dev->resuming = true;
-   rc = drv->resume(dev, resume_state_change_complete);
-   }
-   if (rc < 0) {
-   if (is_pause)
-   dev->pausing = false;
-   else
-   dev->resuming = false;
-   (*notify_func)(dev, -EINVAL);
+   err = drv->resume(dev, resume_state_change_complete);
}
+
+   return err;
 }
 
 /**
@@ -1268,7 +1244,14 @@ initiate_chipset_device_pause_resume(struct visor_device 
*dev, bool is_pause)
 void
 chipset_device_pause(struct visor_device *dev_info)
 {
-   initiate_chipset_device_pause_resume(dev_info, true);
+   int err;
+
+   err = initiate_chipset_device_pause_resume(dev_info, true);
+
+   if (err < 0) {
+   dev_info->pausing = false;
+   device_pause_response(dev_info, err);
+   }
 }
 
 /**
@@ -1282,7 +1265,14 @@ chipset_device_pause(struct visor_device *dev_info)
 void
 chipset_device_resume(struct visor_device *dev_info)
 {
-   initiate_chipset_device_pause_resume(dev_info, false);
+   int err;
+
+   err = initiate_chipset_device_pause_resume(dev_info, false);
+
+   if (err < 0) {
+   device_resume_response(dev_info, err);
+   dev_info->resuming = false;
+   }
 }
 
 int
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 38/44] staging: unisys: visorbus: get rid of braces around single statements

2017-03-28 Thread David Kershner
Remove braces around single line if statements, they are not needed.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index e094a50..4348072 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -710,9 +710,9 @@ get_vbus_header_info(struct visorchannel *chan,
return -EINVAL;
 
if (hdr_info->device_info_struct_bytes <
-   sizeof(struct ultra_vbus_deviceinfo)) {
+   sizeof(struct ultra_vbus_deviceinfo))
return -EINVAL;
-   }
+
return 0;
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/44] staging: unisys: visorbus: add error handling textid_show

2017-03-28 Thread David Kershner
Don't just drop the error from visorchannel_read on the floor, report it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index b09ef4c..cd2f419 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -205,12 +205,16 @@ static ssize_t textid_show(struct device *dev, struct 
device_attribute *attr,
   char *buf)
 {
u32 text_id = 0;
+   int err;
+
+   err = visorchannel_read
+   (chipset_dev->controlvm_channel,
+offsetof(struct spar_controlvm_channel_protocol,
+ installation_text_id),
+_id, sizeof(u32));
+   if (err)
+   return err;
 
-   visorchannel_read
-   (chipset_dev->controlvm_channel,
-offsetof(struct spar_controlvm_channel_protocol,
- installation_text_id),
-_id, sizeof(u32));
return sprintf(buf, "%i\n", text_id);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 27/44] staging: unisys: visorbus: add error handling visorbus_enable_channel_interrupt

2017-03-28 Thread David Kershner
Add error handling to visorbus_enable_channel_interrupt.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/include/visorbus.h   | 2 +-
 drivers/staging/unisys/visorbus/visorbus_main.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/include/visorbus.h 
b/drivers/staging/unisys/include/visorbus.h
index 6582939..de06355 100644
--- a/drivers/staging/unisys/include/visorbus.h
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -180,7 +180,7 @@ int visorbus_read_channel(struct visor_device *dev,
 int visorbus_write_channel(struct visor_device *dev,
   unsigned long offset, void *src,
   unsigned long nbytes);
-void visorbus_enable_channel_interrupts(struct visor_device *dev);
+int visorbus_enable_channel_interrupts(struct visor_device *dev);
 void visorbus_disable_channel_interrupts(struct visor_device *dev);
 
 /* Levels of severity for diagnostic events, in order from lowest severity to
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index c97f32f..bf0f191 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -580,17 +580,17 @@ EXPORT_SYMBOL_GPL(visorbus_write_channel);
  * Currently we don't yet have a real interrupt, so for now we just call the
  * interrupt function periodically via a timer.
  */
-void
+int
 visorbus_enable_channel_interrupts(struct visor_device *dev)
 {
struct visor_driver *drv = to_visor_driver(dev->device.driver);
 
if (!drv->channel_interrupt) {
dev_err(>device, "%s no interrupt function!\n", __func__);
-   return;
+   return -ENOENT;
}
 
-   dev_start_periodic_work(dev);
+   return dev_start_periodic_work(dev);
 }
 EXPORT_SYMBOL_GPL(visorbus_enable_channel_interrupts);
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/44] staging: unisys: visorbus: add error handling to controlvm_periodic_work

2017-03-28 Thread David Kershner
The function controlvm_periodic_work should handle errors appropriately.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 67 +--
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index d4f4afe..8185430 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1727,52 +1727,49 @@ static void
 controlvm_periodic_work(struct work_struct *work)
 {
struct controlvm_message inmsg;
-   bool got_command = false;
-   bool handle_command_failed = false;
-
-   while (!visorchannel_signalremove(chipset_dev->controlvm_channel,
- CONTROLVM_QUEUE_RESPONSE,
- ))
-   ;
-   if (!got_command) {
-   if (chipset_dev->controlvm_pending_msg_valid) {
-   /*
-* we throttled processing of a prior
-* msg, so try to process it again
-* rather than reading a new one
-*/
-   inmsg = chipset_dev->controlvm_pending_msg;
-   chipset_dev->controlvm_pending_msg_valid = false;
-   got_command = true;
-   } else {
-   got_command = (read_controlvm_event() == 0);
-   }
+   int err;
+
+   /* Drain the RESPONSE queue make it empty */
+   do {
+   err = visorchannel_signalremove(chipset_dev->controlvm_channel,
+   CONTROLVM_QUEUE_RESPONSE,
+   );
+   } while (!err);
+
+   if (err != -EAGAIN)
+   goto schedule_out;
+
+   if (chipset_dev->controlvm_pending_msg_valid) {
+   /*
+* we throttled processing of a prior
+* msg, so try to process it again
+* rather than reading a new one
+*/
+   inmsg = chipset_dev->controlvm_pending_msg;
+   chipset_dev->controlvm_pending_msg_valid = false;
+   err = 0;
+   } else {
+   err = read_controlvm_event();
}
 
-   handle_command_failed = false;
-   while (got_command && (!handle_command_failed)) {
+   while (!err) {
chipset_dev->most_recent_message_jiffies = jiffies;
-   if (handle_command(inmsg,
-  visorchannel_get_physaddr
-  (chipset_dev->controlvm_channel) != -EAGAIN))
-   got_command = (read_controlvm_event() == 0);
-   else {
-   /*
-* this is a scenario where throttling
-* is required, but probably NOT an
-* error...; we stash the current
-* controlvm msg so we will attempt to
-* reprocess it on our next loop
-*/
-   handle_command_failed = true;
+   err = handle_command(inmsg,
+visorchannel_get_physaddr
+(chipset_dev->controlvm_channel));
+   if (err == -EAGAIN) {
chipset_dev->controlvm_pending_msg = inmsg;
chipset_dev->controlvm_pending_msg_valid = true;
+   break;
}
+
+   err = read_controlvm_event();
}
 
/* parahotplug_worker */
parahotplug_process_list();
 
+schedule_out:
if (time_after(jiffies, chipset_dev->most_recent_message_jiffies +
(HZ * MIN_IDLE_SECONDS))) {
/*
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 41/44] staging: unisys: visorbus: get rid of ISSUE_IO_VMCALL

2017-03-28 Thread David Kershner
The macro ISSUE_IO_VMCALL was a wrapper around the function unisys_vmcall.
It doesn't need to exist and was just being noisy, so get rid of it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c| 2 +-
 drivers/staging/unisys/visorbus/vmcallinterface.h | 8 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 260307b..b6e2b8e 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1362,7 +1362,7 @@ issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 
*control_bytes)
u64 physaddr;
 
physaddr = virt_to_phys();
-   ISSUE_IO_VMCALL(VMCALL_CONTROLVM_ADDR, physaddr, result);
+   unisys_vmcall(VMCALL_CONTROLVM_ADDR, physaddr, result);
if (VMCALL_SUCCESSFUL(result)) {
*control_addr = params.address;
*control_bytes = params.channel_bytes;
diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h 
b/drivers/staging/unisys/visorbus/vmcallinterface.h
index 8d5a84f..abc10fa 100644
--- a/drivers/staging/unisys/visorbus/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -81,13 +81,11 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL 
identification tuples  */
 #define VMCALL_SUCCESS 0
 #define VMCALL_SUCCESSFUL(result) (result == 0)
 
-#define unisys_vmcall(tuple, reg_ebx, reg_ecx) \
-   __unisys_vmcall_gnuc(tuple, reg_ebx, reg_ecx)
 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
-#define ISSUE_IO_VMCALL(method, param, result) \
-   (result = unisys_vmcall(method, (param) & 0x, \
-   (param) >> 32))
+#define unisys_vmcall(method, param, result) \
+   (result = __unisys_vmcall_gnuc((method), (param) & 0x, \
+  (param) >> 32))
 
 /* Structures for IO VMCALLs */
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/44] staging: unisys: visorbus: convert ret to err to be consistent

2017-03-28 Thread David Kershner
The ret variable was only returning an error, so changing it to err to
be more consistent across the file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index b2b201b..0f30ff9 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -108,19 +108,19 @@ static ssize_t toolaction_store(struct device *dev,
const char *buf, size_t count)
 {
u8 tool_action;
-   int ret;
+   int err;
 
if (kstrtou8(buf, 10, _action))
return -EINVAL;
 
-   ret = visorchannel_write
+   err = visorchannel_write
(chipset_dev->controlvm_channel,
 offsetof(struct spar_controlvm_channel_protocol,
  tool_action),
 _action, sizeof(u8));
 
-   if (ret)
-   return ret;
+   if (err)
+   return err;
return count;
 }
 static DEVICE_ATTR_RW(toolaction);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 44/44] staging: unisys: visorbus: Have unisys_vmcall return Linux error instead of VMCALL error

2017-03-28 Thread David Kershner
The function unisys_vmcall was returning VMCALL specific errors and the
calling code was ignoring which error was actually returned. Instead we
should be mapping the VMCALL error into a proper Linux error and then
returning that, since we now have an error we know what to do with, we
don't have to drop it but we can send it up the stack.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c| 33 +++-
 drivers/staging/unisys/visorbus/vmcallinterface.h | 10 -
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 9c48cfa..c370b6d 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1371,22 +1371,37 @@ static int unisys_vmcall(unsigned long tuple, unsigned 
long param)
__asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
"a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
 
-   return result;
+   if (result)
+   goto error;
+
+   return 0;
+
+error: /* Need to convert from VMCALL error codes to Linux */
+   switch (result) {
+   case VMCALL_RESULT_INVALID_PARAM:
+   return -EINVAL;
+   case VMCALL_RESULT_DATA_UNAVAILABLE:
+   return -ENODEV;
+   default:
+   return -EFAULT;
+   }
 }
 static unsigned int
 issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
 {
struct vmcall_io_controlvm_addr_params params;
-   int result = VMCALL_SUCCESS;
+   int err;
u64 physaddr;
 
physaddr = virt_to_phys();
-   result = unisys_vmcall(VMCALL_CONTROLVM_ADDR, physaddr);
-   if (VMCALL_SUCCESSFUL(result)) {
-   *control_addr = params.address;
-   *control_bytes = params.channel_bytes;
-   }
-   return result;
+   err = unisys_vmcall(VMCALL_CONTROLVM_ADDR, physaddr);
+   if (err)
+   return err;
+
+   *control_addr = params.address;
+   *control_bytes = params.channel_bytes;
+
+   return 0;
 }
 
 static u64 controlvm_get_channel_address(void)
@@ -1394,7 +1409,7 @@ static u64 controlvm_get_channel_address(void)
u64 addr = 0;
u32 size = 0;
 
-   if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(, )))
+   if (issue_vmcall_io_controlvm_addr(, ))
return 0;
 
return addr;
diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h 
b/drivers/staging/unisys/visorbus/vmcallinterface.h
index 1b36505..1440cc8 100644
--- a/drivers/staging/unisys/visorbus/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -62,8 +62,14 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL 
identification tuples  */
VMCALL_UPDATE_PHYSICAL_TIME = 0x0a02
 };
 
-#define VMCALL_SUCCESS 0
-#define VMCALL_SUCCESSFUL(result) (result == 0)
+enum vmcall_result {
+   VMCALL_RESULT_SUCCESS = 0,
+   VMCALL_RESULT_INVALID_PARAM = 1,
+   VMCALL_RESULT_DATA_UNAVAILABLE = 2,
+   VMCALL_RESULT_FAILURE_UNAVAILABLE = 3,
+   VMCALL_RESULT_DEVICE_ERROR = 4,
+   VMCALL_RESULT_DEVICE_NOT_READY = 5
+};
 
 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 42/44] staging: unisys: visorbus: Update vmcallinterface comment

2017-03-28 Thread David Kershner
The comment at the beginning of the vmcallinterface.h file references IO
Virtualization. It should be more specific that it is referencing s-Par
Virtualization.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/vmcallinterface.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h 
b/drivers/staging/unisys/visorbus/vmcallinterface.h
index abc10fa..df6ee54 100644
--- a/drivers/staging/unisys/visorbus/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -16,9 +16,9 @@
 #define __VMCALLINTERFACE_H__
 
 /*
- * This file contains all structures needed to support the VMCALLs for IO
- * Virtualization.  The VMCALLs are provided by Monitor and used by IO code
- * running on IO Partitions.
+ * This file contains all structures needed to support the VMCALLs for s-Par
+ * Virtualization.  The VMCALLs are provided by Monitor and used by s-Par
+ * drivers running in a Linux guest partition.
  */
 static inline unsigned long
 __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 34/44] staging: unisys: visorbus: don't ignore visorchannel_read error

2017-03-28 Thread David Kershner
Don't override the visorchannel_read_error, just return the
error that it generates.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index f5b637c..af9bf24 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -691,6 +691,8 @@ static int
 get_vbus_header_info(struct visorchannel *chan,
 struct spar_vbus_headerinfo *hdr_info)
 {
+   int err;
+
if (!spar_check_channel(visorchannel_get_header(chan),
spar_vbus_channel_protocol_uuid,
"vbus",
@@ -699,10 +701,11 @@ get_vbus_header_info(struct visorchannel *chan,
SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE))
return -EINVAL;
 
-   if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info,
- sizeof(*hdr_info)) < 0) {
-   return -EIO;
-   }
+   err = visorchannel_read(chan, sizeof(struct channel_header), hdr_info,
+   sizeof(*hdr_info));
+   if (err < 0)
+   return err;
+
if (hdr_info->struct_bytes < sizeof(struct spar_vbus_headerinfo))
return -EINVAL;
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 33/44] staging: unisys: visorbus: check for err from dev_set_name

2017-03-28 Thread David Kershner
The function dev_set_name can return an error, don't just ignore it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index ce897a2..f5b637c 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -642,8 +642,10 @@ create_visor_device(struct visor_device *dev)
 * (NOT bus instance).  That's why we need to include the bus
 * number within the name.
 */
-   dev_set_name(>device, "vbus%u:dev%u",
-chipset_bus_no, chipset_dev_no);
+   err = dev_set_name(>device, "vbus%u:dev%u",
+  chipset_bus_no, chipset_dev_no);
+   if (err)
+   goto err_put;
 
/*
 * device_add does this:
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 35/44] staging: unisys: visorbus: don't unregister if we failed to register

2017-03-28 Thread David Kershner
If we fail to register the visordriver, don't call unregister, just
return with the error.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index af9bf24..0aa731d 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -959,8 +959,6 @@ visordriver_probe_device(struct device *xdev)
  */
 int visorbus_register_visor_driver(struct visor_driver *drv)
 {
-   int rc = 0;
-
drv->driver.name = drv->name;
drv->driver.bus = _type;
drv->driver.probe = visordriver_probe_device;
@@ -980,10 +978,7 @@ int visorbus_register_visor_driver(struct visor_driver 
*drv)
 * dev.drv = NULL
 */
 
-   rc = driver_register(>driver);
-   if (rc < 0)
-   driver_unregister(>driver);
-   return rc;
+   return driver_register(>driver);
 }
 EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 39/44] staging: unisys: visorbus: consolidate if statements

2017-03-28 Thread David Kershner
We had several if statements inside of if statements that should be
consolidated into an if statement with an && to clean up the code some
more.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchannel.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c 
b/drivers/staging/unisys/visorbus/visorchannel.c
index 686137a..8c27b56 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -418,12 +418,9 @@ visorchannel_create_guts(u64 physaddr, unsigned long 
channel_bytes,
 * release later on.
 */
channel->requested = request_mem_region(physaddr, size, MYDRVNAME);
-   if (!channel->requested) {
-   if (uuid_le_cmp(guid, spar_video_guid)) {
-   /* Not the video channel we care about this */
-   goto err_destroy_channel;
-   }
-   }
+   if (!channel->requested && uuid_le_cmp(guid, spar_video_guid))
+   /* we only care about errors if this is not the video channel */
+   goto err_destroy_channel;
 
channel->mapped = memremap(physaddr, size, MEMREMAP_WB);
if (!channel->mapped) {
@@ -451,12 +448,9 @@ visorchannel_create_guts(u64 physaddr, unsigned long 
channel_bytes,
channel->mapped = NULL;
channel->requested = request_mem_region(channel->physaddr,
channel_bytes, MYDRVNAME);
-   if (!channel->requested) {
-   if (uuid_le_cmp(guid, spar_video_guid)) {
-   /* Different we care about this */
-   goto err_destroy_channel;
-   }
-   }
+   if (!channel->requested && uuid_le_cmp(guid, spar_video_guid))
+   /* we only care about errors if this is not the video channel */
+   goto err_destroy_channel;
 
channel->mapped = memremap(channel->physaddr, channel_bytes,
MEMREMAP_WB);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 43/44] staging: unisys: visorbus: move unisys_vmcall into visorchipset

2017-03-28 Thread David Kershner
The only one using unisys_vmcall was visorchipset.c, it can be moved into
the visorchipset file directly instead of being in a header file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c| 21 +++-
 drivers/staging/unisys/visorbus/vmcallinterface.h | 19 +--
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index b6e2b8e..9c48cfa 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1354,6 +1354,25 @@ chipset_notready_uevent(struct controlvm_message_header 
*msg_hdr)
return res;
 }
 
+static int unisys_vmcall(unsigned long tuple, unsigned long param)
+{
+   int result = 0;
+   unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
+   unsigned long reg_ebx;
+   unsigned long reg_ecx;
+
+   reg_ebx = param & 0x;
+   reg_ecx = param >> 32;
+
+   cpuid(0x0001, _eax, _ebx, _ecx, _edx);
+   if (!(cpuid_ecx & 0x8000))
+   return -EPERM;
+
+   __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
+   "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
+
+   return result;
+}
 static unsigned int
 issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
 {
@@ -1362,7 +1381,7 @@ issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 
*control_bytes)
u64 physaddr;
 
physaddr = virt_to_phys();
-   unisys_vmcall(VMCALL_CONTROLVM_ADDR, physaddr, result);
+   result = unisys_vmcall(VMCALL_CONTROLVM_ADDR, physaddr);
if (VMCALL_SUCCESSFUL(result)) {
*control_addr = params.address;
*control_bytes = params.channel_bytes;
diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h 
b/drivers/staging/unisys/visorbus/vmcallinterface.h
index df6ee54..1b36505 100644
--- a/drivers/staging/unisys/visorbus/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -21,22 +21,6 @@
  * drivers running in a Linux guest partition.
  */
 static inline unsigned long
-__unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx,
-unsigned long reg_ecx)
-{
-   unsigned long result = 0;
-   unsigned int cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
-
-   cpuid(0x0001, _eax, _ebx, _ecx, _edx);
-   if (!(cpuid_ecx & 0x8000))
-   return -EPERM;
-
-   __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) :
-   "a"(tuple), "b"(reg_ebx), "c"(reg_ecx));
-   return result;
-}
-
-static inline unsigned long
 __unisys_extended_vmcall_gnuc(unsigned long long tuple,
  unsigned long long reg_ebx,
  unsigned long long reg_ecx,
@@ -83,9 +67,6 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL 
identification tuples  */
 
 #define unisys_extended_vmcall(tuple, reg_ebx, reg_ecx, reg_edx) \
__unisys_extended_vmcall_gnuc(tuple, reg_ebx, reg_ecx, reg_edx)
-#define unisys_vmcall(method, param, result) \
-   (result = __unisys_vmcall_gnuc((method), (param) & 0x, \
-  (param) >> 32))
 
 /* Structures for IO VMCALLs */
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 40/44] staging: unisys: visorbus: remove useless ifdef

2017-03-28 Thread David Kershner
We shouldn't be checking if VMCALL_CONTROLVM_ADDR is defined, remove it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/vmcallinterface.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/vmcallinterface.h 
b/drivers/staging/unisys/visorbus/vmcallinterface.h
index 06bd300..8d5a84f 100644
--- a/drivers/staging/unisys/visorbus/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -54,10 +54,6 @@ __unisys_extended_vmcall_gnuc(unsigned long long tuple,
return result;
 }
 
-#ifdef VMCALL_CONTROLVM_ADDR
-#undef VMCALL_CONTROLVM_ADDR
-#endif /*  */
-
 /* define subsystem number for AppOS, used in uislib driver  */
 #define MDS_APPOS 0x4000L /* subsystem = 62 - AppOS */
 enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  
*/
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 37/44] staging: unisys: visorbus: add error handling to chipset_device_pause/resume

2017-03-28 Thread David Kershner
If there is an error in chipset_device_pause/resume don't try to respond,
error out and let the calling functions respond to this error just like
any other error they encounter.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c| 12 
 drivers/staging/unisys/visorbus/visorbus_private.h |  4 ++--
 drivers/staging/unisys/visorbus/visorchipset.c |  9 ++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 58e4009..e094a50 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1241,7 +1241,7 @@ initiate_chipset_device_pause_resume(struct visor_device 
*dev, bool is_pause)
  * that device.  Success/failure result is returned asynchronously
  * via a callback function; see pause_state_change_complete().
  */
-void
+int
 chipset_device_pause(struct visor_device *dev_info)
 {
int err;
@@ -1250,8 +1250,10 @@ chipset_device_pause(struct visor_device *dev_info)
 
if (err < 0) {
dev_info->pausing = false;
-   device_pause_response(dev_info, err);
+   return err;
}
+
+   return 0;
 }
 
 /**
@@ -1262,7 +1264,7 @@ chipset_device_pause(struct visor_device *dev_info)
  * that device.  Success/failure result is returned asynchronously
  * via a callback function; see resume_state_change_complete().
  */
-void
+int
 chipset_device_resume(struct visor_device *dev_info)
 {
int err;
@@ -1270,9 +1272,11 @@ chipset_device_resume(struct visor_device *dev_info)
err = initiate_chipset_device_pause_resume(dev_info, false);
 
if (err < 0) {
-   device_resume_response(dev_info, err);
dev_info->resuming = false;
+   return err;
}
+
+   return 0;
 }
 
 int
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h 
b/drivers/staging/unisys/visorbus/visorbus_private.h
index 7efe4d4..9f030b1 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -31,8 +31,8 @@ int chipset_bus_create(struct visor_device *bus_info);
 void chipset_bus_destroy(struct visor_device *bus_info);
 int chipset_device_create(struct visor_device *dev_info);
 void chipset_device_destroy(struct visor_device *dev_info);
-void chipset_device_pause(struct visor_device *dev_info);
-void chipset_device_resume(struct visor_device *dev_info);
+int chipset_device_pause(struct visor_device *dev_info);
+int chipset_device_resume(struct visor_device *dev_info);
 
 void bus_create_response(struct visor_device *p, int response);
 void bus_destroy_response(struct visor_device *p, int response);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index be1171e..260307b 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -883,7 +883,7 @@ my_device_changestate(struct controlvm_message *inmsg)
u32 dev_no = cmd->device_change_state.dev_no;
struct spar_segment_state state = cmd->device_change_state.state;
struct visor_device *dev_info;
-   int err;
+   int err = 0;
 
dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL);
if (!dev_info) {
@@ -918,7 +918,7 @@ my_device_changestate(struct controlvm_message *inmsg)
if (state.alive == segment_state_running.alive &&
state.operating == segment_state_running.operating)
/* Response will be sent from chipset_device_resume */
-   chipset_device_resume(dev_info);
+   err = chipset_device_resume(dev_info);
/* ServerNotReady / ServerLost / SegmentStateStandby */
else if (state.alive == segment_state_standby.alive &&
 state.operating == segment_state_standby.operating)
@@ -926,7 +926,10 @@ my_device_changestate(struct controlvm_message *inmsg)
 * technically this is standby case where server is lost.
 * Response will be sent from chipset_device_pause.
 */
-   chipset_device_pause(dev_info);
+   err = chipset_device_pause(dev_info);
+   if (err)
+   goto err_respond;
+
return 0;
 
 err_respond:
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 32/44] staging: unisys: visorbus: cleanup error handling in visorbus_uevent

2017-03-28 Thread David Kershner
The add_uevent_var returns an error. Don't overwrite the error with
-ENOMEM, just pass the error code back up.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index f5e7dd6..ce897a2 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -82,9 +82,7 @@ visorbus_uevent(struct device *xdev, struct kobj_uevent_env 
*env)
dev = to_visor_device(xdev);
guid = visorchannel_get_uuid(dev->visorchannel);
 
-   if (add_uevent_var(env, "MODALIAS=visorbus:%pUl", ))
-   return -ENOMEM;
-   return 0;
+   return add_uevent_var(env, "MODALIAS=visorbus:%pUl", );
 }
 
 /*
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 31/44] staging: unisys: visorbus: get rid of unused parameter forcenomatch

2017-03-28 Thread David Kershner
The forcenomatch parameter was not being used, so get rid of it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c |  9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 4e7cfa2..f5e7dd6 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -23,9 +23,6 @@
 
 #define MYDRVNAME "visorbus"
 
-/* module parameters */
-static int visorbus_forcenomatch;
-
 /* Display string that is guaranteed to be no longer the 99 characters*/
 #define LINESIZE 99
 
@@ -111,8 +108,6 @@ visorbus_match(struct device *xdev, struct device_driver 
*xdrv)
drv = to_visor_driver(xdrv);
channel_type = visorchannel_get_uuid(dev->visorchannel);
 
-   if (visorbus_forcenomatch)
-   return 0;
if (!drv->channel_types)
return 0;
 
@@ -1337,7 +1332,3 @@ visorbus_exit(void)
bus_unregister(_type);
debugfs_remove_recursive(visorbus_debugfs_dir);
 }
-
-module_param_named(forcenomatch, visorbus_forcenomatch, int, 0444);
-MODULE_PARM_DESC(visorbus_forcenomatch,
-"1 to force an UNsuccessful dev <--> drv match");
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 29/44] staging: unisys: visorbus: get rid of create_bus_type.

2017-03-28 Thread David Kershner
Create bus_type was just calling register_bustype. Since we control how
many times we call create_bus_type it was extraneous keeping a counter if
the bus was already registered, so the functions were no longer needed.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 32 +-
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 3e756ca..dedcee4 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -33,7 +33,6 @@ static int visorbus_forcenomatch;
 #define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
 #define POLLJIFFIES_NORMALCHANNEL 10
 
-static int busreg_rc = -ENODEV; /* stores the result from bus registration */
 static struct dentry *visorbus_debugfs_dir;
 
 /*
@@ -967,9 +966,6 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
 {
int rc = 0;
 
-   if (busreg_rc < 0)
-   return -ENODEV; /*can't register on a nonexistent bus*/
-
drv->driver.name = drv->name;
drv->driver.bus = _type;
drv->driver.probe = visordriver_probe_device;
@@ -1081,29 +1077,6 @@ remove_bus_instance(struct visor_device *dev)
 }
 
 /*
- * create_bus_type() - create and register the one-and-only one instance of
- * the visor bus type (visorbus_type)
- * Return: 0 for success, otherwise negative errno value returned by
- * bus_register() indicating the reason for failure
- */
-static int
-create_bus_type(void)
-{
-   busreg_rc = bus_register(_type);
-   return busreg_rc;
-}
-
-/*
- * remove_bus_type() - remove the one-and-only one instance of the visor bus
- * type (visorbus_type)
- */
-static void
-remove_bus_type(void)
-{
-   bus_unregister(_type);
-}
-
-/*
  * remove_all_visor_devices() - remove all child visor bus device instances
  */
 static void
@@ -1335,7 +1308,7 @@ visorbus_init(void)
 
bus_device_info_init(_driverinfo, "clientbus", "visorbus");
 
-   err = create_bus_type();
+   err = bus_register(_type);
if (err < 0) {
POSTCODE_LINUX(BUS_CREATE_ENTRY_PC, 0, 0, DIAG_SEVERITY_ERR);
goto error;
@@ -1363,7 +1336,8 @@ visorbus_exit(void)
  list_all);
remove_bus_instance(dev);
}
-   remove_bus_type();
+
+   bus_unregister(_type);
debugfs_remove_recursive(visorbus_debugfs_dir);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 28/44] staging: unisys: visorbus: fix error handling in create_bus_instance

2017-03-28 Thread David Kershner
The function get_vbus_header_info returns errors that were being handled
incorrectly. Fix the error handling in create_bus_instance.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 39 ++
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index bf0f191..3e756ca 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1023,46 +1023,35 @@ create_bus_instance(struct visor_device *dev)
 
dev->debugfs_dir = debugfs_create_dir(dev_name(>device),
  visorbus_debugfs_dir);
-   if (!dev->debugfs_dir) {
-   err = -ENOMEM;
-   goto err_hdr_info;
-   }
dev->debugfs_client_bus_info =
debugfs_create_file("client_bus_info", 0440,
dev->debugfs_dir, dev,
_bus_info_debugfs_fops);
-   if (!dev->debugfs_client_bus_info) {
-   err = -ENOMEM;
+
+   dev_set_drvdata(>device, dev);
+   err = get_vbus_header_info(dev->visorchannel, hdr_info);
+   if (err < 0)
goto err_debugfs_dir;
-   }
 
-   if (device_register(>device) < 0) {
+   err = device_register(>device);
+   if (err < 0) {
POSTCODE_LINUX(DEVICE_CREATE_FAILURE_PC, 0, id,
   DIAG_SEVERITY_ERR);
-   err = -ENODEV;
-   goto err_debugfs_created;
+   goto err_debugfs_dir;
}
 
-   if (get_vbus_header_info(dev->visorchannel, hdr_info) >= 0) {
-   dev->vbus_hdr_info = (void *)hdr_info;
-   write_vbus_chp_info(dev->visorchannel, hdr_info,
-   _driverinfo);
-   write_vbus_bus_info(dev->visorchannel, hdr_info,
-   _driverinfo);
-   } else {
-   kfree(hdr_info);
-   }
list_add_tail(>list_all, _all_bus_instances);
-   dev_set_drvdata(>device, dev);
-   return 0;
 
-err_debugfs_created:
-   debugfs_remove(dev->debugfs_client_bus_info);
+   dev->vbus_hdr_info = (void *)hdr_info;
+   write_vbus_chp_info(dev->visorchannel, hdr_info,
+   _driverinfo);
+   write_vbus_bus_info(dev->visorchannel, hdr_info,
+   _driverinfo);
+
+   return 0;
 
 err_debugfs_dir:
debugfs_remove_recursive(dev->debugfs_dir);
-
-err_hdr_info:
kfree(hdr_info);
return err;
 }
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/44] staging: unisys: visorbus: add __packed to structures in controlvmchannel.h

2017-03-28 Thread David Kershner
From: Sameer Wadgaonkar 

Added the __packed keyword to all structures in controlvmchannel.h
to ensure alignment and size in memory.

Signed-off-by: Sameer Wadgaonkar 
Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/controlvmchannel.h | 58 ---
 1 file changed, 34 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/controlvmchannel.h 
b/drivers/staging/unisys/visorbus/controlvmchannel.h
index 63f9e44..e66d154 100644
--- a/drivers/staging/unisys/visorbus/controlvmchannel.h
+++ b/drivers/staging/unisys/visorbus/controlvmchannel.h
@@ -69,10 +69,12 @@ struct spar_segment_state  {
u16 ready:1;
/* Bit 7: resource is configured and operating */
u16 operating:1;
+   /* Natural alignment*/
+   u16 reserved:8;
 /* Note: don't use high bit unless we need to switch to ushort
  * which is non-compliant
  */
-};
+} __packed;
 
 static const struct spar_segment_state segment_state_running = {
1, 1, 1, 0, 1, 1, 1, 1
@@ -145,7 +147,7 @@ struct irq_info {
  */
u8 recv_irq_shared;
u8 reserved[3]; /* Natural alignment purposes */
-};
+} __packed;
 
 struct efi_spar_indication  {
u64 boot_to_fw_ui:1;/* Bit 0: Stop in uefi ui */
@@ -153,7 +155,8 @@ struct efi_spar_indication  {
u64 clear_cmos:1;   /* Bit 2: Clear CMOS */
u64 boot_to_tool:1; /* Bit 3: Run install tool */
/* remaining bits are available */
-};
+   u64 reserved:60;/* Natural alignment */
+} __packed;
 
 enum ultra_chipset_feature {
ULTRA_CHIPSET_FEATURE_REPLY = 0x0001,
@@ -195,7 +198,9 @@ struct controlvm_message_header  {
u32 preserve:1;
/* =1 the DiagWriter is active in the Diagnostic Partition */
u32 writer_in_diag:1;
-   } flags;
+   /* Natural alignment */
+   u32 reserve:25;
+   } __packed flags;
/* Natural alignment */
u32 reserved;
/* Identifies the particular message instance */
@@ -208,7 +213,7 @@ struct controlvm_message_header  {
/* Actual number of bytes of payload area to copy between IO/Command */
u32 payload_bytes;
/* if non-zero, there is a payload to copy. */
-};
+} __packed;
 
 struct controlvm_packet_device_create  {
u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */
@@ -221,24 +226,24 @@ struct controlvm_packet_device_create  {
uuid_le data_type_uuid; /* specifies format of data in channel */
uuid_le dev_inst_uuid;  /* instance guid for the device */
struct irq_info intr;   /* specifies interrupt information */
-}; /* for CONTROLVM_DEVICE_CREATE */
+} __packed;/* for CONTROLVM_DEVICE_CREATE */
 
 struct controlvm_packet_device_configure  {
/* bus # (0..n-1) from the msg receiver's perspective */
u32 bus_no;
/* Control uses header SegmentIndex field to access bus number... */
u32 dev_no;   /* bus-relative (0..n-1) device number */
-} ;/* for CONTROLVM_DEVICE_CONFIGURE */
+} __packed;/* for CONTROLVM_DEVICE_CONFIGURE */
 
 struct controlvm_message_device_create {
struct controlvm_message_header header;
struct controlvm_packet_device_create packet;
-}; /* total 128 bytes */
+} __packed;/* total 128 bytes */
 
 struct controlvm_message_device_configure  {
struct controlvm_message_header header;
struct controlvm_packet_device_configure packet;
-}; /* total 56 bytes */
+} __packed;/* total 56 bytes */
 
 /* This is the format for a message in any ControlVm queue. */
 struct controlvm_message_packet  {
@@ -256,12 +261,12 @@ struct controlvm_message_packet  {
/* indicates format of data in bus channel*/
uuid_le bus_data_type_uuid;
uuid_le bus_inst_uuid;  /* instance uuid for the bus */
-   } create_bus;   /* for CONTROLVM_BUS_CREATE */
+   } __packed create_bus;  /* for CONTROLVM_BUS_CREATE */
struct  {
/* bus # (0..n-1) from the msg receiver's perspective */
u32 bus_no;
u32 reserved;   /* Natural alignment purposes */
-   } destroy_bus;  /* for CONTROLVM_BUS_DESTROY */
+   } __packed destroy_bus; /* for CONTROLVM_BUS_DESTROY */
struct  {
/* bus # (0..n-1) from the receiver's perspective */
u32 bus_no;
@@ -275,26 +280,27 @@ struct controlvm_message_packet  {
 * notifications.  The corresponding
 * sendBusInterruptHandle is kept in CP.
 */
-   } configure_bus;/* for 

[PATCH 25/44] staging: unisys: remove client from spar_check_channel

2017-03-28 Thread David Kershner
We only have one version of spar_check_channel, get rid of the client
at the end and help save space.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/include/channel.h   | 12 +--
 drivers/staging/unisys/include/iochannel.h | 16 +++
 drivers/staging/unisys/visorbus/controlvmchannel.h | 12 +--
 drivers/staging/unisys/visorbus/visorbus_main.c| 13 +---
 4 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/unisys/include/channel.h 
b/drivers/staging/unisys/include/channel.h
index 71defbd..057421e 100644
--- a/drivers/staging/unisys/include/channel.h
+++ b/drivers/staging/unisys/include/channel.h
@@ -204,12 +204,12 @@ struct signal_queue_header {
  * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
  */
 static inline int
-spar_check_channel_client(struct channel_header *ch,
- uuid_le expected_uuid,
- char *chname,
- u64 expected_min_bytes,
- u32 expected_version,
- u64 expected_signature)
+spar_check_channel(struct channel_header *ch,
+  uuid_le expected_uuid,
+  char *chname,
+  u64 expected_min_bytes,
+  u32 expected_version,
+  u64 expected_signature)
 {
if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
/* caller wants us to verify type GUID */
diff --git a/drivers/staging/unisys/include/iochannel.h 
b/drivers/staging/unisys/include/iochannel.h
index 5d8a500..9bde848 100644
--- a/drivers/staging/unisys/include/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -51,16 +51,16 @@
 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
 
 #define SPAR_VHBA_CHANNEL_OK_CLIENT(ch) \
-   (spar_check_channel_client(ch, spar_vhba_channel_protocol_uuid, \
-  "vhba", MIN_IO_CHANNEL_SIZE, \
-  ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
-  ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+   (spar_check_channel(ch, spar_vhba_channel_protocol_uuid, \
+   "vhba", MIN_IO_CHANNEL_SIZE,\
+   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
+   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
 
 #define SPAR_VNIC_CHANNEL_OK_CLIENT(ch) \
-   (spar_check_channel_client(ch, spar_vnic_channel_protocol_uuid, \
-  "vnic", MIN_IO_CHANNEL_SIZE, \
-  ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
-  ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
+   (spar_check_channel(ch, spar_vnic_channel_protocol_uuid, \
+   "vnic", MIN_IO_CHANNEL_SIZE,\
+   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
+   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
 
 /*
  * Everything necessary to handle SCSI & NIC traffic between Guest Partition 
and
diff --git a/drivers/staging/unisys/visorbus/controlvmchannel.h 
b/drivers/staging/unisys/visorbus/controlvmchannel.h
index e66d154..274f724 100644
--- a/drivers/staging/unisys/visorbus/controlvmchannel.h
+++ b/drivers/staging/unisys/visorbus/controlvmchannel.h
@@ -36,12 +36,12 @@
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
 
 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \
-   (spar_check_channel_client(ch, \
-   SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
-   "controlvm", \
-   sizeof(struct spar_controlvm_channel_protocol), \
-   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
-   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
+   (spar_check_channel(ch, \
+   SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
+   "controlvm", \
+   sizeof(struct spar_controlvm_channel_protocol), \
+   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
+   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
 
 /* Defines for various channel queues */
 #define CONTROLVM_QUEUE_REQUEST 0
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 8b434b0..6f3bbe5 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -699,13 +699,12 @@ static int
 get_vbus_header_info(struct visorchannel *chan,
 struct spar_vbus_headerinfo *hdr_info)
 {
-   if (!spar_check_channel_client(visorchannel_get_header(chan),
-  spar_vbus_channel_protocol_uuid,
-  "vbus",
-  sizeof
-

[PATCH 26/44] staging: unisys: visorbus: add error handling for dev_start_periodic_work

2017-03-28 Thread David Kershner
Report errors if we have a problem in dev_start_periodic_work.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 6f3bbe5..c97f32f 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -464,16 +464,17 @@ dev_periodic_work(unsigned long __opaque)
mod_timer(>timer, jiffies + POLLJIFFIES_NORMALCHANNEL);
 }
 
-static void
+static int
 dev_start_periodic_work(struct visor_device *dev)
 {
if (dev->being_removed || dev->timer_active)
-   return;
+   return -EINVAL;
/* now up by at least 2 */
get_device(>device);
dev->timer.expires = jiffies + POLLJIFFIES_NORMALCHANNEL;
add_timer(>timer);
dev->timer_active = true;
+   return 0;
 }
 
 static void
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 23/44] staging: unisys: visorbus: move vbuschannel_print_devinfo from .h to .c file

2017-03-28 Thread David Kershner
Move vbuschannel_print_devinfo from vbuchannel.h to visorbus_main.c since
it is only referenced in visorbus_main.c. Since it is in a .c file, get
rid of the inline for it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/vbuschannel.h   | 35 +--
 drivers/staging/unisys/visorbus/visorbus_main.c | 34 +-
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/vbuschannel.h 
b/drivers/staging/unisys/visorbus/vbuschannel.h
index 447fef2..4ef70fd 100644
--- a/drivers/staging/unisys/visorbus/vbuschannel.h
+++ b/drivers/staging/unisys/visorbus/vbuschannel.h
@@ -64,41 +64,6 @@ struct ultra_vbus_deviceinfo {
u8 reserved[128];   /* pad size to 256 bytes */
 } __packed;
 
-/*
- * vbuschannel_print_devinfo() - format a struct ultra_vbus_deviceinfo
- *   and write it to a seq_file
- * @devinfo: the struct ultra_vbus_deviceinfo to format
- * @seq: seq_file to write to
- * @devix: the device index to be included in the output data, or -1 if no
- * device index is to be included
- *
- * Reads @devInfo, and writes it in human-readable notation to @seq.
- */
-static inline void
-vbuschannel_print_devinfo(struct ultra_vbus_deviceinfo *devinfo,
- struct seq_file *seq, int devix)
-{
-   if (!isprint(devinfo->devtype[0]))
-   return; /* uninitialized vbus device entry */
-
-   if (devix >= 0)
-   seq_printf(seq, "[%d]", devix);
-   else
-   /* vbus device entry is for bus or chipset */
-   seq_puts(seq, "   ");
-
-   /*
-* Note: because the s-Par back-end is free to scribble in this area,
-* we never assume '\0'-termination.
-*/
-   seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->devtype),
-  (int)sizeof(devinfo->devtype), devinfo->devtype);
-   seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->drvname),
-  (int)sizeof(devinfo->drvname), devinfo->drvname);
-   seq_printf(seq, "%.*s\n", (int)sizeof(devinfo->infostrs),
-  devinfo->infostrs);
-}
-
 struct spar_vbus_headerinfo {
u32 struct_bytes;   /* size of this struct in bytes */
u32 device_info_struct_bytes;   /* sizeof(ULTRA_VBUS_DEVICEINFO) */
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 9ef91c7..094a60e 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -366,6 +366,40 @@ static const struct attribute_group *visorbus_groups[] = {
  *  define & implement display of debugfs attributes under
  *  /sys/kernel/debug/visorbus/visorbus.
  */
+/*
+ * vbuschannel_print_devinfo() - format a struct ultra_vbus_deviceinfo
+ *   and write it to a seq_file
+ * @devinfo: the struct ultra_vbus_deviceinfo to format
+ * @seq: seq_file to write to
+ * @devix: the device index to be included in the output data, or -1 if no
+ * device index is to be included
+ *
+ * Reads @devInfo, and writes it in human-readable notation to @seq.
+ */
+static void
+vbuschannel_print_devinfo(struct ultra_vbus_deviceinfo *devinfo,
+ struct seq_file *seq, int devix)
+{
+   if (!isprint(devinfo->devtype[0]))
+   return; /* uninitialized vbus device entry */
+
+   if (devix >= 0)
+   seq_printf(seq, "[%d]", devix);
+   else
+   /* vbus device entry is for bus or chipset */
+   seq_puts(seq, "   ");
+
+   /*
+* Note: because the s-Par back-end is free to scribble in this area,
+* we never assume '\0'-termination.
+*/
+   seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->devtype),
+  (int)sizeof(devinfo->devtype), devinfo->devtype);
+   seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->drvname),
+  (int)sizeof(devinfo->drvname), devinfo->drvname);
+   seq_printf(seq, "%.*s\n", (int)sizeof(devinfo->infostrs),
+  devinfo->infostrs);
+}
 
 static int client_bus_info_debugfs_show(struct seq_file *seq, void *v)
 {
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 21/44] staging: unisys: visorbus: add error handling for chipset_device_create

2017-03-28 Thread David Kershner
Adds error handling to the chipset_device_create message. If it returns
a failure, it is assumed it has not signaled the s-Par firmware of the
failure and the caller must do that.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c| 22 ---
 drivers/staging/unisys/visorbus/visorbus_private.h |  2 +-
 drivers/staging/unisys/visorbus/visorchipset.c | 12 ++--
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 87fb343..9ef91c7 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1118,25 +1118,29 @@ chipset_bus_destroy(struct visor_device *dev)
bus_destroy_response(dev, 0);
 }
 
-void
+int
 chipset_device_create(struct visor_device *dev_info)
 {
-   int rc;
+   int err;
u32 bus_no = dev_info->chipset_bus_no;
u32 dev_no = dev_info->chipset_dev_no;
 
POSTCODE_LINUX(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
   DIAG_SEVERITY_PRINT);
 
-   rc = create_visor_device(dev_info);
-   device_create_response(dev_info, rc);
-
-   if (rc < 0)
+   err = create_visor_device(dev_info);
+   if (err < 0) {
POSTCODE_LINUX(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
   DIAG_SEVERITY_ERR);
-   else
-   POSTCODE_LINUX(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
-  DIAG_SEVERITY_PRINT);
+   return err;
+   }
+
+   POSTCODE_LINUX(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
+  DIAG_SEVERITY_PRINT);
+
+   device_create_response(dev_info, err);
+
+   return 0;
 }
 
 void
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h 
b/drivers/staging/unisys/visorbus/visorbus_private.h
index 597c2de..7efe4d4 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -29,7 +29,7 @@
 
 int chipset_bus_create(struct visor_device *bus_info);
 void chipset_bus_destroy(struct visor_device *bus_info);
-void chipset_device_create(struct visor_device *dev_info);
+int chipset_device_create(struct visor_device *dev_info);
 void chipset_device_destroy(struct visor_device *dev_info);
 void chipset_device_pause(struct visor_device *dev_info);
 void chipset_device_resume(struct visor_device *dev_info);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index d7ddf55..2582053 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -853,14 +853,14 @@ my_device_create(struct controlvm_message *inmsg)
spar_vhba_channel_protocol_uuid) == 0) {
err = save_crash_message(inmsg, CRASH_DEV);
if (err)
-   goto err_free_dev_info;
+   goto err_destroy_visorchannel;
}
 
if (inmsg->hdr.flags.response_expected == 1) {
pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
if (!pmsg_hdr) {
err = -ENOMEM;
-   goto err_free_dev_info;
+   goto err_destroy_visorchannel;
}
 
memcpy(pmsg_hdr, >hdr,
@@ -868,11 +868,17 @@ my_device_create(struct controlvm_message *inmsg)
dev_info->pending_msg_hdr = pmsg_hdr;
}
/* Chipset_device_create will send response */
-   chipset_device_create(dev_info);
+   err = chipset_device_create(dev_info);
+   if (err)
+   goto err_destroy_visorchannel;
+
POSTCODE_LINUX(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
   DIAG_SEVERITY_PRINT);
return 0;
 
+err_destroy_visorchannel:
+   visorchannel_destroy(visorchannel);
+
 err_free_dev_info:
kfree(dev_info);
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 24/44] staging: unisys: visorbus: get rid of shouting SPAR_VBUS_CHANNEL_CLIENT_OK macro

2017-03-28 Thread David Kershner
The macro SPAR_VBUS_CHANNEL_CLIENT_OK was noisy and only used in one place
so get rid of it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/vbuschannel.h   | 8 
 drivers/staging/unisys/visorbus/visorbus_main.c | 8 +++-
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/vbuschannel.h 
b/drivers/staging/unisys/visorbus/vbuschannel.h
index 4ef70fd..f0ef5ec 100644
--- a/drivers/staging/unisys/visorbus/vbuschannel.h
+++ b/drivers/staging/unisys/visorbus/vbuschannel.h
@@ -43,14 +43,6 @@ static const uuid_le spar_vbus_channel_protocol_uuid =
  */
 #define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
 
-#define SPAR_VBUS_CHANNEL_OK_CLIENT(ch) \
-   spar_check_channel_client(ch, \
- spar_vbus_channel_protocol_uuid, \
- "vbus", \
- sizeof(struct spar_vbus_channel_protocol), \
- SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
- SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)
-
 /*
  * An array of this struct is present in the channel area for each vbus.
  * (See vbuschannel.h.)
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index 094a60e..8b434b0 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -699,7 +699,13 @@ static int
 get_vbus_header_info(struct visorchannel *chan,
 struct spar_vbus_headerinfo *hdr_info)
 {
-   if (!SPAR_VBUS_CHANNEL_OK_CLIENT(visorchannel_get_header(chan)))
+   if (!spar_check_channel_client(visorchannel_get_header(chan),
+  spar_vbus_channel_protocol_uuid,
+  "vbus",
+  sizeof
+   (struct spar_vbus_channel_protocol),
+  SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID,
+  SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE))
return -EINVAL;
 
if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info,
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/44] staging: unisys: visorbus: textid_store convert ret to err

2017-03-28 Thread David Kershner
The ret variable was only returning an error, so changing it to err to
be more consistent across the file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index b883800..45fc394 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -222,18 +222,18 @@ static ssize_t textid_store(struct device *dev, struct 
device_attribute *attr,
const char *buf, size_t count)
 {
u32 text_id;
-   int ret;
+   int err;
 
if (kstrtou32(buf, 10, _id))
return -EINVAL;
 
-   ret = visorchannel_write
+   err = visorchannel_write
(chipset_dev->controlvm_channel,
 offsetof(struct spar_controlvm_channel_protocol,
  installation_text_id),
 _id, sizeof(u32));
-   if (ret)
-   return ret;
+   if (err)
+   return err;
return count;
 }
 static DEVICE_ATTR_RW(textid);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/44] staging: unisys: visorbus: add error handling to chipset_bus_create

2017-03-28 Thread David Kershner
The function chipset_bus_create should return an error. If an error
is returned, it is assumed the response has not been sent by bus_create.

Correctly handle when the error has been returned in visorchipset.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c| 17 +++
 drivers/staging/unisys/visorbus/visorbus_private.h |  2 +-
 drivers/staging/unisys/visorbus/visorchipset.c |  8 ++-
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index b99adaa..87fb343 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1090,24 +1090,25 @@ remove_all_visor_devices(void)
}
 }
 
-void
+int
 chipset_bus_create(struct visor_device *dev)
 {
-   int rc;
+   int err;
u32 bus_no = dev->chipset_bus_no;
 
POSTCODE_LINUX(BUS_CREATE_ENTRY_PC, 0, bus_no, DIAG_SEVERITY_PRINT);
-   rc = create_bus_instance(dev);
+   err = create_bus_instance(dev);
POSTCODE_LINUX(BUS_CREATE_EXIT_PC, 0, bus_no, DIAG_SEVERITY_PRINT);
 
-   if (rc < 0)
+   if (err < 0) {
POSTCODE_LINUX(BUS_CREATE_FAILURE_PC, 0, bus_no,
   DIAG_SEVERITY_ERR);
-   else
-   POSTCODE_LINUX(CHIPSET_INIT_SUCCESS_PC, 0, bus_no,
-  DIAG_SEVERITY_PRINT);
+   return err;
+   }
 
-   bus_create_response(dev, rc);
+   bus_create_response(dev, err);
+
+   return 0;
 }
 
 void
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h 
b/drivers/staging/unisys/visorbus/visorbus_private.h
index fdccfcb..597c2de 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -27,7 +27,7 @@
  * command line
  */
 
-void chipset_bus_create(struct visor_device *bus_info);
+int chipset_bus_create(struct visor_device *bus_info);
 void chipset_bus_destroy(struct visor_device *bus_info);
 void chipset_device_create(struct visor_device *dev_info);
 void chipset_device_destroy(struct visor_device *dev_info);
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index d617ba1..d7ddf55 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -656,11 +656,17 @@ bus_create(struct controlvm_message *inmsg)
bus_info->visorchannel = visorchannel;
 
/* Response will be handled by chipset_bus_create */
-   chipset_bus_create(bus_info);
+   err = chipset_bus_create(bus_info);
+   /* If error chipset_bus_create didn't respond, need to respond here */
+   if (err)
+   goto err_destroy_channel;
 
POSTCODE_LINUX(BUS_CREATE_EXIT_PC, 0, bus_no, DIAG_SEVERITY_PRINT);
return 0;
 
+err_destroy_channel:
+   visorchannel_destroy(visorchannel);
+
 err_free_pending_msg:
kfree(bus_info->pending_msg_hdr);
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/44] staging: unisys: visorbus: error_store convert ret to err

2017-03-28 Thread David Kershner
The ret variable was only returning an error, so changing it to err to
be more consistent across the file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 00fae14..b883800 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -185,18 +185,18 @@ static ssize_t error_store(struct device *dev, struct 
device_attribute *attr,
   const char *buf, size_t count)
 {
u32 error;
-   int ret;
+   int err;
 
if (kstrtou32(buf, 10, ))
return -EINVAL;
 
-   ret = visorchannel_write
+   err = visorchannel_write
(chipset_dev->controlvm_channel,
 offsetof(struct spar_controlvm_channel_protocol,
  installation_error),
 , sizeof(u32));
-   if (ret)
-   return ret;
+   if (err)
+   return err;
return count;
 }
 static DEVICE_ATTR_RW(error);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/44] staging: unisys: visorbus: consolidate bus_responder and device_responder

2017-03-28 Thread David Kershner
With all the code churn, bus_responder and device_responder have become
identical, consolidate them to the same function.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 50 ++-
 1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 2582053..be1171e 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -537,9 +537,9 @@ save_crash_message(struct controlvm_message *msg, enum 
crash_obj_type typ)
 }
 
 static int
-bus_responder(enum controlvm_id cmd_id,
- struct controlvm_message_header *pending_msg_hdr,
- int response)
+controlvm_responder(enum controlvm_id cmd_id,
+   struct controlvm_message_header *pending_msg_hdr,
+   int response)
 {
if (!pending_msg_hdr)
return -EIO;
@@ -575,20 +575,6 @@ device_changestate_responder(enum controlvm_id cmd_id,
 }
 
 static int
-device_responder(enum controlvm_id cmd_id,
-struct controlvm_message_header *pending_msg_hdr,
-int response)
-{
-   if (!pending_msg_hdr)
-   return -EIO;
-
-   if (pending_msg_hdr->id != (u32)cmd_id)
-   return -EINVAL;
-
-   return controlvm_respond(pending_msg_hdr, response);
-}
-
-static int
 bus_create(struct controlvm_message *inmsg)
 {
struct controlvm_message_packet *cmd = >cmd;
@@ -675,7 +661,7 @@ bus_create(struct controlvm_message *inmsg)
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   bus_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -723,7 +709,7 @@ bus_destroy(struct controlvm_message *inmsg)
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   bus_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -773,12 +759,12 @@ bus_configure(struct controlvm_message *inmsg,
   DIAG_SEVERITY_PRINT);
 
if (inmsg->hdr.flags.response_expected == 1)
-   bus_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return 0;
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   bus_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -884,7 +870,7 @@ my_device_create(struct controlvm_message *inmsg)
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   device_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -945,7 +931,7 @@ my_device_changestate(struct controlvm_message *inmsg)
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   device_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -991,7 +977,7 @@ my_device_destroy(struct controlvm_message *inmsg)
 
 err_respond:
if (inmsg->hdr.flags.response_expected == 1)
-   device_responder(inmsg->hdr.id, >hdr, err);
+   controlvm_responder(inmsg->hdr.id, >hdr, err);
return err;
 }
 
@@ -1484,8 +1470,8 @@ bus_create_response(struct visor_device *bus_info, int 
response)
if (response >= 0)
bus_info->state.created = 1;
 
-   bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr,
- response);
+   controlvm_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr,
+   response);
 
kfree(bus_info->pending_msg_hdr);
bus_info->pending_msg_hdr = NULL;
@@ -1494,8 +1480,8 @@ bus_create_response(struct visor_device *bus_info, int 
response)
 void
 bus_destroy_response(struct visor_device *bus_info, int response)
 {
-   bus_responder(CONTROLVM_BUS_DESTROY, bus_info->pending_msg_hdr,
- response);
+   controlvm_responder(CONTROLVM_BUS_DESTROY, bus_info->pending_msg_hdr,
+   response);
 
kfree(bus_info->pending_msg_hdr);
bus_info->pending_msg_hdr = NULL;
@@ -1507,8 +1493,8 @@ device_create_response(struct visor_device *dev_info, int 
response)
if (response >= 0)
dev_info->state.created = 1;
 
-   device_responder(CONTROLVM_DEVICE_CREATE, dev_info->pending_msg_hdr,
-response);
+   controlvm_responder(CONTROLVM_DEVICE_CREATE, dev_info->pending_msg_hdr,
+   response);
 
kfree(dev_info->pending_msg_hdr);
dev_info->pending_msg_hdr = 

[PATCH 14/44] staging: unisys: visorbus: boottotool convert ret to err

2017-03-28 Thread David Kershner
The ret variable was only returning an error, so changing it to err to
be more consistent across the file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 0f30ff9..00fae14 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -147,21 +147,21 @@ static ssize_t boottotool_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
 {
-   int val, ret;
+   int val, err;
struct efi_spar_indication efi_spar_indication;
 
if (kstrtoint(buf, 10, ))
return -EINVAL;
 
efi_spar_indication.boot_to_tool = val;
-   ret = visorchannel_write
+   err = visorchannel_write
(chipset_dev->controlvm_channel,
 offsetof(struct spar_controlvm_channel_protocol,
  efi_spar_ind), &(efi_spar_indication),
 sizeof(struct efi_spar_indication));
 
-   if (ret)
-   return ret;
+   if (err)
+   return err;
return count;
 }
 static DEVICE_ATTR_RW(boottotool);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/44] staging: unisys: visornic: add error handling for visorchannel_signalinsert/remove

2017-03-28 Thread David Kershner
Since signalinsert/remove now return valid error codes, we need to check
them when we call them in visornic. The error codes need to propagate out
to the calling functions.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visornic/visornic_main.c | 137 -
 1 file changed, 97 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index ac8ed04..feece91 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -407,12 +407,14 @@ alloc_rcv_buf(struct net_device *netdev)
  * @skb: skb to give to the IO partition
  *
  * Send the skb to the IO Partition.
- * Returns void
+ * Returns 0 or error
  */
-static void
+static int
 post_skb(struct uiscmdrsp *cmdrsp,
 struct visornic_devdata *devdata, struct sk_buff *skb)
 {
+   int err;
+
cmdrsp->net.buf = skb;
cmdrsp->net.rcvpost.frag.pi_pfn = page_to_pfn(virt_to_page(skb->data));
cmdrsp->net.rcvpost.frag.pi_off =
@@ -420,18 +422,23 @@ post_skb(struct uiscmdrsp *cmdrsp,
cmdrsp->net.rcvpost.frag.pi_len = skb->len;
cmdrsp->net.rcvpost.unique_num = devdata->incarnation_id;
 
-   if ((cmdrsp->net.rcvpost.frag.pi_off + skb->len) <= PI_PAGE_SIZE) {
-   cmdrsp->net.type = NET_RCV_POST;
-   cmdrsp->cmdtype = CMD_NET_TYPE;
-   if (!visorchannel_signalinsert(devdata->dev->visorchannel,
-  IOCHAN_TO_IOPART,
-  cmdrsp)) {
-   atomic_inc(>num_rcvbuf_in_iovm);
-   devdata->chstat.sent_post++;
-   } else {
-   devdata->chstat.sent_post_failed++;
-   }
+   if ((cmdrsp->net.rcvpost.frag.pi_off + skb->len) > PI_PAGE_SIZE)
+   return -EINVAL;
+
+   cmdrsp->net.type = NET_RCV_POST;
+   cmdrsp->cmdtype = CMD_NET_TYPE;
+   err = visorchannel_signalinsert(devdata->dev->visorchannel,
+   IOCHAN_TO_IOPART,
+   cmdrsp);
+   if (err) {
+   devdata->chstat.sent_post_failed++;
+   return err;
}
+
+   atomic_inc(>num_rcvbuf_in_iovm);
+   devdata->chstat.sent_post++;
+
+   return 0;
 }
 
 /*
@@ -442,20 +449,25 @@ post_skb(struct uiscmdrsp *cmdrsp,
  * @devdata: visornic device we are enabling/disabling
  *
  * Send the enable/disable message to the IO Partition.
- * Returns void
+ * Returns 0 or error
  */
-static void
+static int
 send_enbdis(struct net_device *netdev, int state,
struct visornic_devdata *devdata)
 {
+   int err;
+
devdata->cmdrsp_rcv->net.enbdis.enable = state;
devdata->cmdrsp_rcv->net.enbdis.context = netdev;
devdata->cmdrsp_rcv->net.type = NET_RCV_ENBDIS;
devdata->cmdrsp_rcv->cmdtype = CMD_NET_TYPE;
-   if (!visorchannel_signalinsert(devdata->dev->visorchannel,
-  IOCHAN_TO_IOPART,
-  devdata->cmdrsp_rcv))
-   devdata->chstat.sent_enbdis++;
+   err = visorchannel_signalinsert(devdata->dev->visorchannel,
+   IOCHAN_TO_IOPART,
+   devdata->cmdrsp_rcv);
+   if (err)
+   return err;
+   devdata->chstat.sent_enbdis++;
+   return 0;
 }
 
 /*
@@ -476,6 +488,7 @@ visornic_disable_with_timeout(struct net_device *netdev, 
const int timeout)
int i;
unsigned long flags;
int wait = 0;
+   int err;
 
/* send a msg telling the other end we are stopping incoming pkts */
spin_lock_irqsave(>priv_lock, flags);
@@ -485,8 +498,11 @@ visornic_disable_with_timeout(struct net_device *netdev, 
const int timeout)
 
/* send disable and wait for ack -- don't hold lock when sending
 * disable because if the queue is full, insert might sleep.
+* If an error occurs, don't wait for the timeout.
 */
-   send_enbdis(netdev, 0, devdata);
+   err = send_enbdis(netdev, 0, devdata);
+   if (err)
+   return err;
 
/* wait for ack to arrive before we try to free rcv buffers
 * NOTE: the other end automatically unposts the rcv buffers when
@@ -555,7 +571,7 @@ visornic_disable_with_timeout(struct net_device *netdev, 
const int timeout)
 static int
 init_rcv_bufs(struct net_device *netdev, struct visornic_devdata *devdata)
 {
-   int i, count;
+   int i, j, count, err;
 
/* allocate fixed number of receive buffers to post to uisnic
 * post receive buffers after we've allocated a required amount
@@ -585,8 +601,25 @@ init_rcv_bufs(struct net_device *netdev, 

[PATCH 08/44] staging: unisys: visorbus: add error handling to error_show

2017-03-28 Thread David Kershner
Don't just drop the error from visorchannel_read on the floor, report it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 00fd02f..b09ef4c 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -170,11 +170,14 @@ static ssize_t error_show(struct device *dev, struct 
device_attribute *attr,
  char *buf)
 {
u32 error = 0;
+   int err;
 
-   visorchannel_read(chipset_dev->controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
-  installation_error),
- , sizeof(u32));
+   err = visorchannel_read(chipset_dev->controlvm_channel,
+   offsetof(struct spar_controlvm_channel_protocol,
+installation_error),
+   , sizeof(u32));
+   if (err)
+   return err;
return sprintf(buf, "%i\n", error);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/44] staging: unisys: visorbus: add error handling to remaining_steps_show

2017-03-28 Thread David Kershner
Don't just drop the error from visorchannel_read on the floor, report it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index cd2f419..b2b201b 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -242,11 +242,15 @@ static ssize_t remaining_steps_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
u16 remaining_steps = 0;
+   int err;
+
+   err = visorchannel_read(chipset_dev->controlvm_channel,
+   offsetof(struct spar_controlvm_channel_protocol,
+installation_remaining_steps),
+   _steps, sizeof(u16));
+   if (err)
+   return err;
 
-   visorchannel_read(chipset_dev->controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
-  installation_remaining_steps),
- _steps, sizeof(u16));
return sprintf(buf, "%hu\n", remaining_steps);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/44] staging: unisys: visorbus: remaining_steps convert ret to err

2017-03-28 Thread David Kershner
The ret variable was only returning an error, so changing it to err to
be more consistent across the file.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 45fc394..d617ba1 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -259,18 +259,18 @@ static ssize_t remaining_steps_store(struct device *dev,
 const char *buf, size_t count)
 {
u16 remaining_steps;
-   int ret;
+   int err;
 
if (kstrtou16(buf, 10, _steps))
return -EINVAL;
 
-   ret = visorchannel_write
+   err = visorchannel_write
(chipset_dev->controlvm_channel,
 offsetof(struct spar_controlvm_channel_protocol,
  installation_remaining_steps),
 _steps, sizeof(u16));
-   if (ret)
-   return ret;
+   if (err)
+   return err;
return count;
 }
 static DEVICE_ATTR_RW(remaining_steps);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/44] staging: unisys: visorbus: move bus_device_info_init to visorbus_main.c

2017-03-28 Thread David Kershner
The function bus_device_info_init was defined in visorbus_private.h. The
only file that uses it is visorbus_main.c so move the function into the .c
file instead.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c| 16 +++-
 drivers/staging/unisys/visorbus/visorbus_private.h | 16 +---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index fc841b1..bb1b6a0 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -763,6 +763,22 @@ write_vbus_dev_info(struct visorchannel *chan,
visorchannel_write(chan, off, info, sizeof(*info));
 }
 
+static void bus_device_info_init(
+   struct ultra_vbus_deviceinfo *bus_device_info_ptr,
+   const char *dev_type, const char *drv_name)
+{
+   memset(bus_device_info_ptr, 0, sizeof(struct ultra_vbus_deviceinfo));
+   snprintf(bus_device_info_ptr->devtype,
+sizeof(bus_device_info_ptr->devtype),
+"%s", (dev_type) ? dev_type : "unknownType");
+   snprintf(bus_device_info_ptr->drvname,
+sizeof(bus_device_info_ptr->drvname),
+"%s", (drv_name) ? drv_name : "unknownDriver");
+   snprintf(bus_device_info_ptr->infostrs,
+sizeof(bus_device_info_ptr->infostrs), "kernel ver. %s",
+utsname()->release);
+}
+
 /*
  * fix_vbus_dev_info() - for a child device just created on a client bus, fill
  *   in information about the driver that is controlling
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h 
b/drivers/staging/unisys/visorbus/visorbus_private.h
index eb8b3ec..fdccfcb 100644
--- a/drivers/staging/unisys/visorbus/visorbus_private.h
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -27,22 +27,6 @@
  * command line
  */
 
-static inline void bus_device_info_init(
-   struct ultra_vbus_deviceinfo *bus_device_info_ptr,
-   const char *dev_type, const char *drv_name)
-{
-   memset(bus_device_info_ptr, 0, sizeof(struct ultra_vbus_deviceinfo));
-   snprintf(bus_device_info_ptr->devtype,
-sizeof(bus_device_info_ptr->devtype),
-"%s", (dev_type) ? dev_type : "unknownType");
-   snprintf(bus_device_info_ptr->drvname,
-sizeof(bus_device_info_ptr->drvname),
-"%s", (drv_name) ? drv_name : "unknownDriver");
-   snprintf(bus_device_info_ptr->infostrs,
-sizeof(bus_device_info_ptr->infostrs), "kernel ver. %s",
-utsname()->release);
-}
-
 void chipset_bus_create(struct visor_device *bus_info);
 void chipset_bus_destroy(struct visor_device *bus_info);
 void chipset_device_create(struct visor_device *dev_info);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/44] staging: unisys: visorbus: remove invalid comment, we are one driver.

2017-03-28 Thread David Kershner
Removed a comment that was describing the relationship between the
visorchipset driver and the visorbus driver. Since they are now one
driver the comment no longer makes sense.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorbus_main.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
b/drivers/staging/unisys/visorbus/visorbus_main.c
index bb1b6a0..b99adaa 100644
--- a/drivers/staging/unisys/visorbus/visorbus_main.c
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -1227,14 +1227,6 @@ initiate_chipset_device_pause_resume(struct visor_device 
*dev, bool is_pause)
return;
}
 
-   /*
-* Note that even though both drv->pause() and drv->resume
-* specify a callback function, it is NOT necessary for us to
-* increment our local module usage count.  Reason is, there
-* is already a linkage dependency between child function
-* drivers and visorbus, so it is already IMPOSSIBLE to unload
-* visorbus while child function drivers are still running.
-*/
if (is_pause) {
if (!drv->pause) {
(*notify_func)(dev, -EINVAL);
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/44] staging: unisys: visorbus: parahotplug_process_message add error handling

2017-03-28 Thread David Kershner
Add error handling to the parahotplug_process_message function so that it
returns the proper error.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 46c5a93..9c0a07f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1211,7 +1211,7 @@ parahotplug_request_kickoff(struct parahotplug_request 
*req)
  * off a udev script
  * @inmsg: the message indicating whether to enable or disable
  */
-static void
+static int
 parahotplug_process_message(struct controlvm_message *inmsg)
 {
struct parahotplug_request *req;
@@ -1219,7 +1219,7 @@ parahotplug_process_message(struct controlvm_message 
*inmsg)
req = parahotplug_request_create(inmsg);
 
if (!req)
-   return;
+   return -ENOMEM;
 
if (inmsg->cmd.device_change_state.state.active) {
/*
@@ -1252,6 +1252,7 @@ parahotplug_process_message(struct controlvm_message 
*inmsg)
 
parahotplug_request_kickoff(req);
}
+   return 0;
 }
 
 /*
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/44] staging: unisys: visorbus: add error handling for parahotplug_request_kickoff

2017-03-28 Thread David Kershner
The function kobject_uevent_env returns an error we shouldn't just drop it
on the floor but we should report it back to the caller. Since it now
returns an error, need to add proper error handling to
parahotplug_process_message.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 44 ---
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 8185430..47b167f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1181,7 +1181,7 @@ static const struct attribute_group 
*visorchipset_dev_groups[] = {
  * Cause uevent to run the user level script to do the disable/enable specified
  * in the parahotplug_request.
  */
-static void
+static int
 parahotplug_request_kickoff(struct parahotplug_request *req)
 {
struct controlvm_message_packet *cmd = >msg.cmd;
@@ -1202,8 +1202,8 @@ parahotplug_request_kickoff(struct parahotplug_request 
*req)
sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
cmd->device_change_state.dev_no & 0x7);
 
-   kobject_uevent_env(_dev->acpi_device->dev.kobj, KOBJ_CHANGE,
-  envp);
+   return kobject_uevent_env(_dev->acpi_device->dev.kobj,
+ KOBJ_CHANGE, envp);
 }
 
 /*
@@ -1215,6 +1215,7 @@ static int
 parahotplug_process_message(struct controlvm_message *inmsg)
 {
struct parahotplug_request *req;
+   int err;
 
req = parahotplug_request_create(inmsg);
 
@@ -1233,26 +1234,37 @@ parahotplug_process_message(struct controlvm_message 
*inmsg)
 * devices are automatically enabled at
 * initialization.
 */
-   parahotplug_request_kickoff(req);
+   err = parahotplug_request_kickoff(req);
+   if (err)
+   goto err_respond;
controlvm_respond_physdev_changestate
(>hdr,
 CONTROLVM_RESP_SUCCESS,
 inmsg->cmd.device_change_state.state);
parahotplug_request_destroy(req);
-   } else {
-   /*
-* For disable messages, add the request to the
-* request list before kicking off the udev script. It
-* won't get responded to until the script has
-* indicated it's done.
-*/
-   spin_lock(_request_list_lock);
-   list_add_tail(>list, _request_list);
-   spin_unlock(_request_list_lock);
-
-   parahotplug_request_kickoff(req);
+   return 0;
}
+
+   /*
+* For disable messages, add the request to the
+* request list before kicking off the udev script. It
+* won't get responded to until the script has
+* indicated it's done.
+*/
+   spin_lock(_request_list_lock);
+   list_add_tail(>list, _request_list);
+   spin_unlock(_request_list_lock);
+
+   err = parahotplug_request_kickoff(req);
+   if (err)
+   goto err_respond;
return 0;
+
+err_respond:
+   controlvm_respond_physdev_changestate
+   (>hdr, err,
+inmsg->cmd.device_change_state.state);
+   return err;
 }
 
 /*
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/44] staging: unisys: visorbus: add error handling around kobject_uevent

2017-03-28 Thread David Kershner
The function kobject_uevent_env can return an error, pass that error
to the caller so it can be handled correctly.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 26 +++
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 47b167f..cb8c6f9 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1277,12 +1277,15 @@ parahotplug_process_message(struct controlvm_message 
*inmsg)
 static int
 chipset_ready_uevent(struct controlvm_message_header *msg_hdr)
 {
-   kobject_uevent(_dev->acpi_device->dev.kobj, KOBJ_ONLINE);
+   int res;
+
+   res = kobject_uevent(_dev->acpi_device->dev.kobj,
+KOBJ_ONLINE);
 
if (msg_hdr->flags.response_expected)
-   return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS);
+   controlvm_respond(msg_hdr, res);
 
-   return 0;
+   return res;
 }
 
 /*
@@ -1297,15 +1300,16 @@ chipset_selftest_uevent(struct controlvm_message_header 
*msg_hdr)
 {
char env_selftest[20];
char *envp[] = { env_selftest, NULL };
+   int res;
 
sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
-   kobject_uevent_env(_dev->acpi_device->dev.kobj, KOBJ_CHANGE,
-  envp);
+   res = kobject_uevent_env(_dev->acpi_device->dev.kobj,
+KOBJ_CHANGE, envp);
 
if (msg_hdr->flags.response_expected)
-   return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS);
+   controlvm_respond(msg_hdr, res);
 
-   return 0;
+   return res;
 }
 
 /*
@@ -1318,12 +1322,14 @@ chipset_selftest_uevent(struct controlvm_message_header 
*msg_hdr)
 static int
 chipset_notready_uevent(struct controlvm_message_header *msg_hdr)
 {
-   kobject_uevent(_dev->acpi_device->dev.kobj, KOBJ_OFFLINE);
+   int res;
 
+   res = kobject_uevent(_dev->acpi_device->dev.kobj,
+KOBJ_OFFLINE);
if (msg_hdr->flags.response_expected)
-   return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS);
+   controlvm_respond(msg_hdr, res);
 
-   return 0;
+   return res;
 }
 
 static unsigned int
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/44] staging: unisys: visorbus: add error handling to toolaction_show

2017-03-28 Thread David Kershner
Don't just drop the error from visorchannel_read on the floor, report it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index cb8c6f9..543218f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -91,10 +91,15 @@ static ssize_t toolaction_show(struct device *dev,
   char *buf)
 {
u8 tool_action = 0;
+   int err;
+
+   err = visorchannel_read(chipset_dev->controlvm_channel,
+   offsetof(struct spar_controlvm_channel_protocol,
+tool_action),
+   _action, sizeof(u8));
+   if (err)
+   return err;
 
-   visorchannel_read(chipset_dev->controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
-  tool_action), _action, sizeof(u8));
return sprintf(buf, "%u\n", tool_action);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/44] staging: unisys: visorbus: add error handling to handle_command

2017-03-28 Thread David Kershner
Add error handling to the function handle_command.

Since handle_command now returns errors, we need to process them correctly
in process_controlvm_event.

Note: It is invalid to have a controlvm test message in the event queue, so
return -EINVAL if one is discovered.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 92 ++-
 1 file changed, 49 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 9c0a07f..d4f4afe 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1557,16 +1557,14 @@ parser_init_byte_stream(u64 addr, u32 bytes, bool 
local, bool *retry)
  * @channel_addr: address of the controlvm channel
  *
  * Return:
- *false - this function will return false only in the case where the
- *controlvm message was NOT processed, but processing must be
- *retried before reading the next controlvm message; a
- *scenario where this can occur is when we need to throttle
- *the allocation of memory in which to copy out controlvm
- *payload data
- *true  - processing of the controlvm message completed,
- *either successfully or with an error
+ * 0   - Successfully processed the message
+ * -EAGAIN - ControlVM message was not processed and should be retried
+ *   reading the next controlvm message; a scenario where this can
+ *   occur is when we need to throttle the allocation of memory in
+ *   which to copy out controlvm payload data.
+ * < 0 - error: ControlVM message was processed but an error occurred.
  */
-static bool
+static int
 handle_command(struct controlvm_message inmsg, u64 channel_addr)
 {
struct controlvm_message_packet *cmd = 
@@ -1575,11 +1573,13 @@ handle_command(struct controlvm_message inmsg, u64 
channel_addr)
struct parser_context *parser_ctx = NULL;
bool local_addr;
struct controlvm_message ackmsg;
+   int err = 0;
 
/* create parsing context if necessary */
local_addr = (inmsg.hdr.flags.test_message == 1);
if (channel_addr == 0)
-   return true;
+   return -EINVAL;
+
parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
parm_bytes = inmsg.hdr.payload_bytes;
 
@@ -1595,66 +1595,68 @@ handle_command(struct controlvm_message inmsg, u64 
channel_addr)
parser_init_byte_stream(parm_addr, parm_bytes,
local_addr, );
if (!parser_ctx && retry)
-   return false;
+   return -EAGAIN;
}
 
if (!local_addr) {
controlvm_init_response(, ,
CONTROLVM_RESP_SUCCESS);
-   if (chipset_dev->controlvm_channel)
-   visorchannel_signalinsert(
-   chipset_dev->controlvm_channel,
-   CONTROLVM_QUEUE_ACK, );
+   err = visorchannel_signalinsert(chipset_dev->controlvm_channel,
+   CONTROLVM_QUEUE_ACK,
+   );
+   if (err)
+   return err;
}
switch (inmsg.hdr.id) {
case CONTROLVM_CHIPSET_INIT:
-   chipset_init();
+   err = chipset_init();
break;
case CONTROLVM_BUS_CREATE:
-   bus_create();
+   err = bus_create();
break;
case CONTROLVM_BUS_DESTROY:
-   bus_destroy();
+   err = bus_destroy();
break;
case CONTROLVM_BUS_CONFIGURE:
-   bus_configure(, parser_ctx);
+   err = bus_configure(, parser_ctx);
break;
case CONTROLVM_DEVICE_CREATE:
-   my_device_create();
+   err = my_device_create();
break;
case CONTROLVM_DEVICE_CHANGESTATE:
if (cmd->device_change_state.flags.phys_device) {
-   parahotplug_process_message();
+   err = parahotplug_process_message();
} else {
/*
 * save the hdr and cmd structures for later use
 * when sending back the response to Command
 */
-   my_device_changestate();
+   err = my_device_changestate();
break;
}
break;
case CONTROLVM_DEVICE_DESTROY:
-   my_device_destroy();
+   err = my_device_destroy();
 

[PATCH 07/44] staging: unisys: visorbus: add error handling to boottotool_show

2017-03-28 Thread David Kershner
Don't just drop the error from visorchannel_read on the floor, report it.

Signed-off-by: David Kershner 
Reviewed-by: Reviewed-by: Tim Sell 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index 543218f..00fd02f 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -130,11 +130,16 @@ static ssize_t boottotool_show(struct device *dev,
   char *buf)
 {
struct efi_spar_indication efi_spar_indication;
+   int err;
 
-   visorchannel_read(chipset_dev->controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
-  efi_spar_ind), _spar_indication,
- sizeof(struct efi_spar_indication));
+   err = visorchannel_read(chipset_dev->controlvm_channel,
+   offsetof(struct spar_controlvm_channel_protocol,
+efi_spar_ind),
+   _spar_indication,
+   sizeof(struct efi_spar_indication));
+
+   if (err)
+   return err;
return sprintf(buf, "%u\n", efi_spar_indication.boot_to_tool);
 }
 
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/44] staging: unisys: Add additional error handling to the s-Par drivers

2017-03-28 Thread David Kershner
This series primarily concentrates on adding additional error handling
so that the s-Par drivers can correctly handle the errors at a
centralized location instead of doing it inconsistently scattered
throughout the source tree.

David Kershner (43):
  staging: unisys: visorbus: parahotplug_process_message add error handling
  staging: unisys: visorbus: add error handling to handle_command
  staging: unisys: visorbus: add error handling to controlvm_periodic_work
  staging: unisys: visorbus: add error handling for parahotplug_request_kickoff
  staging: unisys: visorbus: add error handling around kobject_uevent
  staging: unisys: visorbus:  add error handling to toolaction_show
  staging: unisys: visorbus: add error handling to boottotool_show
  staging: unisys: visorbus: add error handling to error_show
  staging: unisys: visorbus: add error handling textid_show
  staging: unisys: visorbus: add error handling to remaining_steps_show
  staging: unisys: visorbus: move bus_device_info_init to visorbus_main.c
  staging: unisys: visorbus: remove invalid comment, we are one driver.
  staging: unisys: visorbus: convert ret to err to be consistent
  staging: unisys: visorbus: boottotool convert ret to err
  staging: unisys: visorbus: error_store convert ret to err
  staging: unisys: visorbus: textid_store convert ret to err
  staging: unisys: visorbus: remaining_steps convert ret to err
  staging: unisys: visorbus: add error handling to chipset_bus_create
  staging: unisys: visornic: add error handling for 
visorchannel_signalinsert/remove
  staging: unisys: visorbus: add error handling for chipset_device_create
  staging: unisys: visorbus: consolidate bus_responder and device_responder
  staging: unisys: visorbus: move vbuschannel_print_devinfo from .h to .c file
  staging: unisys: visorbus: get rid of shouting SPAR_VBUS_CHANNEL_CLIENT_OK 
macro
  staging: unisys: remove client from spar_check_channel
  staging: unisys: visorbus: add error handling for dev_start_periodic_work
  staging: unisys: visorbus: add error handling 
visorbus_enable_channel_interrupt
  staging: unisys: visorbus: fix error handling in create_bus_instance
  staging: unisys: visorbus: get rid of create_bus_type.
  staging: unisys: visorbus: get rid of unused parameter forcematch
  staging: unisys: visorbus: get rid of unused parameter forcenomatch
  staging: unisys: visorbus: cleanup error handling in visorbus_uevent
  staging: unisys: visorbus: check for err from dev_set_name
  staging: unisys: visorbus: don't ignore visorchannel_read error
  staging: unisys: visorbus: don't unregister if we failed to register
  staging: unisys: visorbus: add error handling to 
initiate_chipset_device_pause_resume
  staging: unisys: visorbus: add error handling to chipset_device_pause/resume
  staging: unisys: visorbus: get rid of braces around single statements
  staging: unisys: visorbus: consolidate if statements
  staging: unisys: visorbus: remove useless ifdef
  staging: unisys: visorbus: get rid of ISSUE_IO_VMCALL
  staging: unisys: visorbus: Update vmcallinterface comment
  staging: unisys: visorbus: move unisys_vmcall into visorchipset
  staging: unisys: visorbus: Have unisys_vmcall return Linux error instead of 
VMCALL error

Sameer Wadgaonkar (1):
  staging: unisys: visorbus: add __packed to structures in controlvmchannel.h

 drivers/staging/unisys/include/channel.h   |  12 +-
 drivers/staging/unisys/include/iochannel.h |  16 +-
 drivers/staging/unisys/include/visorbus.h  |   2 +-
 drivers/staging/unisys/visorbus/controlvmchannel.h |  70 +-
 drivers/staging/unisys/visorbus/vbuschannel.h  |  43 +-
 drivers/staging/unisys/visorbus/visorbus_main.c| 316 --
 drivers/staging/unisys/visorbus/visorbus_private.h |  24 +-
 drivers/staging/unisys/visorbus/visorchannel.c |  18 +-
 drivers/staging/unisys/visorbus/visorchipset.c | 458 --
 drivers/staging/unisys/visorbus/vmcallinterface.h  |  41 +-
 drivers/staging/unisys/visornic/visornic_main.c| 137 ++--
 11 files changed, 595 insertions(+), 542 deletions(-)

base-commit: a15505e69cd2f8d0ebf566cd5c5838bd5c2d56e3
-- 
git-series 0.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] coding style issue fixed

2017-03-28 Thread Vitaly Kuznetsov
Andrea della Porta  writes:

> Coding style issues fixed
>
> Signed-off-by: Andrea della Porta 
> ---
>  .../vc04_services/bcm2835-audio/bcm2835-pcm.c  | 47 
> ++
>  1 file changed, 22 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c 
> b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
> index 8bd69b9..fa6d3d2 100644
> --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
> +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
> @@ -68,7 +68,7 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream 
> *alsa_stream)
>   audio_info(" .. IN\n");
>
>   audio_info("alsa_stream=%p substream=%p\n", alsa_stream,
> - alsa_stream ? alsa_stream->substream : 0);
> +alsa_stream ? alsa_stream->substream : 0);
>
>   if (alsa_stream->open)
>   consumed = bcm2835_audio_retrieve_buffers(alsa_stream);
> @@ -83,10 +83,10 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream 
> *alsa_stream)
>   new_period = 1;
>   }
>   audio_debug("updating pos cur: %d + %d max:%d period_bytes:%d, hw_ptr: 
> %d new_period:%d\n",
> - alsa_stream->pos,
> + alsa_stream->pos,
>   consumed,
>   alsa_stream->buffer_size,
> - (int) (alsa_stream->period_size * 
> alsa_stream->substream->runtime->periods),
> + (int)(alsa_stream->period_size * 
> alsa_stream->substream->runtime->periods),
>   frames_to_bytes(alsa_stream->substream->runtime, 
> alsa_stream->substream->runtime->status->hw_ptr),
>   new_period);
>   if (alsa_stream->buffer_size) {
> @@ -229,6 +229,7 @@ static int snd_bcm2835_playback_close(struct 
> snd_pcm_substream *substream)
>*/
>   if (alsa_stream->running) {
>   int err;
> +
>   err = bcm2835_audio_stop(alsa_stream);
>   alsa_stream->running = 0;
>   if (err)
> @@ -259,7 +260,7 @@ static int snd_bcm2835_playback_close(struct 
> snd_pcm_substream *substream)
>
>  /* hw_params callback */
>  static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream,
> - struct snd_pcm_hw_params *params)
> +  struct snd_pcm_hw_params *params)
>  {
>   struct snd_pcm_runtime *runtime = substream->runtime;
>   struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
> @@ -312,18 +313,16 @@ static int snd_bcm2835_pcm_prepare(struct 
> snd_pcm_substream *substream)
>   channels = alsa_stream->channels;
>
>   err = bcm2835_audio_set_params(alsa_stream, channels,
> - alsa_stream->params_rate,
> - alsa_stream->pcm_format_width);
> +alsa_stream->params_rate,
> +alsa_stream->pcm_format_width);
>   if (err < 0)
>   audio_error(" error setting hw params\n");
>
> -
>   bcm2835_audio_setup(alsa_stream);
>
>   /* in preparation of the stream, set the controls (volume level) of the 
> stream */
>   bcm2835_audio_set_ctls(alsa_stream->chip);
>
> -
>   memset(_stream->pcm_indirect, 0, 
> sizeof(alsa_stream->pcm_indirect));
>
>   alsa_stream->pcm_indirect.hw_buffer_size =
> @@ -335,8 +334,8 @@ static int snd_bcm2835_pcm_prepare(struct 
> snd_pcm_substream *substream)
>   alsa_stream->pos = 0;
>
>   audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n",
> - alsa_stream->buffer_size, alsa_stream->period_size,
> - alsa_stream->pos, runtime->frame_bits);
> + alsa_stream->buffer_size, alsa_stream->period_size,
> + alsa_stream->pos, runtime->frame_bits);
>
>   mutex_unlock(>audio_mutex);
>   audio_info(" .. OUT\n");
> @@ -344,17 +343,16 @@ static int snd_bcm2835_pcm_prepare(struct 
> snd_pcm_substream *substream)
>  }
>
>  static void snd_bcm2835_pcm_transfer(struct snd_pcm_substream *substream,
> - struct snd_pcm_indirect *rec, size_t bytes)
> +  struct snd_pcm_indirect *rec, size_t bytes)
>  {
>   struct snd_pcm_runtime *runtime = substream->runtime;
>   struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
> - void *src = (void *) (substream->runtime->dma_area + rec->sw_data);
> + void *src = (void *)(substream->runtime->dma_area + rec->sw_data);
>   int err;
>
>   err = bcm2835_audio_write(alsa_stream, bytes, src);
>   if (err)
>   audio_error(" Failed to transfer to alsa device (%d)\n", err);
> -
>  }
>
>  static int snd_bcm2835_pcm_ack(struct snd_pcm_substream *substream)
> @@ -381,14 +379,14 @@ static int snd_bcm2835_pcm_trigger(struct 
> snd_pcm_substream *substream, int cmd)
>   switch (cmd) {
>   case SNDRV_PCM_TRIGGER_START:
>   

[PATCH 4.4 59/76] x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic

2017-03-28 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Sumit Semwal 


From: Vitaly Kuznetsov 

[ Upstream commit 59107e2f48831daedc46973ce4988605ab066de3 ]

There is a feature in Hyper-V ('Debug-VM --InjectNonMaskableInterrupt')
which injects NMI to the guest. We may want to crash the guest and do kdump
on this NMI by enabling unknown_nmi_panic. To make kdump succeed we need to
allow the kdump kernel to re-establish VMBus connection so it will see
VMBus devices (storage, network,..).

To properly unload VMBus making it possible to start over during kdump we
need to do the following:

 - Send an 'unload' message to the hypervisor. This can be done on any CPU
   so we do this the crashing CPU.

 - Receive the 'unload finished' reply message. WS2012R2 delivers this
   message to the CPU which was used to establish VMBus connection during
   module load and this CPU may differ from the CPU sending 'unload'.

Receiving a VMBus message means the following:

 - There is a per-CPU slot in memory for one message. This slot can in
   theory be accessed by any CPU.

 - We get an interrupt on the CPU when a message was placed into the slot.

 - When we read the message we need to clear the slot and signal the fact
   to the hypervisor. In case there are more messages to this CPU pending
   the hypervisor will deliver the next message. The signaling is done by
   writing to an MSR so this can only be done on the appropriate CPU.

To avoid doing cross-CPU work on crash we have vmbus_wait_for_unload()
function which checks message slots for all CPUs in a loop waiting for the
'unload finished' messages. However, there is an issue which arises when
these conditions are met:

 - We're crashing on a CPU which is different from the one which was used
   to initially contact the hypervisor.

 - The CPU which was used for the initial contact is blocked with interrupts
   disabled and there is a message pending in the message slot.

In this case we won't be able to read the 'unload finished' message on the
crashing CPU. This is reproducible when we receive unknown NMIs on all CPUs
simultaneously: the first CPU entering panic() will proceed to crash and
all other CPUs will stop themselves with interrupts disabled.

The suggested solution is to handle unknown NMIs for Hyper-V guests on the
first CPU which gets them only. This will allow us to rely on VMBus
interrupt handler being able to receive the 'unload finish' message in
case it is delivered to a different CPU.

The issue is not reproducible on WS2016 as Debug-VM delivers NMI to the
boot CPU only, WS2012R2 and earlier Hyper-V versions are affected.

Signed-off-by: Vitaly Kuznetsov 
Acked-by: K. Y. Srinivasan 
Cc: de...@linuxdriverproject.org
Cc: Haiyang Zhang 
Link: http://lkml.kernel.org/r/20161202100720.28121-1-vkuzn...@redhat.com
Signed-off-by: Thomas Gleixner 
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sumit Semwal 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/kernel/cpu/mshyperv.c |   24 
 1 file changed, 24 insertions(+)

--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct ms_hyperv_info ms_hyperv;
 EXPORT_SYMBOL_GPL(ms_hyperv);
@@ -157,6 +158,26 @@ static unsigned char hv_get_nmi_reason(v
return 0;
 }
 
+#ifdef CONFIG_X86_LOCAL_APIC
+/*
+ * Prior to WS2016 Debug-VM sends NMIs to all CPUs which makes
+ * it dificult to process CHANNELMSG_UNLOAD in case of crash. Handle
+ * unknown NMI on the first CPU which gets it.
+ */
+static int hv_nmi_unknown(unsigned int val, struct pt_regs *regs)
+{
+   static atomic_t nmi_cpu = ATOMIC_INIT(-1);
+
+   if (!unknown_nmi_panic)
+   return NMI_DONE;
+
+   if (atomic_cmpxchg(_cpu, -1, raw_smp_processor_id()) != -1)
+   return NMI_HANDLED;
+
+   return NMI_DONE;
+}
+#endif
+
 static void __init ms_hyperv_init_platform(void)
 {
/*
@@ -182,6 +203,9 @@ static void __init ms_hyperv_init_platfo
printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
lapic_timer_frequency);
}
+
+   register_nmi_handler(NMI_UNKNOWN, hv_nmi_unknown, NMI_FLAG_FIRST,
+"hv_nmi_unknown");
 #endif
 
if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)


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


[PATCH] coding style issue fixed

2017-03-28 Thread Andrea della Porta
Coding style issues fixed

Signed-off-by: Andrea della Porta 
---
 .../vc04_services/bcm2835-audio/bcm2835-pcm.c  | 47 ++
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c 
b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
index 8bd69b9..fa6d3d2 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
@@ -68,7 +68,7 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream 
*alsa_stream)
audio_info(" .. IN\n");
 
audio_info("alsa_stream=%p substream=%p\n", alsa_stream,
-   alsa_stream ? alsa_stream->substream : 0);
+  alsa_stream ? alsa_stream->substream : 0);
 
if (alsa_stream->open)
consumed = bcm2835_audio_retrieve_buffers(alsa_stream);
@@ -83,10 +83,10 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream 
*alsa_stream)
new_period = 1;
}
audio_debug("updating pos cur: %d + %d max:%d period_bytes:%d, hw_ptr: 
%d new_period:%d\n",
-   alsa_stream->pos,
+   alsa_stream->pos,
consumed,
alsa_stream->buffer_size,
-   (int) (alsa_stream->period_size * 
alsa_stream->substream->runtime->periods),
+   (int)(alsa_stream->period_size * 
alsa_stream->substream->runtime->periods),
frames_to_bytes(alsa_stream->substream->runtime, 
alsa_stream->substream->runtime->status->hw_ptr),
new_period);
if (alsa_stream->buffer_size) {
@@ -229,6 +229,7 @@ static int snd_bcm2835_playback_close(struct 
snd_pcm_substream *substream)
 */
if (alsa_stream->running) {
int err;
+
err = bcm2835_audio_stop(alsa_stream);
alsa_stream->running = 0;
if (err)
@@ -259,7 +260,7 @@ static int snd_bcm2835_playback_close(struct 
snd_pcm_substream *substream)
 
 /* hw_params callback */
 static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream,
-   struct snd_pcm_hw_params *params)
+struct snd_pcm_hw_params *params)
 {
struct snd_pcm_runtime *runtime = substream->runtime;
struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
@@ -312,18 +313,16 @@ static int snd_bcm2835_pcm_prepare(struct 
snd_pcm_substream *substream)
channels = alsa_stream->channels;
 
err = bcm2835_audio_set_params(alsa_stream, channels,
-   alsa_stream->params_rate,
-   alsa_stream->pcm_format_width);
+  alsa_stream->params_rate,
+  alsa_stream->pcm_format_width);
if (err < 0)
audio_error(" error setting hw params\n");
 
-
bcm2835_audio_setup(alsa_stream);
 
/* in preparation of the stream, set the controls (volume level) of the 
stream */
bcm2835_audio_set_ctls(alsa_stream->chip);
 
-
memset(_stream->pcm_indirect, 0, 
sizeof(alsa_stream->pcm_indirect));
 
alsa_stream->pcm_indirect.hw_buffer_size =
@@ -335,8 +334,8 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream 
*substream)
alsa_stream->pos = 0;
 
audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n",
-   alsa_stream->buffer_size, alsa_stream->period_size,
-   alsa_stream->pos, runtime->frame_bits);
+   alsa_stream->buffer_size, alsa_stream->period_size,
+   alsa_stream->pos, runtime->frame_bits);
 
mutex_unlock(>audio_mutex);
audio_info(" .. OUT\n");
@@ -344,17 +343,16 @@ static int snd_bcm2835_pcm_prepare(struct 
snd_pcm_substream *substream)
 }
 
 static void snd_bcm2835_pcm_transfer(struct snd_pcm_substream *substream,
-   struct snd_pcm_indirect *rec, size_t bytes)
+struct snd_pcm_indirect *rec, size_t bytes)
 {
struct snd_pcm_runtime *runtime = substream->runtime;
struct bcm2835_alsa_stream *alsa_stream = runtime->private_data;
-   void *src = (void *) (substream->runtime->dma_area + rec->sw_data);
+   void *src = (void *)(substream->runtime->dma_area + rec->sw_data);
int err;
 
err = bcm2835_audio_write(alsa_stream, bytes, src);
if (err)
audio_error(" Failed to transfer to alsa device (%d)\n", err);
-
 }
 
 static int snd_bcm2835_pcm_ack(struct snd_pcm_substream *substream)
@@ -381,14 +379,14 @@ static int snd_bcm2835_pcm_trigger(struct 
snd_pcm_substream *substream, int cmd)
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
audio_debug("bcm2835_AUDIO_TRIGGER_START running=%d\n",
-   alsa_stream->running);
+   alsa_stream->running);
if 

[PATCH] coding style issue resolved

2017-03-28 Thread Andrea della Porta
Coding style issue resolved.

Signed-off-by: Andrea della Porta 
---
 drivers/staging/iio/accel/adis16209.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16209.c 
b/drivers/staging/iio/accel/adis16209.c
index 52fa2e0..159a687 100644
--- a/drivers/staging/iio/accel/adis16209.c
+++ b/drivers/staging/iio/accel/adis16209.c
@@ -255,9 +255,9 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
}
addr = adis16209_addresses[chan->scan_index][0];
ret = adis_read_reg_16(st, addr, );
-   if (ret) {
+   if (ret)
return ret;
-   }
+
val16 &= (1 << bits) - 1;
val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
*val = val16;
-- 
2.4.10

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


[PATCH 1/1] Staging: lustre: lnet: libcfs: Fixed checkpatch.pl coding style errors

2017-03-28 Thread vaibhavddit
From: Vaibhav Kothari 

Shifted open brace { to previous line for 8 functions as indicated by
checkpatch.pl

Signed-off-by: Vaibhav Kothari 
---
 drivers/staging/lustre/lnet/libcfs/hash.c | 43 +++
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c 
b/drivers/staging/lustre/lnet/libcfs/hash.c
index 5c2ce2e..bb966e2 100644
--- a/drivers/staging/lustre/lnet/libcfs/hash.c
+++ b/drivers/staging/lustre/lnet/libcfs/hash.c
@@ -1348,8 +1348,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
 EXPORT_SYMBOL(cfs_hash_lookup);
 
 static void
-cfs_hash_for_each_enter(struct cfs_hash *hs)
-{
+cfs_hash_for_each_enter(struct cfs_hash *hs) {
LASSERT(!cfs_hash_is_exiting(hs));
 
if (!cfs_hash_with_rehash(hs))
@@ -1375,8 +1374,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
 }
 
 static void
-cfs_hash_for_each_exit(struct cfs_hash *hs)
-{
+cfs_hash_for_each_exit(struct cfs_hash *hs) {
int remained;
int bits;
 
@@ -1407,8 +1405,7 @@ void cfs_hash_putref(struct cfs_hash *hs)
  */
 static u64
 cfs_hash_for_each_tight(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-   void *data, int remove_safe)
-{
+   void *data, int remove_safe) {
struct hlist_node *hnode;
struct hlist_node *pos;
struct cfs_hash_bd bd;
@@ -1465,8 +1462,7 @@ struct cfs_hash_cond_arg {
 
 static int
 cfs_hash_cond_del_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
-struct hlist_node *hnode, void *data)
-{
+struct hlist_node *hnode, void *data) {
struct cfs_hash_cond_arg *cond = data;
 
if (cond->func(cfs_hash_object(hs, hnode), cond->arg))
@@ -1480,8 +1476,8 @@ struct cfs_hash_cond_arg {
  * any object be reference.
  */
 void
-cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func, void *data)
-{
+cfs_hash_cond_del(struct cfs_hash *hs, cfs_hash_cond_opt_cb_t func,
+   void *data) {
struct cfs_hash_cond_arg arg = {
.func   = func,
.arg= data,
@@ -1493,31 +1489,27 @@ struct cfs_hash_cond_arg {
 
 void
 cfs_hash_for_each(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
- void *data)
-{
+ void *data) {
cfs_hash_for_each_tight(hs, func, data, 0);
 }
 EXPORT_SYMBOL(cfs_hash_for_each);
 
 void
 cfs_hash_for_each_safe(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-  void *data)
-{
+  void *data) {
cfs_hash_for_each_tight(hs, func, data, 1);
 }
 EXPORT_SYMBOL(cfs_hash_for_each_safe);
 
 static int
 cfs_hash_peek(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *data)
-{
+ struct hlist_node *hnode, void *data) {
*(int *)data = 0;
return 1; /* return 1 to break the loop */
 }
 
 int
-cfs_hash_is_empty(struct cfs_hash *hs)
-{
+cfs_hash_is_empty(struct cfs_hash *hs) {
int empty = 1;
 
cfs_hash_for_each_tight(hs, cfs_hash_peek, , 0);
@@ -1526,8 +1518,7 @@ struct cfs_hash_cond_arg {
 EXPORT_SYMBOL(cfs_hash_is_empty);
 
 u64
-cfs_hash_size_get(struct cfs_hash *hs)
-{
+cfs_hash_size_get(struct cfs_hash *hs) {
return cfs_hash_with_counter(hs) ?
   atomic_read(>hs_count) :
   cfs_hash_for_each_tight(hs, NULL, NULL, 0);
@@ -1551,8 +1542,7 @@ struct cfs_hash_cond_arg {
  */
 static int
 cfs_hash_for_each_relax(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-   void *data, int start)
-{
+   void *data, int start) {
struct hlist_node *hnode;
struct hlist_node *tmp;
struct cfs_hash_bd bd;
@@ -1629,8 +1619,7 @@ struct cfs_hash_cond_arg {
 
 int
 cfs_hash_for_each_nolock(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-void *data, int start)
-{
+void *data, int start) {
if (cfs_hash_with_no_lock(hs) ||
cfs_hash_with_rehash_key(hs) ||
!cfs_hash_with_no_itemref(hs))
@@ -1661,8 +1650,7 @@ struct cfs_hash_cond_arg {
  */
 int
 cfs_hash_for_each_empty(struct cfs_hash *hs, cfs_hash_for_each_cb_t func,
-   void *data)
-{
+   void *data) {
unsigned int i = 0;
 
if (cfs_hash_with_no_lock(hs))
@@ -1718,8 +1706,7 @@ struct cfs_hash_cond_arg {
  */
 void
 cfs_hash_for_each_key(struct cfs_hash *hs, const void *key,
- cfs_hash_for_each_cb_t func, void *data)
-{
+ cfs_hash_for_each_cb_t func, void *data) {
struct hlist_node *hnode;
struct cfs_hash_bd bds[2];
unsigned int i;
-- 
1.9.1

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


[PATCH 2/3] staging: ks7010: factor out send stop request

2017-03-28 Thread Tobin C. Harding
Function contains a block of code combined as a compound
statement. This would be better factored out into a separate function.

Factor compound statement out into a separate function.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 0f5ff68..a820371 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1062,6 +1062,29 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return -ENODEV;
 }
 
+/* send stop request to MAC */
+static int send_stop_request(struct ks_sdio_card *card)
+{
+   struct hostif_stop_request_t *pp;
+   size_t size;
+
+   pp = kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL);
+   if (!pp)
+   return -ENOMEM;
+
+   size = sizeof(*pp) - sizeof(pp->header.size);
+   pp->header.size = cpu_to_le16((uint16_t)size);
+   pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
+
+   sdio_claim_host(card->func);
+   write_to_device(card->priv, (unsigned char *)pp,
+   hif_align_size(sizeof(*pp)));
+   sdio_release_host(card->func);
+
+   kfree(pp);
+   return 0;
+}
+
 static void ks7010_sdio_remove(struct sdio_func *func)
 {
int ret;
@@ -1093,27 +1116,10 @@ static void ks7010_sdio_remove(struct sdio_func *func)
sdio_release_host(func);
DPRINTK(1, "interrupt disable\n");
 
-   /* send stop request to MAC */
-   {
-   struct hostif_stop_request_t *pp;
+   ret = send_stop_request(card);
+   if (ret)
+   return;
 
-   pp = kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL);
-   if (!pp) {
-   DPRINTK(3, "allocate memory failed..\n");
-   return; /* to do goto ni suru */
-   }
-   pp->header.size =
-   cpu_to_le16((uint16_t)
-   (sizeof(*pp) -
-   sizeof(pp->header.size)));
-   pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ);
-
-   sdio_claim_host(func);
-   write_to_device(priv, (unsigned char *)pp,
-   hif_align_size(sizeof(*pp)));
-   sdio_release_host(func);
-   kfree(pp);
-   }
DPRINTK(1, "STOP Req\n");
 
if (priv->ks_wlan_hw.ks7010sdio_wq) {
-- 
2.7.4

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


[PATCH 0/4] staging: ks7010: refactor ks7010_sdio_remove()

2017-03-28 Thread Tobin C. Harding
Function is a candidate for refactoring. None of the kernel static
analysis tools warn about this function but the function has a number
of code smells. There is a block of code separated into a anonymous
compound statement, this is not usual kernel code style and can easily
be factored into a separate function. There are a number of function
calls that could be formatted better to make the code more
readable. Finally there is extraneous whitespace that can be remove,
also mildly improving readability.

Patch 01 reduces the level of indentation.

Patch 02 factors out compound statement.

Patch 03 removes extraneous newlines.

Code is untested. Builds on x86_64 and PowerPC.

Tobin C. Harding (3):
  staging: ks7010: invert conditional, reduce indentation
  staging: ks7010: factor out send stop request
  staging: ks7010: remove extraneous newlines.

 drivers/staging/ks7010/ks7010_sdio.c | 108 ++-
 1 file changed, 57 insertions(+), 51 deletions(-)

-- 
2.7.4

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


Re:

2017-03-28 Thread Western Union
Pick up your Western Union Funds $850,000 USD

Name...Country.. Phone Number

Mr Mike Morris

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


[PATCH 1/3] staging: ks7010: remove unnecessary function parameter

2017-03-28 Thread Tobin C. Harding
Function ks7010_upload_firmware() has two struct pointer parameters,
one of which is a member of the other. This is unnecessary.

Remove unnecessary function parameter.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b16618b..f80e253 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -709,9 +709,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private 
*priv, u32 address,
return ret;
 }
 
-static int ks7010_upload_firmware(struct ks_wlan_private *priv,
- struct ks_sdio_card *card)
+static int ks7010_upload_firmware(struct ks_sdio_card *card)
 {
+   struct ks_wlan_private *priv = card->priv;
unsigned int size, offset, n = 0;
unsigned char *rom_buf;
unsigned char rw_data = 0;
@@ -997,8 +997,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 
ks7010_init_defaults(priv);
 
-   /* Upload firmware */
-   ret = ks7010_upload_firmware(priv, card);   /* firmware load */
+   ret = ks7010_upload_firmware(card);
if (ret) {
dev_err(>func->dev,
"ks7010: firmware load failed !! return code = %d\n",
-- 
2.7.4

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


[PATCH 0/3] staging: ks7010: clean function calls

2017-03-28 Thread Tobin C. Harding
Driver file ks7010_sdio.c contains a few function definition
anomalies. One function is defined with two parameters, one of which
is a struct member of the other. This is unnecessary.

A couple of functions with internal linkage take as input parameters
of type void *. All call sites then cast struct pointers to void * in
order to do the function call, void * must then be cast back to the
original struct pointer type. This casting both ways is unnecessary.

Patch 01 removes the unnecessary function parameter.

Patch 02 fixes the function parameter types so casting is not used.

Patch 03 fixes a buffer overflow, not a real bug since the containing
function has internal linkage. Fixing this prevents future failure.

Code is untested. Builds on x86_64 and PowerPC.

Tobin C. Harding (3):
  staging: ks7010: remove unnecessary function parameter
  staging: ks7010: remove void * cast
  staging: ks7010: fix buffer overflow vulnerability

 drivers/staging/ks7010/ks7010_sdio.c | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

-- 
2.7.4

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


[PATCH 3/3] staging: ks7010: fix buffer overflow vulnerability

2017-03-28 Thread Tobin C. Harding
Constant is used to allocate memory for a buffer, then buffer is
filled upto 'size' which is passed as a parameter. If 'size' is bigger
than the constant then the buffer will overflow. We could check the
'size' parameter and fail but better not to fail.

Use 'size' as the parameter to kmalloc() instead of a constant.

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 3403edd..341bce4 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -683,7 +683,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private 
*priv, u32 address,
int ret;
unsigned char *read_buf;
 
-   read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
+   read_buf = kmalloc(size, GFP_KERNEL);
if (!read_buf)
return -ENOMEM;
 
-- 
2.7.4

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