Re: [PATCH 14/19] staging: iio: isl29028: move failure logging into isl29028_set_als_scale()

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> When isl29028_set_als_scale() fails, it was up to both callers to log
> the failure message. This patch moves the logging into
> isl29028_set_als_scale() to reduce the overall amount of code in the
> driver.
> 
> Signed-off-by: Brian Masney 
> ---
>  drivers/staging/iio/light/isl29028.c | 23 +--
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 0c8a878..11e1673 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -121,11 +121,21 @@ static int isl29028_enable_proximity(struct 
> isl29028_chip *chip)
>  
>  static int isl29028_set_als_scale(struct isl29028_chip *chip, int lux_scale)
>  {
> + struct device *dev = regmap_get_device(chip->regmap);
>   int val = (lux_scale == 2000) ? ISL29028_CONF_ALS_RANGE_HIGH_LUX :
>   ISL29028_CONF_ALS_RANGE_LOW_LUX;
> + int ret;
> +
> + ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> +  ISL29028_CONF_ALS_RANGE_MASK, val);
> + if (ret < 0)
> + dev_err(dev,
> + "%s(): Error %d setting the ALS scale\n", __func__,
> + ret);
Again, I would prefer a direct return here and drop the else.
Where possible it's always nice to have the 'good' path be the inline one and
indent the error cases.
> + else
> + chip->lux_scale = lux_scale;
>  
> - return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> -   ISL29028_CONF_ALS_RANGE_MASK, val);
> + return ret;
>  }
>  
>  static int isl29028_set_als_ir_mode(struct isl29028_chip *chip,
> @@ -322,13 +332,6 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,
>   }
>  
>   ret = isl29028_set_als_scale(chip, val);
> - if (ret < 0) {
> - dev_err(dev,
> - "Setting lux scale fail with error %d\n", ret);
> - break;
> - }
> -
> - chip->lux_scale = val;
>   break;
>   default:
>   dev_err(dev, "Unsupported channel type\n");
> @@ -459,7 +462,7 @@ static int isl29028_chip_init_and_power_on(struct 
> isl29028_chip *chip)
>  
>   ret = isl29028_set_als_scale(chip, chip->lux_scale);
>   if (ret < 0)
> - dev_err(dev, "setting als scale failed, err = %d\n", ret);
> + return ret;
>  
>   chip->suspended = false;
>  
> 

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


Re: [PATCH 11/19] staging: iio: isl29028: made column alignment in isl29028_channels consistent

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> The three info_mask_separate members OR several BIT(xxx) fields
> together. This patch changes the column alignment of these fields to be
> aligned at the same column to improve the overall code readability. It
> also moves the { for the next channel to the next line to improve code
> readability.
Skip the bracket change - to my mind it doesn't improve readability.
I mostly don't care which form is used on these (others are fussier) but
changing it from the one I slightly prefer to the one I dislike
is a step too far ;)

Jonathan

> 
> Signed-off-by: Brian Masney 
> ---
>  drivers/staging/iio/light/isl29028.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 0e727ba..218d165 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -419,14 +419,16 @@ static const struct iio_chan_spec isl29028_channels[] = 
> {
>   {
>   .type = IIO_LIGHT,
>   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
> - BIT(IIO_CHAN_INFO_SCALE),
> - }, {
> +   BIT(IIO_CHAN_INFO_SCALE),
> + },
> + {
>   .type = IIO_INTENSITY,
>   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> - }, {
> + },
> + {
>   .type = IIO_PROXIMITY,
>   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> - BIT(IIO_CHAN_INFO_SAMP_FREQ),
> +   BIT(IIO_CHAN_INFO_SAMP_FREQ),
>   }
>  };
>  
> 

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


Re: [PATCH 19/19] staging: iio: isl29028: remove legacy device tree binding

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> The isl29028 staging driver contains a legacy binding of "isl,isl29028"
> that is marked as legacy and to not use. There are no in tree references
> to that binding. This patch removes the legacy binding in preparation
> for moving the driver out of staging. Otherwise, we will have to support
> this binding indefinitely.
Leave this be.  Given it exists there almost certainly device trees out there
using it. Lets not break them just to save on one line of code.

Supporting legacy bindings isn't exactly costly!

I'm happy with all the patches I haven't commented on. Just can't apply
them because they have dependencies on early patches that I have
raised questions on.

Another generally nice bit of cleanup.

Thanks,

Jonathan
> 
> Signed-off-by: Brian Masney 
> Cc: devicet...@vger.kernel.org
> Cc: Rob Herring 
> Cc: Mark Rutland 
> ---
>  drivers/staging/iio/light/isl29028.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index ae6896f..6be9aa7 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -611,7 +611,6 @@ static const struct i2c_device_id isl29028_id[] = {
>  MODULE_DEVICE_TABLE(i2c, isl29028_id);
>  
>  static const struct of_device_id isl29028_of_match[] = {
> - { .compatible = "isl,isl29028", }, /* for backward compat., don't use */
>   { .compatible = "isil,isl29028", },
>   { },
>  };
> 

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


Re: [PATCH 13/19] staging: iio: isl29028: move failure logging into isl29028_set_proxim_sampling()

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> When isl29028_set_proxim_sampling() fails, it was up to both callers to
> log the failure message. This patch moves the logging into
> isl29028_set_proxim_sampling() to reduce the overall amount of code in
> the driver.
> 
> Signed-off-by: Brian Masney 
Minor point inline.
> ---
>  drivers/staging/iio/light/isl29028.c | 28 ++--
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 23a4db8..0c8a878 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -79,18 +79,28 @@ struct isl29028_chip {
>  static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
>   unsigned int sampling)
>  {
> + struct device *dev = regmap_get_device(chip->regmap);
>   static unsigned int prox_period[] = {800, 400, 200, 100, 75, 50, 12, 0};
>   unsigned int sel;
>   unsigned int period = DIV_ROUND_UP(1000, sampling);
> + int ret;
>  
>   for (sel = 0; sel < ARRAY_SIZE(prox_period); ++sel) {
>   if (period >= prox_period[sel])
>   break;
>   }
>  
> - return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> -   ISL29028_CONF_PROX_SLP_MASK,
> -   sel << ISL29028_CONF_PROX_SLP_SH);
> + ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> +  ISL29028_CONF_PROX_SLP_MASK,
> +  sel << ISL29028_CONF_PROX_SLP_SH);
> + if (ret < 0)
> + dev_err(dev,
> + "%s(): Error %d setting the proximity sampling\n",
> + __func__, ret);
I'd prefer the cleaner style or a return inside this if statement and dropping 
the
else.
> + else
> + chip->prox_sampling = sampling;
> +
> + return ret;
>  }
>  
>  static int isl29028_enable_proximity(struct isl29028_chip *chip)
> @@ -296,14 +306,6 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,
>   }
>  
>   ret = isl29028_set_proxim_sampling(chip, val);
> - if (ret < 0) {
> - dev_err(dev,
> - "Setting proximity samp_freq fail, err %d\n",
> - ret);
> - break;
> - }
> -
> - chip->prox_sampling = val;
>   break;
>   case IIO_LIGHT:
>   if (mask != IIO_CHAN_INFO_SCALE) {
> @@ -452,10 +454,8 @@ static int isl29028_chip_init_and_power_on(struct 
> isl29028_chip *chip)
>   }
>  
>   ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling);
> - if (ret < 0) {
> - dev_err(dev, "setting the proximity, err = %d\n", ret);
> + if (ret < 0)
>   return ret;
> - }
>  
>   ret = isl29028_set_als_scale(chip, chip->lux_scale);
>   if (ret < 0)
> 

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


Re: [PATCH 03/19] staging: iio: isl29028: remove chip test and defaults from isl29028_chip_init()

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> isl29028_chip_init() contains the device driver defaults and
> two I2C calls that detect the presence of the chip. This patch
> moves these into isl29028_probe() so that this function can
> be used by the power management runtinme in a followup patch. This
> patch also renames isl29028_chip_init() to
> isl29028_chip_init_and_power_on().
> 
> Signed-off-by: Brian Masney 
I've skipped patch 2 for now but will carry on applying until they stop going in
cleanly.

Applied to the togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 42 
> +++-
>  1 file changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index c8e234d..4f819a8 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -416,29 +416,11 @@ static const struct iio_info isl29028_info = {
>   .write_raw = isl29028_write_raw,
>  };
>  
> -static int isl29028_chip_init(struct isl29028_chip *chip)
> +static int isl29028_chip_init_and_power_on(struct isl29028_chip *chip)
>  {
>   struct device *dev = regmap_get_device(chip->regmap);
>   int ret;
>  
> - chip->enable_prox  = false;
> - chip->prox_sampling = 20;
> - chip->lux_scale = 2000;
> - chip->als_ir_mode = ISL29028_MODE_NONE;
> -
> - ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0);
> - if (ret < 0) {
> - dev_err(dev, "%s(): write to reg %d failed, err = %d\n",
> - __func__, ISL29028_REG_TEST1_MODE, ret);
> - return ret;
> - }
> - ret = regmap_write(chip->regmap, ISL29028_REG_TEST2_MODE, 0x0);
> - if (ret < 0) {
> - dev_err(dev, "%s(): write to reg %d failed, err = %d\n",
> - __func__, ISL29028_REG_TEST2_MODE, ret);
> - return ret;
> - }
> -
>   ret = regmap_write(chip->regmap, ISL29028_REG_CONFIGURE, 0x0);
>   if (ret < 0) {
>   dev_err(dev, "%s(): write to reg %d failed, err = %d\n",
> @@ -506,7 +488,27 @@ static int isl29028_probe(struct i2c_client *client,
>   return ret;
>   }
>  
> - ret = isl29028_chip_init(chip);
> + chip->enable_prox  = false;
> + chip->prox_sampling = 20;
> + chip->lux_scale = 2000;
> + chip->als_ir_mode = ISL29028_MODE_NONE;
> +
> + ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0);
> + if (ret < 0) {
> + dev_err(&client->dev,
> + "%s(): write to reg %d failed, err = %d\n", __func__,
> + ISL29028_REG_TEST1_MODE, ret);
> + return ret;
> + }
> + ret = regmap_write(chip->regmap, ISL29028_REG_TEST2_MODE, 0x0);
> + if (ret < 0) {
> + dev_err(&client->dev,
> + "%s(): write to reg %d failed, err = %d\n", __func__,
> + ISL29028_REG_TEST2_MODE, ret);
> + return ret;
> + }
> +
> + ret = isl29028_chip_init_and_power_on(chip);
>   if (ret < 0) {
>   dev_err(&client->dev, "chip initialization failed: %d\n", ret);
>   return ret;
> 

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


Re: [PATCH 04/19] staging: iio: isl29028: add power management support

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> This patch adds power management support to the isl29028 driver.
> 
> Signed-off-by: Brian Masney 
Hmm. I'm not sure why we need the suspended boolean.

I 'think' it's impossible to have a sysfs read in progress during suspend or 
resume.
At least I hope it is as a lot of drivers will be broken otherwise :(

Looks like this particular corner is only really present in light sensor 
drivers...

Jonathan

> ---
>  drivers/staging/iio/light/isl29028.c | 59 
> 
>  1 file changed, 59 insertions(+)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 4f819a8..e96a8cb 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -75,6 +75,7 @@ struct isl29028_chip {
>  
>   int lux_scale;
>   enum isl29028_als_ir_mode   als_ir_mode;
> + boolsuspended;
>  };
>  
>  static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
> @@ -274,6 +275,12 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,
>   int ret = -EINVAL;
>  
>   mutex_lock(&chip->lock);
> +
> + if (chip->suspended) {
> + ret = -EBUSY;
> + goto write_done;
> + }
> +
>   switch (chan->type) {
>   case IIO_PROXIMITY:
>   if (mask != IIO_CHAN_INFO_SAMP_FREQ) {
> @@ -322,6 +329,8 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,
>   dev_err(dev, "Unsupported channel type\n");
>   break;
>   }
> +
> +write_done:
>   mutex_unlock(&chip->lock);
>   return ret;
>  }
> @@ -335,6 +344,12 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,
>   int ret = -EINVAL;
>  
>   mutex_lock(&chip->lock);
> +
> + if (chip->suspended) {
> + ret = -EBUSY;
> + goto read_done;
> + }
> +
>   switch (mask) {
>   case IIO_CHAN_INFO_RAW:
>   case IIO_CHAN_INFO_PROCESSED:
> @@ -374,6 +389,8 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,
>   dev_err(dev, "mask value 0x%08lx not supported\n", mask);
>   break;
>   }
> +
> +read_done:
>   mutex_unlock(&chip->lock);
>   return ret;
>  }
> @@ -437,6 +454,9 @@ static int isl29028_chip_init_and_power_on(struct 
> isl29028_chip *chip)
>   ret = isl29028_set_als_scale(chip, chip->lux_scale);
>   if (ret < 0)
>   dev_err(dev, "setting als scale failed, err = %d\n", ret);
> +
> + chip->suspended = false;
> +
>   return ret;
>  }
>  
> @@ -479,6 +499,7 @@ static int isl29028_probe(struct i2c_client *client,
>  
>   i2c_set_clientdata(client, indio_dev);
>   mutex_init(&chip->lock);
> + chip->suspended = true;
>  
>   chip->regmap = devm_regmap_init_i2c(client, &isl29028_regmap_config);
>   if (IS_ERR(chip->regmap)) {
> @@ -530,6 +551,43 @@ static int isl29028_probe(struct i2c_client *client,
>   return 0;
>  }
>  
> +static int __maybe_unused isl29028_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct isl29028_chip *chip = iio_priv(indio_dev);
> + int ret;
> +
> + mutex_lock(&chip->lock);
> +
> + ret = regmap_write(chip->regmap, ISL29028_REG_CONFIGURE, 0x0);
> + if (ret < 0)
> + dev_err(dev, "%s(): Error %d turning off chip\n", __func__,
> + ret);
> +
> + chip->suspended = true;
> +
> + mutex_unlock(&chip->lock);
> +
> + return ret;
> +}
> +
> +static int __maybe_unused isl29028_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct isl29028_chip *chip = iio_priv(indio_dev);
> + int ret;
> +
> + mutex_lock(&chip->lock);
> +
> + ret = isl29028_chip_init_and_power_on(chip);
> +
> + mutex_unlock(&chip->lock);
> +
> + return ret;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(isl29028_pm_ops, isl29028_suspend, isl29028_resume);
> +
>  static const struct i2c_device_id isl29028_id[] = {
>   {"isl29028", 0},
>   {}
> @@ -546,6 +604,7 @@ MODULE_DEVICE_TABLE(of, isl29028_of_match);
>  static struct i2c_driver isl29028_driver = {
>   .driver  = {
>   .name = "isl29028",
> + .pm = &isl29028_pm_ops,
>   .of_match_table = isl29028_of_match,
>   },
>   .probe   = isl29028_probe,
> 

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


Re: [PATCH 05/19] staging: iio: isl29028: made alignment of #defines consistent

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> The alignment of the #defines at the top of the file is not consistent.
> This changes all of the defines to use consistent alignment to improve
> the code readability.
> 
> Signed-off-by: Brian Masney 
Skipped patch 4 for now, but this one still applies fine so applied to the
togreg branch of iio.git.

Will push out as testing later.
> ---
>  drivers/staging/iio/light/isl29028.c | 42 
> ++--
>  1 file changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index e96a8cb..d5b069e 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -27,38 +27,38 @@
>  #include 
>  #include 
>  
> -#define ISL29028_CONV_TIME_MS100
> +#define ISL29028_CONV_TIME_MS100
>  
> -#define ISL29028_REG_CONFIGURE   0x01
> +#define ISL29028_REG_CONFIGURE   0x01
>  
> -#define ISL29028_CONF_ALS_IR_MODE_ALS0
> -#define ISL29028_CONF_ALS_IR_MODE_IR BIT(0)
> -#define ISL29028_CONF_ALS_IR_MODE_MASK   BIT(0)
> +#define ISL29028_CONF_ALS_IR_MODE_ALS0
> +#define ISL29028_CONF_ALS_IR_MODE_IR BIT(0)
> +#define ISL29028_CONF_ALS_IR_MODE_MASK   BIT(0)
>  
> -#define ISL29028_CONF_ALS_RANGE_LOW_LUX  0
> +#define ISL29028_CONF_ALS_RANGE_LOW_LUX  0
>  #define ISL29028_CONF_ALS_RANGE_HIGH_LUX BIT(1)
> -#define ISL29028_CONF_ALS_RANGE_MASK BIT(1)
> +#define ISL29028_CONF_ALS_RANGE_MASK BIT(1)
>  
> -#define ISL29028_CONF_ALS_DIS0
> -#define ISL29028_CONF_ALS_EN BIT(2)
> -#define ISL29028_CONF_ALS_EN_MASKBIT(2)
> +#define ISL29028_CONF_ALS_DIS0
> +#define ISL29028_CONF_ALS_EN BIT(2)
> +#define ISL29028_CONF_ALS_EN_MASKBIT(2)
>  
> -#define ISL29028_CONF_PROX_SLP_SH4
> -#define ISL29028_CONF_PROX_SLP_MASK  (7 << ISL29028_CONF_PROX_SLP_SH)
> +#define ISL29028_CONF_PROX_SLP_SH4
> +#define ISL29028_CONF_PROX_SLP_MASK  (7 << ISL29028_CONF_PROX_SLP_SH)
>  
> -#define ISL29028_CONF_PROX_ENBIT(7)
> -#define ISL29028_CONF_PROX_EN_MASK   BIT(7)
> +#define ISL29028_CONF_PROX_ENBIT(7)
> +#define ISL29028_CONF_PROX_EN_MASK   BIT(7)
>  
> -#define ISL29028_REG_INTERRUPT   0x02
> +#define ISL29028_REG_INTERRUPT   0x02
>  
> -#define ISL29028_REG_PROX_DATA   0x08
> -#define ISL29028_REG_ALSIR_L 0x09
> -#define ISL29028_REG_ALSIR_U 0x0A
> +#define ISL29028_REG_PROX_DATA   0x08
> +#define ISL29028_REG_ALSIR_L 0x09
> +#define ISL29028_REG_ALSIR_U 0x0A
>  
> -#define ISL29028_REG_TEST1_MODE  0x0E
> -#define ISL29028_REG_TEST2_MODE  0x0F
> +#define ISL29028_REG_TEST1_MODE  0x0E
> +#define ISL29028_REG_TEST2_MODE  0x0F
>  
> -#define ISL29028_NUM_REGS(ISL29028_REG_TEST2_MODE + 1)
> +#define ISL29028_NUM_REGS(ISL29028_REG_TEST2_MODE + 1)
>  
>  enum isl29028_als_ir_mode {
>   ISL29028_MODE_NONE = 0,
> 

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


Re: [PATCH 02/19] staging: iio: isl29028: remove enable flag from isl29028_enable_proximity()

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> isl29028_enable_proximity() has a boolean argument named enable. This
> function is only called once and the enable flag is set to true in that
> call. This patch removes the enable parameter from that function.
> 
> Signed-off-by: Brian Masney 
On second thoughts (stupid email is hiding somewhere to be sent when I have wifi
so can't reply to it) perhaps this is a coarse way of only turning proximity on 
if
the LED is present?  Not sure...
> ---
>  drivers/staging/iio/light/isl29028.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 4e35d00..c8e234d 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -93,15 +93,13 @@ static int isl29028_set_proxim_sampling(struct 
> isl29028_chip *chip,
> sel << ISL29028_CONF_PROX_SLP_SH);
>  }
>  
> -static int isl29028_enable_proximity(struct isl29028_chip *chip, bool enable)
> +static int isl29028_enable_proximity(struct isl29028_chip *chip)
>  {
>   int ret;
> - int val = 0;
>  
> - if (enable)
> - val = ISL29028_CONF_PROX_EN;
>   ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> -  ISL29028_CONF_PROX_EN_MASK, val);
> +  ISL29028_CONF_PROX_EN_MASK,
> +  ISL29028_CONF_PROX_EN);
>   if (ret < 0)
>   return ret;
>  
> @@ -215,7 +213,7 @@ static int isl29028_proxim_get(struct isl29028_chip 
> *chip, int *prox_data)
>   int ret;
>  
>   if (!chip->enable_prox) {
> - ret = isl29028_enable_proximity(chip, true);
> + ret = isl29028_enable_proximity(chip);
>   if (ret < 0)
>   return ret;
>   chip->enable_prox = true;
> 

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


Re: [PATCH] staging:iio:addac Fixes Alignment should match open parenthesis

2017-01-08 Thread Jonathan Cameron
On 04/01/17 01:50, Scott Matheina wrote:
> Fixes style issue where Alignment doesn't match open parenthesis
> 
> Signed-off-by: Scott Matheina 
Please include the part number in the patch title. It's more important
than the directory it happens to be in.

Here you have space to include the whole lot
staging:iio:addac:adt7316

Applied with that minor change to the togreg branch of iio.git which
will get pushed out as testing sometime soon.

Jonathan
> ---
>  drivers/staging/iio/addac/adt7316-i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/addac/adt7316-i2c.c 
> b/drivers/staging/iio/addac/adt7316-i2c.c
> index 0ccf192..f66dd3e 100644
> --- a/drivers/staging/iio/addac/adt7316-i2c.c
> +++ b/drivers/staging/iio/addac/adt7316-i2c.c
> @@ -93,7 +93,7 @@ static int adt7316_i2c_multi_write(void *client, u8 reg, u8 
> count, u8 *data)
>   */
>  
>  static int adt7316_i2c_probe(struct i2c_client *client,
> - const struct i2c_device_id *id)
> +  const struct i2c_device_id *id)
>  {
>   struct adt7316_bus bus = {
>   .client = client,
> 

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


Re: [PATCH 02/19] staging: iio: isl29028: remove enable flag from isl29028_enable_proximity()

2017-01-08 Thread Jonathan Cameron
On 04/12/16 02:19, Brian Masney wrote:
> isl29028_enable_proximity() has a boolean argument named enable. This
> function is only called once and the enable flag is set to true in that
> call. This patch removes the enable parameter from that function.
> 
> Signed-off-by: Brian Masney 
The first thing that strikes me about this, is why do we have an enable only 
function?

I think the intention was probably that we also disable the proximity sensing 
after the
reading was done...  Ideally we'd do this a little more cleverly, perhaps using 
runtime
pm so that if someone is requesting a stream of proximity measurements, we 
won't end up
powering up and down each time.

It's a little 'interesting' as we would want to power this element down even if 
we do
have a continuous stream of reads on the ALS.  As such we may need to roll our 
own
equivalent of runtime pm.

In the first instance, I'd just put a disable after the reading is taken.  This 
will
make a bit of a mockery of the faster sampling frequencies but there we are!


Jonathan
> ---
>  drivers/staging/iio/light/isl29028.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c 
> b/drivers/staging/iio/light/isl29028.c
> index 4e35d00..c8e234d 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -93,15 +93,13 @@ static int isl29028_set_proxim_sampling(struct 
> isl29028_chip *chip,
> sel << ISL29028_CONF_PROX_SLP_SH);
>  }
>  
> -static int isl29028_enable_proximity(struct isl29028_chip *chip, bool enable)
> +static int isl29028_enable_proximity(struct isl29028_chip *chip)
>  {
>   int ret;
> - int val = 0;
>  
> - if (enable)
> - val = ISL29028_CONF_PROX_EN;
>   ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
> -  ISL29028_CONF_PROX_EN_MASK, val);
> +  ISL29028_CONF_PROX_EN_MASK,
> +  ISL29028_CONF_PROX_EN);
>   if (ret < 0)
>   return ret;
>  
> @@ -215,7 +213,7 @@ static int isl29028_proxim_get(struct isl29028_chip 
> *chip, int *prox_data)
>   int ret;
>  
>   if (!chip->enable_prox) {
> - ret = isl29028_enable_proximity(chip, true);
> + ret = isl29028_enable_proximity(chip);
>   if (ret < 0)
>   return ret;
>   chip->enable_prox = true;
> 

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


Re: [PATCH 19/19] staging: iio: isl29028: remove legacy device tree binding

2017-01-08 Thread Jonathan Cameron
Sorry all, appears some replies got stuck in my outbox and have just managed to 
send for some reason!

Jonathan

On 04/12/16 11:55, Jonathan Cameron wrote:
> On 04/12/16 02:19, Brian Masney wrote:
>> The isl29028 staging driver contains a legacy binding of "isl,isl29028"
>> that is marked as legacy and to not use. There are no in tree references
>> to that binding. This patch removes the legacy binding in preparation
>> for moving the driver out of staging. Otherwise, we will have to support
>> this binding indefinitely.
> Leave this be.  Given it exists there almost certainly device trees out there
> using it. Lets not break them just to save on one line of code.
> 
> Supporting legacy bindings isn't exactly costly!
> 
> I'm happy with all the patches I haven't commented on. Just can't apply
> them because they have dependencies on early patches that I have
> raised questions on.
> 
> Another generally nice bit of cleanup.
> 
> Thanks,
> 
> Jonathan
>>
>> Signed-off-by: Brian Masney 
>> Cc: devicet...@vger.kernel.org
>> Cc: Rob Herring 
>> Cc: Mark Rutland 
>> ---
>>  drivers/staging/iio/light/isl29028.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/staging/iio/light/isl29028.c 
>> b/drivers/staging/iio/light/isl29028.c
>> index ae6896f..6be9aa7 100644
>> --- a/drivers/staging/iio/light/isl29028.c
>> +++ b/drivers/staging/iio/light/isl29028.c
>> @@ -611,7 +611,6 @@ static const struct i2c_device_id isl29028_id[] = {
>>  MODULE_DEVICE_TABLE(i2c, isl29028_id);
>>  
>>  static const struct of_device_id isl29028_of_match[] = {
>> -{ .compatible = "isl,isl29028", }, /* for backward compat., don't use */
>>  { .compatible = "isil,isl29028", },
>>  { },
>>  };
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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


Re: [PATCH] Staging: speakup: styel fix, octal file permissions

2017-01-08 Thread Greg KH
On Sun, Jan 08, 2017 at 06:01:31PM +1300, Derek Robson wrote:
> On Sat, Jan 07, 2017 at 08:39:45AM +0100, Greg KH wrote:
> > On Sat, Jan 07, 2017 at 05:11:16PM +1300, Derek Robson wrote:
> > > Changed file permission to octal style,
> > > Found using checkpatch
> > 
> > Typo in your subject line :(
> > 
> > > 
> > > Signed-off-by: Derek Robson 
> > > ---
> > >  drivers/staging/speakup/kobjects.c | 54 
> > > +++---
> > >  1 file changed, 27 insertions(+), 27 deletions(-)
> > > 
> > > diff --git a/drivers/staging/speakup/kobjects.c 
> > > b/drivers/staging/speakup/kobjects.c
> > > index e744aa9730ff..4e7ebc306488 100644
> > > --- a/drivers/staging/speakup/kobjects.c
> > > +++ b/drivers/staging/speakup/kobjects.c
> > > @@ -865,66 +865,66 @@ static struct kobj_attribute version_attribute =
> > >   __ATTR_RO(version);
> > >  
> > >  static struct kobj_attribute delimiters_attribute =
> > > - __ATTR(delimiters, S_IWUSR | S_IRUGO, punc_show, punc_store);
> > > + __ATTR(delimiters, 0644, punc_show, punc_store);
> > >  static struct kobj_attribute ex_num_attribute =
> > > - __ATTR(ex_num, S_IWUSR | S_IRUGO, punc_show, punc_store);
> > > + __ATTR(ex_num, 0644, punc_show, punc_store);
> > 
> > Why not just use __ATTR_RW() for all of these instead?  Be much easier
> > and smaller and is recommended instead of spelling out the mode values
> > everywhere.
> 
> It looks like that won't work in this case the handler is reused and not in 
> the standard format of attrName_show. 
> 
> Or have I not understood the use of __ATTR_RW() ?

Ugh, you are right, nevermind.  Please resend this and say why you can't
use __ATTR_RW() in the changelog text so I don't ask you again when it's
resent :)

thanks,

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


[GIT PULL] Staging/IIO driver fixes for 4.10-rc3

2017-01-08 Thread Greg KH
The following changes since commit 0c744ea4f77d72b3dcebb7a8f2684633ec79be88:

  Linux 4.10-rc2 (2017-01-01 14:31:53 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/ 
tags/staging-4.10-rc3

for you to fetch changes up to 01d0f715869161dc70e2bf66fcdf6533a6a782cd:

  MAINTAINERS: add greybus subsystem mailing list (2017-01-07 17:05:42 +0100)


Staging/IIO fixes for 4.10-rc3

Here are some staging and IIO driver fixes for 4.10-rc3.

Most of these are minor IIO fixes of reported issues, along with one
network driver fix to resolve an issue.  And a MAINTAINERS update with a
new mailing list.  All of these, except the MAINTAINERS file update,
have been in linux-next with no reported issues (the MAINTAINERS patch
happened on Friday...)

Signed-off-by: Greg Kroah-Hartman 


Akinobu Mita (1):
  iio: max44000: correct value in illuminance_integration_time_available

Florian Fainelli (1):
  staging: octeon: Call SET_NETDEV_DEV()

Geert Uytterhoeven (1):
  iio: adc: TI_AM335X_ADC should depend on HAS_DMA

Greg Kroah-Hartman (2):
  Merge tag 'iio-fixes-for-4.10a' of git://git.kernel.org/.../jic23/iio 
into staging-linus
  MAINTAINERS: add greybus subsystem mailing list

Linus Walleij (1):
  iio: accel: st_accel: fix LIS3LV02 reading and scaling

Lorenzo Bianconi (1):
  iio: common: st_sensors: fix channel data parsing

Marcin Niestroj (1):
  iio: bmi160: Fix time needed to sleep after command execution

William Breathitt Gray (3):
  iio: 104-quad-8: Fix index control configuration
  iio: 104-quad-8: Fix off-by-one errors when addressing IOR
  iio: 104-quad-8: Fix active level mismatch for the preset enable option

 MAINTAINERS   |  1 +
 drivers/iio/accel/st_accel_core.c | 12 +--
 drivers/iio/adc/Kconfig   |  2 +-
 drivers/iio/common/st_sensors/st_sensors_buffer.c |  4 +++-
 drivers/iio/common/st_sensors/st_sensors_core.c   | 13 +++-
 drivers/iio/counter/104-quad-8.c  | 13 +++-
 drivers/iio/imu/bmi160/bmi160_core.c  | 25 ++-
 drivers/iio/light/max44000.c  |  2 +-
 drivers/staging/octeon/ethernet.c |  2 ++
 include/linux/iio/common/st_sensors.h | 12 +++
 10 files changed, 56 insertions(+), 30 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: olpc_dcon: olpc_dcon_xo_1_5: Remove multiple blank lines.

2017-01-08 Thread Emmanuil Chatzipetru
This issue is caught by checkpatch.pl and is related to the following
warning:
- CHECK: Please don't use multiple blank lines

Signed-off-by: Emmanuil Chatzipetru 
---
 drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c 
b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
index e7a395793b35..75c3c2fe9560 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
@@ -107,7 +107,6 @@ static void set_i2c_line(int sda, int scl)
outb(tmp, 0x3c5);
 }
 
-
 static void dcon_wiggle_xo_1_5(void)
 {
int x;
-- 
2.1.4

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


[PATCH 3/4] staging: olpc_dcon: olpc_dcon: Fix spaces between operator and variables.

2017-01-08 Thread Emmanuil Chatzipetru
This issue is caught by checkpatch.pl and is related to the following
warning:
- CHECK: spaces preferred around that '/' (ctx:VxV)

Signed-off-by: Emmanuil Chatzipetru 
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index dcf89326580c..684815c98789 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -336,7 +336,7 @@ static void dcon_source_switch(struct work_struct *work)
pdata->set_dconload(0);
dcon->load_time = ktime_get();
 
-   wait_event_timeout(dcon->waitq, dcon->switched, HZ/2);
+   wait_event_timeout(dcon->waitq, dcon->switched, HZ / 2);
 
if (!dcon->switched) {
pr_err("Timeout entering DCON mode; expect a screen 
glitch.\n");
-- 
2.1.4

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


[PATCH 2/4] staging: olpc_dcon: olpc_dcon_xo_1_5: Remove redundant return statement.

2017-01-08 Thread Emmanuil Chatzipetru
dcon_was_irq(); should return a boolean value if PMIO_Rx50[6] is either
set or unset, which is evaluated in the first return statement. Therefore,
the following return statement is redundant and thus, removed.

Signed-off-by: Emmanuil Chatzipetru 
---
 drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c 
b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
index 1e23ef15b263..e7a395793b35 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
@@ -53,9 +53,8 @@ static int dcon_was_irq(void)
 
/* irq status will appear in PMIO_Rx50[6] on gpio12 */
tmp = inb(VX855_GPI_STATUS_CHG);
-   return !!(tmp & BIT_GPIO12);
 
-   return 0;
+   return !!(tmp & BIT_GPIO12);
 }
 
 static int dcon_init_xo_1_5(struct dcon_priv *dcon)
-- 
2.1.4

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


[PATCH 1/4] staging: olpc_dcon: olpc_dcon: Fix open parenthesis alignment.

2017-01-08 Thread Emmanuil Chatzipetru
This issue is caught by checkpatch.pl and is related to the following
warning:
- CHECK: Alignment should match open parenthesis

Signed-off-by: Emmanuil Chatzipetru 
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index f45b2ef05f48..dcf89326580c 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -81,7 +81,7 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init)
 
if (ver < 0xdc02) {
dev_err(&dcon->client->dev,
-   "DCON v1 is unsupported, giving up..\n");
+   "DCON v1 is unsupported, giving up..\n");
rc = -ENODEV;
goto err;
}
@@ -90,7 +90,7 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init)
dcon_write(dcon, 0x3a, 0xc040);
dcon_write(dcon, DCON_REG_MEM_OPT_A, 0x);  /* clear option bits */
dcon_write(dcon, DCON_REG_MEM_OPT_A,
-   MEM_DLL_CLOCK_DELAY | MEM_POWER_DOWN);
+  MEM_DLL_CLOCK_DELAY | MEM_POWER_DOWN);
dcon_write(dcon, DCON_REG_MEM_OPT_B, MEM_SOFT_RESET);
 
/* Colour swizzle, AA, no passthrough, backlight */
@@ -261,14 +261,14 @@ static bool dcon_blank_fb(struct dcon_priv *dcon, bool 
blank)
 
dcon->ignore_fb_events = true;
err = fb_blank(dcon->fbinfo,
-   blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
+  blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK);
dcon->ignore_fb_events = false;
unlock_fb_info(dcon->fbinfo);
console_unlock();
 
if (err) {
dev_err(&dcon->client->dev, "couldn't %sblank framebuffer\n",
-   blank ? "" : "un");
+   blank ? "" : "un");
return false;
}
return true;
@@ -293,7 +293,7 @@ static void dcon_source_switch(struct work_struct *work)
pr_info("dcon_source_switch to CPU\n");
/* Enable the scanline interrupt bit */
if (dcon_write(dcon, DCON_REG_MODE,
-   dcon->disp_mode | MODE_SCAN_INT))
+  dcon->disp_mode | MODE_SCAN_INT))
pr_err("couldn't enable scanline interrupt!\n");
else
/* Wait up to one second for the scanline interrupt */
@@ -646,7 +646,7 @@ static int dcon_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
dcon, &dcon_bl_ops, &dcon_bl_props);
if (IS_ERR(dcon->bl_dev)) {
dev_err(&client->dev, "cannot register backlight dev (%ld)\n",
-   PTR_ERR(dcon->bl_dev));
+   PTR_ERR(dcon->bl_dev));
dcon->bl_dev = NULL;
}
 
-- 
2.1.4

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


[PATCH 2/2] staging: greybus: loopback: fix oops on rmmod gb_loopback

2017-01-08 Thread Bryan O'Donoghue
Doing an rmmod gb_loopback will cause an oops with the following backtrace.

Call Trace:
 debugfs_remove+0xaf/0x180
 gb_loopback_disconnect+0x36/0x160 [gb_loopback]
 greybus_remove+0x87/0x1a0 [greybus]
 device_release_driver_internal+0x14a/0x200
 driver_detach+0x39/0x60
 bus_remove_driver+0x47/0xa0
 driver_unregister+0x27/0x50
 greybus_deregister_driver+0xd/0x10 [greybus]
 loopback_exit+0x1c/0x36 [gb_loopback]
 SyS_delete_module+0x170/0x1b0
 entry_SYSCALL_64_fastpath+0x13/0x93

This happens because gb_dev.root is removed prior to
greybus_deregister_driver which itself will trigger gb_loopback_disconnect
to run - leading to the parent of gb->file being NULL.

Typically up to this point when tearing down greybus modules we have
removed gb_es2 prior to removing gb_loopback. In this case gb_es2 will run
subordinate greybus->disconnect() routines. A subsequent rmmod of
gb_loopback then will not re-run gb_loopback_disconnect().

On project Ara the second module removal flow was the only practiced flow
hence it's only now in gbsim where we have more freedom to rmmod that this
bug is apparent. The fix itself is pretty straight-forward.

Signed-off-by: Bryan O'Donoghue 
---
 drivers/staging/greybus/loopback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/loopback.c 
b/drivers/staging/greybus/loopback.c
index 88d4f5c..8f3eb33 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -1260,9 +1260,9 @@ module_init(loopback_init);
 
 static void __exit loopback_exit(void)
 {
-   debugfs_remove_recursive(gb_dev.root);
greybus_deregister(&gb_loopback_driver);
class_unregister(&loopback_class);
+   debugfs_remove_recursive(gb_dev.root);
ida_destroy(&loopback_ida);
 }
 module_exit(loopback_exit);
-- 
2.7.4

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


[PATCH 1/2] staging: greybus: loopback: fix gb_pm_runtime_get_sync error handling

2017-01-08 Thread Bryan O'Donoghue
commit e854ff58ed70 ("greybus: loopback: add runtime pm support")
introduces pm runtime support to the loopback code. If a
gb_pm_runtime_get_sync() fails, currently we immediately return from the
loopback thread.

Alexandre reports that later on, subsequent to the afore mentioned failure,
doing an rmmod will trigger a kthread_stop() which will will generate a
fault. The fault results from dereferencing gb->task in
gb_loopback_disconnect().

One way to fix that is to have the loopback thread do_exit() instead of
simply returning on gb_pm_runtime_get_sync() failure - however this will
leave dangling sysfs entries with no loopback thread to take action based
on the sysfs inputs.

This patch fixes the fault by ignoring the gb_pm_runtime_get_sync() result
code, this will allow only gb_loopback_disconnect() to terminate the
loopback thread. Fix validated in gbsim.

Next steps on this driver entail changing the relationship between /sysfs
and the loopback thread - probably making the loopback thread dynamically
started/stopped - as opposed to the pre-allocation model currently used
but, those changes are for a future series to address.

Reported-by: Alexandre Bailon 
Signed-off-by: Bryan O'Donoghue 
---
 drivers/staging/greybus/loopback.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/loopback.c 
b/drivers/staging/greybus/loopback.c
index 83f3b9f..88d4f5c 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -886,9 +886,7 @@ static int gb_loopback_fn(void *data)
gb_pm_runtime_put_autosuspend(bundle);
wait_event_interruptible(gb->wq, gb->type ||
 kthread_should_stop());
-   ret = gb_pm_runtime_get_sync(bundle);
-   if (ret)
-   return ret;
+   gb_pm_runtime_get_sync(bundle);
}
 
if (kthread_should_stop())
-- 
2.7.4

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


[PATCH 0/2] staging: greybus: loopback: Fix two oops paths in gb_loopback

2017-01-08 Thread Bryan O'Donoghue
Alexandre reported a bug in the loopback rmmod path subsequent to a failure
in gb_pm_runtime_get_sync - something that can happen when you are
developing device-side firmware easily. Doing some cursory rmmod testing on
gb_loopback then showed a second (and long standing) error pertaining to
removal of gb_dev.root.

This series fixes both issues.

Bryan O'Donoghue (2):
  staging: greybus: loopback: fix gb_pm_runtime_get_sync error handling
  staging: greybus: loopback: fix oops on rmmod gb_loopback

 drivers/staging/greybus/loopback.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

-- 
2.7.4

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


[PATCH 6/9] staging: vc04_services: Improve readability of kthread names

2017-01-08 Thread Stefan Wahren
This patch tries to make the kernel thread names of vchiq a little
bit more self explaining and look closer to the existing ones:

slot handler: VCHIQ-%d -> vchiq-slot/%d
recycle thread: VCHIQr-%d -> vchiq-recy/%d
sync thread: VCHIQs-%d -> vhciq-sync/%d
keep-alive thread: VCHIQka-%d -> vchiq-keep/%d

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |4 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 46fc06d..dd9590b 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2824,10 +2824,10 @@ void vchiq_platform_conn_state_changed(VCHIQ_STATE_T 
*state,
if (state->conn_state == VCHIQ_CONNSTATE_CONNECTED) {
write_lock_bh(&arm_state->susp_res_lock);
if (!arm_state->first_connect) {
-   char threadname[10];
+   char threadname[16];
arm_state->first_connect = 1;
write_unlock_bh(&arm_state->susp_res_lock);
-   snprintf(threadname, sizeof(threadname), "VCHIQka-%d",
+   snprintf(threadname, sizeof(threadname), 
"vchiq-keep/%d",
state->id);
arm_state->ka_thread = kthread_create(
&vchiq_keepalive_thread_func,
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index dfee63e..f4eab62 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -2315,7 +2315,7 @@ static const char *msg_type_str(unsigned int msg_type)
VCHIQ_SHARED_STATE_T *local;
VCHIQ_SHARED_STATE_T *remote;
VCHIQ_STATUS_T status;
-   char threadname[10];
+   char threadname[16];
static int id;
int i;
 
@@ -2483,7 +2483,7 @@ static const char *msg_type_str(unsigned int msg_type)
/*
bring up slot handler thread
 */
-   snprintf(threadname, sizeof(threadname), "VCHIQ-%d", state->id);
+   snprintf(threadname, sizeof(threadname), "vchiq-slot/%d", state->id);
state->slot_handler_thread = kthread_create(&slot_handler_func,
(void *)state,
threadname);
@@ -2497,7 +2497,7 @@ static const char *msg_type_str(unsigned int msg_type)
set_user_nice(state->slot_handler_thread, -19);
wake_up_process(state->slot_handler_thread);
 
-   snprintf(threadname, sizeof(threadname), "VCHIQr-%d", state->id);
+   snprintf(threadname, sizeof(threadname), "vchiq-recy/%d", state->id);
state->recycle_thread = kthread_create(&recycle_func,
(void *)state,
threadname);
@@ -2510,7 +2510,7 @@ static const char *msg_type_str(unsigned int msg_type)
set_user_nice(state->recycle_thread, -19);
wake_up_process(state->recycle_thread);
 
-   snprintf(threadname, sizeof(threadname), "VCHIQs-%d", state->id);
+   snprintf(threadname, sizeof(threadname), "vchiq-sync/%d", state->id);
state->sync_thread = kthread_create(&sync_func,
(void *)state,
threadname);
-- 
1.7.9.5

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


[PATCH 1/9] staging: vchiq_arm: remove vchiq_platform_check_resume

2017-01-08 Thread Stefan Wahren
This function is never used, so we could remove it.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |   46 
 1 file changed, 46 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 0d98789..758a3a8 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2372,52 +2372,6 @@ struct vchiq_io_copy_callback_context {
return resume;
 }
 
-void
-vchiq_platform_check_resume(VCHIQ_STATE_T *state)
-{
-   VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state);
-   int res = 0;
-
-   if (!arm_state)
-   goto out;
-
-   vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
-
-   write_lock_bh(&arm_state->susp_res_lock);
-   if (arm_state->wake_address == 0) {
-   vchiq_log_info(vchiq_susp_log_level,
-   "%s: already awake", __func__);
-   goto unlock;
-   }
-   if (arm_state->vc_resume_state == VC_RESUME_IN_PROGRESS) {
-   vchiq_log_info(vchiq_susp_log_level,
-   "%s: already resuming", __func__);
-   goto unlock;
-   }
-
-   if (arm_state->vc_resume_state == VC_RESUME_REQUESTED) {
-   set_resume_state(arm_state, VC_RESUME_IN_PROGRESS);
-   res = 1;
-   } else
-   vchiq_log_trace(vchiq_susp_log_level,
-   "%s: not resuming (resume state %s)", __func__,
-   resume_state_names[arm_state->vc_resume_state +
-   VC_RESUME_NUM_OFFSET]);
-
-unlock:
-   write_unlock_bh(&arm_state->susp_res_lock);
-
-   if (res)
-   vchiq_platform_resume(state);
-
-out:
-   vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__);
-   return;
-
-}
-
-
-
 VCHIQ_STATUS_T
 vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service,
enum USE_TYPE_E use_type)
-- 
1.7.9.5

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


[PATCH 2/9] staging: vchiq_core: remove unused variable type

2017-01-08 Thread Stefan Wahren
This variable is assigned a value, but never used. So remove it.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 32b00f8..802f114 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1513,12 +1513,10 @@ static const char *msg_type_str(unsigned int msg_type)
 {
VCHIQ_SERVICE_T *service = NULL;
int msgid, size;
-   int type;
unsigned int localport, remoteport;
 
msgid = header->msgid;
size = header->size;
-   type = VCHIQ_MSG_TYPE(msgid);
localport = VCHIQ_MSG_DSTPORT(msgid);
remoteport = VCHIQ_MSG_SRCPORT(msgid);
if (size >= sizeof(struct vchiq_open_payload)) {
-- 
1.7.9.5

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


[PATCH 4/9] staging: vchiq_core: make local spinlock static

2017-01-08 Thread Stefan Wahren
The quota_spinlock is only local. So make it static.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index e788561..623163a 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -90,7 +90,7 @@ enum
 
 static DEFINE_SPINLOCK(service_spinlock);
 DEFINE_SPINLOCK(bulk_waiter_spinlock);
-DEFINE_SPINLOCK(quota_spinlock);
+static DEFINE_SPINLOCK(quota_spinlock);
 
 VCHIQ_STATE_T *vchiq_states[VCHIQ_MAX_STATES];
 static unsigned int handle_seq;
-- 
1.7.9.5

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


[PATCH 7/9] staging: vc04_services: Drop vchiq_2835.h

2017-01-08 Thread Stefan Wahren
There is no need for a vchiq_2835.h with its 2 local defines.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_2835.h |   42 
 .../interface/vchiq_arm/vchiq_2835_arm.c   |5 ++-
 2 files changed, 4 insertions(+), 43 deletions(-)
 delete mode 100644 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835.h

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835.h 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835.h
deleted file mode 100644
index 7ea5c64..000
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) 2010-2012 Broadcom. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions, and the following disclaimer,
- *without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. The names of the above-listed copyright holders may not be used
- *to endorse or promote products derived from this software without
- *specific prior written permission.
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2, as published by the Free
- * Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef VCHIQ_2835_H
-#define VCHIQ_2835_H
-
-#include "vchiq_pagelist.h"
-
-#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0
-#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX  1
-
-#endif /* VCHIQ_2835_H */
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 2b500d8..1615c13 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -48,12 +48,15 @@
 #define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32)
 
 #include "vchiq_arm.h"
-#include "vchiq_2835.h"
 #include "vchiq_connected.h"
 #include "vchiq_killable.h"
+#include "vchiq_pagelist.h"
 
 #define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2)
 
+#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0
+#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX  1
+
 #define BELL0  0x00
 #define BELL2  0x08
 
-- 
1.7.9.5

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


[PATCH 0/9] staging: vc04_services: Clean up vchiq driver

2017-01-08 Thread Stefan Wahren
This is a loose bunch of clean up patches for the bcm2835 vchiq driver.

Stefan Wahren (9):
  staging: staging: vchiq_arm: remove vchiq_platform_check_resume
  staging: vchiq_core: remove unused variable type
  staging: vc04_services: make local functions static
  staging: vchiq_core: make local spinlock static
  staging: vc04_services: Use preferred kernel types
  staging: vc04_services: Improve readability of kthread names
  staging: vc04_services: Drop vchiq_2835.h
  staging: vc04_services: Fix indentation
  staging: vc04_services: Fix space issues

 .../vc04_services/interface/vchiq_arm/vchiq_2835.h |   42 
 .../interface/vchiq_arm/vchiq_2835_arm.c   |   49 +++---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |   68 
 .../vc04_services/interface/vchiq_arm/vchiq_arm.h  |2 +-
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |   50 +++---
 .../interface/vchiq_arm/vchiq_kern_lib.c   |   14 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_shim.c |   24 +++
 7 files changed, 82 insertions(+), 167 deletions(-)
 delete mode 100644 
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835.h

-- 
1.7.9.5

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


[PATCH 3/9] staging: vc04_services: make local functions static

2017-01-08 Thread Stefan Wahren
The functions vchiq_dump_shared_state() and vchiq_is_connected() are only
used locally. So make them static.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |2 +-
 .../interface/vchiq_arm/vchiq_kern_lib.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 802f114..e788561 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -3624,7 +3624,7 @@ static const char *msg_type_str(unsigned int msg_type)
return status;
 }
 
-void
+static void
 vchiq_dump_shared_state(void *dump_context, VCHIQ_STATE_T *state,
VCHIQ_SHARED_STATE_T *shared, const char *label)
 {
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
index e93922a..d21b67c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
@@ -172,7 +172,7 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance)
 *
 ***/
 
-int vchiq_is_connected(VCHIQ_INSTANCE_T instance)
+static int vchiq_is_connected(VCHIQ_INSTANCE_T instance)
 {
return instance->connected;
 }
-- 
1.7.9.5

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


[PATCH 9/9] staging: vc04_services: Fix space issues

2017-01-08 Thread Stefan Wahren
This fixes the space coding styles issues complained by checkpatch.

Signed-off-by: Stefan Wahren 
---
 .../interface/vchiq_arm/vchiq_2835_arm.c   |   14 +++---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |4 ++--
 .../interface/vchiq_arm/vchiq_kern_lib.c   |6 +++---
 .../vc04_services/interface/vchiq_arm/vchiq_shim.c |6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 971c26c..e6241fb 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -203,11 +203,11 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 {
VCHIQ_STATUS_T status = VCHIQ_SUCCESS;
state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), 
GFP_KERNEL);
-   ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 1;
-   status = vchiq_arm_init_state(state, 
&((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state);
-   if(status != VCHIQ_SUCCESS)
+   ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 1;
+   status = vchiq_arm_init_state(state, &((VCHIQ_2835_ARM_STATE_T 
*)state->platform_state)->arm_state);
+   if (status != VCHIQ_SUCCESS)
{
-   ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 0;
+   ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 0;
}
return status;
 }
@@ -215,11 +215,11 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 VCHIQ_ARM_STATE_T*
 vchiq_platform_get_arm_state(VCHIQ_STATE_T *state)
 {
-   if(!((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited)
+   if (!((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited)
{
BUG();
}
-   return &((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state;
+   return &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state;
 }
 
 void
@@ -315,7 +315,7 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 }
 
 int
-vchiq_platform_videocore_wanted(VCHIQ_STATE_T* state)
+vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state)
 {
return 1; // autosuspend not supported - videocore always wanted
 }
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index bfa47d0..0525211 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1996,7 +1996,7 @@ struct vchiq_io_copy_callback_context {
&arm_state->blocked_blocker, timeout_val)
<= 0) {
vchiq_log_error(vchiq_susp_log_level, "%s wait for "
-   "previously blocked clients failed" , __func__);
+   "previously blocked clients failed", __func__);
status = VCHIQ_ERROR;
write_lock_bh(&arm_state->susp_res_lock);
goto out;
@@ -2012,7 +2012,7 @@ struct vchiq_io_copy_callback_context {
if (resume_count > 1) {
status = VCHIQ_ERROR;
vchiq_log_error(vchiq_susp_log_level, "%s waited too "
-   "many times for resume" , __func__);
+   "many times for resume", __func__);
goto out;
}
write_unlock_bh(&arm_state->susp_res_lock);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
index 53c975c..4317c06 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
@@ -81,17 +81,17 @@ VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T 
*instance_out)
 
/* VideoCore may not be ready due to boot up timing.
   It may never be ready if kernel and firmware are mismatched, so 
don't block forever. */
-   for (i=0; i0) {
+   } else if (i > 0) {
vchiq_log_warning(vchiq_core_log_level,
"%s: videocore initialized after %d retries\n", 
__func__, i);
}
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
index 388255f..a6b2ae0 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c
@@ -739,16 +739,16 @@ int32_t vchi_service_set_option(const 
VCHI_SERVICE_HANDLE_T handle,
 }
 EXPORT_SYMBOL(vchi_se

[PATCH 8/9] staging: vc04_services: Fix indentation

2017-01-08 Thread Stefan Wahren
This should fix the indentation issues found by checkpatch.

Signed-off-by: Stefan Wahren 
---
 .../interface/vchiq_arm/vchiq_2835_arm.c   |   42 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |4 +-
 .../vc04_services/interface/vchiq_arm/vchiq_arm.h  |2 +-
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |   24 +--
 .../interface/vchiq_arm/vchiq_kern_lib.c   |8 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_shim.c |   22 +-
 6 files changed, 52 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 1615c13..971c26c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -61,8 +61,8 @@
 #define BELL2  0x08
 
 typedef struct vchiq_2835_state_struct {
-   int inited;
-   VCHIQ_ARM_STATE_T arm_state;
+   int inited;
+   VCHIQ_ARM_STATE_T arm_state;
 } VCHIQ_2835_ARM_STATE_T;
 
 struct vchiq_pagelist_info {
@@ -195,31 +195,31 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 
vchiq_call_connected_callbacks();
 
-   return 0;
+   return 0;
 }
 
 VCHIQ_STATUS_T
 vchiq_platform_init_state(VCHIQ_STATE_T *state)
 {
-   VCHIQ_STATUS_T status = VCHIQ_SUCCESS;
-   state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), GFP_KERNEL);
-   ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 1;
-   status = vchiq_arm_init_state(state, 
&((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state);
-   if(status != VCHIQ_SUCCESS)
-   {
-  ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 0;
-   }
-   return status;
+   VCHIQ_STATUS_T status = VCHIQ_SUCCESS;
+   state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), 
GFP_KERNEL);
+   ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 1;
+   status = vchiq_arm_init_state(state, 
&((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state);
+   if(status != VCHIQ_SUCCESS)
+   {
+   ((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited = 0;
+   }
+   return status;
 }
 
 VCHIQ_ARM_STATE_T*
 vchiq_platform_get_arm_state(VCHIQ_STATE_T *state)
 {
-   if(!((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited)
-   {
-  BUG();
-   }
-   return &((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state;
+   if(!((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->inited)
+   {
+   BUG();
+   }
+   return &((VCHIQ_2835_ARM_STATE_T*)state->platform_state)->arm_state;
 }
 
 void
@@ -295,13 +295,13 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 VCHIQ_STATUS_T
 vchiq_platform_suspend(VCHIQ_STATE_T *state)
 {
-   return VCHIQ_ERROR;
+   return VCHIQ_ERROR;
 }
 
 VCHIQ_STATUS_T
 vchiq_platform_resume(VCHIQ_STATE_T *state)
 {
-   return VCHIQ_SUCCESS;
+   return VCHIQ_SUCCESS;
 }
 
 void
@@ -317,13 +317,13 @@ int vchiq_platform_init(struct platform_device *pdev, 
VCHIQ_STATE_T *state)
 int
 vchiq_platform_videocore_wanted(VCHIQ_STATE_T* state)
 {
-   return 1; // autosuspend not supported - videocore always wanted
+   return 1; // autosuspend not supported - videocore always wanted
 }
 
 int
 vchiq_platform_use_suspend_timer(void)
 {
-   return 0;
+   return 0;
 }
 void
 vchiq_dump_platform_use_state(VCHIQ_STATE_T *state)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index dd9590b..bfa47d0 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -665,7 +665,7 @@ struct vchiq_io_copy_callback_context {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the
-   wait in vchiq_close_service has been interrupted. */
+  wait in vchiq_close_service has been interrupted. */
if (!user_service->close_pending) {
status = vchiq_close_service(service->handle);
if (status != VCHIQ_SUCCESS)
@@ -691,7 +691,7 @@ struct vchiq_io_copy_callback_context {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the
-   wait in vchiq_close_service has been interrupted. */
+  wait in vchiq_close_service has been interrupted. */
if (!user_service->close_pending) {
status = vchiq_re

[PATCH 5/9] staging: vc04_services: Use preferred kernel types

2017-01-08 Thread Stefan Wahren
This patch fixes issues reported by checkpatch.pl about preferred
kernel types.

Signed-off-by: Stefan Wahren 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |   10 +-
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |   12 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 758a3a8..46fc06d 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -194,7 +194,7 @@ struct vchiq_instance_struct {
(VCHIQ_IOC_MAX + 1));
 
 static void
-dump_phys_mem(void *virt_addr, uint32_t num_bytes);
+dump_phys_mem(void *virt_addr, u32 num_bytes);
 
 /
 *
@@ -1535,10 +1535,10 @@ struct vchiq_io_copy_callback_context {
 ***/
 
 static void
-dump_phys_mem(void *virt_addr, uint32_t num_bytes)
+dump_phys_mem(void *virt_addr, u32 num_bytes)
 {
intrc;
-   uint8_t   *end_virt_addr = virt_addr + num_bytes;
+   u8*end_virt_addr = virt_addr + num_bytes;
intnum_pages;
intoffset;
intend_offset;
@@ -1546,7 +1546,7 @@ struct vchiq_io_copy_callback_context {
intprev_idx;
struct page   *page;
struct page  **pages;
-   uint8_t   *kmapped_virt_ptr;
+   u8*kmapped_virt_ptr;
 
/* Align virtAddr and endVirtAddr to 16 byte boundaries. */
 
@@ -1602,7 +1602,7 @@ struct vchiq_io_copy_callback_context {
 
if (vchiq_arm_log_level >= VCHIQ_LOG_TRACE)
vchiq_log_dump_mem("ph",
-   (uint32_t)(unsigned long)&kmapped_virt_ptr[
+   (u32)(unsigned long)&kmapped_virt_ptr[
page_offset],
&kmapped_virt_ptr[page_offset], 16);
 
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 623163a..dfee63e 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -517,7 +517,7 @@ static const char *msg_type_str(unsigned int msg_type)
 inline void
 request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int poll_type)
 {
-   uint32_t value;
+   u32 value;
 
if (service) {
do {
@@ -1286,14 +1286,14 @@ static const char *msg_type_str(unsigned int msg_type)
int group, i;
 
for (group = 0; group < BITSET_SIZE(state->unused_service); group++) {
-   uint32_t flags;
+   u32 flags;
flags = atomic_xchg(&state->poll_services[group], 0);
for (i = 0; flags; i++) {
if (flags & (1 << i)) {
VCHIQ_SERVICE_T *service =
find_service_by_port(state,
(group<<5) + i);
-   uint32_t service_flags;
+   u32 service_flags;
flags &= ~(1 << i);
if (!service)
continue;
@@ -3879,10 +3879,10 @@ VCHIQ_STATUS_T 
vchiq_send_remote_use_active(VCHIQ_STATE_T *state)
return status;
 }
 
-void vchiq_log_dump_mem(const char *label, uint32_t addr, const void *void_mem,
+void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem,
size_t num_bytes)
 {
-   const uint8_t  *mem = (const uint8_t *)void_mem;
+   const u8  *mem = (const u8 *)void_mem;
size_t  offset;
charline_buf[100];
char   *s;
@@ -3899,7 +3899,7 @@ void vchiq_log_dump_mem(const char *label, uint32_t addr, 
const void *void_mem,
 
for (offset = 0; offset < 16; offset++) {
if (offset < num_bytes) {
-   uint8_t ch = mem[offset];
+   u8 ch = mem[offset];
 
if ((ch < ' ') || (ch > '~'))
ch = '.';
-- 
1.7.9.5

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


[PATCH 2/2] staging/media/s5p-cec/exynos_hdmi_cecctrl.c Fixed blank line before closing brace '}'

2017-01-08 Thread Scott Matheina
Fixed checkpatch check blank line before closing brace '}'

Signed-off-by: Scott Matheina 
---
 drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c 
b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
index f2b24a4..1edf667 100644
--- a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
+++ b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
@@ -87,7 +87,6 @@ void s5p_cec_mask_tx_interrupts(struct s5p_cec_dev *cec)
reg |= S5P_CEC_IRQ_TX_DONE;
reg |= S5P_CEC_IRQ_TX_ERROR;
writeb(reg, cec->reg + S5P_CEC_IRQ_MASK);
-
 }
 
 void s5p_cec_unmask_tx_interrupts(struct s5p_cec_dev *cec)
-- 
2.7.4

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


[PATCH 1/2] staging:media:s5p-cec:exynos_hdmi_cecctrl.c Fixed Alignment should match open parenthesis

2017-01-08 Thread Scott Matheina
Fixed Checkpatch check "Alignment should match open parenthesis"

Signed-off-by: Scott Matheina 
---
 drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c 
b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
index ce95e0f..f2b24a4 100644
--- a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
+++ b/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c
@@ -186,13 +186,13 @@ u32 s5p_cec_get_status(struct s5p_cec_dev *cec)
 void s5p_clr_pending_tx(struct s5p_cec_dev *cec)
 {
writeb(S5P_CEC_IRQ_TX_DONE | S5P_CEC_IRQ_TX_ERROR,
-   cec->reg + S5P_CEC_IRQ_CLEAR);
+  cec->reg + S5P_CEC_IRQ_CLEAR);
 }
 
 void s5p_clr_pending_rx(struct s5p_cec_dev *cec)
 {
writeb(S5P_CEC_IRQ_RX_DONE | S5P_CEC_IRQ_RX_ERROR,
-   cec->reg + S5P_CEC_IRQ_CLEAR);
+  cec->reg + S5P_CEC_IRQ_CLEAR);
 }
 
 void s5p_cec_get_rx_buf(struct s5p_cec_dev *cec, u32 size, u8 *buffer)
-- 
2.7.4

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


[PATCH] Staging: speakup: style fix, octal file permissions

2017-01-08 Thread Derek Robson
Changed file permission to octal style,
Can't use __ATTR_RW() as the handler is in standard format.
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/speakup/kobjects.c | 54 +++---
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/speakup/kobjects.c 
b/drivers/staging/speakup/kobjects.c
index e744aa9730ff..4e7ebc306488 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -865,66 +865,66 @@ static struct kobj_attribute version_attribute =
__ATTR_RO(version);
 
 static struct kobj_attribute delimiters_attribute =
-   __ATTR(delimiters, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(delimiters, 0644, punc_show, punc_store);
 static struct kobj_attribute ex_num_attribute =
-   __ATTR(ex_num, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(ex_num, 0644, punc_show, punc_store);
 static struct kobj_attribute punc_all_attribute =
-   __ATTR(punc_all, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(punc_all, 0644, punc_show, punc_store);
 static struct kobj_attribute punc_most_attribute =
-   __ATTR(punc_most, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(punc_most, 0644, punc_show, punc_store);
 static struct kobj_attribute punc_some_attribute =
-   __ATTR(punc_some, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(punc_some, 0644, punc_show, punc_store);
 static struct kobj_attribute repeats_attribute =
-   __ATTR(repeats, S_IWUSR | S_IRUGO, punc_show, punc_store);
+   __ATTR(repeats, 0644, punc_show, punc_store);
 
 static struct kobj_attribute attrib_bleep_attribute =
-   __ATTR(attrib_bleep, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(attrib_bleep, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute bell_pos_attribute =
-   __ATTR(bell_pos, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(bell_pos, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute bleep_time_attribute =
-   __ATTR(bleep_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(bleep_time, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute bleeps_attribute =
-   __ATTR(bleeps, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(bleeps, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute cursor_time_attribute =
-   __ATTR(cursor_time, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(cursor_time, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute key_echo_attribute =
-   __ATTR(key_echo, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(key_echo, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute no_interrupt_attribute =
-   __ATTR(no_interrupt, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(no_interrupt, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute punc_level_attribute =
-   __ATTR(punc_level, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(punc_level, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute reading_punc_attribute =
-   __ATTR(reading_punc, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(reading_punc, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute say_control_attribute =
-   __ATTR(say_control, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(say_control, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute say_word_ctl_attribute =
-   __ATTR(say_word_ctl, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(say_word_ctl, 0644, spk_var_show, spk_var_store);
 static struct kobj_attribute spell_delay_attribute =
-   __ATTR(spell_delay, S_IWUSR | S_IRUGO, spk_var_show, spk_var_store);
+   __ATTR(spell_delay, 0644, spk_var_show, spk_var_store);
 
 /*
  * These attributes are i18n related.
  */
 static struct kobj_attribute announcements_attribute =
-   __ATTR(announcements, S_IWUSR | S_IRUGO, message_show, message_store);
+   __ATTR(announcements, 0644, message_show, message_store);
 static struct kobj_attribute characters_attribute =
-   __ATTR(characters, S_IWUSR | S_IRUGO, chars_chartab_show,
+   __ATTR(characters, 0644, chars_chartab_show,
   chars_chartab_store);
 static struct kobj_attribute chartab_attribute =
-   __ATTR(chartab, S_IWUSR | S_IRUGO, chars_chartab_show,
+   __ATTR(chartab, 0644, chars_chartab_show,
   chars_chartab_store);
 static struct kobj_attribute ctl_keys_attribute =
-   __ATTR(ctl_keys, S_IWUSR | S_IRUGO, message_show, message_store);
+   __ATTR(ctl_keys, 0644, message_show, message_store);
 static struct kobj_attribute colors_attribute =
-   __ATTR(colors, S_IWUSR | S_IRUGO, message_show, message_store);
+   __ATTR(colors, 0644, message_show, message_store);
 static struc

Re: [PATCH] Staging: lustre: lustre: lmv: Compress return logic into one line.

2017-01-08 Thread Dilger, Andreas
On Jan 4, 2017, at 22:14, Gustavo A. R. Silva  
wrote:
> 
> Simplify return logic to avoid unnecessary variable assignments.
> These issues were detected using Coccinelle and the following semantic patch:
> 
> @@
> local idexpression ret;
> expression e;
> @@
> 
> -ret =
> +return
> e;
> -return ret;
> 
> Signed-off-by: Gustavo A. R. Silva 

Reviewed-by: Andreas Dilger 

> ---
> drivers/staging/lustre/lustre/lmv/lmv_obd.c | 58 -
> 1 file changed, 16 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
> b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index f124f6c..76a0306 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -771,7 +771,6 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
> unsigned int cmd, int len,
>struct lustre_kernelcomm *lk,
>void __user *uarg)
> {
> - int rc = 0;
>   __u32 i;
> 
>   /* unregister request (call from llapi_hsm_copytool_fini) */
> @@ -791,9 +790,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, 
> unsigned int cmd, int len,
>* Unreached coordinators will get EPIPE on next requests
>* and will unregister automatically.
>*/
> - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
> -
> - return rc;
> + return libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
> }
> 
> static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
> @@ -1425,8 +1422,7 @@ static int lmv_getstatus(struct obd_export *exp,
>   if (rc)
>   return rc;
> 
> - rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid);
> - return rc;
> + return md_getstatus(lmv->tgts[0]->ltd_exp, fid);
> }
> 
> static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
> @@ -1447,10 +1443,8 @@ static int lmv_getxattr(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_getxattr(tgt->ltd_exp, fid, valid, name, input,
> + return md_getxattr(tgt->ltd_exp, fid, valid, name, input,
>input_size, output_size, flags, request);
> -
> - return rc;
> }
> 
> static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
> @@ -1472,11 +1466,9 @@ static int lmv_setxattr(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_setxattr(tgt->ltd_exp, fid, valid, name, input,
> + return md_setxattr(tgt->ltd_exp, fid, valid, name, input,
>input_size, output_size, flags, suppgid,
>request);
> -
> - return rc;
> }
> 
> static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
> @@ -1500,9 +1492,7 @@ static int lmv_getattr(struct obd_export *exp, struct 
> md_op_data *op_data,
>   return 0;
>   }
> 
> - rc = md_getattr(tgt->ltd_exp, op_data, request);
> -
> - return rc;
> + return md_getattr(tgt->ltd_exp, op_data, request);
> }
> 
> static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid)
> @@ -1549,8 +1539,7 @@ static int lmv_close(struct obd_export *exp, struct 
> md_op_data *op_data,
>   return PTR_ERR(tgt);
> 
>   CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1));
> - rc = md_close(tgt->ltd_exp, op_data, mod, request);
> - return rc;
> + return md_close(tgt->ltd_exp, op_data, mod, request);
> }
> 
> /**
> @@ -1743,10 +1732,8 @@ lmv_enqueue(struct obd_export *exp, struct 
> ldlm_enqueue_info *einfo,
>   CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID " -> mds #%u\n",
>  LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
> 
> - rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
> + return md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
>   extra_lock_flags);
> -
> - return rc;
> }
> 
> static int
> @@ -1894,9 +1881,7 @@ static int lmv_link(struct obd_export *exp, struct 
> md_op_data *op_data,
>   if (rc != 0)
>   return rc;
> 
> - rc = md_link(tgt->ltd_exp, op_data, request);
> -
> - return rc;
> + return md_link(tgt->ltd_exp, op_data, request);
> }
> 
> static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
> @@ -2109,8 +2094,7 @@ static int lmv_sync(struct obd_export *exp, const 
> struct lu_fid *fid,
>   if (IS_ERR(tgt))
>   return PTR_ERR(tgt);
> 
> - rc = md_sync(tgt->ltd_exp, fid, request);
> - return rc;
> + return md_sync(tgt->ltd_exp, fid, request);
> }
> 
> /**
> @@ -2428,17 +2412,14 @@ static int lmv_read_page(struct obd_export *exp, 
> struct md_op_data *op_data,
>   return rc;
> 
>   if (unlikely(lsm)) {
> - rc = lmv_read_striped_page(exp, op_data, cb_op, offset, ppage);
> - return 

Re: [PATCH] staging: wilc1000: Connect to highest RSSI value for required SSID

2017-01-08 Thread Aditya Shankar
On Thu, 5 Jan 2017 15:14:50 +0300
Dan Carpenter  wrote:

> On Thu, Jan 05, 2017 at 01:03:41PM +0530, Aditya Shankar wrote:
> > Connect to the highest rssi with the required SSID in the shadow
> > table if the connection criteria is based only on the SSID.
> > For the first matching SSID, an index to the table is saved.
> > Later the index is updated if matching SSID has a higher
> > RSSI value than the last saved index.
> > 
> > However if decision is made based on BSSID, there is only one match
> > in the table and corresponding index is used.
> > 
> > Signed-off-by: Aditya Shankar 
> > ---
> >  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 20 ++--
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
> > b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> > index c1a24f7..32206b8 100644
> > --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> > +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> > @@ -665,6 +665,7 @@ static int connect(struct wiphy *wiphy, struct 
> > net_device *dev,
> >  {
> > s32 s32Error = 0;
> > u32 i;
> > +   u32 sel_bssi_idx = last_scanned_cnt + 1;  
> 
> 
> My understanding from reading the code is that "last_scanned_cnt + 1"
> is a randomly chosen invalid value.  Just saying:
> 
>   sel_bssi_idx = last_scanned_cnt;
> 
> would  also work because it's also invalid and slightly shorter to type.
> But I suggest that you go with something like UINT_MAX because that's
> more clearly invalid.

Thanks. Will change this.
> 
> > u8 u8security = NO_ENCRYPT;
> > enum AUTHTYPE tenuAuth_type = ANY;
> >  
> > @@ -688,18 +689,25 @@ static int connect(struct wiphy *wiphy, struct 
> > net_device *dev,
> > memcmp(last_scanned_shadow[i].ssid,
> >sme->ssid,
> >sme->ssid_len) == 0) {
> > -   if (!sme->bssid)
> > -   break;
> > -   else
> > +   if (!sme->bssid) {
> > +   if (sel_bssi_idx == (last_scanned_cnt + 1))
> > +   sel_bssi_idx = i;
> > +   else if (last_scanned_shadow[i].rssi >
> > +last_scanned_shadow[sel_bssi_idx].rssi)
> > +   sel_bssi_idx = i;  
> 
> Combine these with an ||.
> 
>   if (!sme->bssid) {
>   if (sel_bssi_idx == UINT_MAX ||
>   last_scanned_shadow[i].rssi >
>   last_scanned_shadow[sel_bssi_idx].rssi)
>   sel_bssi_idx = i;
>
>
> 
> In a separate patch, you can reverse the if statement at the start of
> the loop:
> 
>   if (sme->ssid_len != last_scanned_shadow[i].ssid_len ||
>   memcmp(last_scanned_shadow[i].ssid, sme->ssid,
>  sme->ssid_len) != 0)
>   continue;
> 
> That way you can pull these lines in a tab.
> 
> 
> > +   } else {
> > if (memcmp(last_scanned_shadow[i].bssid,
> >sme->bssid,
> > -  ETH_ALEN) == 0)
> > +  ETH_ALEN) == 0){  
> 
> Add a space before the curly brace.
> 
> regards,
> dan carpenter
> 
> 

I shall send an updated patch with the suggested changes and a separate
patch for the change at the beginning of the loop. 

Thanks for your review!

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


[PATCH v2] staging: wilc1000: Connect to highest RSSI value for required SSID

2017-01-08 Thread Aditya Shankar
Connect to the highest rssi with the required SSID in the shadow
table if the connection criteria is based only on the SSID.
For the first matching SSID, an index to the table is saved.
Later the index is updated if matching SSID has a higher
RSSI value than the last saved index.

However if decision is made based on BSSID, there is only one match
in the table and corresponding index is used.

changes in v2:
initialize sel_bssi_idx to UINT_MAX.
Combine two checks for identifying
sel_bssi_idx value for a SSID.

Signed-off-by: Aditya Shankar 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index c1a24f7..507bdf7 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -665,6 +665,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
 {
s32 s32Error = 0;
u32 i;
+   u32 sel_bssi_idx = UINT_MAX;
u8 u8security = NO_ENCRYPT;
enum AUTHTYPE tenuAuth_type = ANY;
 
@@ -688,18 +689,24 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
memcmp(last_scanned_shadow[i].ssid,
   sme->ssid,
   sme->ssid_len) == 0) {
-   if (!sme->bssid)
-   break;
-   else
+   if (!sme->bssid) {
+   if (sel_bssi_idx == UINT_MAX ||
+   last_scanned_shadow[i].rssi >
+   last_scanned_shadow[sel_bssi_idx].rssi)
+   sel_bssi_idx = i;
+   } else {
if (memcmp(last_scanned_shadow[i].bssid,
   sme->bssid,
-  ETH_ALEN) == 0)
+  ETH_ALEN) == 0) {
+   sel_bssi_idx = i;
break;
+   }
+   }
}
}
 
-   if (i < last_scanned_cnt) {
-   pstrNetworkInfo = &last_scanned_shadow[i];
+   if (sel_bssi_idx < last_scanned_cnt) {
+   pstrNetworkInfo = &last_scanned_shadow[sel_bssi_idx];
} else {
s32Error = -ENOENT;
wilc_connecting = 0;
-- 
2.7.4

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