[PATCH] staging: rtl8712: fix "Alignment match open parenthesis"

2017-07-06 Thread Arushi Singhal
Fix checkpatch issues: "CHECK: Alignment should match open parenthesis".

Signed-off-by: Arushi Singhal 
---
 drivers/staging/rtl8712/mlme_linux.c| 4 ++--
 drivers/staging/rtl8712/rtl8712_cmd.c   | 2 +-
 drivers/staging/rtl8712/rtl8712_efuse.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/mlme_linux.c 
b/drivers/staging/rtl8712/mlme_linux.c
index 2037265..a077069 100644
--- a/drivers/staging/rtl8712/mlme_linux.c
+++ b/drivers/staging/rtl8712/mlme_linux.c
@@ -111,8 +111,8 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
 */
 
memcpy([0],
-   >securitypriv.PMKIDList[0],
-   sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
+  >securitypriv.PMKIDList[0],
+  sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
backupTKIPCountermeasure =
adapter->securitypriv.btkip_countermeasure;
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c 
b/drivers/staging/rtl8712/rtl8712_cmd.c
index 5346c65..0104ace 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -385,7 +385,7 @@ int r8712_cmd_thread(void *context)
if (blnPending)
wr_sz += 8;   /* Append 8 bytes */
r8712_write_mem(padapter, RTL8712_DMA_H2CCMD, wr_sz,
-  (u8 *)pdesc);
+   (u8 *)pdesc);
pcmdpriv->cmd_seq++;
if (pcmd->cmdcode == GEN_CMD_CODE(_CreateBss)) {
pcmd->res = H2C_SUCCESS;
diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c 
b/drivers/staging/rtl8712/rtl8712_efuse.c
index 205298e..d90213e 100644
--- a/drivers/staging/rtl8712/rtl8712_efuse.c
+++ b/drivers/staging/rtl8712/rtl8712_efuse.c
@@ -347,7 +347,7 @@ static u8 fix_header(struct _adapter *padapter, u8 header, 
u16 header_addr)
ret = false;
if (value == 0xFF) /* write again */
efuse_one_byte_write(padapter, addr,
-   pkt.data[i * 2]);
+pkt.data[i * 2]);
}
if (!efuse_one_byte_read(padapter, addr + 1, )) {
ret = false;
-- 
2.7.4

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


[PATCH 4/4] Staging: Lustre Fix block statement style issue

2017-07-06 Thread Craig Inches
This fixes a block statement which didnt end with */

Signed-off-by: Craig Inches 
---
 drivers/staging/lustre/include/linux/lnet/socklnd.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h 
b/drivers/staging/lustre/include/linux/lnet/socklnd.h
index dd5bc0e46560..a1ae66ede7a8 100644
--- a/drivers/staging/lustre/include/linux/lnet/socklnd.h
+++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h
@@ -76,7 +76,8 @@ struct ksock_msg {
__u64   ksm_zc_cookies[2];  /* Zero-Copy request/ACK cookie */
union {
struct ksock_lnet_msg lnetmsg; /* lnet message, it's empty if
- * it's NOOP */
+   * it's NOOP
+   */
} WIRE_ATTR ksm_u;
 } WIRE_ATTR;
 
-- 
2.13.0

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


[PATCH 3/4] Staging: Lustre Fixing multiline block comments in lnetst.h

2017-07-06 Thread Craig Inches
This fixes multiple block statements found not to match
style as per checkpatch

Signed-off-by: Craig Inches 
---
 drivers/staging/lustre/include/linux/lnet/lnetst.h | 129 +
 1 file changed, 81 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h 
b/drivers/staging/lustre/include/linux/lnet/lnetst.h
index ea736f8d5231..a4f9ff01d458 100644
--- a/drivers/staging/lustre/include/linux/lnet/lnetst.h
+++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h
@@ -54,7 +54,8 @@
 #define LSTIO_GROUP_ADD0xC10   /* add group */
 #define LSTIO_GROUP_LIST   0xC11   /* list all groups in session */
 #define LSTIO_GROUP_INFO   0xC12   /* query default information of
-* specified group */
+* specified group
+*/
 #define LSTIO_GROUP_DEL0xC13   /* delete group */
 #define LSTIO_NODES_ADD0xC14   /* add nodes to specified group 
*/
 #define LSTIO_GROUP_UPDATE  0xC15  /* update group */
@@ -102,27 +103,32 @@ struct lstcon_test_ent {
int tse_type;   /* test type */
int tse_loop;   /* loop count */
int tse_concur; /* concurrency of test */
-}; /*** test summary entry, for
-*** list_batch command */
+}; /* test summary entry, for
+* list_batch command
+*/
 
 struct lstcon_batch_ent {
int bae_state;  /* batch status */
int bae_timeout;/* batch timeout */
int bae_ntest;  /* # of tests in the batch */
-}; /*** batch summary entry, for
-*** list_batch command */
+}; /* batch summary entry, for
+* list_batch command
+*/
 
 struct lstcon_test_batch_ent {
struct lstcon_ndlist_ent   tbe_cli_nle; /* client (group) node_list
-* entry */
+* entry
+*/
struct lstcon_ndlist_ent   tbe_srv_nle; /* server (group) node_list
-* entry */
+* entry
+*/
union {
struct lstcon_test_ent  tbe_test; /* test entry */
struct lstcon_batch_ent tbe_batch;/* batch entry */
} u;
-}; /*** test/batch verbose information entry,
-*** for list_batch command */
+}; /* test/batch verbose information entry,
+* for list_batch command
+*/
 
 struct lstcon_rpc_ent {
struct list_headrpe_link;   /* link chain */
@@ -138,10 +144,10 @@ struct lstcon_rpc_ent {
 };
 
 struct lstcon_trans_stat {
-   int trs_rpc_stat[4];/* RPCs stat (0: total
- 1: failed
- 2: finished
- 4: reserved */
+   int trs_rpc_stat[4];/* RPCs stat (0: total 1: failed
+* 2: finished
+* 4: reserved
+*/
int trs_rpc_errno;  /* RPC errno */
int trs_fwk_stat[8];/* framework stat */
int trs_fwk_errno;  /* errno of the first remote error */
@@ -275,22 +281,28 @@ struct lstio_session_end_args {
 struct lstio_debug_args {
int  lstio_dbg_key; /* IN: session key */
int  lstio_dbg_type;/* IN: debug
-   session|batch|
-   group|nodes
-   list */
+* session|batch|
+* group|nodes list
+*/
int  lstio_dbg_flags;   /* IN: reserved debug
-  flags */
+* flags
+*/
int  lstio_dbg_timeout; /* IN: timeout of
-

[PATCH 1/4] Staging: Luster: Clean up line over 80Char in lib-lnet.h

2017-07-06 Thread Craig Inches
This patch fixes a warning generated by checkpatch for
a line over 80 characters.

Signed-off-by: Craig Inches 
---
 drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h 
b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 8ae7423b4543..f534115d402a 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -453,7 +453,8 @@ extern int portal_rotor;
 int lnet_lib_init(void);
 void lnet_lib_exit(void);
 
-int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, int alive, unsigned long 
when);
+int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, int alive,
+   unsigned long when);
 void lnet_notify_locked(struct lnet_peer *lp, int notifylnd, int alive,
unsigned long when);
 int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid,
-- 
2.13.0

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


[PATCH 2/4] Staging: Lustre Fix up multiple Block Comments in lib-types.h

2017-07-06 Thread Craig Inches
This patch fixes some multiline comment blocks which didnt conform
to the style guide, found by checkpatch.

Signed-off-by: Craig Inches 
---
 .../staging/lustre/include/linux/lnet/lib-types.h  | 46 ++
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h 
b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 321752dfe58b..ddb808ed5d0b 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -308,9 +308,11 @@ struct lnet_rc_data {
 struct lnet_peer {
struct list_head lp_hashlist;   /* chain on peer hash */
struct list_head lp_txq;/* messages blocking for
-  tx credits */
+* tx credits
+*/
struct list_head lp_rtrq;   /* messages blocking for
-  router credits */
+* router credits
+*/
struct list_head lp_rtr_list;   /* chain on router list */
int  lp_txcredits;  /* # tx credits available */
int  lp_mintxcredits;  /* low water mark */
@@ -319,23 +321,31 @@ struct lnet_peer {
unsigned int lp_alive:1;   /* alive/dead? */
unsigned int lp_notify:1;   /* notification outstanding? */
unsigned int lp_notifylnd:1;/* outstanding notification
-  for LND? */
+* for LND?
+*/
unsigned int lp_notifying:1; /* some thread is handling
-   notification */
+ * notification
+ */
unsigned int lp_ping_notsent;/* SEND event outstanding
-   from ping */
+ * from ping
+ */
int  lp_alive_count; /* # times router went
-   dead<->alive */
-   long lp_txqnob;  /* bytes queued for sending */
+ * dead<->alive
+ */
+   long lp_txqnob;  /* ytes queued for sending */
unsigned longlp_timestamp;   /* time of last aliveness
-   news */
+ * news
+ */
unsigned longlp_ping_timestamp;/* time of last ping
- attempt */
+   * attempt
+   */
unsigned longlp_ping_deadline; /* != 0 if ping reply
- expected */
+   * expected
+   */
unsigned longlp_last_alive; /* when I was last alive */
unsigned longlp_last_query; /* when lp_ni was queried
-  last time */
+* last time
+*/
struct lnet_ni  *lp_ni; /* interface peer is on */
lnet_nid_t   lp_nid;/* peer's NID */
int  lp_refcount;   /* # refs */
@@ -386,7 +396,8 @@ struct lnet_route {
 
 struct lnet_remotenet {
struct list_headlrn_list;   /* chain on
-  ln_remote_nets_hash */
+* ln_remote_nets_hash
+*/
struct list_headlrn_routes; /* routes to me */
__u32   lrn_net;/* my net number */
 };
@@ -399,14 +410,16 @@ struct lnet_remotenet {
 struct lnet_rtrbufpool {
struct list_headrbp_bufs;   /* my free buffer pool */
struct list_headrbp_msgs;   /* messages blocking
-  for a buffer */
+* for a buffer
+*/
int   

[PATCH 0/4] Staging: Lustre Style Fixes

2017-07-06 Thread Craig Inches
This series fixes a few style issues in lustre. All where picked up
by checkpatch. 

Craig Inches (4):
  Staging: Luster: Clean up line over 80Char in lib-lnet.h
  Staging: Lustre Fix up multiple Block Comments in lib-types.h
  Staging: Lustre Fixing multiline block comments in lnetst.h
  Staging: Lustre Fix block statement style issue

 .../staging/lustre/include/linux/lnet/lib-lnet.h   |   3 +-
 .../staging/lustre/include/linux/lnet/lib-types.h  |  46 +---
 drivers/staging/lustre/include/linux/lnet/lnetst.h | 129 +
 .../staging/lustre/include/linux/lnet/socklnd.h|   3 +-
 4 files changed, 115 insertions(+), 66 deletions(-)

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


Re: [PATCH v2] staging: typec: Fix endianness warning discovered by sparse

2017-07-06 Thread Thomas Gardner
Guenter Roeck / 2017-07-06T17:13-0700
> On 07/06/2017 03:54 PM, Thomas Gardner wrote:
> > The below warning is resolved by removing the cpu_to_le32() call. This
> > call was redundant; vdm_run_state_machine() ensures that SVDM responses
> > have the correct endianness before sending.
> > 
> > typec/tcpm.c:1019:49: warning: incorrect type in assignment (different base 
> > types)
> > typec/tcpm.c:1019:49:expected unsigned int [unsigned] [usertype] 
> > 
> > typec/tcpm.c:1019:49:got restricted __le32 [usertype] 
> > 
> > Signed-off-by: Thomas Gardner 
> > ---
> >   drivers/staging/typec/tcpm.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
> > index 20eb4ebcf8c3..0b596f56d18c 100644
> > --- a/drivers/staging/typec/tcpm.c
> > +++ b/drivers/staging/typec/tcpm.c
> > @@ -1015,8 +1015,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const 
> > __le32 *payload, int cnt,
> > if (port->data_role == TYPEC_DEVICE &&
> > port->nr_snk_vdo) {
> > for (i = 0; i <  port->nr_snk_vdo; i++)
> > -   response[i + 1]
> > -   = cpu_to_le32(port->snk_vdo[i]);
> > +   response[i + 1] = (port->snk_vdo[i]);
> 
> Unnecessary ( ).

Is there an adaptation of Muphry's Law for patches claiming to remove
redundancy?

> Guenter
> 
> > rlen = port->nr_snk_vdo + 1;
> > }
> > break;
> > 
> 


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


[PATCH v3] staging: typec: Fix endianness warning discovered by sparse

2017-07-06 Thread Thomas Gardner
The below warning is resolved by removing the cpu_to_le32() call. This
call was redundant; vdm_run_state_machine() ensures that SVDM responses
have the correct endianness before sending.

typec/tcpm.c:1019:49: warning: incorrect type in assignment (different base 
types)
typec/tcpm.c:1019:49:expected unsigned int [unsigned] [usertype] 
typec/tcpm.c:1019:49:got restricted __le32 [usertype] 

Signed-off-by: Thomas Gardner 
---
 drivers/staging/typec/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..2195c80235a1 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1015,8 +1015,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const 
__le32 *payload, int cnt,
if (port->data_role == TYPEC_DEVICE &&
port->nr_snk_vdo) {
for (i = 0; i <  port->nr_snk_vdo; i++)
-   response[i + 1]
-   = cpu_to_le32(port->snk_vdo[i]);
+   response[i + 1] = port->snk_vdo[i];
rlen = port->nr_snk_vdo + 1;
}
break;
-- 
2.13.2

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


Re: [PATCH v2] staging: typec: Fix endianness warning discovered by sparse

2017-07-06 Thread Guenter Roeck

On 07/06/2017 03:54 PM, Thomas Gardner wrote:

The below warning is resolved by removing the cpu_to_le32() call. This
call was redundant; vdm_run_state_machine() ensures that SVDM responses
have the correct endianness before sending.

typec/tcpm.c:1019:49: warning: incorrect type in assignment (different base 
types)
typec/tcpm.c:1019:49:expected unsigned int [unsigned] [usertype] 
typec/tcpm.c:1019:49:got restricted __le32 [usertype] 

Signed-off-by: Thomas Gardner 
---
  drivers/staging/typec/tcpm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..0b596f56d18c 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1015,8 +1015,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const 
__le32 *payload, int cnt,
if (port->data_role == TYPEC_DEVICE &&
port->nr_snk_vdo) {
for (i = 0; i <  port->nr_snk_vdo; i++)
-   response[i + 1]
-   = cpu_to_le32(port->snk_vdo[i]);
+   response[i + 1] = (port->snk_vdo[i]);


Unnecessary ( ).

Guenter


rlen = port->nr_snk_vdo + 1;
}
break;



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


[PATCH] vmbus: fix the missed signaling in hv_signal_on_read()

2017-07-06 Thread Dexuan Cui
There is an off-by-one bug here, which can cause host-to-guest write to stall.

When cur_write_sz == pending_sz, we shouldn't signal the host because it's
meaningless: the ring mustn't be 100% full.

But when cached_write_sz == pending_sz, we must signal the host.

Fixes: 433e19cf33d3 ("Drivers: hv: vmbus: finally fix
hv_need_to_signal_on_read()")

Signed-off-by: John Starks 
Signed-off-by: Dexuan Cui 
Cc: Haiyang Zhang 
Cc: Stephen Hemminger 
Cc: "K. Y. Srinivasan" 
Cc: 
---
 include/linux/hyperv.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ba93b7e..246bc6b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1501,11 +1501,11 @@ static inline  void hv_signal_on_read(struct 
vmbus_channel *channel)
 
cur_write_sz = hv_get_bytes_to_write(rbi);
 
-   if (cur_write_sz < pending_sz)
+   if (cur_write_sz <= pending_sz)
return;
 
cached_write_sz = hv_get_cached_bytes_to_write(rbi);
-   if (cached_write_sz < pending_sz)
+   if (cached_write_sz <= pending_sz)
vmbus_setevent(channel);
 
return;
-- 
2.7.4

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


[PATCH v2 9/9] staging: iio: tsl2x7x: check return value from tsl2x7x_invoke_change()

2017-07-06 Thread Brian Masney
The return value from tsl2x7x_invoke_change() was not checked in most
places in the driver. This patch adds the proper error checks. The
return values inside tsl2x7x_invoke_change() are now checked by
this patch as well.

Previously, if there was an error turning the chip back on, then the
driver would attempt to turn the chip off and incorrectly return
success. The code to power off the chip is removed by this patch
since we should fail fast.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 55 +
 1 file changed, 37 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 033468d..c00278d 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -771,22 +771,24 @@ int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
int device_status = chip->tsl2x7x_chip_status;
+   int ret;
 
mutex_lock(>als_mutex);
mutex_lock(>prox_mutex);
 
-   if (device_status == TSL2X7X_CHIP_WORKING)
-   tsl2x7x_chip_off(indio_dev);
-
-   tsl2x7x_chip_on(indio_dev);
+   if (device_status == TSL2X7X_CHIP_WORKING) {
+   ret = tsl2x7x_chip_off(indio_dev);
+   if (ret < 0)
+   goto unlock;
+   }
 
-   if (device_status != TSL2X7X_CHIP_WORKING)
-   tsl2x7x_chip_off(indio_dev);
+   ret = tsl2x7x_chip_on(indio_dev);
 
+unlock:
mutex_unlock(>prox_mutex);
mutex_unlock(>als_mutex);
 
-   return 0;
+   return ret;
 }
 
 static
@@ -925,6 +927,7 @@ static ssize_t in_illuminance0_target_input_store(struct 
device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
unsigned long value;
+   int ret;
 
if (kstrtoul(buf, 0, ))
return -EINVAL;
@@ -932,7 +935,9 @@ static ssize_t in_illuminance0_target_input_store(struct 
device *dev,
if (value)
chip->tsl2x7x_settings.als_cal_target = value;
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
return len;
 }
@@ -981,7 +986,9 @@ static ssize_t in_intensity0_thresh_period_store(struct 
device *dev,
dev_info(>client->dev, "%s: als persistence = %d",
 __func__, filter_delay);
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
return IIO_VAL_INT_PLUS_MICRO;
 }
@@ -1029,7 +1036,10 @@ static ssize_t in_proximity0_thresh_period_store(struct 
device *dev,
dev_info(>client->dev, "%s: prox persistence = %d",
 __func__, filter_delay);
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
+
 
return IIO_VAL_INT_PLUS_MICRO;
 }
@@ -1040,6 +1050,7 @@ static ssize_t in_illuminance0_calibrate_store(struct 
device *dev,
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
bool value;
+   int ret;
 
if (strtobool(buf, ))
return -EINVAL;
@@ -1047,7 +1058,9 @@ static ssize_t in_illuminance0_calibrate_store(struct 
device *dev,
if (value)
tsl2x7x_als_calibrate(indio_dev);
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
return len;
 }
@@ -1087,7 +1100,7 @@ static ssize_t in_illuminance0_lux_table_store(struct 
device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
int value[ARRAY_SIZE(chip->tsl2x7x_device_lux) * 3 + 1];
-   int n;
+   int n, ret;
 
get_options(buf, ARRAY_SIZE(value), value);
 
@@ -1115,7 +1128,9 @@ static ssize_t in_illuminance0_lux_table_store(struct 
device *dev,
memset(chip->tsl2x7x_device_lux, 0, sizeof(chip->tsl2x7x_device_lux));
memcpy(chip->tsl2x7x_device_lux, [1], (value[0] * 4));
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
return len;
 }
@@ -1126,6 +1141,7 @@ static ssize_t in_proximity0_calibrate_store(struct 
device *dev,
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
bool value;
+   int ret;
 
if (strtobool(buf, ))
return -EINVAL;
@@ -1133,7 +1149,9 @@ static ssize_t in_proximity0_calibrate_store(struct 
device *dev,
if (value)
tsl2x7x_prox_cal(indio_dev);
 
-   tsl2x7x_invoke_change(indio_dev);
+   ret = tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
 

[PATCH v2 6/9] staging: iio: tsl2x7x: refactor {read, write}_event_value to allow handling multiple iio_event_infos

2017-07-06 Thread Brian Masney
tsl2x7x_read_thresh() and tsl2x7x_write_thresh() currently assumes
that IIO_EV_INFO_VALUE is the only iio_event_info that will be
passed in.  This patch refactors these two functions so that
additional iio_event_infos can be passed in. The functions are
renamed from tsl2x7x_{read,write}_thresh() to
tsl2x7x_{read,write}_event_value(). This patch also adds the
missing return value check to tsl2x7x_invoke_change() since this
was previously missing. This patch is in preparation for moving
the in_intensity0_thresh_period and in_proximity0_thresh_period sysfs
attributes to be created by iio_event_spec.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 157 +---
 1 file changed, 90 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 5734628..d80f5dc 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1218,78 +1218,101 @@ static int tsl2x7x_write_interrupt_config(struct 
iio_dev *indio_dev,
return 0;
 }
 
-static int tsl2x7x_write_thresh(struct iio_dev *indio_dev,
-   const struct iio_chan_spec *chan,
-   enum iio_event_type type,
-   enum iio_event_direction dir,
-   enum iio_event_info info,
-   int val, int val2)
+static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
+const struct iio_chan_spec *chan,
+enum iio_event_type type,
+enum iio_event_direction dir,
+enum iio_event_info info,
+int val, int val2)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+   int ret = -EINVAL;
 
-   if (chan->type == IIO_INTENSITY) {
-   switch (dir) {
-   case IIO_EV_DIR_RISING:
-   chip->tsl2x7x_settings.als_thresh_high = val;
-   break;
-   case IIO_EV_DIR_FALLING:
-   chip->tsl2x7x_settings.als_thresh_low = val;
-   break;
-   default:
-   return -EINVAL;
-   }
-   } else {
-   switch (dir) {
-   case IIO_EV_DIR_RISING:
-   chip->tsl2x7x_settings.prox_thres_high = val;
-   break;
-   case IIO_EV_DIR_FALLING:
-   chip->tsl2x7x_settings.prox_thres_low = val;
-   break;
-   default:
-   return -EINVAL;
+   switch (info) {
+   case IIO_EV_INFO_VALUE:
+   if (chan->type == IIO_INTENSITY) {
+   switch (dir) {
+   case IIO_EV_DIR_RISING:
+   chip->tsl2x7x_settings.als_thresh_high = val;
+   ret = 0;
+   break;
+   case IIO_EV_DIR_FALLING:
+   chip->tsl2x7x_settings.als_thresh_low = val;
+   ret = 0;
+   break;
+   default:
+   break;
+   }
+   } else {
+   switch (dir) {
+   case IIO_EV_DIR_RISING:
+   chip->tsl2x7x_settings.prox_thres_high = val;
+   ret = 0;
+   break;
+   case IIO_EV_DIR_FALLING:
+   chip->tsl2x7x_settings.prox_thres_low = val;
+   ret = 0;
+   break;
+   default:
+   break;
+   }
}
+   break;
+   default:
+   break;
}
 
-   tsl2x7x_invoke_change(indio_dev);
+   if (ret < 0)
+   return ret;
 
-   return 0;
+   return tsl2x7x_invoke_change(indio_dev);
 }
 
-static int tsl2x7x_read_thresh(struct iio_dev *indio_dev,
-  const struct iio_chan_spec *chan,
-  enum iio_event_type type,
-  enum iio_event_direction dir,
-  enum iio_event_info info,
-  int *val, int *val2)
+static int tsl2x7x_read_event_value(struct iio_dev *indio_dev,
+   const struct iio_chan_spec *chan,
+   enum iio_event_type type,
+   enum iio_event_direction dir,
+   enum iio_event_info info,
+   int *val, int 

[PATCH v2 8/9] staging: iio: tsl2x7x: migrate in_illuminance0_integration_time sysfs attribute to iio_chan_spec

2017-07-06 Thread Brian Masney
The driver explicitly creates the in_illuminance0_integration_time sysfs
attribute outside the IIO core. This attribute is available in the IIO
core so this patches migrates the attribute to be created by
the iio_chan_spec.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 68 +++--
 1 file changed, 19 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index c38bd64..033468d 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -905,46 +905,6 @@ static ssize_t 
in_proximity0_calibscale_available_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
 }
 
-static ssize_t in_illuminance0_integration_time_show(struct device *dev,
-struct device_attribute *attr,
-char *buf)
-{
-   struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-   int y, z;
-
-   y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
-   z = y * TSL2X7X_MIN_ITIME;
-   y /= 1000;
-   z %= 1000;
-
-   return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
-}
-
-static ssize_t in_illuminance0_integration_time_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
-   struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-   struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   struct tsl2x7x_parse_result result;
-   int ret;
-
-   ret = iio_str_to_fixpoint(buf, 100, , );
-   if (ret)
-   return ret;
-
-   result.fract /= 3;
-   chip->tsl2x7x_settings.als_time =
-   TSL2X7X_MAX_TIMER_CNT - (u8)result.fract;
-
-   dev_info(>client->dev, "%s: als time = %d",
-__func__, chip->tsl2x7x_settings.als_time);
-
-   tsl2x7x_invoke_change(indio_dev);
-
-   return IIO_VAL_INT_PLUS_MICRO;
-}
-
 static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
".00272 - .696");
 
@@ -1369,7 +1329,13 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
*val = chip->tsl2x7x_settings.als_gain_trim;
ret = IIO_VAL_INT;
break;
-
+   case IIO_CHAN_INFO_INT_TIME:
+   *val = (TSL2X7X_MAX_TIMER_CNT - chip->tsl2x7x_settings.als_time)
+   + 1;
+   *val2 = (*val * TSL2X7X_MIN_ITIME) % 1000;
+   *val /= 1000;
+   ret = IIO_VAL_INT_PLUS_MICRO;
+   break;
default:
ret = -EINVAL;
}
@@ -1445,7 +1411,13 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_CALIBBIAS:
chip->tsl2x7x_settings.als_gain_trim = val;
break;
+   case IIO_CHAN_INFO_INT_TIME:
+   chip->tsl2x7x_settings.als_time =
+   TSL2X7X_MAX_TIMER_CNT - (val2 / 3);
 
+   dev_info(>client->dev, "%s: als time = %d",
+__func__, chip->tsl2x7x_settings.als_time);
+   break;
default:
return -EINVAL;
}
@@ -1459,8 +1431,6 @@ static DEVICE_ATTR_RO(in_proximity0_calibscale_available);
 
 static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
 
-static DEVICE_ATTR_RW(in_illuminance0_integration_time);
-
 static DEVICE_ATTR_RW(in_illuminance0_target_input);
 
 static DEVICE_ATTR_WO(in_illuminance0_calibrate);
@@ -1540,7 +1510,6 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1555,7 +1524,6 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1572,7 +1540,6 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1710,7 +1677,8 @@ static const struct tsl2x7x_chip_info 

[PATCH v2 4/9] staging: iio: tsl2x7x: remove tsl2x7x_i2c_read()

2017-07-06 Thread Brian Masney
tsl2x7x_i2c_read() would call i2c_smbus_write_byte() and
i2c_smbus_read_byte(). These two i2c functions can be replaced with a
single call to i2c_smbus_read_byte_data(). This patch removes the
tsl2x7x_i2c_read() function and replaces all occurrences with a call to
i2c_smbus_read_byte_data().

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 71 -
 1 file changed, 22 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 95ed7cc6..6c9f06b 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -285,35 +285,6 @@ static const u8 device_channel_config[] = {
 };
 
 /**
- * tsl2x7x_i2c_read() - Read a byte from a register.
- * @client:i2c client
- * @reg:   device register to read from
- * @*val:  pointer to location to store register contents.
- *
- */
-static int
-tsl2x7x_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
-{
-   int ret;
-
-   /* select register to write */
-   ret = i2c_smbus_write_byte(client, (TSL2X7X_CMD_REG | reg));
-   if (ret < 0) {
-   dev_err(>dev, "failed to write register %x\n", reg);
-   return ret;
-   }
-
-   /* read the data */
-   ret = i2c_smbus_read_byte(client);
-   if (ret >= 0)
-   *val = (u8)ret;
-   else
-   dev_err(>dev, "failed to read register %x\n", reg);
-
-   return ret;
-}
-
-/**
  * tsl2x7x_get_lux() - Reads and calculates current lux value.
  * @indio_dev: pointer to IIO device
  *
@@ -352,15 +323,15 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
goto out_unlock;
}
 
-   ret = tsl2x7x_i2c_read(chip->client,
-  (TSL2X7X_CMD_REG | TSL2X7X_STATUS), [0]);
+   ret = i2c_smbus_read_byte_data(chip->client,
+  TSL2X7X_CMD_REG | TSL2X7X_STATUS);
if (ret < 0) {
dev_err(>client->dev,
"%s: Failed to read STATUS Reg\n", __func__);
goto out_unlock;
}
/* is data new & valid */
-   if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
+   if (!(ret & TSL2X7X_STA_ADC_VALID)) {
dev_err(>client->dev,
"%s: data not valid yet\n", __func__);
ret = chip->als_cur_info.lux; /* return LAST VALUE */
@@ -368,14 +339,16 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
}
 
for (i = 0; i < 4; i++) {
-   ret = tsl2x7x_i2c_read(chip->client,
-  (TSL2X7X_CMD_REG |
-  (TSL2X7X_ALS_CHAN0LO + i)), [i]);
+   int reg = TSL2X7X_CMD_REG | (TSL2X7X_ALS_CHAN0LO + i);
+
+   ret = i2c_smbus_read_byte_data(chip->client, reg);
if (ret < 0) {
dev_err(>client->dev,
"failed to read. err=%x\n", ret);
goto out_unlock;
}
+
+   buf[i] = ret;
}
 
/* clear any existing interrupt status */
@@ -475,7 +448,6 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 {
int i;
int ret;
-   u8 status;
u8 chdata[2];
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
@@ -485,8 +457,8 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
return -EBUSY;
}
 
-   ret = tsl2x7x_i2c_read(chip->client,
-  (TSL2X7X_CMD_REG | TSL2X7X_STATUS), );
+   ret = i2c_smbus_read_byte_data(chip->client,
+  TSL2X7X_CMD_REG | TSL2X7X_STATUS);
if (ret < 0) {
dev_err(>client->dev, "i2c err=%d\n", ret);
goto prox_poll_err;
@@ -498,7 +470,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
case tmd2671:
case tsl2771:
case tmd2771:
-   if (!(status & TSL2X7X_STA_ADC_VALID))
+   if (!(ret & TSL2X7X_STA_ADC_VALID))
goto prox_poll_err;
break;
case tsl2572:
@@ -506,17 +478,19 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
case tmd2672:
case tsl2772:
case tmd2772:
-   if (!(status & TSL2X7X_STA_PRX_VALID))
+   if (!(ret & TSL2X7X_STA_PRX_VALID))
goto prox_poll_err;
break;
}
 
for (i = 0; i < 2; i++) {
-   ret = tsl2x7x_i2c_read(chip->client,
-  (TSL2X7X_CMD_REG |
-  (TSL2X7X_PRX_LO + i)), [i]);
+   int reg = TSL2X7X_CMD_REG | (TSL2X7X_PRX_LO + i);
+
+   ret = i2c_smbus_read_byte_data(chip->client, reg);
if (ret < 0)
goto prox_poll_err;
+
+  

[PATCH v2 5/9] staging: iio: tsl2x7x: cleaned up i2c calls in tsl2x7x_als_calibrate()

2017-07-06 Thread Brian Masney
The calibration function calls i2c_smbus_write_byte() and
i2c_smbus_read_byte(). These two function calls are replaced with a
single call to i2c_smbus_read_byte_data() by this patch. This patch
also removes an unnecessary call that reads the CNTRL register
a second time. One of the error paths returned -1 if the ADC was not
enabled and this patch changes that return value to -EINVAL.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 34 --
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 6c9f06b..5734628 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -542,39 +542,29 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
 static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   u8 reg_val;
int gain_trim_val;
int ret;
int lux_val;
 
-   ret = i2c_smbus_write_byte(chip->client,
-  (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
+   ret = i2c_smbus_read_byte_data(chip->client,
+  TSL2X7X_CMD_REG | TSL2X7X_CNTRL);
if (ret < 0) {
dev_err(>client->dev,
-   "failed to write CNTRL register, ret=%d\n", ret);
+   "%s: failed to read from the CNTRL register\n",
+   __func__);
return ret;
}
 
-   reg_val = i2c_smbus_read_byte(chip->client);
-   if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
-   != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
-   dev_err(>client->dev,
-   "%s: failed: ADC not enabled\n", __func__);
-   return -1;
-   }
-
-   ret = i2c_smbus_write_byte(chip->client,
-  (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
-   if (ret < 0) {
+   if ((ret & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
+   != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
dev_err(>client->dev,
-   "failed to write ctrl reg: ret=%d\n", ret);
-   return ret;
-   }
-
-   reg_val = i2c_smbus_read_byte(chip->client);
-   if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
+   "%s: Device is not powered on and/or ADC is not 
enabled\n",
+   __func__);
+   return -EINVAL;
+   } else if ((ret & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
dev_err(>client->dev,
-   "%s: failed: STATUS - ADC not valid.\n", __func__);
+   "%s: The two ADC channels have not completed an 
integration cycle\n",
+   __func__);
return -ENODATA;
}
 
-- 
2.9.4

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


[PATCH v2 7/9] staging: iio: tsl2x7x: use usleep_range() instead of mdelay()

2017-07-06 Thread Brian Masney
This driver in some cases can busy wait for upwards of 15ms. Since the
kernel at this point is not running in atomic context, and is running in
process context, we can safely use usleep_range() instead. This patch
changes the two occurrences of mdelay() to usleep_range().

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index d80f5dc..c38bd64 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -686,7 +686,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
}
}
 
-   mdelay(3);  /* Power-on settling time */
+   /* Power-on settling time */
+   usleep_range(3000, 3500);
 
/*
 * NOW enable the ADC
@@ -853,7 +854,7 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
 
/*gather the samples*/
for (i = 0; i < chip->tsl2x7x_settings.prox_max_samples_cal; i++) {
-   mdelay(15);
+   usleep_range(15000, 17500);
tsl2x7x_get_prox(indio_dev);
prox_history[i] = chip->prox_data;
dev_info(>client->dev, "2 i=%d prox data= %d\n",
-- 
2.9.4

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


[PATCH v2 2/9] staging: iio: tsl2x7x: add device tree documentation

2017-07-06 Thread Brian Masney
Add device tree documentation for the tsl2x7x IIO driver.

Signed-off-by: Brian Masney 
CC: Rob Herring 
CC: Mark Rutland 
CC: devicet...@vger.kernel.org
---
 Documentation/devicetree/bindings/trivial-devices.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/trivial-devices.txt 
b/Documentation/devicetree/bindings/trivial-devices.txt
index 35f406d..0e6e953 100644
--- a/Documentation/devicetree/bindings/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/trivial-devices.txt
@@ -21,6 +21,16 @@ adi,adt7490  +/-1C TDM Extended Temp Range I.C
 adi,adxl345Three-Axis Digital Accelerometer
 adi,adxl346Three-Axis Digital Accelerometer 
(backward-compatibility value "adi,adxl345" must be listed too)
 ams,iaq-core   AMS iAQ-Core VOC Sensor
+amstaos,tsl2571AMS/TAOS ALS and proximity sensor
+amstaos,tsl2671AMS/TAOS ALS and proximity sensor
+amstaos,tmd2671AMS/TAOS ALS and proximity sensor
+amstaos,tsl2771AMS/TAOS ALS and proximity sensor
+amstaos,tmd2771AMS/TAOS ALS and proximity sensor
+amstaos,tsl2572AMS/TAOS ALS and proximity sensor
+amstaos,tsl2672AMS/TAOS ALS and proximity sensor
+amstaos,tmd2672AMS/TAOS ALS and proximity sensor
+amstaos,tsl2772AMS/TAOS ALS and proximity sensor
+amstaos,tmd2772AMS/TAOS ALS and proximity sensor
 at,24c08   i2c serial eeprom  (24cxx)
 atmel,at97sc3204t  i2c trusted platform module (TPM)
 capella,cm32181CM32181: Ambient Light Sensor
-- 
2.9.4

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


[PATCH v2 0/9] staging: iio: tsl2x7x: staging cleanups

2017-07-06 Thread Brian Masney
This begins my work to clean this driver up and eventually move it out
of staging. Driver changes were tested using a TSL2771 hooked up to a
Raspberry Pi 2.

Thanks to Jon Brenner at AMS/TAOS for loaning me some hardware samples
to test my driver changes.

Changes since v1:
- checkpatch cleanups (oops)
- Split out the device tree documentation and driver change into
  two separate commits so that the changes can be accepted in separate
  trees to avoid merge conflicts later.
- New patch: migrate in_illuminance0_integration_time sysfs
  attribute to iio_chan_spec
- New patch: check return value from tsl2x7x_invoke_change()

Brian Masney (9):
  staging: iio: tsl2x7x: add of_match table for device tree support
  staging: iio: tsl2x7x: add device tree documentation
  staging: iio: tsl2x7x: remove redundant power_state sysfs attribute
  staging: iio: tsl2x7x: remove tsl2x7x_i2c_read()
  staging: iio: tsl2x7x: cleaned up i2c calls in tsl2x7x_als_calibrate()
  staging: iio: tsl2x7x: refactor {read,write}_event_value to allow
handling multiple iio_event_infos
  staging: iio: tsl2x7x: use usleep_range() instead of mdelay()
  staging: iio: tsl2x7x: migrate in_illuminance0_integration_time sysfs
attribute to iio_chan_spec
  staging: iio: tsl2x7x: check return value from tsl2x7x_invoke_change()

 .../devicetree/bindings/trivial-devices.txt|  10 +
 drivers/staging/iio/light/tsl2x7x.c| 440 ++---
 2 files changed, 209 insertions(+), 241 deletions(-)

-- 
2.9.4

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


[PATCH v2 1/9] staging: iio: tsl2x7x: add of_match table for device tree support

2017-07-06 Thread Brian Masney
Add device tree support for the tsl2x7x IIO driver with no custom
properties. The device tree documentation is in a separate commit so
that the changes to trivial-devices.txt can go in via the device
tree subsystem.

Signed-off-by: Brian Masney 
CC: Rob Herring 
CC: Mark Rutland 
CC: devicet...@vger.kernel.org
---
 drivers/staging/iio/light/tsl2x7x.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 1467199..8148986 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -2026,6 +2026,21 @@ static struct i2c_device_id tsl2x7x_idtable[] = {
 
 MODULE_DEVICE_TABLE(i2c, tsl2x7x_idtable);
 
+static const struct of_device_id tsl2x7x_of_match[] = {
+   { .compatible = "amstaos,tsl2571" },
+   { .compatible = "amstaos,tsl2671" },
+   { .compatible = "amstaos,tmd2671" },
+   { .compatible = "amstaos,tsl2771" },
+   { .compatible = "amstaos,tmd2771" },
+   { .compatible = "amstaos,tsl2572" },
+   { .compatible = "amstaos,tsl2672" },
+   { .compatible = "amstaos,tmd2672" },
+   { .compatible = "amstaos,tsl2772" },
+   { .compatible = "amstaos,tmd2772" },
+   {}
+};
+MODULE_DEVICE_TABLE(of, tsl2x7x_of_match);
+
 static const struct dev_pm_ops tsl2x7x_pm_ops = {
.suspend = tsl2x7x_suspend,
.resume  = tsl2x7x_resume,
@@ -2035,6 +2050,7 @@ static const struct dev_pm_ops tsl2x7x_pm_ops = {
 static struct i2c_driver tsl2x7x_driver = {
.driver = {
.name = "tsl2x7x",
+   .of_match_table = tsl2x7x_of_match,
.pm = _pm_ops,
},
.id_table = tsl2x7x_idtable,
-- 
2.9.4

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


[PATCH v2 3/9] staging: iio: tsl2x7x: remove redundant power_state sysfs attribute

2017-07-06 Thread Brian Masney
The TSL2X7X driver has a custom power_state sysfs attribute. Remove this
attribute since the runtime power management code provides a sysfs
attribute to control the power state of the device.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 34 --
 1 file changed, 34 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 8148986..95ed7cc6 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -915,33 +915,6 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
tsl2x7x_chip_on(indio_dev);
 }
 
-static ssize_t power_state_show(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
-{
-   struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
-
-   return snprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
-}
-
-static ssize_t power_state_store(struct device *dev,
-struct device_attribute *attr,
-const char *buf, size_t len)
-{
-   struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-   bool value;
-
-   if (strtobool(buf, ))
-   return -EINVAL;
-
-   if (value)
-   tsl2x7x_chip_on(indio_dev);
-   else
-   tsl2x7x_chip_off(indio_dev);
-
-   return len;
-}
-
 static ssize_t in_illuminance0_calibscale_available_show(struct device *dev,
   struct device_attribute *attr,
   char *buf)
@@ -1494,8 +1467,6 @@ static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
return 0;
 }
 
-static DEVICE_ATTR_RW(power_state);
-
 static DEVICE_ATTR_RO(in_proximity0_calibscale_available);
 
 static DEVICE_ATTR_RO(in_illuminance0_calibscale_available);
@@ -1580,7 +1551,6 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 }
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
-   _attr_power_state.attr,
_attr_in_illuminance0_calibscale_available.attr,
_attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
@@ -1591,13 +1561,11 @@ static struct attribute *tsl2x7x_ALS_device_attrs[] = {
 };
 
 static struct attribute *tsl2x7x_PRX_device_attrs[] = {
-   _attr_power_state.attr,
_attr_in_proximity0_calibrate.attr,
NULL
 };
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
-   _attr_power_state.attr,
_attr_in_illuminance0_calibscale_available.attr,
_attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
@@ -1609,14 +1577,12 @@ static struct attribute *tsl2x7x_ALSPRX_device_attrs[] 
= {
 };
 
 static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
-   _attr_power_state.attr,
_attr_in_proximity0_calibrate.attr,
_attr_in_proximity0_calibscale_available.attr,
NULL
 };
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
-   _attr_power_state.attr,
_attr_in_illuminance0_calibscale_available.attr,
_attr_in_illuminance0_integration_time.attr,

_const_attr_in_illuminance0_integration_time_available.dev_attr.attr,
-- 
2.9.4

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


[PATCH v2] staging: typec: Fix endianness warning discovered by sparse

2017-07-06 Thread Thomas Gardner
The below warning is resolved by removing the cpu_to_le32() call. This
call was redundant; vdm_run_state_machine() ensures that SVDM responses
have the correct endianness before sending.

typec/tcpm.c:1019:49: warning: incorrect type in assignment (different base 
types)
typec/tcpm.c:1019:49:expected unsigned int [unsigned] [usertype] 
typec/tcpm.c:1019:49:got restricted __le32 [usertype] 

Signed-off-by: Thomas Gardner 
---
 drivers/staging/typec/tcpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..0b596f56d18c 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1015,8 +1015,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const 
__le32 *payload, int cnt,
if (port->data_role == TYPEC_DEVICE &&
port->nr_snk_vdo) {
for (i = 0; i <  port->nr_snk_vdo; i++)
-   response[i + 1]
-   = cpu_to_le32(port->snk_vdo[i]);
+   response[i + 1] = (port->snk_vdo[i]);
rlen = port->nr_snk_vdo + 1;
}
break;
-- 
2.13.2

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


Re: [PATCH v4] staging: lustre: lnet: remove dead code and crc32_le() wrapper

2017-07-06 Thread Dmitriy Cherkasov

On 06/29/2017 10:50 PM, Dmitriy Cherkasov wrote:

After removing code which was permanently disabled with ifdefs, the
function ksocknal_csum() becomes just a wrapper for crc32_le(). Remove
this useless wrapper and instead call crc32_le() directly.



Any feedback on v4 please?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/6] staging: iio: tsl2x7x: add of_match table for device tree support

2017-07-06 Thread Rob Herring
On Thu, Jun 29, 2017 at 01:03:47PM -0400, Brian Masney wrote:
> Add device tree support for the tsl2x7x IIO driver with no custom
> properties.
> 
> Signed-off-by: Brian Masney 
> CC: Rob Herring 
> CC: Mark Rutland 
> CC: devicet...@vger.kernel.org
> ---
>  Documentation/devicetree/bindings/trivial-devices.txt | 10 ++

It's better if you split this so I can take it and avoid any conflicts.

>  drivers/staging/iio/light/tsl2x7x.c   | 16 
>  2 files changed, 26 insertions(+)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: atomisp: gc2235: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  107541360   4   121182f56
drivers/staging/media/atomisp/i2c/gc2235.o

File size After adding 'const':
   textdata bss dec hex filename
  108181296   4   121182f56
drivers/staging/media/atomisp/i2c/gc2235.o

Signed-off-by: Arvind Yadav 
---
 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 50f4317..48ca23b 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/gc2235.c
@@ -1183,7 +1183,7 @@ static int gc2235_probe(struct i2c_client *client,
return ret;
 }
 
-static struct acpi_device_id gc2235_acpi_match[] = {
+static const struct acpi_device_id gc2235_acpi_match[] = {
{ "INT33F8" },
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: mt9m114: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  151482640   8   177964584
drivers/staging/media/atomisp/i2c/mt9m114.o

File size After adding 'const':
   textdata bss dec hex filename
  152442512   8   177644564
drivers/staging/media/atomisp/i2c/mt9m114.o

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

diff --git a/drivers/staging/media/atomisp/i2c/mt9m114.c 
b/drivers/staging/media/atomisp/i2c/mt9m114.c
index ced175c..68980ab 100644
--- a/drivers/staging/media/atomisp/i2c/mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/mt9m114.c
@@ -1928,7 +1928,7 @@ static int mt9m114_probe(struct i2c_client *client,
 
 MODULE_DEVICE_TABLE(i2c, mt9m114_id);
 
-static struct acpi_device_id mt9m114_acpi_match[] = {
+static const struct acpi_device_id mt9m114_acpi_match[] = {
{ "INT33F0" },
{ "CRMT1040" },
{},
-- 
2.7.4

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


[PATCH] staging: atomisp: ov5693: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  207293264   0   239935db9
drivers/staging/media/atomisp/i2c/ov5693/ov5693.o

File size After adding 'const':
   textdata bss dec hex filename
  207933200   0   239935db9
drivers/staging/media/atomisp/i2c/ov5693/ov5693.o

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

diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c 
b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
index 5e9dafe..2c79678 100644
--- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
+++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
@@ -2032,7 +2032,7 @@ static int ov5693_probe(struct i2c_client *client,
 
 MODULE_DEVICE_TABLE(i2c, ov5693_id);
 
-static struct acpi_device_id ov5693_acpi_match[] = {
+static const struct acpi_device_id ov5693_acpi_match[] = {
{"INT33BE"},
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: ov2722: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  147711880   0   16651410b 
drivers/staging/media/atomisp/i2c/ov2722.o

File size After adding 'const':
   textdata bss dec hex filename
  148351816   0   16651410b 
drivers/staging/media/atomisp/i2c/ov2722.o

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

diff --git a/drivers/staging/media/atomisp/i2c/ov2722.c 
b/drivers/staging/media/atomisp/i2c/ov2722.c
index b7afade..10094ac 100644
--- a/drivers/staging/media/atomisp/i2c/ov2722.c
+++ b/drivers/staging/media/atomisp/i2c/ov2722.c
@@ -1337,7 +1337,7 @@ static int ov2722_probe(struct i2c_client *client,
 
 MODULE_DEVICE_TABLE(i2c, ov2722_id);
 
-static struct acpi_device_id ov2722_acpi_match[] = {
+static const struct acpi_device_id ov2722_acpi_match[] = {
{ "INT33FB" },
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: gc0310: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  102971888   0   121852f99 
drivers/staging/media/atomisp/i2c/gc0310.o

File size After adding 'const':
   textdata bss dec hex filename
  103611824   0   121852f99 
drivers/staging/media/atomisp/i2c/gc0310.o

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

diff --git a/drivers/staging/media/atomisp/i2c/gc0310.c 
b/drivers/staging/media/atomisp/i2c/gc0310.c
index 1ec616a..c8162bb 100644
--- a/drivers/staging/media/atomisp/i2c/gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/gc0310.c
@@ -1453,7 +1453,7 @@ static int gc0310_probe(struct i2c_client *client,
return ret;
 }
 
-static struct acpi_device_id gc0310_acpi_match[] = {
+static const struct acpi_device_id gc0310_acpi_match[] = {
{"XXGC0310"},
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: ov8858: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  238048448   0   322527dfc 
drivers/staging/media/atomisp/i2c/ov8858.o

File size After adding 'const':
   textdata bss dec hex filename
  238688384   0   322527dfc 
drivers/staging/media/atomisp/i2c/ov8858.o

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

diff --git a/drivers/staging/media/atomisp/i2c/ov8858.c 
b/drivers/staging/media/atomisp/i2c/ov8858.c
index 9574bc4..43e1638 100644
--- a/drivers/staging/media/atomisp/i2c/ov8858.c
+++ b/drivers/staging/media/atomisp/i2c/ov8858.c
@@ -2189,7 +2189,7 @@ static const struct i2c_device_id ov8858_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, ov8858_id);
 
-static struct acpi_device_id ov8858_acpi_match[] = {
+static const struct acpi_device_id ov8858_acpi_match[] = {
{"INT3477"},
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: ov2680: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
  124663120   8   155943cea 
drivers/staging/media/atomisp/i2c/ov2680.o

File size After adding 'const':
   textdata bss dec hex filename
  125303056   8   155943cea 
drivers/staging/media/atomisp/i2c/ov2680.o

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

diff --git a/drivers/staging/media/atomisp/i2c/ov2680.c 
b/drivers/staging/media/atomisp/i2c/ov2680.c
index 5660910..9671876 100644
--- a/drivers/staging/media/atomisp/i2c/ov2680.c
+++ b/drivers/staging/media/atomisp/i2c/ov2680.c
@@ -1519,7 +1519,7 @@ static int ov2680_probe(struct i2c_client *client,
return ret;
 }
 
-static struct acpi_device_id ov2680_acpi_match[] = {
+static const struct acpi_device_id ov2680_acpi_match[] = {
{"XXOV2680"},
{},
 };
-- 
2.7.4

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


[PATCH] staging: atomisp: lm3554: constify acpi_device_id.

2017-07-06 Thread Arvind Yadav
acpi_device_id are not supposed to change at runtime. All functions
working with acpi_device_id provided by  work with
const acpi_device_id. So mark the non-const structs as const.

File size before:
   textdata bss dec hex filename
   53471920  2472911c7b 
drivers/staging/media/atomisp/i2c/lm3554.o

File size After adding 'const':
   textdata bss dec hex filename
   54111856  2472911c7b 
drivers/staging/media/atomisp/i2c/lm3554.o

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

diff --git a/drivers/staging/media/atomisp/i2c/lm3554.c 
b/drivers/staging/media/atomisp/i2c/lm3554.c
index dd9c9c3..9ba1037 100644
--- a/drivers/staging/media/atomisp/i2c/lm3554.c
+++ b/drivers/staging/media/atomisp/i2c/lm3554.c
@@ -974,7 +974,7 @@ static const struct dev_pm_ops lm3554_pm_ops = {
.resume = lm3554_resume,
 };
 
-static struct acpi_device_id lm3554_acpi_match[] = {
+static const struct acpi_device_id lm3554_acpi_match[] = {
{ "INTCF1C" },
{},
 };
-- 
2.7.4

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


Re: [PATCH] staging: typec: Fix type mismatch found with sparse

2017-07-06 Thread Guenter Roeck

On 07/05/2017 07:57 PM, Thomas Gardner wrote:

Guenter Roeck / 2017-07-05T07:25-0700

On 07/05/2017 07:00 AM, Thomas Gardner wrote:

The warning below is resolved by casting the LHS to __le32.

typec/tcpm.c:1019:49: warning: incorrect type in assignment (different base 
types)
typec/tcpm.c:1019:49:expected unsigned int [unsigned] [usertype] 
typec/tcpm.c:1019:49:got restricted __le32 [usertype] 

Signed-off-by: Thomas Gardner 
---
   drivers/staging/typec/tcpm.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..7699bb27a4d9 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -1015,7 +1015,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const 
__le32 *payload, int cnt,
if (port->data_role == TYPEC_DEVICE &&
port->nr_snk_vdo) {
for (i = 0; i <  port->nr_snk_vdo; i++)
-   response[i + 1]
+   ((__le32 *)response)[i + 1]
= cpu_to_le32(port->snk_vdo[i]);
rlen = port->nr_snk_vdo + 1;
}


I think this would just hide a number of at least potential endianness issues
in the driver. response[] should be of type __le32 instead, with everything
that comes with it.


Greetings Guenter, is this conversion actually necessary? The state
machine tries to fix endianness of the response before sending at,

for (i = 0; i < port->vdo_count; i++)
msg.payload[i] = cpu_to_le32(port->vdo_data[i]);

Perhaps the patch should be,

-   response[i + 1]
-   = cpu_to_le32(port->snk_vdo[i]);
+   response[i + 1] = port->snk_vdo[i];

which also clears the warning.



Yes, looking through the code, that is correct.

Thanks for tracking this down. Can you send an updated patch ?

Guenter


Which makes me wonder, since I don't see any of those warnings - what
does it take to see them ?


I can see them by running,

make C=2 ./drivers/staging/typec/


Guenter







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


Re: [PATCH 2/2] Staging: dgnc: I have fixed the changes in dgnc_neo.c This is a patch to the dgnc_neo.c warning udealy to usleep range Signed-off-by: Yash Omer <yashomer0...@gmail.com>

2017-07-06 Thread Dan Carpenter
On Thu, Jul 06, 2017 at 07:29:32AM +0530, yash007 wrote:
> From: Yash Omer 
> 

Send your patch to yourself until you figure out the right format then
send it to the list.

regards,
dan carpenter

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


[PATCH 2/2] Staging: dgnc: I have fixed the changes in dgnc_neo.c This is a patch to the dgnc_neo.c warning udealy to usleep range Signed-off-by: Yash Omer <yashomer0...@gmail.com>

2017-07-06 Thread yash007
From: Yash Omer 

---
 drivers/staging/dgnc/dgnc_neo.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 1943e66..0034ebe 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1230,7 +1230,7 @@ static void neo_flush_uart_write(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 4)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1261,7 +1261,7 @@ static void neo_flush_uart_read(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 2)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1483,7 +1483,7 @@ static void neo_assert_modem_signals(struct channel_t *ch)
neo_pci_posting_flush(ch->ch_bd);
 
/* Give time for the UART to actually raise/drop the signals */
-   udelay(10);
+   usleep_range(10);
 }
 
 static void neo_send_start_character(struct channel_t *ch)
@@ -1495,7 +1495,7 @@ static void neo_send_start_character(struct channel_t *ch)
ch->ch_xon_sends++;
writeb(ch->ch_startc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
@@ -1508,7 +1508,7 @@ static void neo_send_stop_character(struct channel_t *ch)
ch->ch_xoff_sends++;
writeb(ch->ch_stopc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
-- 
2.1.4

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


Re: [PATCH 8/8] Staging: lustre :lustre: include :lustre_compat.h: Prefer using the BIT macro

2017-07-06 Thread Frans Klaver
On Thu, Jul 6, 2017 at 9:13 AM, Jaya Durga  wrote:
> Subject: Staging: lustre :lustre: include :lustre_compat.h: Prefer using the 
> BIT macro

Don't overdo it ;-).

Subject: staging: lustre: lustre_compat.h: Prefer using the BIT macro

> Replace all instances of (1 << 27) with BIT(27) to fix
> checkpatch check messages

While it may technically be true that this one instance is every
instance of (1<<27) there is in lustre_compat.h, I must say I expected
a bigger patch when I saw "replace all instances".


> Signed-off-by: Jaya Durga 
> ---
>  drivers/staging/lustre/lustre/include/lustre_compat.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
> b/drivers/staging/lustre/lustre/include/lustre_compat.h
> index da9ce19..686a251 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_compat.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
> @@ -43,7 +43,7 @@
>   * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
>   * ATTR_* attributes (see bug 13828)
>   */
> -#define ATTR_BLOCKS(1 << 27)
> +#define ATTR_BLOCKSBIT(27)
>
>  #define current_ngroups current_cred()->group_info->ngroups
>  #define current_groups current_cred()->group_info->small_block
> --
> 1.9.1
>
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 8/8] Staging: lustre :lustre: include :lustre_compat.h: Prefer using the BIT macro

2017-07-06 Thread Jaya Durga
Replace all instances of (1 << 27) with BIT(27) to fix
checkpatch check messages

Signed-off-by: Jaya Durga 
---
 drivers/staging/lustre/lustre/include/lustre_compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_compat.h 
b/drivers/staging/lustre/lustre/include/lustre_compat.h
index da9ce19..686a251 100644
--- a/drivers/staging/lustre/lustre/include/lustre_compat.h
+++ b/drivers/staging/lustre/lustre/include/lustre_compat.h
@@ -43,7 +43,7 @@
  * set ATTR_BLOCKS to a high value to avoid any risk of collision with other
  * ATTR_* attributes (see bug 13828)
  */
-#define ATTR_BLOCKS(1 << 27)
+#define ATTR_BLOCKSBIT(27)
 
 #define current_ngroups current_cred()->group_info->ngroups
 #define current_groups current_cred()->group_info->small_block
-- 
1.9.1

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


[PATCH 2/2] Staging: dgnc: I have fixed the changes in dgnc_neo.c This is a patch to the dgnc_neo.c warning udealy to usleep range Signed-off-by: Yash Omer <yashomer0...@gmail.com>

2017-07-06 Thread yash007
From: Yash Omer 

---
 drivers/staging/dgnc/dgnc_neo.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 1943e66..0034ebe 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1230,7 +1230,7 @@ static void neo_flush_uart_write(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 4)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1261,7 +1261,7 @@ static void neo_flush_uart_read(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 2)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1483,7 +1483,7 @@ static void neo_assert_modem_signals(struct channel_t *ch)
neo_pci_posting_flush(ch->ch_bd);
 
/* Give time for the UART to actually raise/drop the signals */
-   udelay(10);
+   usleep_range(10);
 }
 
 static void neo_send_start_character(struct channel_t *ch)
@@ -1495,7 +1495,7 @@ static void neo_send_start_character(struct channel_t *ch)
ch->ch_xon_sends++;
writeb(ch->ch_startc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
@@ -1508,7 +1508,7 @@ static void neo_send_stop_character(struct channel_t *ch)
ch->ch_xoff_sends++;
writeb(ch->ch_stopc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
-- 
2.1.4

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


[PATCH 2/2] Staging: dgnc: I have fixed the changes in dgnc_neo.c This is a patch to the dgnc_neo.c warning udealy to usleep range Signed-off-by: Yash Omer <yashomer0...@gmail.com>

2017-07-06 Thread yash007
From: Yash Omer 

---
 drivers/staging/dgnc/dgnc_neo.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 1943e66..0034ebe 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1230,7 +1230,7 @@ static void neo_flush_uart_write(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 4)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1261,7 +1261,7 @@ static void neo_flush_uart_read(struct channel_t *ch)
 */
tmp = readb(>ch_neo_uart->isr_fcr);
if (tmp & 2)
-   udelay(10);
+   usleep_range(10);
else
break;
}
@@ -1483,7 +1483,7 @@ static void neo_assert_modem_signals(struct channel_t *ch)
neo_pci_posting_flush(ch->ch_bd);
 
/* Give time for the UART to actually raise/drop the signals */
-   udelay(10);
+   usleep_range(10);
 }
 
 static void neo_send_start_character(struct channel_t *ch)
@@ -1495,7 +1495,7 @@ static void neo_send_start_character(struct channel_t *ch)
ch->ch_xon_sends++;
writeb(ch->ch_startc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
@@ -1508,7 +1508,7 @@ static void neo_send_stop_character(struct channel_t *ch)
ch->ch_xoff_sends++;
writeb(ch->ch_stopc, >ch_neo_uart->txrx);
neo_pci_posting_flush(ch->ch_bd);
-   udelay(10);
+   usleep_range(10);
}
 }
 
-- 
2.1.4

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