Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread Richard Cochran
On Sat, Apr 21, 2018 at 07:41:35AM +0300, Dan Carpenter wrote:
> On Fri, Apr 20, 2018 at 02:01:25PM -0700, Richard Cochran wrote:
> > On Thu, Apr 19, 2018 at 01:40:08PM +0300, Dan Carpenter wrote:
> > > This driver seems nice and so far as I can see it doesn't need to be in
> > > staging once we get the other parts merged.
> > 
> > Please explain how this unit ties in with the MAC units.
> > 
> 
> I have no idea.  I assumed there were some dependencies which prevented
> this code from being merged into the normal part of the kernel.  From
> what I can see the code looks nice so if there aren't dependencies then
> we should put it in the normal part instead of in staging.

My question is really for Yangbo...

If the driver can't work without out-of-tree hacks, then it shouldn't
be merged (but I wouldn't object in that case for inclusion in staging
just so users can integrate it).

So we need to understand how this clock driver will be connected to
the time stamping MAC drivers.

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


Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread Dan Carpenter
On Fri, Apr 20, 2018 at 02:01:25PM -0700, Richard Cochran wrote:
> On Thu, Apr 19, 2018 at 01:40:08PM +0300, Dan Carpenter wrote:
> > This driver seems nice and so far as I can see it doesn't need to be in
> > staging once we get the other parts merged.
> 
> Please explain how this unit ties in with the MAC units.
> 

I have no idea.  I assumed there were some dependencies which prevented
this code from being merged into the normal part of the kernel.  From
what I can see the code looks nice so if there aren't dependencies then
we should put it in the normal part instead of in staging.

regards,
dan carpenter

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


[PATCH] staging: android: ion: remove duplicate buffer field initializes

2018-04-20 Thread Todd Poynor
As a result of various previous patches, ion_buffer_create() now
has two sets of identical statements for initializing two fields of
the buffer struct, next to each other.  Remove one set.

Move the initialization of these two fields together with the
statements that initialize the other two fields from the function
parameters, prior to the heap allocate() call, for consistency.

Signed-off-by: Todd Poynor 
---
 drivers/staging/android/ion/ion.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e74db7902549..269a431646be 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -74,6 +74,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap 
*heap,
 
buffer->heap = heap;
buffer->flags = flags;
+   buffer->dev = dev;
+   buffer->size = len;
 
ret = heap->ops->allocate(heap, buffer, len, flags);
 
@@ -93,11 +95,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap 
*heap,
goto err1;
}
 
-   buffer->dev = dev;
-   buffer->size = len;
 
-   buffer->dev = dev;
-   buffer->size = len;
INIT_LIST_HEAD(>attachments);
mutex_init(>lock);
mutex_lock(>buffer_lock);
-- 
2.17.0.484.g0c8726318c-goog

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


[PATCH 10/13] staging: iio: tsl2x7x: rename prx to prox for consistency

2018-04-20 Thread Brian Masney
The driver mostly uses the 'prox' naming convention for most of the
proximity settings, however prx_time and tsl2x7x_prx_gain was present.
This patch renames these to prox_time and tsl2x7x_prox_gain for
consistency with everything else in the driver.

The kernel documentation for prx_gain is corrected to prox_gain so that
it matches what is actually in the structure.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 12 ++--
 drivers/staging/iio/light/tsl2x7x.h |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 87b99deef7a8..a7b4fcba7935 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -203,7 +203,7 @@ static const struct tsl2x7x_lux 
*tsl2x7x_default_lux_table_group[] = {
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
.als_time = 219, /* 101 ms */
.als_gain = 0,
-   .prx_time = 254, /* 5.4 ms */
+   .prox_time = 254, /* 5.4 ms */
.prox_gain = 0,
.wait_time = 245,
.prox_config = 0,
@@ -230,7 +230,7 @@ static const s16 tsl2x7x_als_gain[] = {
120
 };
 
-static const s16 tsl2x7x_prx_gain[] = {
+static const s16 tsl2x7x_prox_gain[] = {
1,
2,
4,
@@ -594,7 +594,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
u8 *dev_reg, reg_val;
 
/* Non calculated parameters */
-   chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prx_time;
+   chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
 
@@ -1021,7 +1021,7 @@ static int tsl2x7x_write_event_value(struct iio_dev 
*indio_dev,
if (chan->type == IIO_INTENSITY)
time = chip->settings.als_time;
else
-   time = chip->settings.prx_time;
+   time = chip->settings.prox_time;
 
y = (TSL2X7X_MAX_TIMER_CNT - time) + 1;
z = y * TSL2X7X_MIN_ITIME;
@@ -1090,7 +1090,7 @@ static int tsl2x7x_read_event_value(struct iio_dev 
*indio_dev,
time = chip->settings.als_time;
mult = chip->settings.als_persistence;
} else {
-   time = chip->settings.prx_time;
+   time = chip->settings.prox_time;
mult = chip->settings.prox_persistence;
}
 
@@ -1153,7 +1153,7 @@ static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
if (chan->type == IIO_LIGHT)
*val = tsl2x7x_als_gain[chip->settings.als_gain];
else
-   *val = tsl2x7x_prx_gain[chip->settings.prox_gain];
+   *val = tsl2x7x_prox_gain[chip->settings.prox_gain];
ret = IIO_VAL_INT;
break;
case IIO_CHAN_INFO_CALIBBIAS:
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index 2c96f0b39b1e..408e5a89edb1 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -44,9 +44,9 @@ struct tsl2x7x_lux {
  *  aperture effects.
  *  @wait_time: Time between PRX and ALS cycles
  *  in 2.7 periods
- *  @prx_time:  5.2ms prox integration time -
+ *  @prox_time: 5.2ms prox integration time -
  *  decrease in 2.7ms periods
- *  @prx_gain:  Proximity gain index
+ *  @prox_gain: Proximity gain index
  *  @prox_config:   Prox configuration filters.
  *  @als_cal_target:Known external ALS reading for
  *  calibration.
@@ -68,7 +68,7 @@ struct tsl2x7x_settings {
int als_gain;
int als_gain_trim;
int wait_time;
-   int prx_time;
+   int prox_time;
int prox_gain;
int prox_config;
int als_cal_target;
-- 
2.14.3

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


[PATCH 13/13] staging: iio: tsl2x7x: rename prox_config to als_prox_config

2018-04-20 Thread Brian Masney
The configuration register on the device is represented with the
prox_config member on the tsl2x7x_settings structure. According to the
TSL2772 data sheet, this register can hold: 1) the proximity drive
level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
patch renames prox_config to als_prox_config since ALS settings can
be stored here as well.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 05c0f3d5fac0..708b2c6bdf4b 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -56,7 +56,7 @@
 #define TSL2X7X_PRX_MAXTHRESHLO0X0A
 #define TSL2X7X_PRX_MAXTHRESHHI0X0B
 #define TSL2X7X_PERSISTENCE0x0C
-#define TSL2X7X_PRX_CONFIG 0x0D
+#define TSL2X7X_ALS_PRX_CONFIG 0x0D
 #define TSL2X7X_PRX_COUNT  0x0E
 #define TSL2X7X_GAIN   0x0F
 #define TSL2X7X_NOTUSED0x10
@@ -207,7 +207,7 @@ static const struct tsl2x7x_settings 
tsl2x7x_default_settings = {
.prox_time = 255, /* 2.73 ms */
.prox_gain = 0,
.wait_time = 255,
-   .prox_config = 0,
+   .als_prox_config = 0,
.als_gain_trim = 1000,
.als_cal_target = 150,
.als_persistence = 1,
@@ -594,7 +594,8 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
/* Non calculated parameters */
chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time;
chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time;
-   chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] = chip->settings.prox_config;
+   chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] =
+   chip->settings.als_prox_config;
 
chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
(chip->settings.als_thresh_low) & 0xFF;
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index 85d8fe7a94c8..6e30e71a2127 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -48,7 +48,8 @@ struct tsl2x7x_lux {
  *  increments. Total integration time is
  *  (256 - prx_time) * 2.73.
  *  @prox_gain: Index into the tsl2x7x_prx_gain array.
- *  @prox_config:   Prox configuration filters.
+ *  @als_prox_config:   The value of the ALS / Proximity configuration
+ *  register.
  *  @als_cal_target:Known external ALS reading for calibration.
  *  @als_persistence:   H/W Filters, Number of 'out of limits' ALS 
readings.
  *  @als_interrupt_en:  Enable/Disable ALS interrupts
@@ -73,7 +74,7 @@ struct tsl2x7x_settings {
int wait_time;
int prox_time;
int prox_gain;
-   int prox_config;
+   int als_prox_config;
int als_cal_target;
u8 als_persistence;
bool als_interrupt_en;
-- 
2.14.3

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


[PATCH 05/13] staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume

2018-04-20 Thread Brian Masney
tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
current chip status is. These checks are not necessary so this patch
removes those checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index f37fc74b8fbc..8d8af0cf9768 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1682,27 +1682,15 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 static int tsl2x7x_suspend(struct device *dev)
 {
struct iio_dev *indio_dev = dev_get_drvdata(dev);
-   struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   int ret = 0;
-
-   if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
-   ret = tsl2x7x_chip_off(indio_dev);
-   chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
-   }
 
-   return ret;
+   return tsl2x7x_chip_off(indio_dev);
 }
 
 static int tsl2x7x_resume(struct device *dev)
 {
struct iio_dev *indio_dev = dev_get_drvdata(dev);
-   struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   int ret = 0;
 
-   if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
-   ret = tsl2x7x_chip_on(indio_dev);
-
-   return ret;
+   return tsl2x7x_chip_on(indio_dev);
 }
 
 static int tsl2x7x_remove(struct i2c_client *client)
-- 
2.14.3

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


[PATCH 04/13] staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function

2018-04-20 Thread Brian Masney
tsl2x7x_clear_interrupts() takes a reg argument but there are only
two callers to this function and both callers pass the same value.
Since this function was introduced, interrupts are now working
properly for this driver, and several unnecessary calls to
tsl2x7x_clear_interrupts() were removed. This patch removes the
tsl2x7x_clear_interrupts() function and replaces the two callers
with the i2c_smbus_write_byte() call instead.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 95a00b965c5e..f37fc74b8fbc 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -271,20 +271,6 @@ static const u8 device_channel_config[] = {
ALSPRX2
 };
 
-static int tsl2x7x_clear_interrupts(struct tsl2X7X_chip *chip, int reg)
-{
-   int ret;
-
-   ret = i2c_smbus_write_byte(chip->client,
-  TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | reg);
-   if (ret < 0)
-   dev_err(>client->dev,
-   "%s: failed to clear interrupt status %x: %d\n",
-   __func__, reg, ret);
-
-   return ret;
-}
-
 static int tsl2x7x_read_status(struct tsl2X7X_chip *chip)
 {
int ret;
@@ -714,9 +700,15 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
if (ret < 0)
return ret;
 
-   ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-   if (ret < 0)
+   ret = i2c_smbus_write_byte(chip->client,
+  TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+  TSL2X7X_CMD_PROXALS_INT_CLR);
+   if (ret < 0) {
+   dev_err(>client->dev,
+   "%s: failed to clear interrupt status: %d\n",
+   __func__, ret);
return ret;
+   }
 
chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
 
@@ -1341,7 +1333,13 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
   timestamp);
}
 
-   tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
+   ret = i2c_smbus_write_byte(chip->client,
+  TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+  TSL2X7X_CMD_PROXALS_INT_CLR);
+   if (ret < 0)
+   dev_err(>client->dev,
+   "%s: failed to clear interrupt status: %d\n",
+   __func__, ret);
 
return IRQ_HANDLED;
 }
-- 
2.14.3

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


[PATCH 08/13] staging: iio: tsl2x7x: add range checking to three sysfs attributes

2018-04-20 Thread Brian Masney
The sysfs attributes in_illuminance0_target_input,
in_illuminance0_calibrate, and in_proximity0_calibrate did not have
proper range checking in place so this patch adds the correct range
checks.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 56730baea927..15bc0af1bb6c 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -835,9 +835,10 @@ static ssize_t in_illuminance0_target_input_store(struct 
device *dev,
if (kstrtoul(buf, 0, ))
return -EINVAL;
 
-   if (value)
-   chip->settings.als_cal_target = value;
+   if (value < 0 || value > 65535)
+   return -ERANGE;
 
+   chip->settings.als_cal_target = value;
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
return ret;
@@ -853,14 +854,12 @@ static ssize_t in_illuminance0_calibrate_store(struct 
device *dev,
bool value;
int ret;
 
-   if (strtobool(buf, ))
+   if (kstrtobool(buf, ) || !value)
return -EINVAL;
 
-   if (value) {
-   ret = tsl2x7x_als_calibrate(indio_dev);
-   if (ret < 0)
-   return ret;
-   }
+   ret = tsl2x7x_als_calibrate(indio_dev);
+   if (ret < 0)
+   return ret;
 
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
@@ -946,14 +945,12 @@ static ssize_t in_proximity0_calibrate_store(struct 
device *dev,
bool value;
int ret;
 
-   if (strtobool(buf, ))
+   if (kstrtobool(buf, ) || !value)
return -EINVAL;
 
-   if (value) {
-   ret = tsl2x7x_prox_cal(indio_dev);
-   if (ret < 0)
-   return ret;
-   }
+   ret = tsl2x7x_prox_cal(indio_dev);
+   if (ret < 0)
+   return ret;
 
ret = tsl2x7x_invoke_change(indio_dev);
if (ret < 0)
-- 
2.14.3

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


[PATCH 12/13] staging: iio: tsl2x7x: various comment cleanups

2018-04-20 Thread Brian Masney
This patch removes several unnecessary comments, changes some comments
so that the use as much of the allowable 80 characters as possible, adds
the proper whitespace, removes some structure members from the kernel
docs that are no longer present, and improves the existing kernel doc
information for some existing structure members.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 59 +
 drivers/staging/iio/light/tsl2x7x.h | 48 +++---
 2 files changed, 51 insertions(+), 56 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 293810ff11b9..05c0f3d5fac0 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1,6 +1,6 @@
 /*
- * Device driver for monitoring ambient light intensity in (lux)
- * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
+ * Device driver for monitoring ambient light intensity in (lux) and proximity
+ * detection (prox) within the TAOS TSL2X7X family of devices.
  *
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney 
@@ -21,7 +21,7 @@
 #include 
 #include "tsl2x7x.h"
 
-/* Cal defs*/
+/* Cal defs */
 #define PROX_STAT_CAL  0
 #define PROX_STAT_SAMP 1
 #define MAX_SAMPLES_CAL200
@@ -34,10 +34,11 @@
 /* Lux calculation constants */
 #define TSL2X7X_LUX_CALC_OVER_FLOW 65535
 
-/* TAOS Register definitions - note:
- * depending on device, some of these register are not used and the
- * register address is benign.
+/*
+ * TAOS Register definitions - Note: depending on device, some of these 
register
+ * are not used and the register address is benign.
  */
+
 /* 2X7X register offsets */
 #define TSL2X7X_MAX_CONFIG_REG 16
 
@@ -342,15 +343,14 @@ static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip 
*chip, int lower_reg,
  * @indio_dev: pointer to IIO device
  *
  * The raw ch0 and ch1 values of the ambient light sensed in the last
- * integration cycle are read from the device.
- * Time scale factor array values are adjusted based on the integration time.
- * The raw values are multiplied by a scale factor, and device gain is obtained
- * using gain index. Limit checks are done next, then the ratio of a multiple
- * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
- * is then scanned to find the first ratio value that is just above the ratio
- * we just calculated. The ch0 and ch1 multiplier constants in the array are
- * then used along with the time scale factor array values, to calculate the
- * lux.
+ * integration cycle are read from the device. Time scale factor array values
+ * are adjusted based on the integration time. The raw values are multiplied
+ * by a scale factor, and device gain is obtained using gain index. Limit
+ * checks are done next, then the ratio of a multiple of ch1 value, to the
+ * ch0 value, is calculated. Array tsl2x7x_device_lux[] is then scanned to
+ * find the first ratio value that is just above the ratio we just calculated.
+ * The ch0 and ch1 multiplier constants in the array are then used along with
+ * the time scale factor array values, to calculate the lux.
  */
 static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 {
@@ -363,7 +363,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
mutex_lock(>als_mutex);
 
if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
-   /* device is not enabled */
dev_err(>client->dev, "%s: device is not enabled\n",
__func__);
ret = -EBUSY;
@@ -374,7 +373,6 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
if (ret < 0)
goto out_unlock;
 
-   /* is data new & valid */
if (!(ret & TSL2X7X_STA_ADC_VALID)) {
dev_err(>client->dev,
"%s: data not valid yet\n", __func__);
@@ -430,12 +428,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
lux = (lux + (chip->als_time_scale >> 1)) /
chip->als_time_scale;
 
-   /* adjust for active gain scale
-* The tsl2x7x_device_lux tables have a factor of 256 built-in.
-* User-specified gain provides a multiplier.
+   /*
+* adjust for active gain scale. The tsl2x7x_device_lux tables have a
+* factor of 256 built-in. User-specified gain provides a multiplier.
 * Apply user-specified gain before shifting right to retain precision.
-* Use 64 bits to avoid overflow on multiplication.
-* Then go back to 32 bits before division to avoid using div_u64().
+* Use 64 bits to avoid overflow on multiplication. Then go back to
+* 32 bits before division to avoid using div_u64().
 */
 
lux64 = lux;
@@ -713,14 +711,13 @@ static 

[PATCH 01/13] staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel

2018-04-20 Thread Brian Masney
The integration_time* attributes are currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. Directory listing of the sysfs attributes for a TSL2772
with this patch applied:

dev
events
in_illuminance0_calibrate
in_illuminance0_calibscale_available
in_illuminance0_input
in_illuminance0_lux_table
in_illuminance0_target_input
in_intensity0_calibbias
in_intensity0_calibscale
in_intensity0_integration_time
in_intensity0_integration_time_available
in_intensity0_raw
in_intensity1_raw
in_proximity0_calibrate
in_proximity0_calibscale
in_proximity0_calibscale_available
in_proximity0_raw
name
of_node
power
subsystem
uevent

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 9991b0483956..eeccfbb0eb1f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -827,7 +827,7 @@ in_illuminance0_calibscale_available_show(struct device 
*dev,
 
 static IIO_CONST_ATTR(in_proximity0_calibscale_available, "1 2 4 8");
 
-static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
+static IIO_CONST_ATTR(in_intensity0_integration_time_available,
".00272 - .696");
 
 static ssize_t in_illuminance0_target_input_show(struct device *dev,
@@ -1358,7 +1358,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 
 static struct attribute *tsl2x7x_ALS_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_illuminance0_integration_time_available
+   _const_attr_in_intensity0_integration_time_available
.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1373,7 +1373,7 @@ static struct attribute *tsl2x7x_PRX_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_illuminance0_integration_time_available
+   _const_attr_in_intensity0_integration_time_available
.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1389,7 +1389,7 @@ static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
 
 static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
_attr_in_illuminance0_calibscale_available.attr,
-   _const_attr_in_illuminance0_integration_time_available
+   _const_attr_in_intensity0_integration_time_available
.dev_attr.attr,
_attr_in_illuminance0_target_input.attr,
_attr_in_illuminance0_calibrate.attr,
@@ -1489,13 +1489,13 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.type = IIO_LIGHT,
.indexed = 1,
.channel = 0,
-   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
+   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
}, {
.type = IIO_INTENSITY,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+   BIT(IIO_CHAN_INFO_INT_TIME) |
BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS),
.event_spec = tsl2x7x_events,
@@ -1529,13 +1529,13 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.type = IIO_LIGHT,
.indexed = 1,
.channel = 0,
-   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
+   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
}, {
.type = IIO_INTENSITY,
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+   BIT(IIO_CHAN_INFO_INT_TIME) |
BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS),
.event_spec = tsl2x7x_events,
@@ -1578,13 +1578,13 @@ static const struct tsl2x7x_chip_info 
tsl2x7x_chip_info_tbl[] = {
.type = IIO_LIGHT,
.indexed = 1,
.channel = 0,
-   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
- BIT(IIO_CHAN_INFO_INT_TIME),
+   

[PATCH 07/13] staging: iio: tsl2x7x: simplify device id verification

2018-04-20 Thread Brian Masney
This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
removes the unnecessary pointer on the id parameter, and only calls
the verification function once.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index d202bc7e1f4f..56730baea927 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1277,22 +1277,22 @@ static DEVICE_ATTR_WO(in_proximity0_calibrate);
 static DEVICE_ATTR_RW(in_illuminance0_lux_table);
 
 /* Use the default register values to identify the Taos device */
-static int tsl2x7x_device_id(int *id, int target)
+static int tsl2x7x_device_id_verif(int id, int target)
 {
switch (target) {
case tsl2571:
case tsl2671:
case tsl2771:
-   return (*id & 0xf0) == TRITON_ID;
+   return (id & 0xf0) == TRITON_ID;
case tmd2671:
case tmd2771:
-   return (*id & 0xf0) == HALIBUT_ID;
+   return (id & 0xf0) == HALIBUT_ID;
case tsl2572:
case tsl2672:
case tmd2672:
case tsl2772:
case tmd2772:
-   return (*id & 0xf0) == SWORDFISH_ID;
+   return (id & 0xf0) == SWORDFISH_ID;
}
 
return -EINVAL;
@@ -1612,8 +1612,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
if (ret < 0)
return ret;
 
-   if ((!tsl2x7x_device_id(, id->driver_data)) ||
-   (tsl2x7x_device_id(, id->driver_data) == -EINVAL)) {
+   if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) {
dev_info(>client->dev,
 "%s: i2c device found does not match expected id\n",
__func__);
-- 
2.14.3

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


[PATCH 11/13] staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time

2018-04-20 Thread Brian Masney
This patch changes the defaults of the als_time, prox_time and
wait_time to match the defaults according to the TSL2772 datasheet.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index a7b4fcba7935..293810ff11b9 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -201,11 +201,11 @@ static const struct tsl2x7x_lux 
*tsl2x7x_default_lux_table_group[] = {
 };
 
 static const struct tsl2x7x_settings tsl2x7x_default_settings = {
-   .als_time = 219, /* 101 ms */
+   .als_time = 255, /* 2.73 ms */
.als_gain = 0,
-   .prox_time = 254, /* 5.4 ms */
+   .prox_time = 255, /* 2.73 ms */
.prox_gain = 0,
-   .wait_time = 245,
+   .wait_time = 255,
.prox_config = 0,
.als_gain_trim = 1000,
.als_cal_target = 150,
-- 
2.14.3

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


[PATCH 09/13] staging: iio: tsl2x7x: move power and diode settings into header file

2018-04-20 Thread Brian Masney
The power and diode defines are needed for the platform data so this
patch moves the defines out of the .c file and into the header file. A
comment for the diode is also cleaned up while this code is touched.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 12 
 drivers/staging/iio/light/tsl2x7x.h | 12 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 15bc0af1bb6c..87b99deef7a8 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -103,18 +103,6 @@
 #define TSL2X7X_CNTL_PROXPON_ENBL  0x0F
 #define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F
 
-/*Prox diode to use */
-#define TSL2X7X_DIODE0 0x01
-#define TSL2X7X_DIODE1 0x02
-#define TSL2X7X_DIODE_BOTH 0x03
-
-/* LED Power */
-#define TSL2X7X_100_mA 0x00
-#define TSL2X7X_50_mA  0x01
-#define TSL2X7X_25_mA  0x02
-#define TSL2X7X_13_mA  0x03
-#define TSL2X7X_MAX_TIMER_CNT  0xFF
-
 #define TSL2X7X_MIN_ITIME  3
 
 /* TAOS txx2x7x Device family members */
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index 992ee2465609..2c96f0b39b1e 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -23,6 +23,18 @@ struct tsl2x7x_lux {
 #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
 TSL2X7X_DEF_LUX_TABLE_SZ)
 
+/* Proximity diode to use */
+#define TSL2X7X_DIODE0  0x01
+#define TSL2X7X_DIODE1  0x02
+#define TSL2X7X_DIODE_BOTH  0x03
+
+/* LED Power */
+#define TSL2X7X_100_mA  0x00
+#define TSL2X7X_50_mA   0x01
+#define TSL2X7X_25_mA   0x02
+#define TSL2X7X_13_mA   0x03
+#define TSL2X7X_MAX_TIMER_CNT   0xFF
+
 /**
  * struct tsl2x7x_default_settings - power on defaults unless
  *   overridden by platform data.
-- 
2.14.3

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


[PATCH 00/13] iio: tsl2x7x: staging cleanups

2018-04-20 Thread Brian Masney
Here is another round of staging cleanups for this driver mostly based
on Jonathon's feedback. We're very close to a staging graduation and I
only have a few items remaining on my todo list:
 
- Remove wildcards from the driver name. Jonathan suggested tsl2571.
- Don't make the events/ directory available to user space via sysfs if
  an interrupt pin is not configured.
- Go through the newer ALS part numbers on AMS's site and see if there
  are other part numbers that can be added to this driver.
- I found this week an issue with the integration_time sysfs attribute.

Hopefully I'll have time to wrap this up next week.

Brian Masney (13):
  staging: iio: tsl2x7x: move integration_time* attributes to
IIO_INTENSITY channel
  staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
  staging: iio: tsl2x7x: don't return error in IRQ handler
  staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
  staging: iio: tsl2x7x: remove unnecessary chip status checks in
suspend/resume
  staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
  staging: iio: tsl2x7x: simplify device id verification
  staging: iio: tsl2x7x: add range checking to three sysfs attributes
  staging: iio: tsl2x7x: move power and diode settings into header file
  staging: iio: tsl2x7x: rename prx to prox for consistency
  staging: iio: tsl2x7x: use device defaults for als_time, prox_time and
wait_time
  staging: iio: tsl2x7x: various comment cleanups
  staging: iio: tsl2x7x: rename prox_config to als_prox_config

 drivers/staging/iio/light/tsl2x7x.c | 217 ++--
 drivers/staging/iio/light/tsl2x7x.h |  81 +++---
 2 files changed, 125 insertions(+), 173 deletions(-)

-- 
2.14.3

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


[PATCH 06/13] staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return

2018-04-20 Thread Brian Masney
tsl2x7x_write_interrupt_config() has an unnecessary return value check
at the end of the function. This patch changes the function to just
return the value from the call to tsl2x7x_invoke_change().

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 8d8af0cf9768..d202bc7e1f4f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -982,18 +982,13 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev 
*indio_dev,
  int val)
 {
struct tsl2X7X_chip *chip = iio_priv(indio_dev);
-   int ret;
 
if (chan->type == IIO_INTENSITY)
chip->settings.als_interrupt_en = val ? true : false;
else
chip->settings.prox_interrupt_en = val ? true : false;
 
-   ret = tsl2x7x_invoke_change(indio_dev);
-   if (ret < 0)
-   return ret;
-
-   return 0;
+   return tsl2x7x_invoke_change(indio_dev);
 }
 
 static int tsl2x7x_write_event_value(struct iio_dev *indio_dev,
-- 
2.14.3

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


[PATCH 03/13] staging: iio: tsl2x7x: don't return error in IRQ handler

2018-04-20 Thread Brian Masney
tsl2x7x_event_handler() could return an error and this could cause the
interrupt to remain masked. We shouldn't return an error in the
interrupt handler so this patch always returns IRQ_HANDLED. An error
will be logged if one occurs.

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

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index 9cdcc8c9e812..95a00b965c5e 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -1320,7 +1320,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
 
ret = tsl2x7x_read_status(chip);
if (ret < 0)
-   return ret;
+   return IRQ_HANDLED;
 
/* What type of interrupt do we need to process */
if (ret & TSL2X7X_STA_PRX_INTR) {
@@ -1341,9 +1341,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void 
*private)
   timestamp);
}
 
-   ret = tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
-   if (ret < 0)
-   return ret;
+   tsl2x7x_clear_interrupts(chip, TSL2X7X_CMD_PROXALS_INT_CLR);
 
return IRQ_HANDLED;
 }
-- 
2.14.3

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


[PATCH 02/13] staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier

2018-04-20 Thread Brian Masney
The summary text for the GPL is not needed since the SPDX identifier
is a legally binding shorthand that can be used instead.

Signed-off-by: Brian Masney 
---
 drivers/staging/iio/light/tsl2x7x.c | 10 +-
 drivers/staging/iio/light/tsl2x7x.h | 14 +-
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/iio/light/tsl2x7x.c 
b/drivers/staging/iio/light/tsl2x7x.c
index eeccfbb0eb1f..9cdcc8c9e812 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -5,15 +5,7 @@
  * Copyright (c) 2012, TAOS Corporation.
  * Copyright (c) 2017-2018 Brian Masney 
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #include 
diff --git a/drivers/staging/iio/light/tsl2x7x.h 
b/drivers/staging/iio/light/tsl2x7x.h
index d382cdbb976e..992ee2465609 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -4,19 +4,7 @@
  *
  * Copyright (c) 2012, TAOS Corporation.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * SPDX-License-Identifier: GPL-2.0+
  */
 
 #ifndef __TSL2X7X_H
-- 
2.14.3

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


Re: [PATCH 11/31] staging: mt7621-mmc: Remove multiple assignments

2018-04-20 Thread NeilBrown
On Sat, Apr 21 2018, Christian Luetke wrote:

> Am 21.04.2018 00:22, schrieb NeilBrown:
>> On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:
>> 
>>> Fix checkpatch: multiple assignments should be avoided, to improve
>>> readability.
>>> 
>>> Signed-off-by: Christian Lütke-Stetzkamp 
>>> ---
>>>  drivers/staging/mt7621-mmc/sd.c | 7 ---
>>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/drivers/staging/mt7621-mmc/sd.c 
>>> b/drivers/staging/mt7621-mmc/sd.c
>>> index 3871602b4651..357c10551773 100644
>>> --- a/drivers/staging/mt7621-mmc/sd.c
>>> +++ b/drivers/staging/mt7621-mmc/sd.c
>>> @@ -1473,11 +1473,12 @@ static int msdc_do_request(struct mmc_host 
>>> *mmc, struct mmc_request *mrq)
>>> 
>>> /* deside the transfer mode */
>>> if (drv_mode[host->id] == MODE_PIO)
>>> -   host->dma_xfer = dma = 0;
>>> +   host->dma_xfer = 0;
>>> else if (drv_mode[host->id] == MODE_DMA)
>>> -   host->dma_xfer = dma = 1;
>>> +   host->dma_xfer = 1;
>>> else if (drv_mode[host->id] == MODE_SIZE_DEP)
>>> -   host->dma_xfer = dma = ((host->xfer_size >= 
>>> dma_size[host->id]) ? 
>>> 1 : 0);
>>> +   host->dma_xfer = ((host->xfer_size >= 
>>> dma_size[host->id]) ? 1 : 
>>> 0);
>>> +   dma = host->dma_xfer;
>> 
>> You've changed behaviour here.
>> Previously, if none of the 3 conditions were true, dma would have the
>> value of 0 that it was initialized to.
>> No it will take the value of host->dma_xfer from the previous transfer.
>> I doubt that is correct.
>> 
>> I would change the if branches to assign to dma, not to host->dma_xfer.
>> Then "host->dma_xfer = dma;".  This isn't *quite* what the original 
>> code
>> does, but I think it is close enough.
>
> But drv_mode has the type msdc_mode, that is an enum that has only the
> elements MODE_PIO, MODE_DMA and MODE_SIZE_DEP. So the original code is 
> not
> optimal, maybe the last else if should be an else. Shall I change the 
> patch to
> respect that? Or should I change it to a switch case? (Also this code 
> will be
> removed in the next series, as you suggested, what I already thought of 
> -
> removing the non DMA mode. )

The patch worried me because it claimed to just fix a check-patch
warning, but it appears to change behaviour.  That happens too easily
and can be very problematic.  So I jumped on it.
I would be happy if you:
 - explained in the patch description why the code is actually correct,
   even though it isn't obvious.
 - changed the last "else if" to "else" - again it requires an
   explanation
 - changed to a switch - with explanation.

Given that we are likely to discard the code, I really don't care which.
If we were going to keep the code, I would prefer the switch.

Thanks,
NeilBrown


>
> Thanks for the review.
>
> Regards,
> Christian


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


Re: [PATCH 11/31] staging: mt7621-mmc: Remove multiple assignments

2018-04-20 Thread Christian Luetke

Am 21.04.2018 00:22, schrieb NeilBrown:

On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:


Fix checkpatch: multiple assignments should be avoided, to improve
readability.

Signed-off-by: Christian Lütke-Stetzkamp 
---
 drivers/staging/mt7621-mmc/sd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c 
b/drivers/staging/mt7621-mmc/sd.c

index 3871602b4651..357c10551773 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -1473,11 +1473,12 @@ static int msdc_do_request(struct mmc_host 
*mmc, struct mmc_request *mrq)


/* deside the transfer mode */
if (drv_mode[host->id] == MODE_PIO)
-   host->dma_xfer = dma = 0;
+   host->dma_xfer = 0;
else if (drv_mode[host->id] == MODE_DMA)
-   host->dma_xfer = dma = 1;
+   host->dma_xfer = 1;
else if (drv_mode[host->id] == MODE_SIZE_DEP)
-			host->dma_xfer = dma = ((host->xfer_size >= dma_size[host->id]) ? 
1 : 0);
+			host->dma_xfer = ((host->xfer_size >= dma_size[host->id]) ? 1 : 
0);

+   dma = host->dma_xfer;


You've changed behaviour here.
Previously, if none of the 3 conditions were true, dma would have the
value of 0 that it was initialized to.
No it will take the value of host->dma_xfer from the previous transfer.
I doubt that is correct.

I would change the if branches to assign to dma, not to host->dma_xfer.
Then "host->dma_xfer = dma;".  This isn't *quite* what the original 
code

does, but I think it is close enough.


But drv_mode has the type msdc_mode, that is an enum that has only the
elements MODE_PIO, MODE_DMA and MODE_SIZE_DEP. So the original code is 
not
optimal, maybe the last else if should be an else. Shall I change the 
patch to
respect that? Or should I change it to a switch case? (Also this code 
will be
removed in the next series, as you suggested, what I already thought of 
-

removing the non DMA mode. )

Thanks for the review.

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


Re: Representative Needed.

2018-04-20 Thread PPMC OFFSHORE
Good day,

  I am seeking your concept with great gratitude to present you as a 
representative to carry out business transactions with a reasonable share upon 
your interest and cooperation to work with us in trust. If interested please 
get back.

Regards
Kingsley

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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


Re: [PATCH 00/31] staging: mt7621-mmc: Next cleanups

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> Here are the next cleanups for the mt7621-mmc driver. Most of them
> just remove some unused code, but there are also some other cleanups
> and fixes. This also changes the default to always using DMA for data
> transfer, if there are no performance issues with that, the non-DMA
> code will be removed in the future, because the mtk-sd driver is also
> always using DMA.
>
> Christian Lütke-Stetzkamp (31):
>   staging: mt7621-mmc: Remove unused code from board.h
>   staging: mt7621-mmc: Remove unused field get_cd_status from msdc_hw
>   staging: mt7621-mmc: Remove unused field enable_cd_eirq from msdc_hw
>   staging: mt7621-mmc: Remove unused field disable_cd_eirq
>   staging: mt7621-mmc: Fix null pointer deref if ext sdio irq enabled
>   staging: mt7621-mmc: Remove power callbacks from msdc_hw
>   staging: mt7621-mmc: Refactor and rename msdc_reset to msdc_reset_hw
>   staging: mt7621-mmc: Remove code for not existent config
>   staging: mt7621-mmc: Relax cpu while waiting for stable clock
>   staging: mt7621-mmc: Remove unused field data_offset from msdc_hw
>   staging: mt7621-mmc: Remove multiple assignments

Apart from this patch which I commented on separately, and...

>   staging: mt7621-mmc: Remove unused field burstsz from msdc_dma
>   staging: mt7621-mmc: Remove unused function msdc_dma_dump
>   staging: mt7621-mmc: Start cleanup of msdc_dma_config
>   staging: mt7621-mmc: Remove unused fields from msdc_dma
>   staging: mt7621-mmc: Remove flags from msdc_dma
>   staging: mt7621-mmc: Remove unused field xfersz from msdc_dma
>   staging: mt7621-mmc: Fix dma_map_sg may map to fever entries

...this patch - I don't want fever entries in the kernel, but fewer
entries would be fine :-)

They all get
  Reviewed-by: NeilBrown 

(and the other two get that as well if you make the changes I
suggested).

Thanks,
NeilBrown



>   staging: mt7621-mmc: Replace dma dir with mmc_get_dma_dir
>   staging: mt7621-mmc: Correct datatypes for io and sanitize io access
>   staging: mt7621-mmc: Add annotations about held locks
>   staging: mt7621-mmc: Refactor msdc_init_gpd_bd
>   staging: mt7621-mmc: Remove old references to tasklet
>   staging: mt7621-mmc: Change default transfer mode to DMA
>   staging: mt7621-mmc: Remove unused field starttime from msdc_host
>   staging: mt7621:mmc: Remove unused field reserved from msdc_host
>   staging: mt7621-mmc: Remove unused field dma_left_size of msdc_host
>   staging: mt7621-mmc: Remove unused card_workqueue from msdc_host
>   staging: mt7621-mmc: Remove unused field cmd_r1b_done in msdc_host
>   staging: mt7621-mmc: Remove unused field cmd_rsp_done of msdc_host
>   staging: mt7621-mmc: Remove unused field dma_addr of msdc_host
>
>  drivers/staging/mt7621-mmc/board.h |  64 --
>  drivers/staging/mt7621-mmc/dbg.c   |   8 +-
>  drivers/staging/mt7621-mmc/mt6575_sd.h |  69 ++
>  drivers/staging/mt7621-mmc/sd.c| 404 
> +++--
>  4 files changed, 154 insertions(+), 391 deletions(-)
>
> -- 
> 2.16.1


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


Re: [PATCH 24/31] staging: mt7621-mmc: Change default transfer mode to DMA

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> The current default transfer is to use DMA or not depending on the
> size of the data. The upstream driver mtk-sd uses DMA all times,
> change the standard mode here to DMA for testing, if there are any
> performance problems with DMA for small data sizes. If not, the option
> for transfer mode should be removed in the future,
>
> Signed-off-by: Christian Lütke-Stetzkamp 
> ---
>  drivers/staging/mt7621-mmc/dbg.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/mt7621-mmc/dbg.c 
> b/drivers/staging/mt7621-mmc/dbg.c
> index 9a1809d74ea3..0d6e21557d8f 100644
> --- a/drivers/staging/mt7621-mmc/dbg.c
> +++ b/drivers/staging/mt7621-mmc/dbg.c
> @@ -67,10 +67,10 @@ u32 dma_size[4] = {
>  };
>  
>  enum msdc_mode drv_mode[4] = {
> - MODE_SIZE_DEP, /* using DMA or not depend on the size */
> - MODE_SIZE_DEP,
> - MODE_SIZE_DEP,
> - MODE_SIZE_DEP
> + MODE_DMA, /* using DMA always */
> + MODE_DMA,
> + MODE_DMA,
> + MODE_DMA
>  };

It is interesting that this table is in "dbg.c"
Maybe this was only really important during driver development, so that
the developers could experiment and measure... there is a /proc file
which allows the size cutoff to be changed.

On my board I can only use the mmc interface for a micro SD card, so I
cannot test small transfer sizes.  We might just need to bite the bullet
and discard this code. Maybe.

Thanks,
NeilBrown


>  
>  #if defined(MT6575_SD_DEBUG)
> -- 
> 2.16.1


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


Re: [PATCH 11/31] staging: mt7621-mmc: Remove multiple assignments

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> Fix checkpatch: multiple assignments should be avoided, to improve
> readability.
>
> Signed-off-by: Christian Lütke-Stetzkamp 
> ---
>  drivers/staging/mt7621-mmc/sd.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index 3871602b4651..357c10551773 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -1473,11 +1473,12 @@ static int msdc_do_request(struct mmc_host *mmc, 
> struct mmc_request *mrq)
>  
>   /* deside the transfer mode */
>   if (drv_mode[host->id] == MODE_PIO)
> - host->dma_xfer = dma = 0;
> + host->dma_xfer = 0;
>   else if (drv_mode[host->id] == MODE_DMA)
> - host->dma_xfer = dma = 1;
> + host->dma_xfer = 1;
>   else if (drv_mode[host->id] == MODE_SIZE_DEP)
> - host->dma_xfer = dma = ((host->xfer_size >= 
> dma_size[host->id]) ? 1 : 0);
> + host->dma_xfer = ((host->xfer_size >= 
> dma_size[host->id]) ? 1 : 0);
> + dma = host->dma_xfer;

You've changed behaviour here.
Previously, if none of the 3 conditions were true, dma would have the
value of 0 that it was initialized to.
No it will take the value of host->dma_xfer from the previous transfer.
I doubt that is correct.

I would change the if branches to assign to dma, not to host->dma_xfer.
Then "host->dma_xfer = dma;".  This isn't *quite* what the original code
does, but I think it is close enough.

Thanks,
NeilBrown


>  
>   if (read) {
>   if ((host->timeout_ns != data->timeout_ns) ||
> -- 
> 2.16.1


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


Re: [PATCH] staging: mt7621-pci: Remove redundant owner assignment

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> Remove the owner assignment form the platform driver as
> platform_driver_register() already initializes the owner.
> Found using coccinelle.
>
> Signed-off-by: Christian Lütke-Stetzkamp 

Reviewed-by: NeilBrown 

Thanks,
NeilBrown

> ---
>  drivers/staging/mt7621-pci/pci-mt7621.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
> b/drivers/staging/mt7621-pci/pci-mt7621.c
> index 1fa41eb8a87f..8072b817b4e0 100644
> --- a/drivers/staging/mt7621-pci/pci-mt7621.c
> +++ b/drivers/staging/mt7621-pci/pci-mt7621.c
> @@ -827,7 +827,6 @@ static struct platform_driver mt7621_pci_driver = {
>   .probe = mt7621_pci_probe,
>   .driver = {
>   .name = "mt7621-pci",
> - .owner = THIS_MODULE,
>   .of_match_table = of_match_ptr(mt7621_pci_ids),
>   },
>  };
> -- 
> 2.16.1


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


Re: [PATCH] staging: mt7621-pinctrl: Remove redundant owner assignment

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> Remove the owner assignment form the platform driver as
> platform_driver_register() already initializes the owner.
> Found using coccinelle.
>
> Signed-off-by: Christian Lütke-Stetzkamp 

Reviewed-by: NeilBrown 

Thanks,
NeilBrown

> ---
>  drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c 
> b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> index 3d2d1c2a006f..2d9ab2620b82 100644
> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> @@ -459,7 +459,6 @@ static struct platform_driver rt2880_pinmux_driver = {
>   .probe = rt2880_pinmux_probe,
>   .driver = {
>   .name = "rt2880-pinmux",
> - .owner = THIS_MODULE,
>   .of_match_table = rt2880_pinmux_match,
>   },
>  };
> -- 
> 2.16.1


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


Re: [PATCH] staging: mt7621-spi: Remove redundant owner assignment

2018-04-20 Thread NeilBrown
On Wed, Apr 18 2018, Christian Lütke-Stetzkamp wrote:

> Remove the owner assignment form the platform driver as
> platform_driver_register() already initializes the owner.
> Found using coccinelle.
>
> Signed-off-by: Christian Lütke-Stetzkamp 

Reviewed-by: NeilBrown 

Thanks,
NeilBrown


> ---
>  drivers/staging/mt7621-spi/spi-mt7621.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c 
> b/drivers/staging/mt7621-spi/spi-mt7621.c
> index d95e0b32f1f0..d9b55d2059b0 100644
> --- a/drivers/staging/mt7621-spi/spi-mt7621.c
> +++ b/drivers/staging/mt7621-spi/spi-mt7621.c
> @@ -475,7 +475,6 @@ MODULE_ALIAS("platform:" DRIVER_NAME);
>  static struct platform_driver mt7621_spi_driver = {
>   .driver = {
>   .name = DRIVER_NAME,
> - .owner = THIS_MODULE,
>   .of_match_table = mt7621_spi_match,
>   },
>   .probe = mt7621_spi_probe,
> -- 
> 2.16.1


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


Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread Richard Cochran
On Thu, Apr 19, 2018 at 01:40:08PM +0300, Dan Carpenter wrote:
> This driver seems nice and so far as I can see it doesn't need to be in
> staging once we get the other parts merged.

Please explain how this unit ties in with the MAC units.

Thanks,
Richard


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


Re: [PATCH v2] storvsc: Set up correct queue depth values for IDE devices

2018-04-20 Thread Martin K. Petersen

Long,

> If num_cpus=1, we don't have any sub channels.
>
> The host offers one sub channel for VM with 5 CPUs, after that it offers
> an additional sub channel every 4 CPUs.
>
> The primary channel is always offered.

Applied to 4.17/scsi-fixes. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Patch v2] Storvsc: Select channel based on available percentage of ring buffer to write

2018-04-20 Thread Martin K. Petersen

Long,

> This is a best effort for estimating on how busy the ring buffer is
> for that channel, based on available buffer to write in percentage. It
> is still possible that at the time of actual ring buffer write, the
> space may not be available due to other processes may be writing at
> the time.
>
> Selecting a channel based on how full it is can reduce the possibility
> that a ring buffer write will fail, and avoid the situation a channel
> is over busy.
>
> Now it's possible that storvsc can use a smaller ring buffer size
> (e.g. 40k bytes) to take advantage of cache locality.

Applied to 4.18/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/13] staging: iio: ad2s1200: Add scaling factor for angle channel

2018-04-20 Thread David Veenstra
A fractional scaling factor of approximately 2 * Pi / (2^12 -1) is added,
to scale the 12-bits angular position to radians.

Signed-off-by: David Veenstra 
---
Changes in v2:
  - This patch replaces the patch that changed the
the channel for angular position to inclination
channel.

 drivers/staging/iio/resolver/ad2s1200.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 6c56257be3b1..4f5dd28b174a 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -71,6 +71,17 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
+   case IIO_ANGL:
+   /*
+* 2 * Pi / (2^12 - 1) ~= 2 * 103993 / (33102 * 0xFFF)
+*
+* Since there only fit 3 whole radians in 360 degrees,
+* usage of iio_convert_raw_to_processed for this
+* channel will be highly inaccurate.
+*/
+   *val = 103993;
+   *val2 = 16551 * 0xFFF;
+   return IIO_VAL_FRACTIONAL;
case IIO_ANGL_VEL:
/*
 * 2 * Pi ~= 2 * 103993 / 33102
@@ -133,6 +144,7 @@ static const struct iio_chan_spec ad2s1200_channels[] = {
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
}, {
.type = IIO_ANGL_VEL,
.indexed = 1,
-- 
2.16.2

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


[PATCH v2 13/13] staging: iio: ad2s1200: Move driver out of staging

2018-04-20 Thread David Veenstra
Move the iio driver for the ad2s1200 resolver-to-digital
converter out of staging, into mainline iio subsystems.

Signed-off-by: David Veenstra 
---
Changes in v2:
  - Added commit message.
  - Also move device tree binding documentation out of staging.
  - Disabled move detection.

 .../devicetree/bindings/iio/resolver/ad2s1200.txt  |  16 ++
 .../bindings/staging/iio/resolver/ad2s1200.txt |  16 --
 drivers/iio/Kconfig|   1 +
 drivers/iio/Makefile   |   1 +
 drivers/iio/resolver/Kconfig   |  17 ++
 drivers/iio/resolver/Makefile  |   5 +
 drivers/iio/resolver/ad2s1200.c| 250 +
 drivers/staging/iio/resolver/Kconfig   |  12 -
 drivers/staging/iio/resolver/Makefile  |   1 -
 drivers/staging/iio/resolver/ad2s1200.c| 250 -
 10 files changed, 290 insertions(+), 279 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
 delete mode 100644 
Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt
 create mode 100644 drivers/iio/resolver/Kconfig
 create mode 100644 drivers/iio/resolver/Makefile
 create mode 100644 drivers/iio/resolver/ad2s1200.c
 delete mode 100644 drivers/staging/iio/resolver/ad2s1200.c

diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt 
b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
new file mode 100644
index ..85c009987878
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
@@ -0,0 +1,16 @@
+Analog Devices AD2S1200 Resolver-to-Digital Converter
+
+Required properties:
+ - compatible : should be "adi,ad2s1200"
+ - reg : the SPI chip select number of the device
+ - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200
+ - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200
+
+Example:
+
+   resolver {
+   compatible = "adi,ad2s1200";
+   reg = <4>;
+   sample-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   rdvel-gpios = < 6 GPIO_ACTIVE_HIGH>;
+   };
diff --git 
a/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt 
b/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt
deleted file mode 100644
index 85c009987878..
--- a/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Analog Devices AD2S1200 Resolver-to-Digital Converter
-
-Required properties:
- - compatible : should be "adi,ad2s1200"
- - reg : the SPI chip select number of the device
- - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200
- - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200
-
-Example:
-
-   resolver {
-   compatible = "adi,ad2s1200";
-   reg = <4>;
-   sample-gpios = < 5 GPIO_ACTIVE_HIGH>;
-   rdvel-gpios = < 6 GPIO_ACTIVE_HIGH>;
-   };
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index b3c8c6ef0dff..4bec3ccbf4a1 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -92,6 +92,7 @@ source "drivers/iio/potentiometer/Kconfig"
 source "drivers/iio/potentiostat/Kconfig"
 source "drivers/iio/pressure/Kconfig"
 source "drivers/iio/proximity/Kconfig"
+source "drivers/iio/resolver/Kconfig"
 source "drivers/iio/temperature/Kconfig"
 
 endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index b16b2e9ddc40..1865361b8714 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -35,5 +35,6 @@ obj-y += potentiometer/
 obj-y += potentiostat/
 obj-y += pressure/
 obj-y += proximity/
+obj-y += resolver/
 obj-y += temperature/
 obj-y += trigger/
diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig
new file mode 100644
index ..2ced9f22aa70
--- /dev/null
+++ b/drivers/iio/resolver/Kconfig
@@ -0,0 +1,17 @@
+#
+# Resolver/Synchro drivers
+#
+menu "Resolver to digital converters"
+
+config AD2S1200
+   tristate "Analog Devices ad2s1200/ad2s1205 driver"
+   depends on SPI
+   depends on GPIOLIB || COMPILE_TEST
+   help
+ Say yes here to build support for Analog Devices spi resolver
+ to digital converters, ad2s1200 and ad2s1205, provides direct access
+ via sysfs.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ad2s1200.
+endmenu
diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile
new file mode 100644
index ..4e1dccae07e7
--- /dev/null
+++ b/drivers/iio/resolver/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for Resolver/Synchro drivers
+#
+
+obj-$(CONFIG_AD2S1200) += ad2s1200.o
diff --git a/drivers/iio/resolver/ad2s1200.c b/drivers/iio/resolver/ad2s1200.c
new file mode 100644
index ..4f5dd28b174a
--- /dev/null
+++ 

[PATCH v2 08/13] staging: iio: ad2s1200: Replace legacy gpio API with modern API

2018-04-20 Thread David Veenstra
The legacy, integer based gpio API is replaced with the descriptor
based API.

For compatibility, it is first tried to use the platform data to
request the gpio's. Otherwise, it looks for the "sample" and "rdvel"
gpio function.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 51 -
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 11ed9c7332e6..29a9bb666e7b 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -44,8 +45,8 @@
 struct ad2s1200_state {
struct mutex lock;
struct spi_device *sdev;
-   int sample;
-   int rdvel;
+   struct gpio_desc *sample;
+   struct gpio_desc *rdvel;
u8 rx[2] cacheline_aligned;
 };
 
@@ -60,12 +61,12 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
u16 vel;
 
mutex_lock(>lock);
-   gpio_set_value(st->sample, 0);
+   gpiod_set_value(st->sample, 0);
 
/* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
udelay(1);
-   gpio_set_value(st->sample, 1);
-   gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+   gpiod_set_value(st->sample, 1);
+   gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
 
ret = spi_read(st->sdev, st->rx, 2);
if (ret < 0) {
@@ -121,13 +122,18 @@ static int ad2s1200_probe(struct spi_device *spi)
 
dev = >dev;
 
-   for (pn = 0; pn < AD2S1200_PN; pn++) {
-   ret = devm_gpio_request_one(dev, pins[pn], GPIOF_DIR_OUT,
-   DRV_NAME);
-   if (ret) {
-   dev_err(dev, "request gpio pin %d failed\n",
-   pins[pn]);
-   return ret;
+   if (pins) {
+   for (pn = 0; pn < AD2S1200_PN; pn++) {
+   ret = devm_gpio_request_one(dev, pins[pn],
+   GPIOF_DIR_OUT,
+   DRV_NAME);
+   if (ret) {
+   dev_err(dev,
+   "Failed to claim gpio %d\n: err=%d",
+   pins[pn],
+   ret);
+   return ret;
+   }
}
}
 
@@ -139,8 +145,25 @@ static int ad2s1200_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
mutex_init(>lock);
st->sdev = spi;
-   st->sample = pins[0];
-   st->rdvel = pins[1];
+
+   if (pins) {
+   st->sample = gpio_to_desc(pins[0]);
+   st->rdvel = gpio_to_desc(pins[1]);
+   } else {
+   st->sample = devm_gpiod_get(dev, "sample", GPIOD_OUT_LOW);
+   if (IS_ERR(st->sample)) {
+   dev_err(dev, "Failed to claim SAMPLE gpio: err=%ld\n",
+   PTR_ERR(st->sample));
+   return PTR_ERR(st->sample);
+   }
+
+   st->rdvel = devm_gpiod_get(dev, "rdvel", GPIOD_OUT_LOW);
+   if (IS_ERR(st->rdvel)) {
+   dev_err(dev, "Failed to claim RDVEL gpio: err=%ld\n",
+   PTR_ERR(st->rdvel));
+   return PTR_ERR(st->rdvel);
+   }
+   }
 
indio_dev->dev.parent = dev;
indio_dev->info = _info;
-- 
2.16.2

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


[PATCH v2 09/13] staging: iio: ad2s1200: Add documentation for device tree binding

2018-04-20 Thread David Veenstra
Add documentation for the added device tree bindings.

Signed-off-by: David Veenstra 
---
Changes in v2:
  - Introduced in this version.

 .../bindings/staging/iio/resolver/ad2s1200.txt   | 16 
 1 file changed, 16 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt

diff --git 
a/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt 
b/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt
new file mode 100644
index ..85c009987878
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/resolver/ad2s1200.txt
@@ -0,0 +1,16 @@
+Analog Devices AD2S1200 Resolver-to-Digital Converter
+
+Required properties:
+ - compatible : should be "adi,ad2s1200"
+ - reg : the SPI chip select number of the device
+ - sample-gpios : The GPIO pin connected to the SAMPLE line of the AD2S1200
+ - rdvel-gpios : The GPIO pin connected to the RDVEL line of the AD2S1200
+
+Example:
+
+   resolver {
+   compatible = "adi,ad2s1200";
+   reg = <4>;
+   sample-gpios = < 5 GPIO_ACTIVE_HIGH>;
+   rdvel-gpios = < 6 GPIO_ACTIVE_HIGH>;
+   };
-- 
2.16.2

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


[PATCH v2 11/13] staging: iio: Documentation: Add missing sysfs docs for angle channel

2018-04-20 Thread David Veenstra
The iio resolver drivers in staging use angle channels. This patch
add missing documentation for this type of channel.

As was discussed in [1], radians is chosen as the unit, to match the
unit of angular velocity.

[1] https://marc.info/?l=linux-driver-devel=152190078308330=2

Signed-off-by: David Veenstra 
---
Change in v2:
  - Introduces in this version.

 Documentation/ABI/testing/sysfs-bus-iio | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio 
b/Documentation/ABI/testing/sysfs-bus-iio
index 6a5f34b4d5b9..8ad0e55f99ee 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -190,6 +190,15 @@ Description:
but should match other such assignments on device).
Units after application of scale and offset are m/s^2.
 
+What:  /sys/bus/iio/devices/iio:deviceX/in_angl_x_raw
+What:  /sys/bus/iio/devices/iio:deviceX/in_angl_y_raw
+What:  /sys/bus/iio/devices/iio:deviceX/in_angl_z_raw
+KernelVersion: 4.17
+Contact:   linux-...@vger.kernel.org
+Description:
+   Angle about axis x, y or z (may be arbitrarily assigned). Units
+   after application of scale and offset are radians.
+
 What:  /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
 What:  /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
 What:  /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
@@ -297,6 +306,7 @@ What:   
/sys/bus/iio/devices/iio:deviceX/in_pressure_offset
 What:  /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset
 What:  /sys/bus/iio/devices/iio:deviceX/in_magn_offset
 What:  /sys/bus/iio/devices/iio:deviceX/in_rot_offset
+What:  /sys/bus/iio/devices/iio:deviceX/in_angl_offset
 KernelVersion: 2.6.35
 Contact:   linux-...@vger.kernel.org
 Description:
@@ -350,6 +360,7 @@ What:   
/sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale
 What:  
/sys/bus/iio/devices/iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_scale
 What:  /sys/bus/iio/devices/iio:deviceX/in_illuminance_scale
 What:  /sys/bus/iio/devices/iio:deviceX/in_countY_scale
+What:  /sys/bus/iio/devices/iio:deviceX/in_angl_scale
 KernelVersion: 2.6.35
 Contact:   linux-...@vger.kernel.org
 Description:
-- 
2.16.2

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


[PATCH v2 07/13] staging: iio: ad2s1200: Improve readability with be16_to_cpup

2018-04-20 Thread David Veenstra
The manual states that the data is contained in the upper 12 bits
of the 16 bits read by spi. The code that extracts these 12 bits
is correct for both be and le machines, but this is not clear
from a first glance.

To improve readability the relevant expressions are replaced
with equivalent expressions that use be16_to_cpup.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 0a5fc9917e32..11ed9c7332e6 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -57,7 +57,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
 {
struct ad2s1200_state *st = iio_priv(indio_dev);
int ret = 0;
-   s16 vel;
+   u16 vel;
 
mutex_lock(>lock);
gpio_set_value(st->sample, 0);
@@ -73,14 +73,13 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
return ret;
}
 
+   vel = be16_to_cpup((__be16 *)st->rx);
switch (chan->type) {
case IIO_ANGL:
-   *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
+   *val = vel >> 4;
break;
case IIO_ANGL_VEL:
-   vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
-   vel = sign_extend32(vel, 11);
-   *val = vel;
+   *val = sign_extend32((s16)vel >> 4, 11);
break;
default:
mutex_unlock(>lock);
-- 
2.16.2

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


[PATCH v2 10/13] staging: iio: ad2s1200: Add scaling factor for angular velocity channel

2018-04-20 Thread David Veenstra
The sysfs iio ABI states radians per second is expected as the unit for
angular velocity, but the 12-bit angular velocity register has rps
as its unit. So a fractional scaling factor of approximately 2 * Pi is
added to the angular velocity channel.

The added comments will also be relevant for the scaling factor of
the angle channel.

Signed-off-by: David Veenstra 
---
Changes in v2:
  - Move explanation of Pi approximation to top of switch statement,
as this will also be relevant to angle channel.
  - Replaced 33102 / 2 with 16551 on line 84.

 drivers/staging/iio/resolver/ad2s1200.c | 84 +++--
 1 file changed, 59 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 29a9bb666e7b..6c56257be3b1 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -60,38 +60,71 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
int ret = 0;
u16 vel;
 
-   mutex_lock(>lock);
-   gpiod_set_value(st->sample, 0);
+   /*
+* Below a fractional approximation of Pi is needed.
+* The following approximation will be used: 103993 / 33102.
+* This is accurate in 9 decimals places.
+*
+* This fraction is based on OEIS series of nominator/denominator
+* of convergents to Pi (A002485 and A002486).
+*/
+   switch (m) {
+   case IIO_CHAN_INFO_SCALE:
+   switch (chan->type) {
+   case IIO_ANGL_VEL:
+   /*
+* 2 * Pi ~= 2 * 103993 / 33102
+*
+* iio_convert_raw_to_processed uses integer
+* division. This will cause at most 5% error
+* (for very small values). But for 99.5% of the values
+* it will cause less that 1% error.
+*/
+   *val = 103993;
+   *val2 = 16551;
+   return IIO_VAL_FRACTIONAL;
+   default:
+   return -EINVAL;
+   }
+   break;
+   case IIO_CHAN_INFO_RAW:
+   mutex_lock(>lock);
+   gpiod_set_value(st->sample, 0);
+
+   /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
+   udelay(1);
+   gpiod_set_value(st->sample, 1);
+   gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+
+   ret = spi_read(st->sdev, st->rx, 2);
+   if (ret < 0) {
+   mutex_unlock(>lock);
+   return ret;
+   }
 
-   /* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
-   udelay(1);
-   gpiod_set_value(st->sample, 1);
-   gpiod_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+   vel = be16_to_cpup((__be16 *)st->rx);
+   switch (chan->type) {
+   case IIO_ANGL:
+   *val = vel >> 4;
+   break;
+   case IIO_ANGL_VEL:
+   *val = sign_extend32((s16)vel >> 4, 11);
+   break;
+   default:
+   mutex_unlock(>lock);
+   return -EINVAL;
+   }
 
-   ret = spi_read(st->sdev, st->rx, 2);
-   if (ret < 0) {
+   /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
+   udelay(1);
mutex_unlock(>lock);
-   return ret;
-   }
 
-   vel = be16_to_cpup((__be16 *)st->rx);
-   switch (chan->type) {
-   case IIO_ANGL:
-   *val = vel >> 4;
-   break;
-   case IIO_ANGL_VEL:
-   *val = sign_extend32((s16)vel >> 4, 11);
-   break;
+   return IIO_VAL_INT;
default:
-   mutex_unlock(>lock);
-   return -EINVAL;
+   break;
}
 
-   /* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
-   udelay(1);
-   mutex_unlock(>lock);
-
-   return IIO_VAL_INT;
+   return -EINVAL;
 }
 
 static const struct iio_chan_spec ad2s1200_channels[] = {
@@ -105,6 +138,7 @@ static const struct iio_chan_spec ad2s1200_channels[] = {
.indexed = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
}
 };
 
-- 
2.16.2

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


[PATCH v2 06/13] staging: iio: ad2s1200: Introduce variable for repeated value

2018-04-20 Thread David Veenstra
Add variable to hold >dev in ad2s1200_probe. This value is repeatedly
used in ad2s1200_probe.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index f07aab7e7a35..0a5fc9917e32 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -117,19 +117,22 @@ static int ad2s1200_probe(struct spi_device *spi)
unsigned short *pins = spi->dev.platform_data;
struct ad2s1200_state *st;
struct iio_dev *indio_dev;
+   struct device *dev;
int pn, ret = 0;
 
+   dev = >dev;
+
for (pn = 0; pn < AD2S1200_PN; pn++) {
-   ret = devm_gpio_request_one(>dev, pins[pn], GPIOF_DIR_OUT,
+   ret = devm_gpio_request_one(dev, pins[pn], GPIOF_DIR_OUT,
DRV_NAME);
if (ret) {
-   dev_err(>dev, "request gpio pin %d failed\n",
+   dev_err(dev, "request gpio pin %d failed\n",
pins[pn]);
return ret;
}
}
 
-   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
+   indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
 
@@ -140,14 +143,14 @@ static int ad2s1200_probe(struct spi_device *spi)
st->sample = pins[0];
st->rdvel = pins[1];
 
-   indio_dev->dev.parent = >dev;
+   indio_dev->dev.parent = dev;
indio_dev->info = _info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ad2s1200_channels;
indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
indio_dev->name = spi_get_device_id(spi)->name;
 
-   ret = devm_iio_device_register(>dev, indio_dev);
+   ret = devm_iio_device_register(dev, indio_dev);
if (ret)
return ret;
 
-- 
2.16.2

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


[PATCH v2 05/13] staging: iio: ad2s1200: Add kernel docs to driver state

2018-04-20 Thread David Veenstra
Add missing kernel docs to the ad2s1200 driver state.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 357fe3c382b3..f07aab7e7a35 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -33,6 +33,14 @@
 /* clock period in nano second */
 #define AD2S1200_TSCLK (10 / AD2S1200_HZ)
 
+/**
+ * struct ad2s1200_state - driver instance specific data
+ * @lock:  protect driver state
+ * @sdev:  spi device
+ * @sample:GPIO pin SAMPLE
+ * @rdvel: GPIO pin RDVEL
+ * @rx:buffer for spi transfers
+ */
 struct ad2s1200_state {
struct mutex lock;
struct spi_device *sdev;
-- 
2.16.2

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


[PATCH v2 04/13] staging: iio: ad2s1200: Add blank lines

2018-04-20 Thread David Veenstra
Add blank lines to improve readability.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index b6c3a3c8f7fe..357fe3c382b3 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
+
 #include 
 #include 
 #include 
@@ -52,10 +53,12 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
 
mutex_lock(>lock);
gpio_set_value(st->sample, 0);
+
/* delay (6 * AD2S1200_TSCLK + 20) nano seconds */
udelay(1);
gpio_set_value(st->sample, 1);
gpio_set_value(st->rdvel, !!(chan->type == IIO_ANGL));
+
ret = spi_read(st->sdev, st->rx, 2);
if (ret < 0) {
mutex_unlock(>lock);
@@ -75,9 +78,11 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
mutex_unlock(>lock);
return -EINVAL;
}
+
/* delay (2 * AD2S1200_TSCLK + 20) ns for sample pulse */
udelay(1);
mutex_unlock(>lock);
+
return IIO_VAL_INT;
 }
 
@@ -115,9 +120,11 @@ static int ad2s1200_probe(struct spi_device *spi)
return ret;
}
}
+
indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
+
spi_set_drvdata(spi, indio_dev);
st = iio_priv(indio_dev);
mutex_init(>lock);
-- 
2.16.2

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


[PATCH v2 01/13] staging: iio: ad2s1200: Remove unneeded include

2018-04-20 Thread David Veenstra
This patches removes unneeded slab.h header.

Signed-off-by: David Veenstra 
---
Changes in v2:
  - Introduced in this version.

drivers/staging/iio/resolver/ad2s1200.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index aa62c64e9bc4..5d7ed0034422 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.16.2

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


[PATCH v2 03/13] staging: iio: ad2s1200: Reverse Christmas tree ordering

2018-04-20 Thread David Veenstra
Reorders the variable declarations to prefer a reverse Christmas tree
order to improve readability.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index ffcdf4e8eb92..b6c3a3c8f7fe 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -46,9 +46,9 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
 int *val2,
 long m)
 {
+   struct ad2s1200_state *st = iio_priv(indio_dev);
int ret = 0;
s16 vel;
-   struct ad2s1200_state *st = iio_priv(indio_dev);
 
mutex_lock(>lock);
gpio_set_value(st->sample, 0);
@@ -101,10 +101,10 @@ static const struct iio_info ad2s1200_info = {
 
 static int ad2s1200_probe(struct spi_device *spi)
 {
+   unsigned short *pins = spi->dev.platform_data;
struct ad2s1200_state *st;
struct iio_dev *indio_dev;
int pn, ret = 0;
-   unsigned short *pins = spi->dev.platform_data;
 
for (pn = 0; pn < AD2S1200_PN; pn++) {
ret = devm_gpio_request_one(>dev, pins[pn], GPIOF_DIR_OUT,
-- 
2.16.2

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


[PATCH v2 02/13] staging: iio: ad2s1200: Sort includes alphabetically

2018-04-20 Thread David Veenstra
This patches sorts all the includes in alphabetic order.

Signed-off-by: David Veenstra 
---
 drivers/staging/iio/resolver/ad2s1200.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1200.c 
b/drivers/staging/iio/resolver/ad2s1200.c
index 5d7ed0034422..ffcdf4e8eb92 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -9,15 +9,15 @@
  * published by the Free Software Foundation.
  *
  */
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
 #include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
-- 
2.16.2

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


[PATCH v2 00/13] staging: iio: ad2s1200: Driver clean up

2018-04-20 Thread David Veenstra
For v1 of the patch see [1].

A summary of this patch:
1. Clean up of minor code style issues
2. Replace legacy GPIO ABI with modern ABI
4. Add scaling factor for angular position and angular velocity to
   match the sysfs IIO ABI
5. Add documentation for device tree binding, and angle channel
6. Move driver to main line

Changes in v2:
- Removed an unneeded include
- Instead of using inclination channel for the angular position,
  use angle channel
- Added documentation for device tree binding, and sysfs IIO ABI
  documentation for angle channel

For the scaling factors, a fractional approximation of Pi is needed.
As in v1 of the patch, the fraction 103993 / 33102 was chosen, which is
based on the OEIS series of nominator/denominator of convergents to
Pi (A002485 and A002486). I have looked at the implementation of
iio_read_channel_info, and compared using the fraction above, with
the fraction and offset used in the IIO_DEGREE_TO_RAD in iio.h, and
found the first method to be more accurate for all possible 12-bit values,
as the error is neglible. Also it does not cause overflow.

In [2] Jonathan suggested to remove usage of platform data altogether,
and asked for Michael Hennerich opinion. Since Michael didn't weigh in,
I have left this how it was.

Best regards,
David Veenstra

[1] https://marc.info/?l=linux-iio=152137920426820=2
[2] https://marc.info/?l=linux-iio=152181140619243=2

David Veenstra (13):
  staging: iio: ad2s1200: Remove unneeded include
  staging: iio: ad2s1200: Sort includes alphabetically
  staging: iio: ad2s1200: Reverse Christmas tree ordering
  staging: iio: ad2s1200: Add blank lines
  staging: iio: ad2s1200: Add kernel docs to driver state
  staging: iio: ad2s1200: Introduce variable for repeated value
  staging: iio: ad2s1200: Improve readability with be16_to_cpup
  staging: iio: ad2s1200: Replace legacy gpio API with modern API
  staging: iio: ad2s1200: Add documentation for device tree binding
  staging: iio: ad2s1200: Add scaling factor for angular velocity
channel
  staging: iio: Documentation: Add missing sysfs docs for angle channel
  staging: iio: ad2s1200: Add scaling factor for angle channel
  staging: iio: ad2s1200: Move driver out of staging

 Documentation/ABI/testing/sysfs-bus-iio|  11 +
 .../devicetree/bindings/iio/resolver/ad2s1200.txt  |  16 ++
 drivers/iio/Kconfig|   1 +
 drivers/iio/Makefile   |   1 +
 drivers/iio/resolver/Kconfig   |  17 ++
 drivers/iio/resolver/Makefile  |   5 +
 drivers/iio/resolver/ad2s1200.c| 250 +
 drivers/staging/iio/resolver/Kconfig   |  12 -
 drivers/staging/iio/resolver/Makefile  |   1 -
 drivers/staging/iio/resolver/ad2s1200.c| 165 --
 10 files changed, 301 insertions(+), 178 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s1200.txt
 create mode 100644 drivers/iio/resolver/Kconfig
 create mode 100644 drivers/iio/resolver/Makefile
 create mode 100644 drivers/iio/resolver/ad2s1200.c
 delete mode 100644 drivers/staging/iio/resolver/ad2s1200.c

-- 
2.16.2

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


Re: [PATCH 0/8] arm: renesas: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Mark Brown
On Fri, Apr 20, 2018 at 03:28:26PM +0200, Geert Uytterhoeven wrote:

> The first 6 patches can be applied independently by subsystem
> maintainers.
> The last two patches depend on the first 6 patches, and are thus marked
> RFC.

Would it not make sense to try to apply everything en masse rather than
delaying?  I'm happy to apply the subsystem stuff but if it gets things
done quicker or more efficiently I'm also happy to have the lot merged
as one series.


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


Re: [Patch v2] Storvsc: Select channel based on available percentage of ring buffer to write

2018-04-20 Thread Stephen Hemminger
On Thu, 19 Apr 2018 14:54:24 -0700
Long Li  wrote:

> From: Long Li 
> 
> This is a best effort for estimating on how busy the ring buffer is for
> that channel, based on available buffer to write in percentage. It is still
> possible that at the time of actual ring buffer write, the space may not be
> available due to other processes may be writing at the time.
> 
> Selecting a channel based on how full it is can reduce the possibility that
> a ring buffer write will fail, and avoid the situation a channel is over
> busy.
> 
> Now it's possible that storvsc can use a smaller ring buffer size
> (e.g. 40k bytes) to take advantage of cache locality.
> 
> Changes.
> v2: Pre-allocate struct cpumask on the heap.
> Struct cpumask is a big structure (1k bytes) when CONFIG_NR_CPUS=8192 (default
> value when CONFIG_MAXSMP=y). Don't use kernel stack for it by pre-allocating
> them using kmalloc when channels are first initialized.
> 
> Signed-off-by: Long Li 

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


Re: [PATCH 4/8] sh_eth: Change platform check to CONFIG_ARCH_RENESAS

2018-04-20 Thread Sergei Shtylyov
On 04/20/2018 04:28 PM, Geert Uytterhoeven wrote:

> Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
> is CONFIG_ARCH_RENESAS a more appropriate platform check than the legacy
> CONFIG_ARCH_SHMOBILE, hence use the former.
> 
> Renesas SuperH SH-Mobile SoCs are still covered by the CONFIG_CPU_SH4
> check.
> 
> This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
> future.
> 
> Signed-off-by: Geert Uytterhoeven 
[...]

Acked-by: Sergei Shtylyov 

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


Re: [PATCH 1/8] arm: shmobile: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Sergei Shtylyov
On 04/20/2018 04:28 PM, Geert Uytterhoeven wrote:

> Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
> is ARCH_RENESAS a more appropriate platform dependency than the legacy

   "ARCH_RENESAS is", no?

> ARCH_SHMOBILE, hence use the former.
> 
> This will allow to drop ARCH_SHMOBILE on ARM in the near future.
> 
> Signed-off-by: Geert Uytterhoeven 
[...]

MBR, Sergei

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


Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread kbuild test robot
Hi Yangbo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.17-rc1 next-20180420]
[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/Yangbo-Lu/staging-fsl-dpaa2-rtc-add-rtc-driver/20180420-190320
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/staging/fsl-dpaa2/rtc/rtc.c:130:15: error: initialization from 
>> incompatible pointer type [-Werror=incompatible-pointer-types]
 .gettime64 = ptp_dpaa2_gettime,
  ^
   drivers/staging/fsl-dpaa2/rtc/rtc.c:130:15: note: (near initialization for 
'ptp_dpaa2_caps.gettime64')
   drivers/staging/fsl-dpaa2/rtc/rtc.c:131:15: error: initialization from 
incompatible pointer type [-Werror=incompatible-pointer-types]
 .settime64 = ptp_dpaa2_settime,
  ^
   drivers/staging/fsl-dpaa2/rtc/rtc.c:131:15: note: (near initialization for 
'ptp_dpaa2_caps.settime64')
   cc1: some warnings being treated as errors

vim +130 drivers/staging/fsl-dpaa2/rtc/rtc.c

   118  
   119  static struct ptp_clock_info ptp_dpaa2_caps = {
   120  .owner  = THIS_MODULE,
   121  .name   = "DPAA2 PTP Clock",
   122  .max_adj= 512000,
   123  .n_alarm= 2,
   124  .n_ext_ts   = 2,
   125  .n_per_out  = 3,
   126  .n_pins = 0,
   127  .pps= 1,
   128  .adjfreq= ptp_dpaa2_adjfreq,
   129  .adjtime= ptp_dpaa2_adjtime,
 > 130  .gettime64  = ptp_dpaa2_gettime,
   131  .settime64  = ptp_dpaa2_settime,
   132  };
   133  

---
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 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread kbuild test robot
Hi Yangbo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.17-rc1 next-20180420]
[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/Yangbo-Lu/staging-fsl-dpaa2-rtc-add-rtc-driver/20180420-190320
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:43:30: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned int [unsigned] 
>> [usertype] dprtc_id @@got ed int [unsigned] [usertype] dprtc_id @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:43:30:expected unsigned int 
[unsigned] [usertype] dprtc_id
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:43:30:got restricted __le32 
[usertype] 
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:155:31: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned int [unsigned] 
>> [usertype] object_id @@got ed int [unsigned] [usertype] object_id @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:155:31:expected unsigned int 
[unsigned] [usertype] object_id
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:155:31:got restricted __le32 
[usertype] 
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:369:26: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned int [unsigned] 
>> [usertype] mask @@got ed int [unsigned] [usertype] mask @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:369:26:expected unsigned int 
[unsigned] [usertype] mask
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:369:26:got restricted __le32 
[usertype] 
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:414:17: sparse: cast to restricted 
>> __le32
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:448:28: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned int [unsigned] 
>> [usertype] status @@got ed int [unsigned] [usertype] status @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:448:28:expected unsigned int 
[unsigned] [usertype] status
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:448:28:got restricted __le32 
[usertype] 
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:491:28: sparse: incorrect type in 
assignment (different base types) @@expected unsigned int [unsigned] 
[usertype] status @@got ed int [unsigned] [usertype] status @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:491:28:expected unsigned int 
[unsigned] [usertype] status
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:491:28:got restricted __le32 
[usertype] 
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:528:20: sparse: cast to restricted 
__le32
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:557:28: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned long long 
>> [unsigned] [usertype] offset @@got g long [unsigned] [usertype] offset @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:557:28:expected unsigned long long 
[unsigned] [usertype] offset
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:557:28:got restricted __le64 
[usertype] 
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:586:39: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned int [unsigned] 
>> [usertype] freq_compensation @@got ed int [unsigned] [usertype] 
>> freq_compensation @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:586:39:expected unsigned int 
[unsigned] [usertype] freq_compensation
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:586:39:got restricted __le32 
[usertype] 
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:623:30: sparse: cast to restricted 
__le32
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:659:17: sparse: cast to restricted 
>> __le64
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:687:26: sparse: incorrect type in 
>> assignment (different base types) @@expected unsigned long long 
>> [unsigned] [usertype] time @@got g long [unsigned] [usertype] time @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:687:26:expected unsigned long long 
[unsigned] [usertype] time
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:687:26:got restricted __le64 
[usertype] 
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:717:26: sparse: incorrect type in 
assignment (different base types) @@expected unsigned long long [unsigned] 
[usertype] time @@got g long [unsigned] [usertype] time @@
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:717:26:expected unsigned long long 
[unsigned] [usertype] time
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:717:26:got restricted __le64 
[usertype] 
>> drivers/staging/fsl-dpaa2/rtc/dprtc.c:750:22: sparse: cast to restricted 
>> __le16
   drivers/staging/fsl-dpaa2/rtc/dprtc.c:751:22: spa

Re: [PATCH 0/8] arm: renesas: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Arnd Bergmann
On Fri, Apr 20, 2018 at 3:28 PM, Geert Uytterhoeven
 wrote:
> Hi all,
>
> Commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
> started the conversion from ARCH_SHMOBILE to ARCH_RENESAS for Renesas
> ARM SoCs.  This patch series completes the conversion, by:
>   1. Updating dependencies for drivers that weren't converted yet,
>   2. Removing the ARCH_SHMOBILE Kconfig symbols on ARM and ARM64.
>
> The first 6 patches can be applied independently by subsystem
> maintainers.
> The last two patches depend on the first 6 patches, and are thus marked
> RFC.

This all looks fine to me.

Acked-by: Arnd Bergmann 

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


the photo studio

2018-04-20 Thread Harry

How are you doing today?

We have not heard from you yet. Are you still interested in our photo
retouching services?
We mainly do: ecommerce products photo editing, jewelry photos retouching,
beauty retouching,
wedding photo editing, and photo cutting out, clipping path

You may choose to send us a photo for testing which you can check our
quality.

Thanks,
Harry

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


[PATCH 1/8] arm: shmobile: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
is ARCH_RENESAS a more appropriate platform dependency than the legacy
ARCH_SHMOBILE, hence use the former.

This will allow to drop ARCH_SHMOBILE on ARM in the near future.

Signed-off-by: Geert Uytterhoeven 
---
 arch/arm/Kconfig  | 2 +-
 arch/arm/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7f8e7f4b88fdd03..2d34c0a44877e85b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1467,7 +1467,7 @@ config ARM_PSCI
 config ARCH_NR_GPIO
int
default 2048 if ARCH_SOCFPGA
-   default 1024 if ARCH_BRCMSTB || ARCH_SHMOBILE || ARCH_TEGRA || \
+   default 1024 if ARCH_BRCMSTB || ARCH_RENESAS || ARCH_TEGRA || \
ARCH_ZYNQ
default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || \
SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index e4e537f27339f7a1..a92f5a876d96839d 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -212,7 +212,7 @@ machine-$(CONFIG_ARCH_S3C24XX)  += s3c24xx
 machine-$(CONFIG_ARCH_S3C64XX) += s3c64xx
 machine-$(CONFIG_ARCH_S5PV210) += s5pv210
 machine-$(CONFIG_ARCH_SA1100)  += sa1100
-machine-$(CONFIG_ARCH_SHMOBILE)+= shmobile
+machine-$(CONFIG_ARCH_RENESAS) += shmobile
 machine-$(CONFIG_ARCH_SIRF)+= prima2
 machine-$(CONFIG_ARCH_SOCFPGA) += socfpga
 machine-$(CONFIG_ARCH_STI) += sti
-- 
2.7.4

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


[PATCH 4/8] sh_eth: Change platform check to CONFIG_ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
is CONFIG_ARCH_RENESAS a more appropriate platform check than the legacy
CONFIG_ARCH_SHMOBILE, hence use the former.

Renesas SuperH SH-Mobile SoCs are still covered by the CONFIG_CPU_SH4
check.

This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
future.

Signed-off-by: Geert Uytterhoeven 
---
 drivers/net/ethernet/renesas/sh_eth.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.h 
b/drivers/net/ethernet/renesas/sh_eth.h
index a5b792ce2ae7d046..1bf930d4a1e52c18 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -163,7 +163,7 @@ enum {
 };
 
 /* Driver's parameters */
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
+#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_RENESAS)
 #define SH_ETH_RX_ALIGN32
 #else
 #define SH_ETH_RX_ALIGN2
-- 
2.7.4

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


[PATCH/RFC 8/8] arm64: renesas: Remove the ARCH_SHMOBILE Kconfig symbol

2018-04-20 Thread Geert Uytterhoeven
The Kconfig symbol for Renesas 64-bit ARM SoCs has always been
ARCH_RENESAS, with ARCH_SHMOBILE being selected to reuse drivers shared
with Renesas 32-bit ARM and/or Renesas SuperH SH-Mobile SoCs.

Commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
started the conversion from ARCH_SHMOBILE to ARCH_RENESAS for Renesas
32-bit SoCs.  Now all drivers for Renesas ARM SoCs have gained proper
ARCH_RENESAS platform dependencies, there is no longer a need to select
ARCH_SHMOBILE.

With ARCH_SHMOBILE gone, move the ARCH_RENESAS section up, to restore
alphabetical sort order.

Signed-off-by: Geert Uytterhoeven 
---
This depends on the driver patches in this series, hence the RFC.

JFTR, after this, the following symbols for drivers supporting only
Renesas SuperH "SH-Mobile" SoCs can no longer be selected:
  - CONFIG_KEYBOARD_SH_KEYSC,
  - CONFIG_VIDEO_SH_VOU,
  - CONFIG_VIDEO_RENESAS_CEU,
  - CONFIG_FB_SH_MOBILE_MERAM.
(changes for a renesas_defconfig .config)
---
 arch/arm64/Kconfig.platforms | 42 +++---
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index d5aeac351fc3a776..49d8ed1ab84766dd 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -145,31 +145,8 @@ config ARCH_REALTEK
  This enables support for the ARMv8 based Realtek chipsets,
  like the RTD1295.
 
-config ARCH_ROCKCHIP
-   bool "Rockchip Platforms"
-   select ARCH_HAS_RESET_CONTROLLER
-   select GPIOLIB
-   select PINCTRL
-   select PINCTRL_ROCKCHIP
-   select ROCKCHIP_TIMER
-   help
- This enables support for the ARMv8 based Rockchip chipsets,
- like the RK3368.
-
-config ARCH_SEATTLE
-   bool "AMD Seattle SoC Family"
-   help
- This enables support for AMD Seattle SOC Family
-
-config ARCH_SHMOBILE
-   bool
-
-config ARCH_SYNQUACER
-   bool "Socionext SynQuacer SoC Family"
-
 config ARCH_RENESAS
bool "Renesas SoC Platforms"
-   select ARCH_SHMOBILE
select PINCTRL
select PM
select PM_GENERIC_DOMAINS
@@ -220,6 +197,25 @@ config ARCH_R8A77995
help
  This enables support for the Renesas R-Car D3 SoC.
 
+config ARCH_ROCKCHIP
+   bool "Rockchip Platforms"
+   select ARCH_HAS_RESET_CONTROLLER
+   select GPIOLIB
+   select PINCTRL
+   select PINCTRL_ROCKCHIP
+   select ROCKCHIP_TIMER
+   help
+ This enables support for the ARMv8 based Rockchip chipsets,
+ like the RK3368.
+
+config ARCH_SEATTLE
+   bool "AMD Seattle SoC Family"
+   help
+ This enables support for AMD Seattle SOC Family
+
+config ARCH_SYNQUACER
+   bool "Socionext SynQuacer SoC Family"
+
 config ARCH_STRATIX10
bool "Altera's Stratix 10 SoCFPGA Family"
help
-- 
2.7.4

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


[PATCH 3/8] [media] v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
The Renesas Fine Display Processor driver is used on Renesas R-Car SoCs
only.  Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce
ARCH_RENESAS") is ARCH_RENESAS a more appropriate platform dependency
than the legacy ARCH_SHMOBILE, hence use the former.

This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
future.

Signed-off-by: Geert Uytterhoeven 
---
 drivers/media/platform/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f9235e8f8e962d2e..7ad4725f9d1f9627 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -396,7 +396,7 @@ config VIDEO_SH_VEU
 config VIDEO_RENESAS_FDP1
tristate "Renesas Fine Display Processor"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
-   depends on ARCH_SHMOBILE || COMPILE_TEST
+   depends on ARCH_RENESAS || COMPILE_TEST
depends on (!ARCH_RENESAS && !VIDEO_RENESAS_FCP) || VIDEO_RENESAS_FCP
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
-- 
2.7.4

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


[PATCH 5/8] staging: emxx_udc: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
Emma Mobile is a Renesas ARM SoC.  Since commit 9b5ba0df4ea4f940 ("ARM:
shmobile: Introduce ARCH_RENESAS") is ARCH_RENESAS a more appropriate
platform dependency than the legacy ARCH_SHMOBILE, hence use the
former.

This will allow to drop ARCH_SHMOBILE on ARM in the near future.

Signed-off-by: Geert Uytterhoeven 
---
 drivers/staging/emxx_udc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/emxx_udc/Kconfig b/drivers/staging/emxx_udc/Kconfig
index d7577096fb25ae7a..e50e722183648c55 100644
--- a/drivers/staging/emxx_udc/Kconfig
+++ b/drivers/staging/emxx_udc/Kconfig
@@ -1,6 +1,6 @@
 config USB_EMXX
tristate "EMXX USB Function Device Controller"
-   depends on USB_GADGET && (ARCH_SHMOBILE || (ARM && COMPILE_TEST))
+   depends on USB_GADGET && (ARCH_RENESAS || (ARM && COMPILE_TEST))
help
   The Emma Mobile series of SoCs from Renesas Electronics and
   former NEC Electronics include USB Function hardware.
-- 
2.7.4

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


[PATCH 0/8] arm: renesas: Change platform dependency to ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
Hi all,

Commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
started the conversion from ARCH_SHMOBILE to ARCH_RENESAS for Renesas
ARM SoCs.  This patch series completes the conversion, by:
  1. Updating dependencies for drivers that weren't converted yet,
  2. Removing the ARCH_SHMOBILE Kconfig symbols on ARM and ARM64.

The first 6 patches can be applied independently by subsystem
maintainers.
The last two patches depend on the first 6 patches, and are thus marked
RFC.

Thanks for your comments!

Geert Uytterhoeven (8):
  arm: shmobile: Change platform dependency to ARCH_RENESAS
  dmaengine: shdmac: Change platform check to CONFIG_ARCH_RENESAS
  [media] v4l: rcar_fdp1: Change platform dependency to ARCH_RENESAS
  sh_eth: Change platform check to CONFIG_ARCH_RENESAS
  staging: emxx_udc: Change platform dependency to ARCH_RENESAS
  ASoC: sh: Update menu title and platform dependency
  [RFC] ARM: shmobile: Remove the ARCH_SHMOBILE Kconfig symbol
  [RFC] arm64: renesas: Remove the ARCH_SHMOBILE Kconfig symbol

 arch/arm/Kconfig  |  2 +-
 arch/arm/Makefile |  2 +-
 arch/arm/mach-shmobile/Kconfig|  4 ---
 arch/arm64/Kconfig.platforms  | 42 +
 drivers/dma/sh/shdmac.c   | 50 +++
 drivers/media/platform/Kconfig|  2 +-
 drivers/net/ethernet/renesas/sh_eth.h |  2 +-
 drivers/staging/emxx_udc/Kconfig  |  2 +-
 sound/soc/sh/Kconfig  |  4 +--
 9 files changed, 47 insertions(+), 63 deletions(-)

-- 
2.7.4

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/8] ASoC: sh: Update menu title and platform dependency

2018-04-20 Thread Geert Uytterhoeven
Change the menu title to refer to "Renesas SoCs" instead of "SuperH", as
both SuperH and ARM SoCs are supported.

Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
is ARCH_RENESAS a more appropriate platform dependency for Renesas ARM
SoCs than the legacy ARCH_SHMOBILE, hence use the former.
Renesas SuperH SH-Mobile SoCs are still covered by the SUPERH
dependency.

This will allow to drop ARCH_SHMOBILE on ARM and ARM64 in the near
future.

Signed-off-by: Geert Uytterhoeven 
---
 sound/soc/sh/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig
index 1aa5cd77ca24a06f..c1b7fb91e3063f2b 100644
--- a/sound/soc/sh/Kconfig
+++ b/sound/soc/sh/Kconfig
@@ -1,5 +1,5 @@
-menu "SoC Audio support for SuperH"
-   depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
+menu "SoC Audio support for Renesas SoCs"
+   depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
 
 config SND_SOC_PCM_SH7760
tristate "SoC Audio support for Renesas SH7760"
-- 
2.7.4

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


[PATCH/RFC 7/8] ARM: shmobile: Remove the ARCH_SHMOBILE Kconfig symbol

2018-04-20 Thread Geert Uytterhoeven
All drivers for Renesas ARM SoCs have gained proper ARCH_RENESAS
platform dependencies.  Hence finish the conversion from ARCH_SHMOBILE
to ARCH_RENESAS for Renesas 32-bit ARM SoCs, as started by commit
9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS").

Signed-off-by: Geert Uytterhoeven 
---
This depends on the previous patches in this series, hence the RFC.

JFTR, after this, the following symbols for drivers supporting only
Renesas SuperH "SH-Mobile" SoCs can no longer be selected:
  - CONFIG_KEYBOARD_SH_KEYSC,
  - CONFIG_VIDEO_SH_VOU,
  - CONFIG_VIDEO_SH_MOBILE_CEU,
  - CONFIG_DRM_SHMOBILE[*],
  - CONFIG_FB_SH_MOBILE_MERAM.
(changes for a shmobile_defconfig .config)

[*] CONFIG_DRM_SHMOBILE has a dependency on ARM, but it was never wired
up.  From the use of sh_mobile_meram, I guess it was meant for
SH-Mobile AP4 on Mackerel or AP4EVB, which are long gone.
So the only remaining upstream platforms that could make use of it
are legacy SuperH SH-Mobile SoCs?
---
 arch/arm/mach-shmobile/Kconfig | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 96672da02f5f17b9..d892c5b52b6f5627 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -1,6 +1,3 @@
-config ARCH_SHMOBILE
-   bool
-
 config PM_RMOBILE
bool
select PM
@@ -30,7 +27,6 @@ menuconfig ARCH_RENESAS
bool "Renesas ARM SoCs"
depends on ARCH_MULTI_V7 && MMU
select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
-   select ARCH_SHMOBILE
select ARM_GIC
select GPIOLIB
select HAVE_ARM_SCU if SMP
-- 
2.7.4

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


[PATCH 2/8] dmaengine: shdmac: Change platform check to CONFIG_ARCH_RENESAS

2018-04-20 Thread Geert Uytterhoeven
Since commit 9b5ba0df4ea4f940 ("ARM: shmobile: Introduce ARCH_RENESAS")
is CONFIG_ARCH_RENESAS a more appropriate platform check than the legacy
CONFIG_ARCH_SHMOBILE, hence use the former.

Renesas SuperH SH-Mobile SoCs are still covered by the CONFIG_CPU_SH4
check, just like before support for Renesas ARM SoCs was added.

Instead of blindly changing all the #ifdefs, switch the main code block
in sh_dmae_probe() to IS_ENABLED(), as this allows to remove all the
remaining #ifdefs.

This will allow to drop ARCH_SHMOBILE on ARM in the near future.

Signed-off-by: Geert Uytterhoeven 
---
 drivers/dma/sh/shdmac.c | 50 +
 1 file changed, 21 insertions(+), 29 deletions(-)

diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
index 516f5487cc44cf96..8fcaae482ce0949a 100644
--- a/drivers/dma/sh/shdmac.c
+++ b/drivers/dma/sh/shdmac.c
@@ -440,7 +440,6 @@ static bool sh_dmae_reset(struct sh_dmae_device *shdev)
return ret;
 }
 
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
 static irqreturn_t sh_dmae_err(int irq, void *data)
 {
struct sh_dmae_device *shdev = data;
@@ -451,7 +450,6 @@ static irqreturn_t sh_dmae_err(int irq, void *data)
sh_dmae_reset(shdev);
return IRQ_HANDLED;
 }
-#endif
 
 static bool sh_dmae_desc_completed(struct shdma_chan *schan,
   struct shdma_desc *sdesc)
@@ -683,11 +681,8 @@ static int sh_dmae_probe(struct platform_device *pdev)
const struct sh_dmae_pdata *pdata;
unsigned long chan_flag[SH_DMAE_MAX_CHANNELS] = {};
int chan_irq[SH_DMAE_MAX_CHANNELS];
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
unsigned long irqflags = 0;
-   int errirq;
-#endif
-   int err, i, irq_cnt = 0, irqres = 0, irq_cap = 0;
+   int err, errirq, i, irq_cnt = 0, irqres = 0, irq_cap = 0;
struct sh_dmae_device *shdev;
struct dma_device *dma_dev;
struct resource *chan, *dmars, *errirq_res, *chanirq_res;
@@ -789,33 +784,32 @@ static int sh_dmae_probe(struct platform_device *pdev)
if (err)
goto rst_err;
 
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
-   chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
+   if (IS_ENABLED(CONFIG_CPU_SH4) || IS_ENABLED(CONFIG_ARCH_RENESAS)) {
+   chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
 
-   if (!chanirq_res)
-   chanirq_res = errirq_res;
-   else
-   irqres++;
+   if (!chanirq_res)
+   chanirq_res = errirq_res;
+   else
+   irqres++;
 
-   if (chanirq_res == errirq_res ||
-   (errirq_res->flags & IORESOURCE_BITS) == IORESOURCE_IRQ_SHAREABLE)
-   irqflags = IRQF_SHARED;
+   if (chanirq_res == errirq_res ||
+   (errirq_res->flags & IORESOURCE_BITS) == 
IORESOURCE_IRQ_SHAREABLE)
+   irqflags = IRQF_SHARED;
 
-   errirq = errirq_res->start;
+   errirq = errirq_res->start;
 
-   err = devm_request_irq(>dev, errirq, sh_dmae_err, irqflags,
-  "DMAC Address Error", shdev);
-   if (err) {
-   dev_err(>dev,
-   "DMA failed requesting irq #%d, error %d\n",
-   errirq, err);
-   goto eirq_err;
+   err = devm_request_irq(>dev, errirq, sh_dmae_err,
+  irqflags, "DMAC Address Error", shdev);
+   if (err) {
+   dev_err(>dev,
+   "DMA failed requesting irq #%d, error %d\n",
+   errirq, err);
+   goto eirq_err;
+   }
+   } else {
+   chanirq_res = errirq_res;
}
 
-#else
-   chanirq_res = errirq_res;
-#endif /* CONFIG_CPU_SH4 || CONFIG_ARCH_SHMOBILE */
-
if (chanirq_res->start == chanirq_res->end &&
!platform_get_resource(pdev, IORESOURCE_IRQ, 1)) {
/* Special case - all multiplexed */
@@ -881,9 +875,7 @@ static int sh_dmae_probe(struct platform_device *pdev)
 chan_probe_err:
sh_dmae_chan_remove(shdev);
 
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
 eirq_err:
-#endif
 rst_err:
spin_lock_irq(_dmae_lock);
list_del_rcu(>node);
-- 
2.7.4

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


Re: [PATCH 9/9] staging: wilc1000: Augment TODO file with GPIO work item

2018-04-20 Thread Ajay Singh
On Thu, 19 Apr 2018 10:41:21 +0200
Linus Walleij  wrote:

> To make sure that this driver does not leave staging before it
> is properly converted to use the new GPIO descriptor API,
> augment the TODO file with this work item.
> 

Thanks to update the TODO required to be fixed before moving out
of staging.
I will also send the updated TODO list to remove items which are
already addressed.

> Cc: Johnny Kim 
> Cc: Nicolas Ferre 
> Signed-off-by: Linus Walleij 

Acked-by: Ajay Singh 

> ---
>  drivers/staging/wilc1000/TODO | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/staging/wilc1000/TODO
> b/drivers/staging/wilc1000/TODO index ae61b55f14fd..c441beba75bd
> 100644 --- a/drivers/staging/wilc1000/TODO
> +++ b/drivers/staging/wilc1000/TODO
> @@ -16,3 +16,7 @@ TODO:
>  - support resume/suspend function
>  - replace SIOCDEVPRIVATE commands with generic API functions
>  - use wext-core handling instead of private SIOCSIWPRIV
> implementation +- convert all uses of the old GPIO API from
>  to the
> +  GPIO descriptor API in  and look up GPIO
> +  lines from device tree, ACPI or board files, board files should
> +  use 



Regards,
Ajay

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


Re: [PATCH 5/9] staging: atomisp: Augment TODO file with GPIO work item

2018-04-20 Thread Andy Shevchenko
On Thu, 2018-04-19 at 10:41 +0200, Linus Walleij wrote:
> To make sure that these drivers do not leave staging before they
> are properly converted to use the new GPIO descriptor API,
> augment the TODO file with this work item.

Fine by me.

Acked-by: Andy Shevchenko 

> Cc: Alan Cox 
> Cc: Andy Shevchenko 
> Signed-off-by: Linus Walleij 
> ---
> I'm happy to help to move this forward, however Andy is the
> authority on x86 platform drivers and probably knows best
> how to deal with these GPIOs going forward.
> ---
>  drivers/staging/media/atomisp/TODO | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/staging/media/atomisp/TODO
> b/drivers/staging/media/atomisp/TODO
> index 255ce3630c2a..683da0cfc313 100644
> --- a/drivers/staging/media/atomisp/TODO
> +++ b/drivers/staging/media/atomisp/TODO
> @@ -50,6 +50,11 @@
>  
>  11. Switch from videobuf1 to videobuf2. Videobuf1 is being removed!
>  
> +12. Convert all uses of the old GPIO API from  to the
> +GPIO descriptor API in  and look up GPIO
> +lines from device properties. See other platform drivers for
> +examples.
> +
>  Limitations:
>  
>  1. To test the patches, you also need the ISP firmware

-- 
Andy Shevchenko 
Intel Finland Oy
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] media: davinci_vpfe: fix some potential overflows

2018-04-20 Thread Dan Carpenter
We check "lutdpc->dpc_size" in ipipe_validate_lutdpc_params() but if
it's invalid then we would have corrupted memory already when we do
the memcpy() before calling it.

We don't ever check "gamma->tbl_size" but we should since they come from
the user.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 95942768639c..068be224 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -82,6 +82,8 @@ static int ipipe_set_lutdpc_params(struct vpfe_ipipe_device 
*ipipe, void *param)
lutdpc->en = dpc_param->en;
lutdpc->repl_white = dpc_param->repl_white;
lutdpc->dpc_size = dpc_param->dpc_size;
+   if (dpc_param->dpc_size > LUT_DPC_MAX_SIZE)
+   return -EINVAL;
memcpy(>table, _param->table,
   (dpc_param->dpc_size * sizeof(struct vpfe_ipipe_lutdpc_entry)));
if (ipipe_validate_lutdpc_params(lutdpc) < 0)
@@ -591,7 +593,7 @@ ipipe_validate_gamma_entry(struct vpfe_ipipe_gamma_entry 
*table, int size)
 static int
 ipipe_validate_gamma_params(struct vpfe_ipipe_gamma *gamma, struct device *dev)
 {
-   int table_size;
+   unsigned int table_size;
int err;
 
if (gamma->bypass_r > 1 ||
@@ -603,6 +605,8 @@ ipipe_validate_gamma_params(struct vpfe_ipipe_gamma *gamma, 
struct device *dev)
return 0;
 
table_size = gamma->tbl_size;
+   if (table_size > VPFE_IPIPE_MAX_SIZE_GAMMA)
+   return -EINVAL;
if (!gamma->bypass_r) {
err = ipipe_validate_gamma_entry(gamma->table_r, table_size);
if (err) {
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 49/61] staging: nvec: simplify getting .drvdata

2018-04-20 Thread Marc Dietrich
Am Donnerstag, 19. April 2018, 16:06:19 CEST schrieb Wolfram Sang:
> We should get drvdata from struct device directly. Going via
> platform_device is an unneeded step back and forth.
> 
> Signed-off-by: Wolfram Sang 

Acked-by: Marc Dietrich 

> ---
> 
> Build tested only. buildbot is happy. Please apply individually.
> 
>  drivers/staging/nvec/nvec.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 52054a528723..2a5e0dcf4162 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -925,8 +925,7 @@ static int tegra_nvec_remove(struct platform_device
> *pdev) static int nvec_suspend(struct device *dev)
>  {
>   int err;
> - struct platform_device *pdev = to_platform_device(dev);
> - struct nvec_chip *nvec = platform_get_drvdata(pdev);
> + struct nvec_chip *nvec = dev_get_drvdata(dev);
>   struct nvec_msg *msg;
>   char ap_suspend[] = { NVEC_SLEEP, AP_SUSPEND };
> 
> @@ -946,8 +945,7 @@ static int nvec_suspend(struct device *dev)
> 
>  static int nvec_resume(struct device *dev)
>  {
> - struct platform_device *pdev = to_platform_device(dev);
> - struct nvec_chip *nvec = platform_get_drvdata(pdev);
> + struct nvec_chip *nvec = dev_get_drvdata(dev);
> 
>   dev_dbg(nvec->dev, "resuming\n");
>   tegra_init_i2c_slave(nvec);




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


Re: [PATCH 3/9] staging: greybus: Add TODO file with GPIO work items

2018-04-20 Thread Johan Hovold
On Thu, Apr 19, 2018 at 10:41:15AM +0200, Linus Walleij wrote:
> To make sure that these drivers do not leave staging before they
> are properly converted to use the new GPIO descriptor API, and the
> GPIOLIB_IRQCHIP helper library, create the TODO file with these work
> items.
> 
> Cc: Johan Hovold 
> Signed-off-by: Linus Walleij 

Thanks for documenting this in the tree. This code had to run on old
Android kernels so we could not use fancy things like gpio descriptors
and the gpio-irqchip implementation at the time. ;)

> ---
> I started some work in this area, make sure to just throw me in
> on CC whenever anyone works on it and I will happily help and
> provide examples!
> ---
>  drivers/staging/greybus/TODO | 5 +
>  1 file changed, 5 insertions(+)
>  create mode 100644 drivers/staging/greybus/TODO
> 
> diff --git a/drivers/staging/greybus/TODO b/drivers/staging/greybus/TODO
> new file mode 100644
> index ..3b90a5711998
> --- /dev/null
> +++ b/drivers/staging/greybus/TODO
> @@ -0,0 +1,5 @@
> +* Convert all uses of the old GPIO API from  to the
> +  GPIO descriptor API in  and look up GPIO
> +  lines from device tree or ACPI.

Not sure that this sentence makes sense for greybus however. We're
querying the module about how many lines it provides using the greybus
protocol, and while we had some ideas about moving some such
descriptions to device-tree fragments (which we'd retrieve from the
module instead) that's probably not going to happen for a while.

The chance of ACPI being used for this is nil in any case.

> +* Convert the GPIO driver to use the GPIO irqchip library
> +  GPIOLIB_IRQCHIP instead of reimplementing the same.

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


Re: [PATCH 47/61] staging: greybus: simplify getting .drvdata

2018-04-20 Thread Johan Hovold
On Thu, Apr 19, 2018 at 04:06:17PM +0200, Wolfram Sang wrote:
> We should get drvdata from struct device directly. Going via
> platform_device is an unneeded step back and forth.
> 
> Signed-off-by: Wolfram Sang 

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


[v2, 2/2] MAINTAINERS: add maintainer for the DPAA2 PTP clock driver

2018-04-20 Thread Yangbo Lu
This patch is to add maintainer for the DPAA2 PTP clock driver.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- None.
---
 MAINTAINERS |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a1410d..7733efa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4395,6 +4395,12 @@ L:   linux-ker...@vger.kernel.org
 S: Maintained
 F: drivers/staging/fsl-dpaa2/ethsw
 
+DPAA2 PTP CLOCK DRIVER
+M: Yangbo Lu 
+L: linux-ker...@vger.kernel.org
+S: Maintained
+F: drivers/staging/fsl-dpaa2/rtc
+
 DPT_I2O SCSI RAID DRIVER
 M: Adaptec OEM Raid Solutions 
 L: linux-s...@vger.kernel.org
-- 
1.7.1

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


[v2, 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread Yangbo Lu
This patch is to add driver for the DPAA2 1588 timer module (RTC)
which interfaces to up to an unlimited number of 10/100/1000 or
10G ethernet MACs, providing current time, alarm, and fiper support.
The 1588 IP control block includes these distinctive features.

- External GPIO trigger for time-stamping
- 2 Time-stamp alarms
- 3 FIPER pulse generators
- Phase adjusted output timer clock

Currently this driver only supports basic functions like
settime/gettime/adjtime/adjfreq.

Signed-off-by: Yangbo Lu 
---
Changes for v2:
- Removed some comments.
- Fixed a return value.
---
 drivers/staging/fsl-dpaa2/Kconfig |8 +
 drivers/staging/fsl-dpaa2/Makefile|5 +-
 drivers/staging/fsl-dpaa2/rtc/Makefile|7 +
 drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h |  137 ++
 drivers/staging/fsl-dpaa2/rtc/dprtc.c |  701 +
 drivers/staging/fsl-dpaa2/rtc/dprtc.h |  164 +++
 drivers/staging/fsl-dpaa2/rtc/rtc.c   |  231 ++
 7 files changed, 1251 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/Makefile
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.c
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/dprtc.h
 create mode 100644 drivers/staging/fsl-dpaa2/rtc/rtc.c

diff --git a/drivers/staging/fsl-dpaa2/Kconfig 
b/drivers/staging/fsl-dpaa2/Kconfig
index bbb7af5..ea2d4aa 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -24,3 +24,11 @@ config FSL_DPAA2_ETHSW
---help---
Driver for Freescale DPAA2 Ethernet Switch. Select
BRIDGE to have support for bridge tools.
+
+config FSL_DPAA2_PTP_CLOCK
+   tristate "Freescale DPAA2 PTP Clock"
+   depends on FSL_DPAA2
+   select PTP_1588_CLOCK
+   help
+ This driver adds support for using the DPAA2 1588 timer module
+ as a PTP clock.
diff --git a/drivers/staging/fsl-dpaa2/Makefile 
b/drivers/staging/fsl-dpaa2/Makefile
index 6cfd76b..9c70629 100644
--- a/drivers/staging/fsl-dpaa2/Makefile
+++ b/drivers/staging/fsl-dpaa2/Makefile
@@ -2,5 +2,6 @@
 # Freescale DataPath Acceleration Architecture Gen2 (DPAA2) drivers
 #
 
-obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
-obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
+obj-$(CONFIG_FSL_DPAA2_ETH)+= ethernet/
+obj-$(CONFIG_FSL_DPAA2_ETHSW)  += ethsw/
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK)  += rtc/
diff --git a/drivers/staging/fsl-dpaa2/rtc/Makefile 
b/drivers/staging/fsl-dpaa2/rtc/Makefile
new file mode 100644
index 000..5468da0
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Freescale DPAA2 PTP clock
+#
+
+obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += dpaa2-rtc.o
+
+dpaa2-rtc-objs := rtc.o dprtc.o
diff --git a/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h 
b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
new file mode 100644
index 000..ba7d5a5
--- /dev/null
+++ b/drivers/staging/fsl-dpaa2/rtc/dprtc-cmd.h
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2016-2018 NXP
+ */
+
+#ifndef _FSL_DPRTC_CMD_H
+#define _FSL_DPRTC_CMD_H
+
+/* DPRTC Version */
+#define DPRTC_VER_MAJOR2
+#define DPRTC_VER_MINOR0
+
+/* Command versioning */
+#define DPRTC_CMD_BASE_VERSION 1
+#define DPRTC_CMD_ID_OFFSET4
+
+#define DPRTC_CMD(id)  (((id) << DPRTC_CMD_ID_OFFSET) | DPRTC_CMD_BASE_VERSION)
+
+/* Command IDs */
+#define DPRTC_CMDID_CLOSE  DPRTC_CMD(0x800)
+#define DPRTC_CMDID_OPEN   DPRTC_CMD(0x810)
+#define DPRTC_CMDID_CREATE DPRTC_CMD(0x910)
+#define DPRTC_CMDID_DESTROYDPRTC_CMD(0x990)
+#define DPRTC_CMDID_GET_API_VERSIONDPRTC_CMD(0xa10)
+
+#define DPRTC_CMDID_ENABLE DPRTC_CMD(0x002)
+#define DPRTC_CMDID_DISABLEDPRTC_CMD(0x003)
+#define DPRTC_CMDID_GET_ATTR   DPRTC_CMD(0x004)
+#define DPRTC_CMDID_RESET  DPRTC_CMD(0x005)
+#define DPRTC_CMDID_IS_ENABLED DPRTC_CMD(0x006)
+
+#define DPRTC_CMDID_SET_IRQ_ENABLE DPRTC_CMD(0x012)
+#define DPRTC_CMDID_GET_IRQ_ENABLE DPRTC_CMD(0x013)
+#define DPRTC_CMDID_SET_IRQ_MASK   DPRTC_CMD(0x014)
+#define DPRTC_CMDID_GET_IRQ_MASK   DPRTC_CMD(0x015)
+#define DPRTC_CMDID_GET_IRQ_STATUS DPRTC_CMD(0x016)
+#define DPRTC_CMDID_CLEAR_IRQ_STATUS   DPRTC_CMD(0x017)
+
+#define DPRTC_CMDID_SET_CLOCK_OFFSET   DPRTC_CMD(0x1d0)
+#define DPRTC_CMDID_SET_FREQ_COMPENSATION  DPRTC_CMD(0x1d1)
+#define DPRTC_CMDID_GET_FREQ_COMPENSATION  DPRTC_CMD(0x1d2)
+#define DPRTC_CMDID_GET_TIME   DPRTC_CMD(0x1d3)
+#define DPRTC_CMDID_SET_TIME   DPRTC_CMD(0x1d4)
+#define 

RE: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver

2018-04-20 Thread Y.b. Lu
Hi Dan,

Thanks a lot for your comments.
Please see my comments inline.

Best regards,
Yangbo Lu

> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Thursday, April 19, 2018 6:40 PM
> To: Y.b. Lu 
> Cc: de...@driverdev.osuosl.org; Greg Kroah-Hartman
> ; Richard Cochran 
> Subject: Re: [PATCH 1/2] staging: fsl-dpaa2/rtc: add rtc driver
> 
> On Thu, Apr 19, 2018 at 04:31:36PM +0800, Yangbo Lu wrote:
> > +int dprtc_open(struct fsl_mc_io *mc_io,
> > +  u32 cmd_flags,
> > +  int dprtc_id,
> > +  u16 *token)
> > +{
> > +   struct dprtc_cmd_open *cmd_params;
> > +   struct fsl_mc_command cmd = { 0 };
> > +   int err;
> > +
> > +   /* prepare command */
> 
> These comments are a bit obvious.  Just remove them.
[Y.b. Lu] Will remove them.

> 
> > +   cmd.header = mc_encode_cmd_header(DPRTC_CMDID_OPEN,
> > + cmd_flags,
> > + 0);
> > +   cmd_params = (struct dprtc_cmd_open *)cmd.params;
> > +   cmd_params->dprtc_id = cpu_to_le32(dprtc_id);
> > +
> > +   /* send command to mc*/
> 
> remove
[Y.b. Lu] Will remove them.

> 
> > +   err = mc_send_command(mc_io, );
> > +   if (err)
> > +   return err;
> > +
> > +   /* retrieve response parameters */
> 
> remove
[Y.b. Lu] Will remove them.

> 
> > +   *token = mc_cmd_hdr_read_token();
> > +
> > +   return err;
> 
> return 0;
[Y.b. Lu] Wil fix it.

> 
> > +}
> > +
> > +/**
> > + * dprtc_close() - Close the control session of the object
> > + * @mc_io: Pointer to MC portal's I/O object
> > + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
> > + * @token: Token of DPRTC object
> > + *
> > + * After this function is called, no further operations are
> > + * allowed on the object without opening a new control session.
> > + *
> > + * Return: '0' on Success; Error code otherwise.
> > + */
> > +int dprtc_close(struct fsl_mc_io *mc_io,
> > +   u32 cmd_flags,
> > +   u16 token)
> > +{
> > +   struct fsl_mc_command cmd = { 0 };
> > +
> > +   /* prepare command */
> > +   cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLOSE,
> cmd_flags,
> > + token);
> > +
> > +   /* send command to mc*/
> > +   return mc_send_command(mc_io, ); }
> > +
> > +/**
> > + * dprtc_create() - Create the DPRTC object.
> > + * @mc_io: Pointer to MC portal's I/O object
> > + * @dprc_token:Parent container token; '0' for default container
> > + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
> > + * @cfg:   Configuration structure
> > + * @obj_id:Returned object id
> > + *
> > + * Create the DPRTC object, allocate required resources and
> > + * perform required initialization.
> > + *
> > + * The function accepts an authentication token of a parent
> > + * container that this object should be assigned to. The token
> > + * can be '0' so the object will be assigned to the default container.
> > + * The newly created object can be opened with the returned
> > + * object id and using the container's associated tokens and MC portals.
> > + *
> > + * Return: '0' on Success; Error code otherwise.
> > + */
> > +int dprtc_create(struct fsl_mc_io *mc_io,
> > +u16 dprc_token,
> > +u32 cmd_flags,
> > +const struct dprtc_cfg *cfg,
> > +u32 *obj_id)
> > +{
> > +   struct fsl_mc_command cmd = { 0 };
> > +   int err;
> > +
> > +   (void)(cfg); /* unused */
> 
> You can just remove these.  Static checkers which complain about this are
> stupid and a bit lazy.
[Y.b. Lu] Will remove them.

> 
> This driver seems nice and so far as I can see it doesn't need to be in 
> staging
> once we get the other parts merged.
> 
> regards,
> dan carpenter

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