Re: [PATCH] staging: wilc1000: use kernel define byte order macros

2017-03-22 Thread Robert Perry Hooker
I don't think buff is an ieee80211_hdr struct. I think it's the rx_buffer 
allocated at wilc_wlan.c:1417.

Regards,
Perry

On Wed, 2017-03-22 at 12:24 +0300, Dan Carpenter wrote:
> On Tue, Mar 21, 2017 at 03:40:10PM -0600, Robert Perry Hooker wrote:
> > Thanks for taking a look, Dan. Sorry if I missed the mark here.
> > 
> > Can you tell me a bit more about the bug this would introduce?
> > 
> > I see that ieee80211_is_action is defined like this: static inline bool 
> > ieee80211_is_action(__le16 fc)
> > 
> > ...and that buff[FRAME_TYPE_ID]is a u8 (since FRAME_TYPE_ID = 0).
> > 
> > Is there an issue with calling cpu_to_le16 on a u8 that isn't encountered 
> > by implicitly casting a u8 to __le16? Or 
> > am I
> > missing something else?
> > 
> 
> Oh...  Hm.  You're right.  I just was thinking that since buff was a
> little endian buffer but it's only reading a u8.  It should probably
> be reading a le16...  The buff likely is just a regular ieee80211_hdr
> struct.
> 
> So you're fixing a bug, but probably not in the right way.  We should
> instead just say "struct ieee80211_hdr *hdr = buff;" and instead of
> treating it like an array of u8.  Probably it requires testing...
> 
> regards,
> dan carpenter
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 1/2 v4] pci-hyperv: properly handle pci bus remove

2017-03-22 Thread Long Li


> -Original Message-
> From: Bjorn Helgaas [mailto:helg...@kernel.org]
> Sent: Thursday, March 16, 2017 1:07 PM
> To: Long Li 
> Cc: KY Srinivasan ; Haiyang Zhang
> ; Bjorn Helgaas ;
> de...@linuxdriverproject.org; linux-...@vger.kernel.org; linux-
> ker...@vger.kernel.org
> Subject: Re: [PATCH 1/2 v4] pci-hyperv: properly handle pci bus remove
> 
> On Tue, Feb 28, 2017 at 02:19:45AM +, Long Li wrote:
> > hv_pci_devices_present is called in hv_pci_remove when we remove a PCI
> > device from host (e.g. by disabling SRIOV on a device). In
> > hv_pci_remove, the bus is already removed before the call, so we don't
> > need to rescan the bus in the workqueue scheduled from
> > hv_pci_devices_present. By introducing status hv_pcibus_removed, we
> can avoid this situation.
> >
> > Signed-off-by: Long Li 
> > Reported-by: Xiaofeng Wang 
> > Acked-by: K. Y. Srinivasan 
> 
> This didn't apply for me because saving it to a file resulted in some encoded
> file with "=3D" instead of "=".  I see that mutt is smart enough to deal with
> that in this reply, so there's probably a way for it to decode it when saving 
> to
> a file, but I don't know it.
> 
> I tried to apply it by hand, but the hunk in hv_pci_remove() doesn't match
> the context.  I think your patch is based on something previous to
> 17978524a636 ("PCI: hv: Fix hv_pci_remove() for hot-remove").  Please
> refresh the patch so it applies to my "master" branch (currently v4.11-rc1).
> 
> Also, the "default: break;" case below is redundant and can be removed.
> 
> So I'll wait for your updated versions of both these patches.
> 
> > ---
> >  drivers/pci/host/pci-hyperv.c | 20 +---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pci/host/pci-hyperv.c
> > b/drivers/pci/host/pci-hyperv.c index a8deeca..4a37598 100644
> > --- a/drivers/pci/host/pci-hyperv.c
> > +++ b/drivers/pci/host/pci-hyperv.c
> > @@ -348,6 +348,7 @@ enum hv_pcibus_state {
> > hv_pcibus_init = 0,
> > hv_pcibus_probed,
> > hv_pcibus_installed,
> > +   hv_pcibus_removed,
> > hv_pcibus_maximum
> >  };
> >
> > @@ -1481,13 +1482,24 @@ static void pci_devices_present_work(struct
> work_struct *work)
> > put_pcichild(hpdev, hv_pcidev_ref_initial);
> > }
> >
> > -   /* Tell the core to rescan bus because there may have been changes.
> */
> > -   if (hbus->state == hv_pcibus_installed) {
> > +   switch (hbus->state) {
> > +   case hv_pcibus_installed:
> > +   /*
> > +* Tell the core to rescan bus
> > +* because there may have been changes.
> > +*/
> > pci_lock_rescan_remove();
> > pci_scan_child_bus(hbus->pci_bus);
> > pci_unlock_rescan_remove();
> > -   } else {
> > +   break;
> > +
> > +   case hv_pcibus_init:
> > +   case hv_pcibus_probed:
> > survey_child_resources(hbus);
> > +   break;
> > +
> > +   default:
> > +   break;
> 
> ^ This is redundant.

I found it still needs "default:break", or it will give a compiler warning:

drivers/pci/host/pci-hyperv.c: In function 'pci_devices_present_work':
drivers/pci/host/pci-hyperv.c:1510:2: warning: enumeration value 
'hv_pcibus_removed' not handled in switch [-Wswitch]
  switch(hbus->state) {
  ^
drivers/pci/host/pci-hyperv.c:1510:2: warning: enumeration value 
'hv_pcibus_maximum' not handled in switch [-Wswitch]

> 
> > }
> >
> > up(>enum_sem);
> > @@ -2163,6 +2175,7 @@ static int hv_pci_probe(struct hv_device *hdev,
> > hbus = kzalloc(sizeof(*hbus), GFP_KERNEL);
> > if (!hbus)
> > return -ENOMEM;
> > +   hbus->state = hv_pcibus_init;
> >
> > /*
> >  * The PCI bus "domain" is what is called "segment" in ACPI and @@
> > -2305,6 +2318,7 @@ static int hv_pci_remove(struct hv_device *hdev)
> > pci_stop_root_bus(hbus->pci_bus);
> > pci_remove_root_bus(hbus->pci_bus);
> > pci_unlock_rescan_remove();
> > +   hbus->state = hv_pcibus_removed;
> > }
> >
> > ret = hv_send_resources_released(hdev);
> > --
> > 1.8.5.6
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Outreachy kernel] [PATCH v2] staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Julia Lawall


On Wed, 22 Mar 2017, Arushi Singhal wrote:

> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
>
> -1 << c
> +BIT(c)
>
> Signed-off-by: Arushi Singhal 
> ---
> changes in v2
>  -remove/correct the wrong code.
>
>  drivers/staging/iio/cdc/ad7150.c |  2 +-
>  drivers/staging/iio/cdc/ad7746.c | 16 
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index ca72af3e9d4b..a6f249e9c1e1 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
> *indio_dev,
>   if (ret < 0)
>   goto error_ret;
>
> - cfg = ret & ~((0x03 << 5) | (0x1 << 7));
> + cfg = ret & ~((0x03 << 5) | BIT(7));
>
>   switch (type) {
>   case IIO_EV_TYPE_MAG_ADAPTIVE:
> diff --git a/drivers/staging/iio/cdc/ad7746.c 
> b/drivers/staging/iio/cdc/ad7746.c
> index 81f8b9ee1120..453d3978879d 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -45,10 +45,10 @@
>  #define AD7746_STATUS_RDYCAP BIT(0)
>
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) 
> */
> -#define AD7746_CAPSETUP_CAPEN(1 << 7)
> -#define AD7746_CAPSETUP_CIN2 (1 << 6) /* AD7746 only */
> -#define AD7746_CAPSETUP_CAPDIFF  (1 << 5)
> -#define AD7746_CAPSETUP_CACHOP   (1 << 0)
> +#define AD7746_CAPSETUP_CAPEN(BIT(7))
> +#define AD7746_CAPSETUP_CIN2 (BIT(6)) /* AD7746 only */
> +#define AD7746_CAPSETUP_CAPDIFF  (BIT(5))
> +#define AD7746_CAPSETUP_CACHOP   (BIT(0))

The parentheses here are not needed.

>
>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) 
> */
>  #define AD7746_VTSETUP_VTEN  (1 << 7)
> @@ -56,9 +56,9 @@
>  #define AD7746_VTSETUP_VTMD_EXT_TEMP (1 << 5)
>  #define AD7746_VTSETUP_VTMD_VDD_MON  (2 << 5)
>  #define AD7746_VTSETUP_VTMD_EXT_VIN  (3 << 5)
> -#define AD7746_VTSETUP_EXTREF(1 << 4)
> -#define AD7746_VTSETUP_VTSHORT   (1 << 1)
> -#define AD7746_VTSETUP_VTCHOP(1 << 0)
> +#define AD7746_VTSETUP_EXTREF(BIT(4))
> +#define AD7746_VTSETUP_VTSHORT   (BIT(1))
> +#define AD7746_VTSETUP_VTCHOP(BIT(0))
>

Same here.

>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>  #define AD7746_EXCSETUP_CLKCTRL  BIT(7)
> @@ -82,7 +82,7 @@
>  #define AD7746_CONF_MODE_GAIN_CAL(6 << 0)
>
>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
> -#define AD7746_CAPDAC_DACEN  (1 << 7)
> +#define AD7746_CAPDAC_DACEN  (BIT(7))

Here too.

julia

>  #define AD7746_CAPDAC_DACP(x)((x) & 0x7F)
>
>  /*
> --
> 2.11.0
>
> --
> 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/20170322164234.GA18805%40arushi-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH 00/11] staging:speakup: Multiple Checkpatch issues.

2017-03-22 Thread Greg KH
On Wed, Mar 22, 2017 at 12:20:23PM -0700, Arushi Singhal wrote:
> On Tuesday, March 21, 2017 at 5:12:41 PM UTC+5:30, Arushi Singhal wrote:
> 
> Improve readability by fixing multiple checkpatch.pl
> issues in speakup driver.
> 
> Arushi Singhal (11):
>   staging: speakup: Moved logical to previous line.
>   staging: speakup: Remove multiple assignments
>   staging: speakup: Simplify "NULL" comparisons
>   staging: speakup: fixes braces {} should be used on all arms of this
>     statement
>   staging: speakup: Remove multiple assignments
>   staging: speakup: Moved OR operator to previous line.
>   staging: speakup: spaces preferred around operator
>   staging: speakup: Removed Unnecessary parentheses.
>   staging: speakup: Simplify the NULL comparisons
>   staging: speakup: Match alignment with open parenthesis.
>   staging: speakup: Fix alignment with parenthesis.
> 
>  drivers/staging/speakup/fakekey.c        |   2 +-
>  drivers/staging/speakup/kobjects.c       |   2 +-
>  drivers/staging/speakup/main.c           | 110
> +--
>  drivers/staging/speakup/selection.c      |   4 +-
>  drivers/staging/speakup/serialio.c       |   2 +-
>  drivers/staging/speakup/speakup.h        |  12 ++--
>  drivers/staging/speakup/speakup_acntpc.c |   8 +--
>  drivers/staging/speakup/speakup_apollo.c |   2 +-
>  drivers/staging/speakup/speakup_decext.c |  10 +--
>  drivers/staging/speakup/speakup_decpc.c  |  26 
>  drivers/staging/speakup/speakup_dectlk.c |   6 +-
>  drivers/staging/speakup/speakup_dtlk.c   |   2 +-
>  drivers/staging/speakup/speakup_keypc.c  |   6 +-
>  drivers/staging/speakup/speakup_ltlk.c   |   2 +-
>  drivers/staging/speakup/varhandlers.c    |  18 ++---
>  15 files changed, 114 insertions(+), 98 deletions(-)
> 
> 
> Hi
> Any update on these patches?

One day?  Please give us a chance, realize that it's normally a 2 week
timeframe to get a patch reviewed...

thanks,

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


Re: [PATCH] staging: iio: adc: Replace mlock with driver private lock

2017-03-22 Thread Jonathan Cameron
On 20/03/17 14:12, Arushi 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.
> 
> Signed-off-by: Arushi Singhal 
mutex_init?

This partly came from the fact Alison missed it in her example
patch (and I didn't notice!), but all mutexes need to be initialized
before use.  It's an interesting diversion to follow what that actually
does...  There is more to a mutex than you might expect!

Jonathan
> ---
>  drivers/staging/iio/adc/ad7606.c | 8 
>  drivers/staging/iio/adc/ad7606.h | 2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7606.c 
> b/drivers/staging/iio/adc/ad7606.c
> index 9dbfa64b1e53..9f529b34e018 100644
> --- a/drivers/staging/iio/adc/ad7606.c
> +++ b/drivers/staging/iio/adc/ad7606.c
> @@ -208,7 +208,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   switch (mask) {
>   case IIO_CHAN_INFO_SCALE:
>   ret = -EINVAL;
> - mutex_lock(_dev->mlock);
> + mutex_lock(>lock);
>   for (i = 0; i < ARRAY_SIZE(scale_avail); i++)
>   if (val2 == scale_avail[i][1]) {
>   gpiod_set_value(st->gpio_range, i);
> @@ -217,7 +217,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   ret = 0;
>   break;
>   }
> - mutex_unlock(_dev->mlock);
> + mutex_unlock(>lock);
>  
>   return ret;
>   case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> @@ -231,11 +231,11 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   values[1] = (ret >> 1) & 1;
>   values[2] = (ret >> 2) & 1;
>  
> - mutex_lock(_dev->mlock);
> + mutex_lock(>lock);
>   gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
> values);
>   st->oversampling = val;
> - mutex_unlock(_dev->mlock);
> + mutex_unlock(>lock);
>  
>   return 0;
>   default:
> diff --git a/drivers/staging/iio/adc/ad7606.h 
> b/drivers/staging/iio/adc/ad7606.h
> index 746f9553d2ba..5d59bdd78727 100644
> --- a/drivers/staging/iio/adc/ad7606.h
> +++ b/drivers/staging/iio/adc/ad7606.h
> @@ -14,6 +14,7 @@
>   * @name:identification string for chip
>   * @channels:channel specification
>   * @num_channels:number of channels
> + * @lock protect sensor state
>   */
>  
>  struct ad7606_chip_info {
> @@ -37,6 +38,7 @@ struct ad7606_state {
>   booldone;
>   void __iomem*base_address;
>  
> + struct mutexlock; /* protect sensor state */
>   struct gpio_desc*gpio_convst;
>   struct gpio_desc*gpio_reset;
>   struct gpio_desc*gpio_range;
> 

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


Re: [PATCH] staging: ad7759: Replace mlock with driver private lock

2017-03-22 Thread Jonathan Cameron
On 20/03/17 16:09, Arushi 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.
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/iio/meter/ade7759.c | 4 ++--
>  drivers/staging/iio/meter/ade7759.h | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7759.c 
> b/drivers/staging/iio/meter/ade7759.c
> index 944ee3401029..1d1e0b33021f 100644
> --- a/drivers/staging/iio/meter/ade7759.c
> +++ b/drivers/staging/iio/meter/ade7759.c
> @@ -381,7 +381,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)
> @@ -402,7 +402,7 @@ static ssize_t ade7759_write_frequency(struct device *dev,
Deadlock as this call also take the buf_lock mutex..


>   ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg);
>  
>  out:
> - mutex_unlock(_dev->mlock);
> + mutex_unlock(>buf_lock);
>  
>   return ret ? ret : len;
>  }
> diff --git a/drivers/staging/iio/meter/ade7759.h 
> b/drivers/staging/iio/meter/ade7759.h
> index f0716d2fdf8e..4f69bb93cc45 100644
> --- a/drivers/staging/iio/meter/ade7759.h
> +++ b/drivers/staging/iio/meter/ade7759.h
> @@ -42,6 +42,7 @@
>   * @buf_lock:mutex to protect tx and rx
>   * @tx:  transmit buffer
>   * @rx:  receive buffer
> + * @lock protect sensor state
?
>   **/
>  struct ade7759_state {
>   struct spi_device   *us;
> 

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


Re: [PATCH v3] staging: ad7606: Replace mlock with driver private lock

2017-03-22 Thread Jonathan Cameron
On 20/03/17 19:51, Arushi 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.
> 
> Signed-off-by: Arushi Singhal 
Nice patch.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  changes in v3
>  - Add mutex_init.
>  - correct the Documentation.
> 
>  drivers/staging/iio/adc/ad7606.c | 9 +
>  drivers/staging/iio/adc/ad7606.h | 3 +++
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7606.c 
> b/drivers/staging/iio/adc/ad7606.c
> index 9dbfa64b1e53..18f5f139117e 100644
> --- a/drivers/staging/iio/adc/ad7606.c
> +++ b/drivers/staging/iio/adc/ad7606.c
> @@ -208,7 +208,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   switch (mask) {
>   case IIO_CHAN_INFO_SCALE:
>   ret = -EINVAL;
> - mutex_lock(_dev->mlock);
> + mutex_lock(>lock);
>   for (i = 0; i < ARRAY_SIZE(scale_avail); i++)
>   if (val2 == scale_avail[i][1]) {
>   gpiod_set_value(st->gpio_range, i);
> @@ -217,7 +217,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   ret = 0;
>   break;
>   }
> - mutex_unlock(_dev->mlock);
> + mutex_unlock(>lock);
>  
>   return ret;
>   case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> @@ -231,11 +231,11 @@ static int ad7606_write_raw(struct iio_dev *indio_dev,
>   values[1] = (ret >> 1) & 1;
>   values[2] = (ret >> 2) & 1;
>  
> - mutex_lock(_dev->mlock);
> + mutex_lock(>lock);
>   gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc,
> values);
>   st->oversampling = val;
> - mutex_unlock(_dev->mlock);
> + mutex_unlock(>lock);
>  
>   return 0;
>   default:
> @@ -413,6 +413,7 @@ int ad7606_probe(struct device *dev, int irq, void 
> __iomem *base_address,
>   st = iio_priv(indio_dev);
>  
>   st->dev = dev;
> + mutex_init(>lock);
>   st->bops = bops;
>   st->base_address = base_address;
>   /* tied to logic low, analog input range is +/- 5V */
> diff --git a/drivers/staging/iio/adc/ad7606.h 
> b/drivers/staging/iio/adc/ad7606.h
> index 746f9553d2ba..acaed8d5379c 100644
> --- a/drivers/staging/iio/adc/ad7606.h
> +++ b/drivers/staging/iio/adc/ad7606.h
> @@ -14,6 +14,7 @@
>   * @name:identification string for chip
>   * @channels:channel specification
>   * @num_channels:number of channels
> + * @lock protect sensor state
>   */
>  
>  struct ad7606_chip_info {
> @@ -23,6 +24,7 @@ struct ad7606_chip_info {
>  
>  /**
>   * struct ad7606_state - driver instance specific data
> + * @lock protect sensor state
>   */
>  
>  struct ad7606_state {
> @@ -37,6 +39,7 @@ struct ad7606_state {
>   booldone;
>   void __iomem*base_address;
>  
> + struct mutexlock; /* protect sensor state */
>   struct gpio_desc*gpio_convst;
>   struct gpio_desc*gpio_reset;
>   struct gpio_desc*gpio_range;
> 

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


Re: [PATCH v3 2/2] staging: iio: ade7753: Replace mlock with driver private lock

2017-03-22 Thread Jonathan Cameron
On 21/03/17 18:03, 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.
> 
> Signed-off-by: simran singhal 
Mutex is not initialized...
> ---
>  drivers/staging/iio/meter/ade7753.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7753.c 
> b/drivers/staging/iio/meter/ade7753.c
> index b71fbd3..9674e05 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;
>  }
> 

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


Re: [PATCH v3 1/2] staging: iio: ade7753: Remove trailing whitespaces

2017-03-22 Thread Jonathan Cameron
On 21/03/17 18:03, simran singhal wrote:
> This patch removes trailing whitespaces in order to follow the Linux
> coding style.
> 
> Signed-off-by: simran singhal 
Applied and pushed out as testing...

Jonathan
> ---
>  drivers/staging/iio/meter/ade7753.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7753.c 
> b/drivers/staging/iio/meter/ade7753.c
> index dfd8b71..b71fbd3 100644
> --- a/drivers/staging/iio/meter/ade7753.c
> +++ b/drivers/staging/iio/meter/ade7753.c
> @@ -83,10 +83,10 @@
>   * @buf_lock:   mutex to protect tx and rx
>   **/
>  struct ade7753_state {
> - struct spi_device   *us;
> - struct mutexbuf_lock;
> - u8  tx[ADE7753_MAX_TX] 
> cacheline_aligned;
> - u8  rx[ADE7753_MAX_RX];
> + struct spi_device   *us;
> + struct mutexbuf_lock;
> + u8  tx[ADE7753_MAX_TX] cacheline_aligned;
> + u8  rx[ADE7753_MAX_RX];
>  };
>  
>  static int ade7753_spi_write_reg_8(struct device *dev,
> 

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


Re: [PATCH 2/2] staging: ade7754: Clean up #includes

2017-03-22 Thread Jonathan Cameron
On 20/03/17 15:15, simran singhal wrote:
> Alphabetize and separate kernel and subsystem headers.
> 
> Signed-off-by: simran singhal 
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/meter/ade7754.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/meter/ade7754.c 
> b/drivers/staging/iio/meter/ade7754.c
> index 42f7b06..fea93d7 100644
> --- a/drivers/staging/iio/meter/ade7754.c
> +++ b/drivers/staging/iio/meter/ade7754.c
> @@ -6,18 +6,17 @@
>   * Licensed under the GPL-2 or later.
>   */
>  
> -#include 
> -#include 
>  #include 
> -#include 
>  #include 
> +#include 
> +#include 
>  #include 
> +#include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
> -
>  #include 
>  #include 
>  #include "meter.h"
> 

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


Re: [PATCH 1/2] staging: ade7754: Move header content to implementation file

2017-03-22 Thread Jonathan Cameron
On 20/03/17 15:15, simran singhal wrote:
> The contents of ade7754.h are only used in ade7754.c.
> Move the header contents to the implementation file,
> and delete the header file.
> 
> Signed-off-by: simran singhal 
Unfortunately already done by sayli karnik back on the 8th of March.

Jonathan
> ---
>  drivers/staging/iio/meter/ade7754.c | 87 ++-
>  drivers/staging/iio/meter/ade7754.h | 90 
> -
>  2 files changed, 86 insertions(+), 91 deletions(-)
>  delete mode 100644 drivers/staging/iio/meter/ade7754.h
> 
> diff --git a/drivers/staging/iio/meter/ade7754.c 
> b/drivers/staging/iio/meter/ade7754.c
> index 024463a..42f7b06 100644
> --- a/drivers/staging/iio/meter/ade7754.c
> +++ b/drivers/staging/iio/meter/ade7754.c
> @@ -21,7 +21,92 @@
>  #include 
>  #include 
>  #include "meter.h"
> -#include "ade7754.h"
> +
> +#define ADE7754_AENERGY   0x01
> +#define ADE7754_RAENERGY  0x02
> +#define ADE7754_LAENERGY  0x03
> +#define ADE7754_VAENERGY  0x04
> +#define ADE7754_RVAENERGY 0x05
> +#define ADE7754_LVAENERGY 0x06
> +#define ADE7754_PERIOD0x07
> +#define ADE7754_TEMP  0x08
> +#define ADE7754_WFORM 0x09
> +#define ADE7754_OPMODE0x0A
> +#define ADE7754_MMODE 0x0B
> +#define ADE7754_WAVMODE   0x0C
> +#define ADE7754_WATMODE   0x0D
> +#define ADE7754_VAMODE0x0E
> +#define ADE7754_IRQEN 0x0F
> +#define ADE7754_STATUS0x10
> +#define ADE7754_RSTATUS   0x11
> +#define ADE7754_ZXTOUT0x12
> +#define ADE7754_LINCYC0x13
> +#define ADE7754_SAGCYC0x14
> +#define ADE7754_SAGLVL0x15
> +#define ADE7754_VPEAK 0x16
> +#define ADE7754_IPEAK 0x17
> +#define ADE7754_GAIN  0x18
> +#define ADE7754_AWG   0x19
> +#define ADE7754_BWG   0x1A
> +#define ADE7754_CWG   0x1B
> +#define ADE7754_AVAG  0x1C
> +#define ADE7754_BVAG  0x1D
> +#define ADE7754_CVAG  0x1E
> +#define ADE7754_APHCAL0x1F
> +#define ADE7754_BPHCAL0x20
> +#define ADE7754_CPHCAL0x21
> +#define ADE7754_AAPOS 0x22
> +#define ADE7754_BAPOS 0x23
> +#define ADE7754_CAPOS 0x24
> +#define ADE7754_CFNUM 0x25
> +#define ADE7754_CFDEN 0x26
> +#define ADE7754_WDIV  0x27
> +#define ADE7754_VADIV 0x28
> +#define ADE7754_AIRMS 0x29
> +#define ADE7754_BIRMS 0x2A
> +#define ADE7754_CIRMS 0x2B
> +#define ADE7754_AVRMS 0x2C
> +#define ADE7754_BVRMS 0x2D
> +#define ADE7754_CVRMS 0x2E
> +#define ADE7754_AIRMSOS   0x2F
> +#define ADE7754_BIRMSOS   0x30
> +#define ADE7754_CIRMSOS   0x31
> +#define ADE7754_AVRMSOS   0x32
> +#define ADE7754_BVRMSOS   0x33
> +#define ADE7754_CVRMSOS   0x34
> +#define ADE7754_AAPGAIN   0x35
> +#define ADE7754_BAPGAIN   0x36
> +#define ADE7754_CAPGAIN   0x37
> +#define ADE7754_AVGAIN0x38
> +#define ADE7754_BVGAIN0x39
> +#define ADE7754_CVGAIN0x3A
> +#define ADE7754_CHKSUM0x3E
> +#define ADE7754_VERSION   0x3F
> +
> +#define ADE7754_READ_REG(a)a
> +#define ADE7754_WRITE_REG(a) ((a) | 0x80)
> +
> +#define ADE7754_MAX_TX4
> +#define ADE7754_MAX_RX4
> +#define ADE7754_STARTUP_DELAY 1000
> +
> +#define ADE7754_SPI_SLOW (u32)(300 * 1000)
> +#define ADE7754_SPI_BURST(u32)(1000 * 1000)
> +#define ADE7754_SPI_FAST (u32)(2000 * 1000)
> +
> +/**
> + * struct ade7754_state - device instance specific data
> + * @us:  actual spi_device
> + * @buf_lock:mutex to protect tx and rx
> + * @tx:  transmit buffer
> + * @rx:  receive buffer
> + **/
> +struct ade7754_state {
> + struct spi_device   *us;
> + struct mutexbuf_lock;
> + u8  tx[ADE7754_MAX_TX] cacheline_aligned;
> + u8  rx[ADE7754_MAX_RX];
> +};
>  
>  static int ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 
> val)
>  {
> diff --git a/drivers/staging/iio/meter/ade7754.h 
> b/drivers/staging/iio/meter/ade7754.h
> deleted file mode 100644
> index 28f71c2..000
> --- a/drivers/staging/iio/meter/ade7754.h
> +++ /dev/null
> @@ -1,90 +0,0 @@
> -#ifndef _ADE7754_H
> -#define _ADE7754_H
> -
> -#define ADE7754_AENERGY   0x01
> -#define ADE7754_RAENERGY  0x02
> -#define ADE7754_LAENERGY  0x03
> -#define ADE7754_VAENERGY  0x04
> -#define ADE7754_RVAENERGY 0x05
> -#define ADE7754_LVAENERGY 0x06
> -#define ADE7754_PERIOD0x07
> -#define ADE7754_TEMP  0x08
> -#define ADE7754_WFORM 0x09
> -#define ADE7754_OPMODE0x0A
> -#define ADE7754_MMODE 0x0B
> -#define ADE7754_WAVMODE   0x0C
> -#define ADE7754_WATMODE   0x0D
> -#define ADE7754_VAMODE0x0E
> -#define ADE7754_IRQEN 0x0F
> -#define ADE7754_STATUS0x10
> -#define ADE7754_RSTATUS   0x11
> -#define ADE7754_ZXTOUT0x12
> -#define ADE7754_LINCYC0x13
> -#define ADE7754_SAGCYC0x14
> -#define ADE7754_SAGLVL0x15
> -#define ADE7754_VPEAK 0x16
> -#define ADE7754_IPEAK 0x17
> -#define ADE7754_GAIN  

Re: [PATCH v7] staging: adis16060_core: Replace mlock with buf_lock and refactor code

2017-03-22 Thread Jonathan Cameron
On 22/03/17 20:00, kbuild test robot wrote:
> Hi simran,
> 
> [auto build test WARNING on iio/togreg]
> [also build test WARNING on v4.11-rc3 next-20170322]
> [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/simran-singhal/staging-adis16060_core-Replace-mlock-with-buf_lock-and-refactor-code/20170323-031726
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
> config: x86_64-randconfig-s0-03230201 (attached as .config)
> compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All warnings (new ones prefixed by >>):
> 
>drivers/staging/iio/gyro/adis16060_core.c: In function 
> 'adis16060_read_raw':
>>> drivers/staging/iio/gyro/adis16060_core.c:79: warning: unused variable 'st'
Already fixed in V8 which has been applied to the togreg branch of iio.git.

Thanks,
Jonathan
> 
> vim +/st +79 drivers/staging/iio/gyro/adis16060_core.c
> 
> 63if (!ret)
> 64*val = ((st->buf[0] & 0x3) << 12) |
> 65 (st->buf[1] << 4) |
> 66 ((st->buf[2] >> 4) & 0xF);
> 67mutex_unlock(>buf_lock);
> 68
> 69return ret;
> 70}
> 71
> 72static int adis16060_read_raw(struct iio_dev *indio_dev,
> 73  struct iio_chan_spec const *chan,
> 74  int *val, int *val2,
> 75  long mask)
> 76{
> 77u16 tval = 0;
> 78int ret;
>   > 79struct adis16060_state *st = iio_priv(indio_dev);
> 80
> 81switch (mask) {
> 82case IIO_CHAN_INFO_RAW:
> 83ret = adis16060_spi_write_than_read(indio_dev,
> 84
> chan->address, );
> 85if (ret < 0)
> 86return ret;
> 87
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> 

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


Re: [PATCH v7] staging: adis16060_core: Replace mlock with buf_lock and refactor code

2017-03-22 Thread kbuild test robot
Hi simran,

[auto build test WARNING on iio/togreg]
[also build test WARNING on v4.11-rc3 next-20170322]
[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/simran-singhal/staging-adis16060_core-Replace-mlock-with-buf_lock-and-refactor-code/20170323-031726
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: x86_64-randconfig-s0-03230201 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/staging/iio/gyro/adis16060_core.c: In function 'adis16060_read_raw':
>> drivers/staging/iio/gyro/adis16060_core.c:79: warning: unused variable 'st'

vim +/st +79 drivers/staging/iio/gyro/adis16060_core.c

63  if (!ret)
64  *val = ((st->buf[0] & 0x3) << 12) |
65   (st->buf[1] << 4) |
66   ((st->buf[2] >> 4) & 0xF);
67  mutex_unlock(>buf_lock);
68  
69  return ret;
70  }
71  
72  static int adis16060_read_raw(struct iio_dev *indio_dev,
73struct iio_chan_spec const *chan,
74int *val, int *val2,
75long mask)
76  {
77  u16 tval = 0;
78  int ret;
  > 79  struct adis16060_state *st = iio_priv(indio_dev);
80  
81  switch (mask) {
82  case IIO_CHAN_INFO_RAW:
83  ret = adis16060_spi_write_than_read(indio_dev,
84  chan->address, 
);
85  if (ret < 0)
86  return ret;
87  

---
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: [PATCH v2] staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Jonathan Cameron
On 22/03/17 16:42, Arushi Singhal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)
> 
> Signed-off-by: Arushi Singhal 
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> ---
> changes in v2
>  -remove/correct the wrong code.
> 
>  drivers/staging/iio/cdc/ad7150.c |  2 +-
>  drivers/staging/iio/cdc/ad7746.c | 16 
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index ca72af3e9d4b..a6f249e9c1e1 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
> *indio_dev,
>   if (ret < 0)
>   goto error_ret;
>  
> - cfg = ret & ~((0x03 << 5) | (0x1 << 7));
> + cfg = ret & ~((0x03 << 5) | BIT(7));
>  
>   switch (type) {
>   case IIO_EV_TYPE_MAG_ADAPTIVE:
> diff --git a/drivers/staging/iio/cdc/ad7746.c 
> b/drivers/staging/iio/cdc/ad7746.c
> index 81f8b9ee1120..453d3978879d 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -45,10 +45,10 @@
>  #define AD7746_STATUS_RDYCAP BIT(0)
>  
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) 
> */
> -#define AD7746_CAPSETUP_CAPEN(1 << 7)
> -#define AD7746_CAPSETUP_CIN2 (1 << 6) /* AD7746 only */
> -#define AD7746_CAPSETUP_CAPDIFF  (1 << 5)
> -#define AD7746_CAPSETUP_CACHOP   (1 << 0)
> +#define AD7746_CAPSETUP_CAPEN(BIT(7))
> +#define AD7746_CAPSETUP_CIN2 (BIT(6)) /* AD7746 only */
> +#define AD7746_CAPSETUP_CAPDIFF  (BIT(5))
> +#define AD7746_CAPSETUP_CACHOP   (BIT(0))
>  
>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) 
> */
>  #define AD7746_VTSETUP_VTEN  (1 << 7)
> @@ -56,9 +56,9 @@
>  #define AD7746_VTSETUP_VTMD_EXT_TEMP (1 << 5)
>  #define AD7746_VTSETUP_VTMD_VDD_MON  (2 << 5)
>  #define AD7746_VTSETUP_VTMD_EXT_VIN  (3 << 5)
> -#define AD7746_VTSETUP_EXTREF(1 << 4)
> -#define AD7746_VTSETUP_VTSHORT   (1 << 1)
> -#define AD7746_VTSETUP_VTCHOP(1 << 0)
> +#define AD7746_VTSETUP_EXTREF(BIT(4))
> +#define AD7746_VTSETUP_VTSHORT   (BIT(1))
> +#define AD7746_VTSETUP_VTCHOP(BIT(0))
>  
>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>  #define AD7746_EXCSETUP_CLKCTRL  BIT(7)
> @@ -82,7 +82,7 @@
>  #define AD7746_CONF_MODE_GAIN_CAL(6 << 0)
>  
>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
> -#define AD7746_CAPDAC_DACEN  (1 << 7)
> +#define AD7746_CAPDAC_DACEN  (BIT(7))
>  #define AD7746_CAPDAC_DACP(x)((x) & 0x7F)
>  
>  /*
> 

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


Re: [PATCH v8] staging: adis16060: Remove iio_dev mlock and refactor code

2017-03-22 Thread Jonathan Cameron
On 22/03/17 16:20, 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.
> 
> In the driver, buf_lock protects both the adis16060_spi_write() and
> adis16060_spi_read() functions and both are always called in
> pair. First write, then read. Refactor the code to have
> one single function adis16060_spi_write_than_read() and remove
> the use of mlock as adis16060_read_raw() does not require an
> iio_dev->mlock for reads.
I'll slightly modify this description.  The key thing is
that after the above change to have a unified read then write
there is no longer any need for mlock to protect these
read, update, write cycles.
> 
> Signed-off-by: simran singhal 
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

I slightly modified the title as well. It's useful to be a little
more specific than staging, so I added iio: after that.

Thanks,

Jonathan
> ---
> 
>  v8:
>-change subject
>-change commit message
>  v7:
>-Change subject
>-Remove lock from read_raw instead from
> function adis16060_spi_write_than_read().
>  v6:
>-Change commit message
>-Remove nested lock
>  v5:
>-Rename val in adis16060_spi_write_than_read() to conf.
>-Rename val2 in adis16060_spi_write_than_read() to val.
>-Corrected Checkpatch issues.
>-Removed goto from adis16060_read_raw().
>  v4:
>-Refactored code
>-change commit subject
>-change commit message
>  v3:
>-Removed new lock to reuse the existing lock
>  v2:
>-Fixed compilation error
> 
>  drivers/staging/iio/gyro/adis16060_core.c | 33 
> ---
>  1 file changed, 8 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/staging/iio/gyro/adis16060_core.c 
> b/drivers/staging/iio/gyro/adis16060_core.c
> index c9d46e7..e96fce5 100644
> --- a/drivers/staging/iio/gyro/adis16060_core.c
> +++ b/drivers/staging/iio/gyro/adis16060_core.c
> @@ -40,25 +40,18 @@ struct adis16060_state {
>  
>  static struct iio_dev *adis16060_iio_dev;
>  
> -static int adis16060_spi_write(struct iio_dev *indio_dev, u8 val)
> +static int adis16060_spi_write_than_read(struct iio_dev *indio_dev,
> +  u8 conf, u16 *val)
>  {
>   int ret;
>   struct adis16060_state *st = iio_priv(indio_dev);
>  
>   mutex_lock(>buf_lock);
> - st->buf[2] = val; /* The last 8 bits clocked in are latched */
> + st->buf[2] = conf; /* The last 8 bits clocked in are latched */
>   ret = spi_write(st->us_w, st->buf, 3);
> - mutex_unlock(>buf_lock);
> -
> - return ret;
> -}
> -
> -static int adis16060_spi_read(struct iio_dev *indio_dev, u16 *val)
> -{
> - int ret;
> - struct adis16060_state *st = iio_priv(indio_dev);
>  
> - mutex_lock(>buf_lock);
> + if (ret < 0)
> + return ret;
>  
>   ret = spi_read(st->us_r, st->buf, 3);
>  
> @@ -86,17 +79,11 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
>  
>   switch (mask) {
>   case IIO_CHAN_INFO_RAW:
> - /* Take the iio_dev status lock */
> - mutex_lock(_dev->mlock);
> - ret = adis16060_spi_write(indio_dev, chan->address);
> + ret = adis16060_spi_write_than_read(indio_dev,
> + chan->address, );
>   if (ret < 0)
> - goto out_unlock;
> + return ret;
>  
> - ret = adis16060_spi_read(indio_dev, );
> - if (ret < 0)
> - goto out_unlock;
> -
> - mutex_unlock(_dev->mlock);
>   *val = tval;
>   return IIO_VAL_INT;
>   case IIO_CHAN_INFO_OFFSET:
> @@ -110,10 +97,6 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
>   }
>  
>   return -EINVAL;
> -
> -out_unlock:
> - mutex_unlock(_dev->mlock);
> - return ret;
>  }
>  
>  static const struct iio_info adis16060_info = {
> 

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


[PATCH v2] HV: properly delay KVP packets when negotiation is in progress

2017-03-22 Thread Long Li
The host may send multiple negotiation packets (due to timeout) before 
the KVP user-mode daemon is connected. We need to defer processing  
those packets until the daemon is negotiated and connected. It's okay
for guest to respond to all negotiation packets.

In addition, the host may send multiple staged KVP requests as soon as
negotiation is done. We need to properly process those packets using 
one tasklet for exclusive access to ring buffer.

This patch is based on the work of Nick Meier 


The patch v2 has incorporated suggestion from Vitaly Kuznetsov 
.

Signed-off-by: Long Li 
---
 drivers/hv/hv_kvp.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index de26371..845b70b 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -113,7 +113,7 @@ static void kvp_poll_wrapper(void *channel)
 {
/* Transaction is finished, reset the state here to avoid races. */
kvp_transaction.state = HVUTIL_READY;
-   hv_kvp_onchannelcallback(channel);
+   tasklet_schedule(&((struct vmbus_channel*)channel)->callback_event);
 }
 
 static void kvp_register_done(void)
@@ -628,16 +628,17 @@ void hv_kvp_onchannelcallback(void *context)
 NEGO_IN_PROGRESS,
 NEGO_FINISHED} host_negotiatied = NEGO_NOT_STARTED;
 
-   if (host_negotiatied == NEGO_NOT_STARTED &&
-   kvp_transaction.state < HVUTIL_READY) {
+   if (kvp_transaction.state < HVUTIL_READY) {
/*
 * If userspace daemon is not connected and host is asking
 * us to negotiate we need to delay to not lose messages.
 * This is important for Failover IP setting.
 */
-   host_negotiatied = NEGO_IN_PROGRESS;
-   schedule_delayed_work(_host_handshake_work,
+   if (host_negotiatied == NEGO_NOT_STARTED) {
+   host_negotiatied = NEGO_IN_PROGRESS;
+   schedule_delayed_work(_host_handshake_work,
  HV_UTIL_NEGO_TIMEOUT * HZ);
+   }
return;
}
if (kvp_transaction.state > HVUTIL_READY)
@@ -705,6 +706,7 @@ void hv_kvp_onchannelcallback(void *context)
   VM_PKT_DATA_INBAND, 0);
 
host_negotiatied = NEGO_FINISHED;
+   hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper);
}
 
 }
-- 
2.7.4
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v5 00/39] i.MX Media Driver

2017-03-22 Thread Nicolas Dufresne
Le mardi 21 mars 2017 à 11:36 +, Russell King - ARM Linux a écrit :
>     warn: v4l2-test-formats.cpp(1187): S_PARM is
> supported for buftype 2, but not ENUM_FRAMEINTERVALS
>     warn: v4l2-test-formats.cpp(1194): S_PARM is
> supported but doesn't report V4L2_CAP_TIMEPERFRAME

For encoders, the framerate value is used as numerical value to
implement bitrate control. So in most cases any interval is accepted.
Though, it would be cleaner to just implement the enumeration. It's
quite simple when you support everything.

Nicolas

signature.asc
Description: This is a digitally signed message part
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/6] staging: BCM2835 MMAL V4L2 camera driver

2017-03-22 Thread Mauro Carvalho Chehab
Hi Michael,

Em Mon, 20 Mar 2017 08:40:11 -0700
Michael Zoran  escreveu:

> > > Are you using Eric Anholt's HDMI Audio driver that's included in
> > > VC4? 
> > > That could well be incompatible with the firmware driver. Or are
> > > you
> > > using a half mode of VC4 for audio and VCHIQ for video?  
> > 
> > I'm using vanilla staging Kernel, from Greg's tree:
> > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.
> > git/commit/?h=staging-
> > next=7bc49cb9b9b8bad32536c4b6d1aff1824c1adc6c
> > 
> > Plus the DWC2 fixup I wrote and DT changes you pointed
> > (see enclosed).
> > 
> > I can disable the audio overlay here, as I don't have anything 
> > connected to audio inputs/outputs.
> > 
> > Regards,
> > Mauro
> >   
> 
> Why is the vchiq node in the tree twice? For me to even respond anymore
> you you going to have to include your entire dtb(whatever you are
> using) run through dtc -I dtb -O dts.  You are also going to have to
> include your exact .config file you used for building, and exactly what
> these DWC2 fixeups are.
> 
> You don't even state exactly what platform you are using, Is it even an
> RPI of some kind.

It is a RPi3 board. The exact procedure that I took is described here:
https://blogs.s-osg.org/use-v4l2-cameras-raspberry-pi-3-upstream-kernel/

After it, I updated the firmware to the newest one, from:
https://github.com/raspberrypi/firmware.git

commit 384559354762f36aa55584560d8749fc66a4cfd0
Author: popcornmix 
Date:   Sat Mar 18 17:48:59 2017 +
kernel: Bump to 4.9.16

Then I applied two patches on the top of it:

https://patchwork.linuxtv.org/patch/40093/
https://patchwork.linuxtv.org/patch/40146/

As the second patch has entries for vchiq, I ended by having it
duplicated (although the DTB has it only once, as you can see below).

Regards,
Mauro



Output of:
$ dtc -I dtb -O dts /devel/arm_rootdir/install/bcm2837-rpi-3-b.dtb

/dts-v1/;

/ {
compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
model = "Raspberry Pi 3 Model B";
interrupt-parent = <0x1>;
#address-cells = <0x1>;
#size-cells = <0x1>;

chosen {
bootargs = "earlyprintk console=ttyAMA0";
};

soc {
compatible = "simple-bus";
#address-cells = <0x1>;
#size-cells = <0x1>;
ranges = <0x7e00 0x3f00 0x100 0x4000 0x4000 
0x1000>;
dma-ranges = <0xc000 0x0 0x3f00>;

timer@7e003000 {
compatible = "brcm,bcm2835-system-timer";
reg = <0x7e003000 0x1000>;
interrupts = <0x1 0x0 0x1 0x1 0x1 0x2 0x1 0x3>;
clock-frequency = <0xf4240>;
};

dma@7e007000 {
compatible = "brcm,bcm2835-dma";
reg = <0x7e007000 0xf00>;
interrupts = <0x1 0x10 0x1 0x11 0x1 0x12 0x1 0x13 0x1 
0x14 0x1 0x15 0x1 0x16 0x1 0x17 0x1 0x18 0x1 0x19 0x1 0x1a 0x1 0x1b 0x1 0x1b 
0x1 0x1b 0x1 0x1b 0x1 0x1c>;
interrupt-names = "dma0", "dma1", "dma2", "dma3", 
"dma4", "dma5", "dma6", "dma7", "dma8", "dma9", "dma10", "dma11", "dma12", 
"dma13", "dma14", "dma-shared-all";
#dma-cells = <0x1>;
brcm,dma-channel-mask = <0x7f35>;
linux,phandle = <0x5>;
phandle = <0x5>;
};

interrupt-controller@7e00b200 {
compatible = "brcm,bcm2836-armctrl-ic";
reg = <0x7e00b200 0x200>;
interrupt-controller;
#interrupt-cells = <0x2>;
interrupt-parent = <0x2>;
interrupts = <0x8>;
linux,phandle = <0x1>;
phandle = <0x1>;
};

watchdog@7e10 {
compatible = "brcm,bcm2835-pm-wdt";
reg = <0x7e10 0x28>;
};

cprman@7e101000 {
compatible = "brcm,bcm2835-cprman";
#clock-cells = <0x1>;
reg = <0x7e101000 0x2000>;
clocks = <0x3>;
linux,phandle = <0x4>;
phandle = <0x4>;
};

rng@7e104000 {
compatible = "brcm,bcm2835-rng";
reg = <0x7e104000 0x10>;
};

mailbox@7e00b880 {
compatible = "brcm,bcm2835-mbox";
reg = <0x7e00b880 0x40>;
interrupts = <0x0 0x1>;
#mbox-cells = <0x0>;

[PATCH v2] staging: fbtft: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -improve the code.

 drivers/staging/fbtft/fb_agm1264k-fl.c | 2 +-
 drivers/staging/fbtft/fb_ili9163.c | 2 +-
 drivers/staging/fbtft/fb_ili9325.c | 2 +-
 drivers/staging/fbtft/fb_ssd1289.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
b/drivers/staging/fbtft/fb_agm1264k-fl.c
index 4ee76dbd30b5..489151a6bf80 100644
--- a/drivers/staging/fbtft/fb_agm1264k-fl.c
+++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
@@ -369,7 +369,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, 
size_t len)
/* select left side (sc0)
 * set addr
 */
-   write_reg(par, 0x00, (1 << 6) | (u8)addr_win.xs);
+   write_reg(par, 0x00, BIT(6) | (u8)addr_win.xs);
write_reg(par, 0x00, (0x17 << 3) | (u8)y);
 
/* write bitmap */
diff --git a/drivers/staging/fbtft/fb_ili9163.c 
b/drivers/staging/fbtft/fb_ili9163.c
index 579e17734612..045cadc3bc65 100644
--- a/drivers/staging/fbtft/fb_ili9163.c
+++ b/drivers/staging/fbtft/fb_ili9163.c
@@ -194,7 +194,7 @@ static int set_var(struct fbtft_par *par)
 
/* Colorspcae */
if (par->bgr)
-   mactrl_data |= (1 << 2);
+   mactrl_data |= BIT(2);
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, mactrl_data);
write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
return 0;
diff --git a/drivers/staging/fbtft/fb_ili9325.c 
b/drivers/staging/fbtft/fb_ili9325.c
index 7189de5ae4b3..7f9e9b25490e 100644
--- a/drivers/staging/fbtft/fb_ili9325.c
+++ b/drivers/staging/fbtft/fb_ili9325.c
@@ -126,7 +126,7 @@ static int init_display(struct fbtft_par *par)
write_reg(par, 0x0013, 0x); /* VDV[4:0] for VCOM amplitude */
mdelay(200); /* Dis-charge capacitor power voltage */
write_reg(par, 0x0010, /* SAP, BT[3:0], AP, DSTB, SLP, STB */
-   (1 << 12) | (bt << 8) | (1 << 7) | (0x01 << 4));
+   BIT(12) | (bt << 8) | BIT(7) | BIT(4));
write_reg(par, 0x0011, 0x220 | vc); /* DC1[2:0], DC0[2:0], VC[2:0] */
mdelay(50); /* Delay 50ms */
write_reg(par, 0x0012, vrh); /* Internal reference voltage= Vci; */
diff --git a/drivers/staging/fbtft/fb_ssd1289.c 
b/drivers/staging/fbtft/fb_ssd1289.c
index c603e1516e64..129e175fcd7e 100644
--- a/drivers/staging/fbtft/fb_ssd1289.c
+++ b/drivers/staging/fbtft/fb_ssd1289.c
@@ -47,7 +47,7 @@ static int init_display(struct fbtft_par *par)
write_reg(par, 0x0E, 0x2B00);
write_reg(par, 0x1E, 0x00B7);
write_reg(par, 0x01,
-   (1 << 13) | (par->bgr << 11) | (1 << 9) | (HEIGHT - 1));
+   BIT(13) | (par->bgr << 11) | BIT(9) | (HEIGHT - 1));
write_reg(par, 0x02, 0x0600);
write_reg(par, 0x10, 0x);
write_reg(par, 0x05, 0x);
-- 
2.11.0

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


[PATCH v2] staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -remove/correct the wrong code.

 drivers/staging/iio/cdc/ad7150.c |  2 +-
 drivers/staging/iio/cdc/ad7746.c | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index ca72af3e9d4b..a6f249e9c1e1 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
*indio_dev,
if (ret < 0)
goto error_ret;
 
-   cfg = ret & ~((0x03 << 5) | (0x1 << 7));
+   cfg = ret & ~((0x03 << 5) | BIT(7));
 
switch (type) {
case IIO_EV_TYPE_MAG_ADAPTIVE:
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 81f8b9ee1120..453d3978879d 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -45,10 +45,10 @@
 #define AD7746_STATUS_RDYCAP   BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN  (1 << 7)
-#define AD7746_CAPSETUP_CIN2   (1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF(1 << 5)
-#define AD7746_CAPSETUP_CACHOP (1 << 0)
+#define AD7746_CAPSETUP_CAPEN  (BIT(7))
+#define AD7746_CAPSETUP_CIN2   (BIT(6)) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF(BIT(5))
+#define AD7746_CAPSETUP_CACHOP (BIT(0))
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
 #define AD7746_VTSETUP_VTEN(1 << 7)
@@ -56,9 +56,9 @@
 #define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
 #define AD7746_VTSETUP_VTMD_VDD_MON(2 << 5)
 #define AD7746_VTSETUP_VTMD_EXT_VIN(3 << 5)
-#define AD7746_VTSETUP_EXTREF  (1 << 4)
-#define AD7746_VTSETUP_VTSHORT (1 << 1)
-#define AD7746_VTSETUP_VTCHOP  (1 << 0)
+#define AD7746_VTSETUP_EXTREF  (BIT(4))
+#define AD7746_VTSETUP_VTSHORT (BIT(1))
+#define AD7746_VTSETUP_VTCHOP  (BIT(0))
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
 #define AD7746_EXCSETUP_CLKCTRLBIT(7)
@@ -82,7 +82,7 @@
 #define AD7746_CONF_MODE_GAIN_CAL  (6 << 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN(1 << 7)
+#define AD7746_CAPDAC_DACEN(BIT(7))
 #define AD7746_CAPDAC_DACP(x)  ((x) & 0x7F)
 
 /*
-- 
2.11.0

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


Re: [PATCH] staging: fbtft: Replace a bit shift by a use of BIT.

2017-03-22 Thread Andy Shevchenko
On Wed, Mar 22, 2017 at 6:18 PM, Andy Shevchenko
 wrote:
> On Wed, Mar 22, 2017 at 4:37 AM, Arushi Singhal
>  wrote:
>> This patch replaces bit shifting on 1 with the BIT(x) macro.
>> This was done with coccinelle:
>> @@
>> constant c;
>> @@
>>
>> -1 << c
>> +BIT(c)
>>
>
> While using BIT() macro is a good idea, you make it inconsistent here.
> There are at least two options:
> - do nothing
> - define _MASK:s with GENMASK() and reuse in the code (looking at the
> code they are masks, not just separate bits).

Looking a bit more, not masks, but values.
So, best would be define for bits and values like 0x17.

One more thing, you don't need extra parens surround BIT() macro.

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v8] staging: adis16060: Remove iio_dev mlock and refactor code

2017-03-22 Thread simran 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.

In the driver, buf_lock protects both the adis16060_spi_write() and
adis16060_spi_read() functions and both are always called in
pair. First write, then read. Refactor the code to have
one single function adis16060_spi_write_than_read() and remove
the use of mlock as adis16060_read_raw() does not require an
iio_dev->mlock for reads.

Signed-off-by: simran singhal 
---

 v8:
   -change subject
   -change commit message
 v7:
   -Change subject
   -Remove lock from read_raw instead from
function adis16060_spi_write_than_read().
 v6:
   -Change commit message
   -Remove nested lock
 v5:
   -Rename val in adis16060_spi_write_than_read() to conf.
   -Rename val2 in adis16060_spi_write_than_read() to val.
   -Corrected Checkpatch issues.
   -Removed goto from adis16060_read_raw().
 v4:
   -Refactored code
   -change commit subject
   -change commit message
 v3:
   -Removed new lock to reuse the existing lock
 v2:
   -Fixed compilation error

 drivers/staging/iio/gyro/adis16060_core.c | 33 ---
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/iio/gyro/adis16060_core.c 
b/drivers/staging/iio/gyro/adis16060_core.c
index c9d46e7..e96fce5 100644
--- a/drivers/staging/iio/gyro/adis16060_core.c
+++ b/drivers/staging/iio/gyro/adis16060_core.c
@@ -40,25 +40,18 @@ struct adis16060_state {
 
 static struct iio_dev *adis16060_iio_dev;
 
-static int adis16060_spi_write(struct iio_dev *indio_dev, u8 val)
+static int adis16060_spi_write_than_read(struct iio_dev *indio_dev,
+u8 conf, u16 *val)
 {
int ret;
struct adis16060_state *st = iio_priv(indio_dev);
 
mutex_lock(>buf_lock);
-   st->buf[2] = val; /* The last 8 bits clocked in are latched */
+   st->buf[2] = conf; /* The last 8 bits clocked in are latched */
ret = spi_write(st->us_w, st->buf, 3);
-   mutex_unlock(>buf_lock);
-
-   return ret;
-}
-
-static int adis16060_spi_read(struct iio_dev *indio_dev, u16 *val)
-{
-   int ret;
-   struct adis16060_state *st = iio_priv(indio_dev);
 
-   mutex_lock(>buf_lock);
+   if (ret < 0)
+   return ret;
 
ret = spi_read(st->us_r, st->buf, 3);
 
@@ -86,17 +79,11 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
 
switch (mask) {
case IIO_CHAN_INFO_RAW:
-   /* Take the iio_dev status lock */
-   mutex_lock(_dev->mlock);
-   ret = adis16060_spi_write(indio_dev, chan->address);
+   ret = adis16060_spi_write_than_read(indio_dev,
+   chan->address, );
if (ret < 0)
-   goto out_unlock;
+   return ret;
 
-   ret = adis16060_spi_read(indio_dev, );
-   if (ret < 0)
-   goto out_unlock;
-
-   mutex_unlock(_dev->mlock);
*val = tval;
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET:
@@ -110,10 +97,6 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
}
 
return -EINVAL;
-
-out_unlock:
-   mutex_unlock(_dev->mlock);
-   return ret;
 }
 
 static const struct iio_info adis16060_info = {
-- 
2.7.4

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


Re: [PATCH] staging: fbtft: Replace a bit shift by a use of BIT.

2017-03-22 Thread Andy Shevchenko
On Wed, Mar 22, 2017 at 4:37 AM, Arushi Singhal
 wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
>
> -1 << c
> +BIT(c)
>

While using BIT() macro is a good idea, you make it inconsistent here.
There are at least two options:
- do nothing
- define _MASK:s with GENMASK() and reuse in the code (looking at the
code they are masks, not just separate bits).


> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/fbtft/fb_agm1264k-fl.c | 4 ++--
>  drivers/staging/fbtft/fb_ili9163.c | 2 +-
>  drivers/staging/fbtft/fb_ili9325.c | 2 +-
>  drivers/staging/fbtft/fb_ssd1289.c | 2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c 
> b/drivers/staging/fbtft/fb_agm1264k-fl.c
> index 4ee76dbd30b5..d31deeab69b2 100644
> --- a/drivers/staging/fbtft/fb_agm1264k-fl.c
> +++ b/drivers/staging/fbtft/fb_agm1264k-fl.c
> @@ -369,7 +369,7 @@ static int write_vmem(struct fbtft_par *par, size_t 
> offset, size_t len)
> /* select left side (sc0)
>  * set addr
>  */
> -   write_reg(par, 0x00, (1 << 6) | (u8)addr_win.xs);
> +   write_reg(par, 0x00, (BIT(6)) | (u8)addr_win.xs);
> write_reg(par, 0x00, (0x17 << 3) | (u8)y);
>
> /* write bitmap */
> @@ -392,7 +392,7 @@ static int write_vmem(struct fbtft_par *par, size_t 
> offset, size_t len)
> /* select right side (sc1)
>  * set addr
>  */
> -   write_reg(par, 0x01, 1 << 6);
> +   write_reg(par, 0x01, BIT(6));
> write_reg(par, 0x01, (0x17 << 3) | (u8)y);
>
> /* write bitmap */
> diff --git a/drivers/staging/fbtft/fb_ili9163.c 
> b/drivers/staging/fbtft/fb_ili9163.c
> index 579e17734612..06a5a5f6e33e 100644
> --- a/drivers/staging/fbtft/fb_ili9163.c
> +++ b/drivers/staging/fbtft/fb_ili9163.c
> @@ -194,7 +194,7 @@ static int set_var(struct fbtft_par *par)
>
> /* Colorspcae */
> if (par->bgr)
> -   mactrl_data |= (1 << 2);
> +   mactrl_data |= (BIT(2));
> write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, mactrl_data);
> write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
> return 0;
> diff --git a/drivers/staging/fbtft/fb_ili9325.c 
> b/drivers/staging/fbtft/fb_ili9325.c
> index 7189de5ae4b3..ab1267a9cd11 100644
> --- a/drivers/staging/fbtft/fb_ili9325.c
> +++ b/drivers/staging/fbtft/fb_ili9325.c
> @@ -126,7 +126,7 @@ static int init_display(struct fbtft_par *par)
> write_reg(par, 0x0013, 0x); /* VDV[4:0] for VCOM amplitude */
> mdelay(200); /* Dis-charge capacitor power voltage */
> write_reg(par, 0x0010, /* SAP, BT[3:0], AP, DSTB, SLP, STB */
> -   (1 << 12) | (bt << 8) | (1 << 7) | (0x01 << 4));
> +   (BIT(12)) | (bt << 8) | (BIT(7)) | (BIT(4)));
> write_reg(par, 0x0011, 0x220 | vc); /* DC1[2:0], DC0[2:0], VC[2:0] */
> mdelay(50); /* Delay 50ms */
> write_reg(par, 0x0012, vrh); /* Internal reference voltage= Vci; */
> diff --git a/drivers/staging/fbtft/fb_ssd1289.c 
> b/drivers/staging/fbtft/fb_ssd1289.c
> index c603e1516e64..b22a07d79b34 100644
> --- a/drivers/staging/fbtft/fb_ssd1289.c
> +++ b/drivers/staging/fbtft/fb_ssd1289.c
> @@ -47,7 +47,7 @@ static int init_display(struct fbtft_par *par)
> write_reg(par, 0x0E, 0x2B00);
> write_reg(par, 0x1E, 0x00B7);
> write_reg(par, 0x01,
> -   (1 << 13) | (par->bgr << 11) | (1 << 9) | (HEIGHT - 1));
> +   (BIT(13)) | (par->bgr << 11) | (BIT(9)) | (HEIGHT - 1));
> write_reg(par, 0x02, 0x0600);
> write_reg(par, 0x10, 0x);
> write_reg(par, 0x05, 0x);
> --
> 2.11.0
>



-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: removed coding style errors

2017-03-22 Thread Prasant Jalan
The patch replaces spaces with tabs as required by kernel coding
standards.

Signed-off-by: Prasant Jalan 
---
 drivers/staging/vt6656/rxtx.c | 40 ++--
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 1835cd1..0f89d4f 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -114,7 +114,7 @@ static __le16 vnt_time_stamp_off(struct vnt_private *priv, 
u16 rate)
 }
 
 static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type,
-   u32 frame_length, u16 rate, int need_ack)
+   u32 frame_length, u16 rate, int need_ack)
 {
u32 data_time, ack_time;
 
@@ -123,10 +123,12 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 
pkt_type,
 
if (pkt_type == PK_TYPE_11B)
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, 
(u16)priv->top_cck_basic_rate);
+   14,
+   (u16)priv->top_cck_basic_rate);
else
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, 
(u16)priv->top_ofdm_basic_rate);
+   14,
+   (u16)priv->top_ofdm_basic_rate);
 
if (need_ack)
return data_time + priv->sifs + ack_time;
@@ -135,14 +137,15 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 
pkt_type,
 }
 
 static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
-u32 frame_length, u16 rate, int need_ack)
+   u32 frame_length, u16 rate, int need_ack)
 {
return cpu_to_le16((u16)vnt_get_rsvtime(priv, pkt_type,
frame_length, rate, need_ack));
 }
 
 static __le16 vnt_get_rtscts_rsvtime_le(struct vnt_private *priv,
-u8 rsv_type, u8 pkt_type, u32 
frame_length, u16 current_rate)
+   u8 rsv_type, u8 pkt_type,
+   u32 frame_length, u16 current_rate)
 {
u32 rrv_time, rts_time, cts_time, ack_time, data_time;
 
@@ -160,19 +163,19 @@ static __le16 vnt_get_rtscts_rsvtime_le(struct 
vnt_private *priv,
rts_time = vnt_get_frame_time(priv->preamble_type,
pkt_type, 20, priv->top_cck_basic_rate);
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
+   14, priv->top_cck_basic_rate);
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
+   14, priv->top_ofdm_basic_rate);
} else if (rsv_type == 2) {
rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 20, priv->top_ofdm_basic_rate);
+   20, priv->top_ofdm_basic_rate);
cts_time = ack_time = vnt_get_frame_time(priv->preamble_type,
pkt_type, 14, priv->top_ofdm_basic_rate);
} else if (rsv_type == 3) {
cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_cck_basic_rate);
+   14, priv->top_cck_basic_rate);
ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
- 14, priv->top_ofdm_basic_rate);
+   14, priv->top_ofdm_basic_rate);
 
rrv_time = cts_time + ack_time + data_time + 2 * priv->sifs;
 
@@ -227,7 +230,8 @@ static __le16 vnt_get_rtscts_duration_le(struct 
vnt_usb_send_context *context,
case RTSDUR_AA_F0:
case RTSDUR_AA_F1:
cts_time = vnt_get_frame_time(priv->preamble_type,
- pkt_type, 14, 
priv->top_ofdm_basic_rate);
+   pkt_type, 14,
+   priv->top_ofdm_basic_rate);
dur_time = cts_time + 2 * priv->sifs +
vnt_get_rsvtime(priv, pkt_type,
frame_length, rate, need_ack);
@@ -410,7 +414,7 @@ static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context 
*tx_context,
u16 current_rate = tx_context->tx_rate;
 
vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
- PK_TYPE_11B, >b);

[PATCH v2] staging: lustre: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 - remove the unnecessary parenthesis.
 - removethe wrong changes.

 drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 
 drivers/staging/lustre/lnet/lnet/lib-ptl.c | 2 +-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index eaa4399e6a2e..2b93ceaa2844 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -1906,14 +1906,14 @@ ksocknal_connect(struct ksock_route *route)
if (retry_later) /* needs reschedule */
break;
 
-   if (wanted & (1 << SOCKLND_CONN_ANY)) {
+   if (wanted & BIT(SOCKLND_CONN_ANY)) {
type = SOCKLND_CONN_ANY;
-   } else if (wanted & (1 << SOCKLND_CONN_CONTROL)) {
+   } else if (wanted & BIT(SOCKLND_CONN_CONTROL)) {
type = SOCKLND_CONN_CONTROL;
-   } else if (wanted & (1 << SOCKLND_CONN_BULK_IN)) {
+   } else if (wanted & BIT(SOCKLND_CONN_BULK_IN)) {
type = SOCKLND_CONN_BULK_IN;
} else {
-   LASSERT(wanted & (1 << SOCKLND_CONN_BULK_OUT));
+   LASSERT(wanted & BIT(SOCKLND_CONN_BULK_OUT));
type = SOCKLND_CONN_BULK_OUT;
}
 
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c 
b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 63cce0c4a065..2724ab94 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -334,7 +334,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int 
pos)
bmap = >mt_exhausted[pos >> LNET_MT_BITS_U64];
pos &= (1 << LNET_MT_BITS_U64) - 1;
 
-   return (*bmap & (1ULL << pos));
+   return (*bmap & BIT(pos));
 }
 
 static void
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c 
b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 40f1fcf8b5c0..c742cba60199 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1308,7 +1308,7 @@ static void ll_display_extents_info(struct 
ll_rw_extents_info *io_extents,
   r, pct(r, read_tot), pct(read_cum, read_tot),
   w, pct(w, write_tot), pct(write_cum, write_tot));
start = end;
-   if (start == 1 << 10) {
+   if (start == 1024) {
start = 1;
units += 10;
unitp++;
-- 
2.11.0

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


Re: [PATCH 1/1] board: Fixed compilation of board.c

2017-03-22 Thread Greg KH
On Wed, Mar 22, 2017 at 03:03:20PM +0100, Artur Lorincz wrote:
> Implementing the find_by_address(...) function differently based on
> the CONFIG_OF switch. The function  of_find_all_nodes() invoked in the
> function body is only available in case the CONFIG_OF switch is set.
> 
> For the other architectures the find_by_address(...) call returns false.
> 
> Signed-off-by: Artur Lorincz 
> ---
>  drivers/staging/board/board.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 86dc411..d383857 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -25,6 +25,7 @@
>  static struct device_node *irqc_node __initdata;
>  static unsigned int irqc_base __initdata;
> 
> +#ifdef CONFIG_OF
>  static bool find_by_address(u64 base_address)
>  {
>   struct device_node *dn = of_find_all_nodes(NULL);
> @@ -42,6 +43,12 @@ static bool find_by_address(u64 base_address)
> 
>   return false;
>  }
> +#else
> +static bool find_by_address(u64 base_address)
> +{
> + return false;
> +}
> +#endif

Shouldn't the default of_* functions just return the correct "of is not
enabled" options here?  Why is the #ifdef needed?

thanks,

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


Re: [Outreachy kernel] [PATCH v2] staging: rts5208: Replace a bit shift by a use of BIT.

2017-03-22 Thread Julia Lawall


On Wed, 22 Mar 2017, Arushi Singhal wrote:

> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
>
> -1 << c
> +BIT(c)
>
> Signed-off-by: Arushi Singhal 

Acked-by: Julia Lawall 

> ---
> changes in v2
>  - remove the unnecessary parenthesis.
>
>  drivers/staging/rts5208/rtsx_chip.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rts5208/rtsx_chip.c 
> b/drivers/staging/rts5208/rtsx_chip.c
> index 3511157a2c78..7f4107bffe31 100644
> --- a/drivers/staging/rts5208/rtsx_chip.c
> +++ b/drivers/staging/rts5208/rtsx_chip.c
> @@ -1490,7 +1490,7 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 
> addr, u8 mask, u8 data)
>
>   for (i = 0; i < MAX_RW_REG_CNT; i++) {
>   val = rtsx_readl(chip, RTSX_HAIMR);
> - if ((val & (1 << 31)) == 0) {
> + if ((val & BIT(31)) == 0) {
>   if (data != (u8)val) {
>   rtsx_trace(chip);
>   return STATUS_FAIL;
> @@ -1518,7 +1518,7 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 
> addr, u8 *data)
>
>   for (i = 0; i < MAX_RW_REG_CNT; i++) {
>   val = rtsx_readl(chip, RTSX_HAIMR);
> - if ((val & (1 << 31)) == 0)
> + if ((val & BIT(31)) == 0)
>   break;
>   }
>
> --
> 2.11.0
>
> --
> 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/20170322131757.GA5335%40arushi-HP-Pavilion-Notebook.
> 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: rts5208: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 - remove the unnecessary parenthesis.

 drivers/staging/rts5208/rtsx_chip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_chip.c 
b/drivers/staging/rts5208/rtsx_chip.c
index 3511157a2c78..7f4107bffe31 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -1490,7 +1490,7 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 addr, 
u8 mask, u8 data)
 
for (i = 0; i < MAX_RW_REG_CNT; i++) {
val = rtsx_readl(chip, RTSX_HAIMR);
-   if ((val & (1 << 31)) == 0) {
+   if ((val & BIT(31)) == 0) {
if (data != (u8)val) {
rtsx_trace(chip);
return STATUS_FAIL;
@@ -1518,7 +1518,7 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, 
u8 *data)
 
for (i = 0; i < MAX_RW_REG_CNT; i++) {
val = rtsx_readl(chip, RTSX_HAIMR);
-   if ((val & (1 << 31)) == 0)
+   if ((val & BIT(31)) == 0)
break;
}
 
-- 
2.11.0

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


Re: [PATCH 1/1] board: Fixed compilation of board.c

2017-03-22 Thread Greg KH
On Wed, Mar 22, 2017 at 02:00:31PM +0100, Artur Lorincz wrote:
> Made the compilation of board.c depend on the CONFIG_OF flag. The
> source file board.c is referencing of_find_all_nodes(...) which is
> included only if the CONFIG_OF flag is set.
> 
> Signed-off-by: Artur Lorincz 
> ---
>  drivers/staging/board/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
> index 6842745..146aab0 100644
> --- a/drivers/staging/board/Makefile
> +++ b/drivers/staging/board/Makefile
> @@ -1,3 +1,3 @@
> -obj-y:= board.o
> +obj-$(CONFIG_OF) += board.o

Ick, no, what about building this code for other systems?

thanks,

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


Re: [PATCH] staging: lustre: Replace a bit shift by a use of BIT.

2017-03-22 Thread Dilger, Andreas
On Mar 21, 2017, at 22:39, Arushi Singhal  
wrote:
> 
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)

Did you take the time to look at what this Coccinelle script actually did, to 
see
if it actually makes sense?  Some of the cases where this replacement was done
makes sense because a specific bit is being accessed (i.e. a bitmask).  
Elsewhere,
it doesn't make sense to use BIT() to specify numeric values (e.g. PAGE_SHIFT,
1 << 12 = 1024, etc) since they are not bitmasks.

> Signed-off-by: Arushi Singhal 
> ---
> drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c   | 2 +-
> drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c| 8 
> drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c | 2 +-
> drivers/staging/lustre/lnet/lnet/lib-ptl.c| 4 ++--
> drivers/staging/lustre/lnet/lnet/net_fault.c  | 8 
> drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++--
> drivers/staging/lustre/lustre/obdclass/lustre_handles.c   | 2 +-
> drivers/staging/lustre/lustre/osc/osc_request.c   | 2 +-
> 8 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c 
> b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 79321e4aaf30..449f04f125b7 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -2241,7 +2241,7 @@ static int kiblnd_hdev_get_attr(struct kib_hca_dev 
> *hdev)
>* matching that of the native system
>*/
>   hdev->ibh_page_shift = PAGE_SHIFT;
> - hdev->ibh_page_size  = 1 << PAGE_SHIFT;
> + hdev->ibh_page_size  = BIT(PAGE_SHIFT);

This should just be replaced with "PAGE_SIZE".

>   hdev->ibh_page_mask  = ~((__u64)hdev->ibh_page_size - 1);
> 
>   hdev->ibh_mr_size = hdev->ibh_ibdev->attrs.max_mr_size;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c 
> b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index eaa4399e6a2e..5bef8a7e053b 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -1906,14 +1906,14 @@ ksocknal_connect(struct ksock_route *route)
>   if (retry_later) /* needs reschedule */
>   break;
> 
> - if (wanted & (1 << SOCKLND_CONN_ANY)) {
> + if (wanted & (BIT(SOCKLND_CONN_ANY))) {

There shouldn't be any need to put parenthesis around (BIT(x)) here, or
any of the cases below, or the BIT macro is broken.  But besides that, the
use of BIT() here looks OK.

>   type = SOCKLND_CONN_ANY;
> - } else if (wanted & (1 << SOCKLND_CONN_CONTROL)) {
> + } else if (wanted & (BIT(SOCKLND_CONN_CONTROL))) {
>   type = SOCKLND_CONN_CONTROL;
> - } else if (wanted & (1 << SOCKLND_CONN_BULK_IN)) {
> + } else if (wanted & (BIT(SOCKLND_CONN_BULK_IN))) {
>   type = SOCKLND_CONN_BULK_IN;
>   } else {
> - LASSERT(wanted & (1 << SOCKLND_CONN_BULK_OUT));
> + LASSERT(wanted & (BIT(SOCKLND_CONN_BULK_OUT)));
>   type = SOCKLND_CONN_BULK_OUT;
>   }
> 
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c 
> b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
> index fc7eec83ac07..2d1e3479cf7e 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
> @@ -71,7 +71,7 @@ static int typed_conns = 1;
> module_param(typed_conns, int, 0444);
> MODULE_PARM_DESC(typed_conns, "use different sockets for bulk");
> 
> -static int min_bulk = 1 << 10;
> +static int min_bulk = BIT(10);

This is a scalar value and not a bitmask.  It could just be "1024", but using
BIT() is not correct.

> module_param(min_bulk, int, 0644);
> MODULE_PARM_DESC(min_bulk, "smallest 'large' message");
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c 
> b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> index 63cce0c4a065..b980c669705e 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
> @@ -332,7 +332,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, 
> int pos)
>   LASSERT(pos <= LNET_MT_HASH_IGNORE);
>   /* mtable::mt_mhash[pos] is marked as exhausted or not */
>   bmap = >mt_exhausted[pos >> LNET_MT_BITS_U64];
> - pos &= (1 << LNET_MT_BITS_U64) - 1;
> + pos &= (BIT(LNET_MT_BITS_U64)) - 1;

The use of BIT() above is probably not correct.  This is creating a mask to 
align
pos to a multiple of (1 << LNET_MT_BITS_U64), and IMHO BIT() shouldn't be used
just 

Re: [PATCH] staging: media: Replace a bit shift by a use of BIT.

2017-03-22 Thread Dilger, Andreas
On Mar 22, 2017, at 00:20, Arushi Singhal  
wrote:
> 
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)

Hi Arushi,
thanks for taking time to contribute to the kernel.  There are a few problems 
with
this patch.

Firstly, I'm not sure why you sent this patch to lustre-devel, Oleg, James, and 
me,
since it has nothing to do with Lustre.  Conversely, the actual maintainer(s) 
of this
code would normally be better suited to review the patch.  This isn't totally 
clear
in this case since get_maintainer.pl lists another person submitting minor 
cleanups,
but "git log" does return some more likely candidates:
- David Daney  (original author)
- Luuk Paulussen  (recent non-trivial 
patcher)
- Kyeong Yoo  (recent non-trivial reviewer)
- Richard Laing   " "
- Chris Packham 
- Tim Beale 
- Hamish Martin 


Secondly, as mentioned with the other patch you submitted, you need to stop and 
look
at whether your changes actually make sense.  In this case, I don't think they 
do
make sense, and this patch should probably just be abandoned.


> Signed-off-by: Arushi Singhal 
> ---
> drivers/staging/octeon/ethernet-tx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/octeon/ethernet-tx.c 
> b/drivers/staging/octeon/ethernet-tx.c
> index ff4119e8de42..f00186ac4e27 100644
> --- a/drivers/staging/octeon/ethernet-tx.c
> +++ b/drivers/staging/octeon/ethernet-tx.c
> @@ -381,7 +381,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device 
> *dev)
>   (ip_hdr(skb)->version == 4) &&
>   (ip_hdr(skb)->ihl == 5) &&
>   ((ip_hdr(skb)->frag_off == 0) ||
> -  (ip_hdr(skb)->frag_off == htons(1 << 14))) &&
> +  (ip_hdr(skb)->frag_off == htons(BIT(14 &&

In this case, it is checking if the fragment offset in bytes is 16384, rather 
than doing
a bit comparison, so I don't think the use of BIT() is appropriate here.

>   ((ip_hdr(skb)->protocol == IPPROTO_TCP) ||
>(ip_hdr(skb)->protocol == IPPROTO_UDP))) {
>   /* Use hardware checksum calc */
> @@ -613,7 +613,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct 
> net_device *dev)
> #endif
>   work->word2.s.is_frag = !((ip_hdr(skb)->frag_off == 0) ||
> (ip_hdr(skb)->frag_off ==
> -   1 << 14));
> +   BIT(14)));

Same.

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







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


Re: [PATCH v2] staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Lars-Peter Clausen
On 03/22/2017 09:38 AM, Arushi Singhal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)

When it comes to doing this type of conversion semantics, i.e. the meaning
of the value, are important. The BIT() macro should only be used when the
value is really a 1 bit value. Otherwise it will be confusing to the reader
of the code.

Also one patch per driver please (Unless it is an absolutely identical
change to multiple driver, not just the same class of change).

> 
> Signed-off-by: Arushi Singhal 
> ---
> changes in v2
>  -change the cc list
> 
>  drivers/staging/iio/adc/ad7816.c |  2 +-
>  drivers/staging/iio/cdc/ad7150.c |  2 +-
>  drivers/staging/iio/cdc/ad7746.c | 22 +++---
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c 
> b/drivers/staging/iio/adc/ad7816.c
> index 17d280581e24..42f637ca0251 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev,
>   value = (s8)((data >> AD7816_TEMP_FLOAT_OFFSET) - 103);
>   data &= AD7816_TEMP_FLOAT_MASK;
>   if (value < 0)
> - data = (1 << AD7816_TEMP_FLOAT_OFFSET) - data;
> + data = (BIT(AD7816_TEMP_FLOAT_OFFSET)) - data;

This for example is just a really poor implementation of unsigned binary to
signed conversion (The formula I think is straight from the datasheet).
Semantically talking about a 1-bit value here makes no sense. What the code
does is to construct a value that is equal to 2**AD7816_TEMP_FLOAT_OFFSET.

>   return sprintf(buf, "%d.%.2d\n", value, data * 25);
>   }
>   return sprintf(buf, "%u\n", data);
> diff --git a/drivers/staging/iio/cdc/ad7150.c 
> b/drivers/staging/iio/cdc/ad7150.c
> index ca72af3e9d4b..c5574b3ee939 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
> *indio_dev,
>   if (ret < 0)
>   goto error_ret;
>  
> - cfg = ret & ~((0x03 << 5) | (0x1 << 7));
> + cfg = ret & ~((0x03 << 5) | (BIT(7)));

This is OK. It's a one bit field that is set here.

>  
>   switch (type) {
>   case IIO_EV_TYPE_MAG_ADAPTIVE:
> diff --git a/drivers/staging/iio/cdc/ad7746.c 
> b/drivers/staging/iio/cdc/ad7746.c
> index 81f8b9ee1120..8c573817826f 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -45,20 +45,20 @@
>  #define AD7746_STATUS_RDYCAP BIT(0)
>  
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) 
> */
> -#define AD7746_CAPSETUP_CAPEN(1 << 7)
> -#define AD7746_CAPSETUP_CIN2 (1 << 6) /* AD7746 only */
> -#define AD7746_CAPSETUP_CAPDIFF  (1 << 5)
> -#define AD7746_CAPSETUP_CACHOP   (1 << 0)
> +#define AD7746_CAPSETUP_CAPEN(BIT(7))
> +#define AD7746_CAPSETUP_CIN2 (BIT(6)) /* AD7746 only */
> +#define AD7746_CAPSETUP_CAPDIFF  (BIT(5))
> +#define AD7746_CAPSETUP_CACHOP   (BIT(0))

These are all OK, they are single bit values or flags.

>  
>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) 
> */
> -#define AD7746_VTSETUP_VTEN  (1 << 7)
> +#define AD7746_VTSETUP_VTEN  (BIT(7))
>  #define AD7746_VTSETUP_VTMD_INT_TEMP (0 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_TEMP (1 << 5)
> +#define AD7746_VTSETUP_VTMD_EXT_TEMP (BIT(5))

This is not OK. This is a multi-bit field. b01 just happens to be one of the
valid values.

>  #define AD7746_VTSETUP_VTMD_VDD_MON  (2 << 5)
>  #define AD7746_VTSETUP_VTMD_EXT_VIN  (3 << 5)
> -#define AD7746_VTSETUP_EXTREF(1 << 4)
> -#define AD7746_VTSETUP_VTSHORT   (1 << 1)
> -#define AD7746_VTSETUP_VTCHOP(1 << 0)
> +#define AD7746_VTSETUP_EXTREF(BIT(4))
> +#define AD7746_VTSETUP_VTSHORT   (BIT(1))
> +#define AD7746_VTSETUP_VTCHOP(BIT(0))

These are OK. All single bit values.

>  
>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>  #define AD7746_EXCSETUP_CLKCTRL  BIT(7)
> @@ -75,14 +75,14 @@
>  #define AD7746_CONF_VTFS_MASKGENMASK(7, 6)
>  #define AD7746_CONF_CAPFS_MASK   GENMASK(5, 3)
>  #define AD7746_CONF_MODE_IDLE(0 << 0)
> -#define AD7746_CONF_MODE_CONT_CONV   (1 << 0)
> +#define AD7746_CONF_MODE_CONT_CONV   (BIT(0))

This again is a multi-bit field where 1 is one of the possible values. So
not OK.

>  #define AD7746_CONF_MODE_SINGLE_CONV (2 << 0)
>  #define AD7746_CONF_MODE_PWRDN   (3 << 0)
>  #define AD7746_CONF_MODE_OFFS_CAL(5 << 0)
>  #define AD7746_CONF_MODE_GAIN_CAL(6 << 0)
>  

Re: [Outreachy kernel] [PATCH] staging: media: Replace a bit shift by a use of BIT.

2017-03-22 Thread Julia Lawall


On Wed, 22 Mar 2017, Arushi Singhal wrote:

> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
>
> -1 << c
> +BIT(c)
>
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/octeon/ethernet-tx.c | 4 ++--

What is the connection to media?  You also seem to have picked up the
Lustre maintainers, who are not relevant.

julia

>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/octeon/ethernet-tx.c 
> b/drivers/staging/octeon/ethernet-tx.c
> index ff4119e8de42..f00186ac4e27 100644
> --- a/drivers/staging/octeon/ethernet-tx.c
> +++ b/drivers/staging/octeon/ethernet-tx.c
> @@ -381,7 +381,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device 
> *dev)
>   (ip_hdr(skb)->version == 4) &&
>   (ip_hdr(skb)->ihl == 5) &&
>   ((ip_hdr(skb)->frag_off == 0) ||
> -  (ip_hdr(skb)->frag_off == htons(1 << 14))) &&
> +  (ip_hdr(skb)->frag_off == htons(BIT(14 &&
>   ((ip_hdr(skb)->protocol == IPPROTO_TCP) ||
>(ip_hdr(skb)->protocol == IPPROTO_UDP))) {
>   /* Use hardware checksum calc */
> @@ -613,7 +613,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct 
> net_device *dev)
>  #endif
>   work->word2.s.is_frag = !((ip_hdr(skb)->frag_off == 0) ||
> (ip_hdr(skb)->frag_off ==
> -   1 << 14));
> +   BIT(14)));
>  #if 0
>   /* Assume Linux is sending a good packet */
>   work->word2.s.IP_exc = 0;
> --
> 2.11.0
>
> --
> 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/20170322042028.GA22848%40arushi-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rts5208: Replace a bit shift by a use of BIT.

2017-03-22 Thread Dan Carpenter
On Wed, Mar 22, 2017 at 08:04:47AM +0530, Arushi Singhal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/rts5208/rtsx_chip.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_chip.c 
> b/drivers/staging/rts5208/rtsx_chip.c
> index 3511157a2c78..06a61800b71a 100644
> --- a/drivers/staging/rts5208/rtsx_chip.c
> +++ b/drivers/staging/rts5208/rtsx_chip.c
> @@ -1490,7 +1490,7 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 
> addr, u8 mask, u8 data)
>  
>   for (i = 0; i < MAX_RW_REG_CNT; i++) {
>   val = rtsx_readl(chip, RTSX_HAIMR);
> - if ((val & (1 << 31)) == 0) {
> + if ((val & (BIT(31))) == 0) {

Extra parens.  Please check all your patches again.

regards,
dan carpenter

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


Re: staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Dan Carpenter
On Wed, Mar 22, 2017 at 08:19:42AM +0530, Arushi Singhal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/iio/adc/ad7816.c |  2 +-
>  drivers/staging/iio/cdc/ad7150.c |  2 +-
>  drivers/staging/iio/cdc/ad7746.c | 22 +++---
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c 
> b/drivers/staging/iio/adc/ad7816.c
> index 17d280581e24..42f637ca0251 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev,
>   value = (s8)((data >> AD7816_TEMP_FLOAT_OFFSET) - 103);
>   data &= AD7816_TEMP_FLOAT_MASK;
>   if (value < 0)
> - data = (1 << AD7816_TEMP_FLOAT_OFFSET) - data;
> + data = (BIT(AD7816_TEMP_FLOAT_OFFSET)) - data;

Remove the extra parentheses from all of these:

data = BIT(AD7816_TEMP_FLOAT_OFFSET) - data;

regards,
dan carpenter

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


Re: [PATCH 09/10] staging: ks7010: remove zero comparison

2017-03-22 Thread Dan Carpenter
On Wed, Mar 22, 2017 at 10:22:24AM +1100, Tobin C. Harding wrote:
> On Tue, Mar 21, 2017 at 03:49:22PM +0300, Dan Carpenter wrote:
> > On Tue, Mar 21, 2017 at 01:37:11PM +1100, Tobin C. Harding wrote:
> > > Comparison, equal to zero, is redundant
> > > 
> > > 'if (foo == 0)'  is equal to  'if (!foo)'
> > > 
> > > Typical kernel coding style is to use the shorter form.
> > > 
> > > Remove unnecessary zero comparison.
> > 
> > Not exactly.  If you're talking about the number zero then == 0 and != 0
> > are good style.  "if (size == 0) ".  Other times we're talking about
> > error codes or whatever and not the number zero so it should be
> > "if (ret) ".  Also for strcmp() functions, please use != 0 and == 0.
> > 
> > if (strcmp(foo, bar) != 0)  <-- read this as "foo != bar"
> > if (strcmp(foo, bar) == 0)  <-- read this as "foo == bar"
> > if (strcmp(foo, bar) < 0)  <-- read this as "foo < bar"
> > 
> > regards,
> > dan carpenter
> > 
> > 
> 
> What is best for flags please?
> 
> -   if (dwrq->flags == 0) {
> +   if (!dwrq->flags) {

The second one.

regards,
dan carpenter

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


Re: [PATCH] staging: wilc1000: use kernel define byte order macros

2017-03-22 Thread Dan Carpenter
On Tue, Mar 21, 2017 at 03:40:10PM -0600, Robert Perry Hooker wrote:
> Thanks for taking a look, Dan. Sorry if I missed the mark here.
> 
> Can you tell me a bit more about the bug this would introduce?
> 
> I see that ieee80211_is_action is defined like this: static inline bool 
> ieee80211_is_action(__le16 fc)
> 
> ...and that buff[FRAME_TYPE_ID]is a u8 (since FRAME_TYPE_ID = 0).
> 
> Is there an issue with calling cpu_to_le16 on a u8 that isn't encountered by 
> implicitly casting a u8 to __le16? Or am I
> missing something else?
> 

Oh...  Hm.  You're right.  I just was thinking that since buff was a
little endian buffer but it's only reading a u8.  It should probably
be reading a le16...  The buff likely is just a regular ieee80211_hdr
struct.

So you're fixing a bug, but probably not in the right way.  We should
instead just say "struct ieee80211_hdr *hdr = buff;" and instead of
treating it like an array of u8.  Probably it requires testing...

regards,
dan carpenter

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


Re: staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arnd Bergmann
On Wed, Mar 22, 2017 at 3:49 AM, Arushi Singhal
 wrote:

> @@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
> *indio_dev,
> if (ret < 0)
> goto error_ret;
>
> -   cfg = ret & ~((0x03 << 5) | (0x1 << 7));
> +   cfg = ret & ~((0x03 << 5) | (BIT(7)));
>
> switch (type) {
> case IIO_EV_TYPE_MAG_ADAPTIVE:

While the change in the #defines is not unusual, this particular change
here makes it harder to read, so I'd recommend leaving it alone, or changing
it to use symbolic names instead of the bit masks.

>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) 
> */
> -#define AD7746_VTSETUP_VTEN(1 << 7)
> +#define AD7746_VTSETUP_VTEN(BIT(7))
>  #define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
> +#define AD7746_VTSETUP_VTMD_EXT_TEMP   (BIT(5))

Why did you leave one of them unchanged?

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


[PATCH v2] staging: dgnc: remove tracing prints in dgnc_tty.c

2017-03-22 Thread Abhishek Bhardwaj
Remove tracing prints in dgnc_tty_send_xchar. The same functionality
could be achieved by using ftrace.

Signed-off-by: Abhishek Bhardwaj 
---
Changes in v2:
  - Remove the tracing prints all together.

 drivers/staging/dgnc/dgnc_tty.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cde00e3702fa..8ae94b441abf 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1862,13 +1862,9 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, 
char c)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return;
 
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n");
-
spin_lock_irqsave(>ch_lock, flags);
bd->bd_ops->send_immediate_char(ch, c);
spin_unlock_irqrestore(>ch_lock, flags);
-
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
 }
 
 /* Return modem signals to ld. */
-- 
2.12.1.500.gab5fba24ee-goog

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


[PATCH] staging: ks7010: fixed a coding style issue

2017-03-22 Thread Xiangyang Zhang
Fixed checkpatch.pl CHECK: Logical continuations should be on the
previous line

Signed-off-by: Xiangyang Zhang 
---
 drivers/staging/ks7010/ks7010_sdio.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 28b91be8..4f032a21 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -313,8 +313,8 @@ static void tx_device_task(void *dev)
int rc = 0;
 
DPRINTK(4, "\n");
-   if (cnt_txqbody(priv) > 0
-   && atomic_read(>psstatus.status) != PS_SNOOZE) {
+   if (cnt_txqbody(priv) > 0 &&
+   atomic_read(>psstatus.status) != PS_SNOOZE) {
sp = >tx_dev.tx_dev_buff[priv->tx_dev.qhead];
if (priv->dev_state >= DEVICE_STATE_BOOT) {
rc = write_to_device(priv, sp->sendp, sp->size);
@@ -558,8 +558,8 @@ static void ks_sdio_interrupt(struct sdio_func *func)
/* read (General Communication B register) */
/* bit5 -> Write Status Idle */
/* bit2 -> Read Status Busy  */
-   if (status & INT_GCR_B
-   || atomic_read(>psstatus.status) == PS_SNOOZE) {
+   if (status & INT_GCR_B ||
+   atomic_read(>psstatus.status) == PS_SNOOZE) {
retval =
ks7010_sdio_read(priv, GCR_B, _data,
 sizeof(rw_data));
-- 
2.11.0

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


[PATCH v2] staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -change the cc list

 drivers/staging/iio/adc/ad7816.c |  2 +-
 drivers/staging/iio/cdc/ad7150.c |  2 +-
 drivers/staging/iio/cdc/ad7746.c | 22 +++---
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 17d280581e24..42f637ca0251 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev,
value = (s8)((data >> AD7816_TEMP_FLOAT_OFFSET) - 103);
data &= AD7816_TEMP_FLOAT_MASK;
if (value < 0)
-   data = (1 << AD7816_TEMP_FLOAT_OFFSET) - data;
+   data = (BIT(AD7816_TEMP_FLOAT_OFFSET)) - data;
return sprintf(buf, "%d.%.2d\n", value, data * 25);
}
return sprintf(buf, "%u\n", data);
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index ca72af3e9d4b..c5574b3ee939 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev 
*indio_dev,
if (ret < 0)
goto error_ret;
 
-   cfg = ret & ~((0x03 << 5) | (0x1 << 7));
+   cfg = ret & ~((0x03 << 5) | (BIT(7)));
 
switch (type) {
case IIO_EV_TYPE_MAG_ADAPTIVE:
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 81f8b9ee1120..8c573817826f 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -45,20 +45,20 @@
 #define AD7746_STATUS_RDYCAP   BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN  (1 << 7)
-#define AD7746_CAPSETUP_CIN2   (1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF(1 << 5)
-#define AD7746_CAPSETUP_CACHOP (1 << 0)
+#define AD7746_CAPSETUP_CAPEN  (BIT(7))
+#define AD7746_CAPSETUP_CIN2   (BIT(6)) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF(BIT(5))
+#define AD7746_CAPSETUP_CACHOP (BIT(0))
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN(1 << 7)
+#define AD7746_VTSETUP_VTEN(BIT(7))
 #define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
+#define AD7746_VTSETUP_VTMD_EXT_TEMP   (BIT(5))
 #define AD7746_VTSETUP_VTMD_VDD_MON(2 << 5)
 #define AD7746_VTSETUP_VTMD_EXT_VIN(3 << 5)
-#define AD7746_VTSETUP_EXTREF  (1 << 4)
-#define AD7746_VTSETUP_VTSHORT (1 << 1)
-#define AD7746_VTSETUP_VTCHOP  (1 << 0)
+#define AD7746_VTSETUP_EXTREF  (BIT(4))
+#define AD7746_VTSETUP_VTSHORT (BIT(1))
+#define AD7746_VTSETUP_VTCHOP  (BIT(0))
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
 #define AD7746_EXCSETUP_CLKCTRLBIT(7)
@@ -75,14 +75,14 @@
 #define AD7746_CONF_VTFS_MASK  GENMASK(7, 6)
 #define AD7746_CONF_CAPFS_MASK GENMASK(5, 3)
 #define AD7746_CONF_MODE_IDLE  (0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV (1 << 0)
+#define AD7746_CONF_MODE_CONT_CONV (BIT(0))
 #define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
 #define AD7746_CONF_MODE_PWRDN (3 << 0)
 #define AD7746_CONF_MODE_OFFS_CAL  (5 << 0)
 #define AD7746_CONF_MODE_GAIN_CAL  (6 << 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN(1 << 7)
+#define AD7746_CAPDAC_DACEN(BIT(7))
 #define AD7746_CAPDAC_DACP(x)  ((x) & 0x7F)
 
 /*
-- 
2.11.0

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


Re: [PATCH v2] staging: dgnc: remove tracing prints in dgnc_tty.c

2017-03-22 Thread Greg KH
On Wed, Mar 22, 2017 at 12:18:43AM -0700, Abhishek Bhardwaj wrote:
> Remove tracing prints in dgnc_tty_send_xchar. The same functionality
> could be achieved by using ftrace.
> 
> Signed-off-by: Abhishek Bhardwaj 
> ---
>  drivers/staging/dgnc/dgnc_tty.c | 4 
>  1 file changed, 4 deletions(-)

What changed from v1?  Always put that info below the --- line, as the
documentation said to.

thanks,

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


[PATCH] drivers/staging/dgnc: Updating dev_dbg function

2017-03-22 Thread Pushkar Jambhlekar
Making use of __func__ instead of using function name directly in dev_dbg.

Signed-off-by: Pushkar Jambhlekar 
---
 drivers/staging/dgnc/dgnc_tty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f7e754e..b0c88b8 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1858,13 +1858,13 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, 
char c)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return;
 
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n");
+   dev_dbg(tty->dev, "%s start\n", __func__);
 
spin_lock_irqsave(>ch_lock, flags);
bd->bd_ops->send_immediate_char(ch, c);
spin_unlock_irqrestore(>ch_lock, flags);
 
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
+   dev_dbg(tty->dev, "%s finish\n", __func__);
 }
 
 /* Return modem signals to ld. */
-- 
2.7.4

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


[PATCH v2] staging: dgnc: remove tracing prints in dgnc_tty.c

2017-03-22 Thread Abhishek Bhardwaj
Remove tracing prints in dgnc_tty_send_xchar. The same functionality
could be achieved by using ftrace.

Signed-off-by: Abhishek Bhardwaj 
---
 drivers/staging/dgnc/dgnc_tty.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cde00e3702fa..8ae94b441abf 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1862,13 +1862,9 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, 
char c)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return;
 
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n");
-
spin_lock_irqsave(>ch_lock, flags);
bd->bd_ops->send_immediate_char(ch, c);
spin_unlock_irqrestore(>ch_lock, flags);
-
-   dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
 }
 
 /* Return modem signals to ld. */
-- 
2.12.1.500.gab5fba24ee-goog

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


Re: staging: iio: Replace a bit shift by a use of BIT.

2017-03-22 Thread Greg Kroah-Hartman
On Wed, Mar 22, 2017 at 08:19:42AM +0530, Arushi Singhal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
> 
> -1 << c
> +BIT(c)
> 
> Signed-off-by: Arushi Singhal 
> ---
>  drivers/staging/iio/adc/ad7816.c |  2 +-
>  drivers/staging/iio/cdc/ad7150.c |  2 +-
>  drivers/staging/iio/cdc/ad7746.c | 22 +++---
>  3 files changed, 13 insertions(+), 13 deletions(-)

Please be careful about your cc: list, you missed the correct list, and
added one not needed at all.  And you forgot the [PATCH] prefix :(

thanks,

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