[PATCH] iio: accel: Bugfix to enbale and allow different events to work parallely.

2017-07-30 Thread Harinath Nampally
This driver supports multiple devices like mma8653, mma8652, mma8452, mma8453 
and
fxls8471. Almost all these devices have more than one event. Current driver 
design
hardcodes the event specific information, so only one event can be supported by 
this
driver and current design doesn't have the flexibility to add more events.

This patch fixes by detaching the event related information from chip_info 
struct,
and based on channel type and event direction the corresponding event 
configuration registers
are picked dynamically. Hence multiple events can be handled in read/write 
callbacks.

Changes are thoroughly tested on fxls8471 device on imx6UL Eval board using 
iio_event_monitor user space program.

After this fix both Freefall and Transient events are handled by the driver 
without any conflicts.

Signed-off-by: Harinath Nampally 
---
 drivers/iio/accel/mma8452.c | 348 ++--
 1 file changed, 175 insertions(+), 173 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index eb6e3dc..114b0e3 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -59,7 +59,9 @@
 #define MMA8452_FF_MT_THS  0x17
 #define  MMA8452_FF_MT_THS_MASK0x7f
 #define MMA8452_FF_MT_COUNT0x18
+#define MMA8452_FF_MT_CHAN_SHIFT   3
 #define MMA8452_TRANSIENT_CFG  0x1d
+#define  MMA8452_TRANSIENT_CFG_CHAN(chan)  BIT(chan + 1)
 #define  MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0)
 #define  MMA8452_TRANSIENT_CFG_ELE BIT(4)
 #define MMA8452_TRANSIENT_SRC  0x1e
@@ -69,6 +71,7 @@
 #define MMA8452_TRANSIENT_THS  0x1f
 #define  MMA8452_TRANSIENT_THS_MASKGENMASK(6, 0)
 #define MMA8452_TRANSIENT_COUNT0x20
+#define MMA8452_TRANSIENT_CHAN_SHIFT 1
 #define MMA8452_CTRL_REG1  0x2a
 #define  MMA8452_CTRL_ACTIVE   BIT(0)
 #define  MMA8452_CTRL_DR_MASK  GENMASK(5, 3)
@@ -107,6 +110,40 @@ struct mma8452_data {
const struct mma_chip_info *chip_info;
 };
 
+ /**
+  * struct mma8452_event_regs - chip specific data related to events
+  * @ev_cfg:   event config register address
+  * @ev_cfg_ele:   latch bit in event config register
+  * @ev_cfg_chan_shift:number of the bit to enable events in X
+  *direction; in event config register
+  * @ev_src:   event source register address
+  * @ev_src_xe:bit in event source register that 
indicates
+  *an event in X direction
+  * @ev_src_ye:bit in event source register that 
indicates
+  *an event in Y direction
+  * @ev_src_ze:bit in event source register that 
indicates
+  *an event in Z direction
+  * @ev_ths:   event threshold register address
+  * @ev_ths_mask:  mask for the threshold value
+  * @ev_count: event count (period) register address
+  *
+  * Since not all chips supported by the driver support comparing high pass
+  * filtered data for events (interrupts), different interrupt sources are
+  * used for different chips and the relevant registers are included here.
+  */
+struct mma8452_event_regs {
+   u8 ev_cfg;
+   u8 ev_cfg_ele;
+   u8 ev_cfg_chan_shift;
+   u8 ev_src;
+   u8 ev_src_xe;
+   u8 ev_src_ye;
+   u8 ev_src_ze;
+   u8 ev_ths;
+   u8 ev_ths_mask;
+   u8 ev_count;
+};
+
 /**
  * struct mma_chip_info - chip specific data
  * @chip_id:   WHO_AM_I register's value
@@ -116,40 +153,12 @@ struct mma8452_data {
  * @mma_scales:scale factors for converting register 
values
  * to m/s^2; 3 modes: 2g, 4g, 8g; 2 integers
  * per mode: m/s^2 and micro m/s^2
- * @ev_cfg:event config register address
- * @ev_cfg_ele:latch bit in event config register
- * @ev_cfg_chan_shift: number of the bit to enable events in X
- * direction; in event config register
- * @ev_src:event source register address
- * @ev_src_xe: bit in event source register that indicates
- * an event in X direction
- * @ev_src_ye: bit in event source register that indicates
- * an event in Y direction
- * @ev_src_ze: bit in event source register that indicates
- * an event in Z direction
- * @ev_ths:event threshold register address
- * @ev_ths_mask:   ma

Re: [PATCH] staging: iio: light: Replace snprintf calls with scnprintf

2017-05-25 Thread harinath Nampally
Greg,

Sure, I will fix it and resend a fresh patch.

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


[PATCH] staging: iio: light: Replace snprintf calls with scnprintf

2017-05-24 Thread Harinath Nampally
This patch fixes the miscoded use of return value of snprintf
by using the scnprintf function which returns the length of actual
string created in the buffer.

Signed-off-by: Harinath Nampally 
---
 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 1467199..6908bc1 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -921,7 +921,7 @@ static ssize_t power_state_show(struct device *dev,
 {
struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 
-   return snprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
+   return scnprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
 }
 
 static ssize_t power_state_store(struct device *dev,
@@ -954,17 +954,17 @@ static ssize_t 
in_illuminance0_calibscale_available_show(struct device *dev,
case tmd2671:
case tsl2771:
case tmd2771:
-   return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 128");
+   return scnprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 128");
}
 
-   return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
+   return scnprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
 }
 
 static ssize_t in_proximity0_calibscale_available_show(struct device *dev,
struct device_attribute *attr,
char *buf)
 {
-   return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
+   return scnprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
 }
 
 static ssize_t in_illuminance0_integration_time_show(struct device *dev,
@@ -979,7 +979,7 @@ static ssize_t in_illuminance0_integration_time_show(struct 
device *dev,
y /= 1000;
z %= 1000;
 
-   return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+   return scnprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
 }
 
 static ssize_t in_illuminance0_integration_time_store(struct device *dev,
@@ -1016,7 +1016,7 @@ static ssize_t in_illuminance0_target_input_show(struct 
device *dev,
 {
struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
 
-   return snprintf(buf, PAGE_SIZE, "%d\n",
+   return scnprintf(buf, PAGE_SIZE, "%d\n",
chip->tsl2x7x_settings.als_cal_target);
 }
 
@@ -1054,7 +1054,7 @@ static ssize_t in_intensity0_thresh_period_show(struct 
device *dev,
y = filter_delay / 1000;
z = filter_delay % 1000;
 
-   return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+   return scnprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
 }
 
 static ssize_t in_intensity0_thresh_period_store(struct device *dev,
@@ -1102,7 +1102,7 @@ static ssize_t in_proximity0_thresh_period_show(struct 
device *dev,
y = filter_delay / 1000;
z = filter_delay % 1000;
 
-   return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+   return scnprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
 }
 
 static ssize_t in_proximity0_thresh_period_store(struct device *dev,
@@ -1163,7 +1163,7 @@ static ssize_t in_illuminance0_lux_table_show(struct 
device *dev,
int offset = 0;
 
while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) {
-   offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,",
+   offset += scnprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,",
chip->tsl2x7x_device_lux[i].ratio,
chip->tsl2x7x_device_lux[i].ch0,
chip->tsl2x7x_device_lux[i].ch1);
@@ -1178,7 +1178,7 @@ static ssize_t in_illuminance0_lux_table_show(struct 
device *dev,
i++;
}
 
-   offset += snprintf(buf + offset, PAGE_SIZE, "\n");
+   offset += scnprintf(buf + offset, PAGE_SIZE, "\n");
return offset;
 }
 
-- 
2.7.4

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


Re: [PATCH] staging: iio: meter: Replace symbolic permissions with octal permissions

2017-05-18 Thread harinath Nampally
Jonathan,

Yes I see it in the testing branch, thank you for letting me know.

Thanks,
Harinath

On Tue, May 16, 2017 at 2:24 PM, Jonathan Cameron  wrote:
> On 15/05/17 05:38, harinath Nampally wrote:
>>
>> Jonathan,
>>
>> Thank you for letting me know about correct iio git tree.
>>
>> I checked out 'togreg' branch, and noticed that
>> latest ade7758_core.c still has checkpatch.pl warnings.
>>
>> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
>> and my patch is fix for similar warnings but it is for different file
>> ade7758_core.c
>
> I guess he did both.
> http://marc.info/?l=linux-iio&m=149359424405696&w=2
>
> Chances are it was still sat in my testing branch as I hadn't
> yet pushed it out as togreg post the autobuilders running
> build tests on it.  I pushed out a few minutes ago so
> should be up to date on the front end servers by now.
>
> Jonathan
>
>>
>> Please correct me if I am wrong.
>>
>> Thanks,
>> Harinath
>>
>> On Mon, May 15, 2017 at 12:27 AM, harinath Nampally
>>  wrote:
>>>
>>> Jonathan,
>>>
>>> Thank you for letting me know about correct iio git tree.
>>>
>>> I checked out 'togreg' branch, and noticed that
>>> latest ade7758_core.c still has checkpatch.pl warnings.
>>>
>>> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
>>> and my patch is fix for similar warnings but it is for different file
>>> ade7758_core.c
>>>
>>> Please refer to below link for Quentin Swain's patch.
>>> https://www.spinics.net/lists/linux-iio/msg33010.html
>>>
>>> Please let me know if I am wrong.
>>>
>>> Thanks,
>>> Harinath
>>>
>>> On Mon, May 15, 2017 at 12:22 AM, harinath Nampally
>>>  wrote:
>>>>
>>>> Jonathan,
>>>>
>>>> Thank you for letting me know about correct iio git tree.
>>>>
>>>> I checked out 'togreg' branch, and noticed that
>>>> latest ade7758_core.c still has checkpatch.pl warnings.
>>>>
>>>> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
>>>> and my patch is fix for similar warnings but it is for different file
>>>> ade7758_core.c
>>>>
>>>> Please refer to below link for Quentin Swain's patch.
>>>> https://www.spinics.net/lists/linux-iio/msg33010.html
>>>>
>>>> Please let me know if I am wrong.
>>>>
>>>> Thanks,
>>>> Harinath
>>>>
>>>> On Sun, May 14, 2017 at 10:41 AM, Jonathan Cameron 
>>>> wrote:
>>>>>
>>>>>
>>>>> On 12/05/17 22:19, Harinath Nampally wrote:
>>>>>>
>>>>>>
>>>>>> This patch fixes below kind of warnings:
>>>>>> WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.
>>>>>>
>>>>>> Issue found and fixed by checkpatch.pl
>>>>>>
>>>>>> Signed-off-by: Harinath Nampally 
>>>>>
>>>>>
>>>>> Already done by Quentin Swain  last month...
>>>>>
>>>>> For IIO related patches, stuff gets queued up in iio.git on
>>>>> kernel.org before it gets sent on to Greg.  This is relatively
>>>>> unusual for staging, but does lead to lots of repeats of
>>>>> patches like this unfortunately.
>>>>>
>>>>> Jonathan
>>>>>
>>>>>> ---
>>>>>>drivers/staging/iio/meter/ade7758_core.c | 50
>>>>>> 
>>>>>>1 file changed, 25 insertions(+), 25 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/staging/iio/meter/ade7758_core.c
>>>>>> b/drivers/staging/iio/meter/ade7758_core.c
>>>>>> index 99c89e6..40498af 100644
>>>>>> --- a/drivers/staging/iio/meter/ade7758_core.c
>>>>>> +++ b/drivers/staging/iio/meter/ade7758_core.c
>>>>>> @@ -301,103 +301,103 @@ static int ade7758_reset(struct device *dev)
>>>>>>  return ret;
>>>>>>}
>>>>>>-static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
>>>>>> +static IIO_DEV_ATTR_VPEAK(0644,
>>>>>>  ade7758_read_8bit,
>>>>>>  ade7758_w

Re: [PATCH] staging: iio: meter: Replace symbolic permissions with octal permissions

2017-05-14 Thread harinath Nampally
Jonathan,

Thank you for letting me know about correct iio git tree.

I checked out 'togreg' branch, and noticed that
latest ade7758_core.c still has checkpatch.pl warnings.

Actually Quentin Swain fixed the similar warnings in the ade7854.c,
and my patch is fix for similar warnings but it is for different file
ade7758_core.c

Please correct me if I am wrong.

Thanks,
Harinath

On Mon, May 15, 2017 at 12:27 AM, harinath Nampally
 wrote:
> Jonathan,
>
> Thank you for letting me know about correct iio git tree.
>
> I checked out 'togreg' branch, and noticed that
> latest ade7758_core.c still has checkpatch.pl warnings.
>
> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
> and my patch is fix for similar warnings but it is for different file
> ade7758_core.c
>
> Please refer to below link for Quentin Swain's patch.
> https://www.spinics.net/lists/linux-iio/msg33010.html
>
> Please let me know if I am wrong.
>
> Thanks,
> Harinath
>
> On Mon, May 15, 2017 at 12:22 AM, harinath Nampally
>  wrote:
>> Jonathan,
>>
>> Thank you for letting me know about correct iio git tree.
>>
>> I checked out 'togreg' branch, and noticed that
>> latest ade7758_core.c still has checkpatch.pl warnings.
>>
>> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
>> and my patch is fix for similar warnings but it is for different file
>> ade7758_core.c
>>
>> Please refer to below link for Quentin Swain's patch.
>> https://www.spinics.net/lists/linux-iio/msg33010.html
>>
>> Please let me know if I am wrong.
>>
>> Thanks,
>> Harinath
>>
>> On Sun, May 14, 2017 at 10:41 AM, Jonathan Cameron  wrote:
>>>
>>> On 12/05/17 22:19, Harinath Nampally wrote:
>>>>
>>>> This patch fixes below kind of warnings:
>>>> WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.
>>>>
>>>> Issue found and fixed by checkpatch.pl
>>>>
>>>> Signed-off-by: Harinath Nampally 
>>>
>>> Already done by Quentin Swain  last month...
>>>
>>> For IIO related patches, stuff gets queued up in iio.git on
>>> kernel.org before it gets sent on to Greg.  This is relatively
>>> unusual for staging, but does lead to lots of repeats of
>>> patches like this unfortunately.
>>>
>>> Jonathan
>>>
>>>> ---
>>>>   drivers/staging/iio/meter/ade7758_core.c | 50
>>>> 
>>>>   1 file changed, 25 insertions(+), 25 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/iio/meter/ade7758_core.c
>>>> b/drivers/staging/iio/meter/ade7758_core.c
>>>> index 99c89e6..40498af 100644
>>>> --- a/drivers/staging/iio/meter/ade7758_core.c
>>>> +++ b/drivers/staging/iio/meter/ade7758_core.c
>>>> @@ -301,103 +301,103 @@ static int ade7758_reset(struct device *dev)
>>>> return ret;
>>>>   }
>>>>   -static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_VPEAK(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_VPEAK);
>>>> -static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_IPEAK(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_VPEAK);
>>>> -static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_APHCAL(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_APHCAL);
>>>> -static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_BPHCAL(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_BPHCAL);
>>>> -static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_CPHCAL(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_CPHCAL);
>>>> -static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
>>>> +static IIO_DEV_ATTR_WDIV(0644,
>>>> ade7758_read_8bit,
>>>> ade7758_write_8bit,
>>>> ADE7758_WDIV);
>>>> -static IIO_DEV_ATTR_VADIV(S_IWUSR | S_IRUGO,
>>>>

Re: [PATCH] staging: iio: meter: Replace symbolic permissions with octal permissions

2017-05-14 Thread harinath Nampally
Jonathan,

Thank you for letting me know about correct iio git tree.

I checked out 'togreg' branch, and noticed that
latest ade7758_core.c still has checkpatch.pl warnings.

Actually Quentin Swain fixed the similar warnings in the ade7854.c,
and my patch is fix for similar warnings but it is for different file
ade7758_core.c

Please refer to below link for Quentin Swain's patch.
https://www.spinics.net/lists/linux-iio/msg33010.html

Please let me know if I am wrong.

Thanks,
Harinath

On Mon, May 15, 2017 at 12:22 AM, harinath Nampally
 wrote:
> Jonathan,
>
> Thank you for letting me know about correct iio git tree.
>
> I checked out 'togreg' branch, and noticed that
> latest ade7758_core.c still has checkpatch.pl warnings.
>
> Actually Quentin Swain fixed the similar warnings in the ade7854.c,
> and my patch is fix for similar warnings but it is for different file
> ade7758_core.c
>
> Please refer to below link for Quentin Swain's patch.
> https://www.spinics.net/lists/linux-iio/msg33010.html
>
> Please let me know if I am wrong.
>
> Thanks,
> Harinath
>
> On Sun, May 14, 2017 at 10:41 AM, Jonathan Cameron  wrote:
>>
>> On 12/05/17 22:19, Harinath Nampally wrote:
>>>
>>> This patch fixes below kind of warnings:
>>> WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.
>>>
>>> Issue found and fixed by checkpatch.pl
>>>
>>> Signed-off-by: Harinath Nampally 
>>
>> Already done by Quentin Swain  last month...
>>
>> For IIO related patches, stuff gets queued up in iio.git on
>> kernel.org before it gets sent on to Greg.  This is relatively
>> unusual for staging, but does lead to lots of repeats of
>> patches like this unfortunately.
>>
>> Jonathan
>>
>>> ---
>>>   drivers/staging/iio/meter/ade7758_core.c | 50
>>> 
>>>   1 file changed, 25 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/meter/ade7758_core.c
>>> b/drivers/staging/iio/meter/ade7758_core.c
>>> index 99c89e6..40498af 100644
>>> --- a/drivers/staging/iio/meter/ade7758_core.c
>>> +++ b/drivers/staging/iio/meter/ade7758_core.c
>>> @@ -301,103 +301,103 @@ static int ade7758_reset(struct device *dev)
>>> return ret;
>>>   }
>>>   -static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_VPEAK(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_VPEAK);
>>> -static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_IPEAK(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_VPEAK);
>>> -static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_APHCAL(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_APHCAL);
>>> -static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_BPHCAL(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_BPHCAL);
>>> -static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_CPHCAL(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_CPHCAL);
>>> -static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_WDIV(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_WDIV);
>>> -static IIO_DEV_ATTR_VADIV(S_IWUSR | S_IRUGO,
>>> +static IIO_DEV_ATTR_VADIV(0644,
>>> ade7758_read_8bit,
>>> ade7758_write_8bit,
>>> ADE7758_VADIV);
>>> -static IIO_DEV_ATTR_AIRMS(S_IRUGO,
>>> +static IIO_DEV_ATTR_AIRMS(0444,
>>> ade7758_read_24bit,
>>> NULL,
>>> ADE7758_AIRMS);
>>> -static IIO_DEV_ATTR_BIRMS(S_IRUGO,
>>> +static IIO_DEV_ATTR_BIRMS(0444,
>>> ade7758_read_24bit,
>>> NULL,
>>> ADE7758_BIRMS);
>>> -static IIO_DEV_ATTR_CIRMS(S_IRUGO,
>>> +static IIO_DEV_ATTR_CIRMS(0444,
>>> ade7758_read_24bit,
>>> NULL,
>>> ADE7758_CIRMS);
>>> -static IIO_DEV_ATTR_

Re: [PATCH v2 3/3] staging: iio: meter: Replace symbolic permissions with octal permissions.

2017-05-14 Thread harinath Nampally
Jonathan,

Thank you for letting me know. In future I will work on 'togreg' branch
of iio.git tree to send my patches.

Thanks,
Harinath

On Sun, May 14, 2017 at 11:29 AM, Jonathan Cameron  wrote:
> On 10/05/17 00:41, Harinath Nampally wrote:
>>
>> This patch fixes below kind of warnings:
>> WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.
>>
>> Below errors are false positives:
>> ade7753.c:382: ERROR: Use 4 digit octal (0777) not decimal permissions
>> ade7753.c:386: ERROR: Use 4 digit octal (0777) not decimal permissions
>>
>> Signed-off-by: Harinath Nampally 
>
> I've already taken a patch for this.
>
> For IIO patches (including for drivers in staging) please also
> check the iio.git tree and in particularly base the on the togreg branch
> of that unless you know something you need is in the testing branch
> (usually more recent) in which case use that.  This stuff all gets
> batched up every few weeks and sent as a pull request to Greg.
> Right now we have just ended a merge window so it's the longest gap
> that typically occurs in these going to Greg.
>
> Thanks,
>
> Jonathan
>
>> ---
>> Changes in v2:
>>   - None because only [PATCH v2 1/3] has improvement
>>
>>   drivers/staging/iio/meter/ade7753.c | 46
>> ++---
>>   1 file changed, 23 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/staging/iio/meter/ade7753.c
>> b/drivers/staging/iio/meter/ade7753.c
>> index 5d45a68..2534bd0 100644
>> --- a/drivers/staging/iio/meter/ade7753.c
>> +++ b/drivers/staging/iio/meter/ade7753.c
>> @@ -298,92 +298,92 @@ static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit,
>> ADE7753_AENERGY);
>>   static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
>>   static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
>>   static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
>> -static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_CFDEN(0644,
>> ade7753_read_16bit,
>> ade7753_write_16bit,
>> ADE7753_CFDEN);
>> -static IIO_DEV_ATTR_CFNUM(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_CFNUM(0644,
>> ade7753_read_8bit,
>> ade7753_write_8bit,
>> ADE7753_CFNUM);
>>   static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
>> -static IIO_DEV_ATTR_PHCAL(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_PHCAL(0644,
>> ade7753_read_16bit,
>> ade7753_write_16bit,
>> ADE7753_PHCAL);
>> -static IIO_DEV_ATTR_APOS(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_APOS(0644,
>> ade7753_read_16bit,
>> ade7753_write_16bit,
>> ADE7753_APOS);
>> -static IIO_DEV_ATTR_SAGCYC(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_SAGCYC(0644,
>> ade7753_read_8bit,
>> ade7753_write_8bit,
>> ADE7753_SAGCYC);
>> -static IIO_DEV_ATTR_SAGLVL(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_SAGLVL(0644,
>> ade7753_read_8bit,
>> ade7753_write_8bit,
>> ADE7753_SAGLVL);
>> -static IIO_DEV_ATTR_LINECYC(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_LINECYC(0644,
>> ade7753_read_8bit,
>> ade7753_write_8bit,
>> ADE7753_LINECYC);
>> -static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_WDIV(0644,
>> ade7753_read_8bit,
>> ade7753_write_8bit,
>> ADE7753_WDIV);
>> -static IIO_DEV_ATTR_IRMS(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_IRMS(0644,
>> ade7753_read_24bit,
>> NULL,
>> ADE7753_IRMS);
>> -static IIO_DEV_ATTR_VRMS(S_IRUGO,
>> +static IIO_DEV_ATTR_VRMS(0444,
>> ade7753_read_24bit,
>> NULL,
>> ADE7753_VRMS);
>> -static IIO_DEV_ATTR_IRMSOS(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_IRMSOS(0644,
>> ade7753_read_16bit,
>> ade7753_write_16bit,
>> ADE7753_IRMSOS);
>> -static IIO_DEV_ATTR_VRMSOS(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR_VRMSOS(0644,
>> ade7753_read_16bit,
>> ade7753_write_16bit,
>> ADE7753_VRMSOS);
>> -static IIO_DEV_ATTR_WGAIN(S_IWUSR | S_IRUGO,
>> +static IIO_DEV_ATTR

[PATCH] staging: iio: meter: Replace symbolic permissions with octal permissions

2017-05-12 Thread Harinath Nampally
This patch fixes below kind of warnings:
WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.

Issue found and fixed by checkpatch.pl

Signed-off-by: Harinath Nampally 
---
 drivers/staging/iio/meter/ade7758_core.c | 50 
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7758_core.c 
b/drivers/staging/iio/meter/ade7758_core.c
index 99c89e6..40498af 100644
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ b/drivers/staging/iio/meter/ade7758_core.c
@@ -301,103 +301,103 @@ static int ade7758_reset(struct device *dev)
return ret;
 }
 
-static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VPEAK(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_VPEAK);
-static IIO_DEV_ATTR_IPEAK(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IPEAK(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_VPEAK);
-static IIO_DEV_ATTR_APHCAL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_APHCAL(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_APHCAL);
-static IIO_DEV_ATTR_BPHCAL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_BPHCAL(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_BPHCAL);
-static IIO_DEV_ATTR_CPHCAL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CPHCAL(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_CPHCAL);
-static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_WDIV(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_WDIV);
-static IIO_DEV_ATTR_VADIV(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VADIV(0644,
ade7758_read_8bit,
ade7758_write_8bit,
ADE7758_VADIV);
-static IIO_DEV_ATTR_AIRMS(S_IRUGO,
+static IIO_DEV_ATTR_AIRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_AIRMS);
-static IIO_DEV_ATTR_BIRMS(S_IRUGO,
+static IIO_DEV_ATTR_BIRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_BIRMS);
-static IIO_DEV_ATTR_CIRMS(S_IRUGO,
+static IIO_DEV_ATTR_CIRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_CIRMS);
-static IIO_DEV_ATTR_AVRMS(S_IRUGO,
+static IIO_DEV_ATTR_AVRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_AVRMS);
-static IIO_DEV_ATTR_BVRMS(S_IRUGO,
+static IIO_DEV_ATTR_BVRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_BVRMS);
-static IIO_DEV_ATTR_CVRMS(S_IRUGO,
+static IIO_DEV_ATTR_CVRMS(0444,
ade7758_read_24bit,
NULL,
ADE7758_CVRMS);
-static IIO_DEV_ATTR_AIRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_AIRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_AIRMSOS);
-static IIO_DEV_ATTR_BIRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_BIRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_BIRMSOS);
-static IIO_DEV_ATTR_CIRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CIRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_CIRMSOS);
-static IIO_DEV_ATTR_AVRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_AVRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_AVRMSOS);
-static IIO_DEV_ATTR_BVRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_BVRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_BVRMSOS);
-static IIO_DEV_ATTR_CVRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CVRMSOS(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_CVRMSOS);
-static IIO_DEV_ATTR_AIGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_AIGAIN(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_AIGAIN);
-static IIO_DEV_ATTR_BIGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_BIGAIN(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_BIGAIN);
-static IIO_DEV_ATTR_CIGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CIGAIN(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_CIGAIN);
-static IIO_DEV_ATTR_AVRMSGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_AVRMSGAIN(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_AVRMSGAIN);
-static IIO_DEV_ATTR_BVRMSGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_BVRMSGAIN(0644,
ade7758_read_16bit,
ade7758_write_16bit,
ADE7758_BVRMSGAIN);
-static IIO_DEV_ATTR

[PATCH v2 0/3] coding style warnings fixes

2017-05-09 Thread Harinath Nampally
This revised patchset is for improvement in [PATCH v2 1/3]
as per the code review comment from Dan Carpenter.

Other two patches [PATCH v2 2/3] and [PATCH v2 3/3] are unchanged,
so they are same as [PATCH 2/3] and [PATCH 3/3] respectively.

Please find the following related patches:
[PATCH v2 1/3] staging: iio: meter: Add the comment for mutex definition
[PATCH v2 2/3] staging: iio: meter: Fix the identations for proper alignments
[PATCH v2 3/3] staging: iio: meter: Replace symbolic permissions with octal 
permissions

Harinath Nampally (3):
  staging: iio: meter: Add the comment for mutex definition
  staging: iio: meter: Fix the identations for proper alignments
  staging: iio: meter: Replace symbolic permissions with octal
permissions 

 drivers/staging/iio/meter/ade7753.c | 104 ++--
 1 file changed, 51 insertions(+), 52 deletions(-)

-- 
2.7.4

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


[PATCH v2 3/3] staging: iio: meter: Replace symbolic permissions with octal permissions.

2017-05-09 Thread Harinath Nampally
This patch fixes below kind of warnings:
WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.

Below errors are false positives:
ade7753.c:382: ERROR: Use 4 digit octal (0777) not decimal permissions
ade7753.c:386: ERROR: Use 4 digit octal (0777) not decimal permissions

Signed-off-by: Harinath Nampally 
---
Changes in v2:
 - None because only [PATCH v2 1/3] has improvement

 drivers/staging/iio/meter/ade7753.c | 46 ++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index 5d45a68..2534bd0 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -298,92 +298,92 @@ static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, 
ADE7753_AENERGY);
 static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
 static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
 static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
-static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CFDEN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_CFDEN);
-static IIO_DEV_ATTR_CFNUM(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CFNUM(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CFNUM);
 static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_PHCAL(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_PHCAL);
-static IIO_DEV_ATTR_APOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_APOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_APOS);
-static IIO_DEV_ATTR_SAGCYC(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_SAGCYC(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_SAGLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_LINECYC(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_LINECYC);
-static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_WDIV(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_WDIV);
-static IIO_DEV_ATTR_IRMS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IRMS(0644,
ade7753_read_24bit,
NULL,
ADE7753_IRMS);
-static IIO_DEV_ATTR_VRMS(S_IRUGO,
+static IIO_DEV_ATTR_VRMS(0444,
ade7753_read_24bit,
NULL,
ADE7753_VRMS);
-static IIO_DEV_ATTR_IRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IRMSOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_IRMSOS);
-static IIO_DEV_ATTR_VRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VRMSOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_VRMSOS);
-static IIO_DEV_ATTR_WGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_WGAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_WGAIN);
-static IIO_DEV_ATTR_VAGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VAGAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_VAGAIN);
-static IIO_DEV_ATTR_PGA_GAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_PGA_GAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_GAIN);
-static IIO_DEV_ATTR_IPKLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IPKLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_IPKLVL);
-static IIO_DEV_ATTR_VPKLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VPKLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_VPKLVL);
-static IIO_DEV_ATTR_IPEAK(S_IRUGO,
+static IIO_DEV_ATTR_IPEAK(0444,
ade7753_read_24bit,
NULL,
ADE7753_IPEAK);
-static IIO_DEV_ATTR_VPEAK(S_IRUGO,
+static IIO_DEV_ATTR_VPEAK(0444,
ade7753_read_24bit,
NULL,
ADE7753_VPEAK);
-static IIO_DEV_ATTR_VPERIOD(S_IRUGO,
+static IIO_DEV_ATTR_VPERIOD(0444,
ade7753_read_16bit,
NULL,
ADE7753_PERIOD);
-static IIO_DEV_ATTR_CH_OFF(1, S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CH_OFF(1, 0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CH1OS);
-static IIO_DEV_ATTR_CH_OFF(2, S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CH_OFF(2, 0644,
ade7753

[PATCH v2 1/3] staging: iio: meter: Add the comment for mutex definition.

2017-05-09 Thread Harinath Nampally
This patch fixes below checkpatch.pl warning:
CHECK: struct mutex definition without comment

Signed-off-by: Harinath Nampally 
---
Changes in v2:
 - Removed the extra comment for mutex in the struct.

 drivers/staging/iio/meter/ade7753.c | 3 ++-
 1 file changed, 1 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index b71fbd3..cffe6bf 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -78,12 +78,13 @@
 /**
  * struct ade7753_state - device instance specific data
  * @us: actual spi_device
+ * @buf_lock:   mutex to protect tx and rx
  * @tx: transmit buffer
  * @rx: receive buffer
- * @buf_lock:   mutex to protect tx and rx
  **/
 struct ade7753_state {
struct spi_device   *us;
struct mutexbuf_lock;
u8  tx[ADE7753_MAX_TX] cacheline_aligned;
u8  rx[ADE7753_MAX_RX];
-- 
2.7.4

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


[PATCH v2 2/3] staging: iio: meter: Fix the identations for proper alignments.

2017-05-09 Thread Harinath Nampally
This patch fixes below checkpatch.pl kind of warnings:
CHECK: Alignment should match open parenthesis

Signed-off-by: Harinath Nampally 
---
Changes in v2:
 - None because only [PATCH v2 1/3] has improvement

 drivers/staging/iio/meter/ade7753.c | 55 ++---
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index cffe6bf..5d45a68 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -108,9 +108,8 @@ static int ade7753_spi_write_reg_8(struct device *dev,
return ret;
 }
 
-static int ade7753_spi_write_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 value)
+static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
+   u16 value)
 {
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -127,8 +126,8 @@ static int ade7753_spi_write_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_8(struct device *dev,
-   u8 reg_address,
-   u8 *val)
+ u8 reg_address,
+ u8 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -137,7 +136,7 @@ static int ade7753_spi_read_reg_8(struct device *dev,
ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
if (ret < 0) {
dev_err(&st->us->dev, "problem when reading 8 bit register 
0x%02X",
-   reg_address);
+   reg_address);
return ret;
}
*val = ret;
@@ -146,8 +145,8 @@ static int ade7753_spi_read_reg_8(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 *val)
+  u8 reg_address,
+  u16 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -166,8 +165,8 @@ static int ade7753_spi_read_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_24(struct device *dev,
-   u8 reg_address,
-   u32 *val)
+  u8 reg_address,
+  u32 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -190,7 +189,7 @@ static int ade7753_spi_read_reg_24(struct device *dev,
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
if (ret) {
dev_err(&st->us->dev, "problem when reading 24 bit register 
0x%02X",
-   reg_address);
+   reg_address);
goto error_ret;
}
*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
@@ -201,8 +200,8 @@ static int ade7753_spi_read_reg_24(struct device *dev,
 }
 
 static ssize_t ade7753_read_8bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+struct device_attribute *attr,
+char *buf)
 {
int ret;
u8 val;
@@ -216,8 +215,8 @@ static ssize_t ade7753_read_8bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_16bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u16 val;
@@ -231,8 +230,8 @@ static ssize_t ade7753_read_16bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_24bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u32 val;
@@ -246,9 +245,9 @@ static ssize_t ade7753_read_24bit(struct device *dev,
 }
 
 static ssize_t ade7753_write_8bit(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
 {
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -264,9 +263,9 @@ static ssize_t ade7753_write_8bit(struct device *dev,
 }
 
 static ssize_t ade7753_write_16bit(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+  struct device_attribute *attr,
+  const char *buf,
+ 

[PATCH 2/3] staging: iio: meter: Fix the identations for proper alignments

2017-05-08 Thread Harinath Nampally
This patch fixes below checkpatch.pl kind of warnings:
CHECK: Alignment should match open parenthesis

Signed-off-by: Harinath Nampally 
---
 drivers/staging/iio/meter/ade7753.c | 55 ++---
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index cffe6bf..5d45a68 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -108,9 +108,8 @@ static int ade7753_spi_write_reg_8(struct device *dev,
return ret;
 }
 
-static int ade7753_spi_write_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 value)
+static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
+   u16 value)
 {
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -127,8 +126,8 @@ static int ade7753_spi_write_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_8(struct device *dev,
-   u8 reg_address,
-   u8 *val)
+ u8 reg_address,
+ u8 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -137,7 +136,7 @@ static int ade7753_spi_read_reg_8(struct device *dev,
ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
if (ret < 0) {
dev_err(&st->us->dev, "problem when reading 8 bit register 
0x%02X",
-   reg_address);
+   reg_address);
return ret;
}
*val = ret;
@@ -146,8 +145,8 @@ static int ade7753_spi_read_reg_8(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 *val)
+  u8 reg_address,
+  u16 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -166,8 +165,8 @@ static int ade7753_spi_read_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_24(struct device *dev,
-   u8 reg_address,
-   u32 *val)
+  u8 reg_address,
+  u32 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -190,7 +189,7 @@ static int ade7753_spi_read_reg_24(struct device *dev,
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
if (ret) {
dev_err(&st->us->dev, "problem when reading 24 bit register 
0x%02X",
-   reg_address);
+   reg_address);
goto error_ret;
}
*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
@@ -201,8 +200,8 @@ static int ade7753_spi_read_reg_24(struct device *dev,
 }
 
 static ssize_t ade7753_read_8bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+struct device_attribute *attr,
+char *buf)
 {
int ret;
u8 val;
@@ -216,8 +215,8 @@ static ssize_t ade7753_read_8bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_16bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u16 val;
@@ -231,8 +230,8 @@ static ssize_t ade7753_read_16bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_24bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u32 val;
@@ -246,9 +245,9 @@ static ssize_t ade7753_read_24bit(struct device *dev,
 }
 
 static ssize_t ade7753_write_8bit(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
 {
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -264,9 +263,9 @@ static ssize_t ade7753_write_8bit(struct device *dev,
 }
 
 static ssize_t ade7753_write_16bit(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf,
-   size_t len)
+  struct device_attribute *attr,
+  const char *buf,
+  size_t len)
 {
struct iio_dev_attr *this_attr = 

[PATCH 3/3] staging: iio: meter: Replace symbolic permissions with octal permissions

2017-05-08 Thread Harinath Nampally
This patch fixes below kind of warnings:
WARNING: Symbolic permissions 'S_IXXX | S_IXXX' are not preferred.

Below errors are false positives:
ade7753.c:382: ERROR: Use 4 digit octal (0777) not decimal permissions
ade7753.c:386: ERROR: Use 4 digit octal (0777) not decimal permissions

Signed-off-by: Harinath Nampally 
---
 drivers/staging/iio/meter/ade7753.c | 46 ++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index 5d45a68..2534bd0 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -298,92 +298,92 @@ static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, 
ADE7753_AENERGY);
 static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY);
 static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY);
 static IIO_DEV_ATTR_LVAENERGY(ade7753_read_24bit, ADE7753_LVAENERGY);
-static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CFDEN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_CFDEN);
-static IIO_DEV_ATTR_CFNUM(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CFNUM(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CFNUM);
 static IIO_DEV_ATTR_CHKSUM(ade7753_read_8bit, ADE7753_CHKSUM);
-static IIO_DEV_ATTR_PHCAL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_PHCAL(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_PHCAL);
-static IIO_DEV_ATTR_APOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_APOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_APOS);
-static IIO_DEV_ATTR_SAGCYC(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_SAGCYC(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_SAGCYC);
-static IIO_DEV_ATTR_SAGLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_SAGLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_SAGLVL);
-static IIO_DEV_ATTR_LINECYC(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_LINECYC(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_LINECYC);
-static IIO_DEV_ATTR_WDIV(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_WDIV(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_WDIV);
-static IIO_DEV_ATTR_IRMS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IRMS(0644,
ade7753_read_24bit,
NULL,
ADE7753_IRMS);
-static IIO_DEV_ATTR_VRMS(S_IRUGO,
+static IIO_DEV_ATTR_VRMS(0444,
ade7753_read_24bit,
NULL,
ADE7753_VRMS);
-static IIO_DEV_ATTR_IRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IRMSOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_IRMSOS);
-static IIO_DEV_ATTR_VRMSOS(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VRMSOS(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_VRMSOS);
-static IIO_DEV_ATTR_WGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_WGAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_WGAIN);
-static IIO_DEV_ATTR_VAGAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VAGAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_VAGAIN);
-static IIO_DEV_ATTR_PGA_GAIN(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_PGA_GAIN(0644,
ade7753_read_16bit,
ade7753_write_16bit,
ADE7753_GAIN);
-static IIO_DEV_ATTR_IPKLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_IPKLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_IPKLVL);
-static IIO_DEV_ATTR_VPKLVL(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_VPKLVL(0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_VPKLVL);
-static IIO_DEV_ATTR_IPEAK(S_IRUGO,
+static IIO_DEV_ATTR_IPEAK(0444,
ade7753_read_24bit,
NULL,
ADE7753_IPEAK);
-static IIO_DEV_ATTR_VPEAK(S_IRUGO,
+static IIO_DEV_ATTR_VPEAK(0444,
ade7753_read_24bit,
NULL,
ADE7753_VPEAK);
-static IIO_DEV_ATTR_VPERIOD(S_IRUGO,
+static IIO_DEV_ATTR_VPERIOD(0444,
ade7753_read_16bit,
NULL,
ADE7753_PERIOD);
-static IIO_DEV_ATTR_CH_OFF(1, S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CH_OFF(1, 0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CH1OS);
-static IIO_DEV_ATTR_CH_OFF(2, S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_CH_OFF(2, 0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CH2OS);
@@ -51

[PATCH 0/3] coding style warnings fixes

2017-05-08 Thread Harinath Nampally
This patchset is for fixes reported by checkpatch.pl

Please find the following related patches:
[PATCH 1/3] staging: iio: meter: Add the comment for mutex definition
[PATCH 2/3] staging: iio: meter: Fix the identations for proper alignments
[PATCH 3/3] staging: iio: meter: Replace symbolic permissions with octal 
permissions
-
Harinath Nampally (3):
  staging: iio: meter: Add the comment for mutex definition
  staging: iio: meter: Fix the identations for proper alignments
  staging: iio: meter: Replace symbolic permissions with octal permissions 

 drivers/staging/iio/meter/ade7753.c | 104 ++--
 1 file changed, 52 insertions(+), 52 deletions(-)

-- 
2.7.4

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


[PATCH 1/3] staging: iio: meter: Add the comment for mutex definition

2017-05-08 Thread Harinath Nampally
This patch fixes below checkpatch.pl warning:
CHECK: struct mutex definition without comment

Signed-off-by: Harinath Nampally 
---
 drivers/staging/iio/meter/ade7753.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index b71fbd3..cffe6bf 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -78,12 +78,13 @@
 /**
  * struct ade7753_state - device instance specific data
  * @us: actual spi_device
+ * @buf_lock:   mutex to protect tx and rx
  * @tx: transmit buffer
  * @rx: receive buffer
- * @buf_lock:   mutex to protect tx and rx
  **/
 struct ade7753_state {
struct spi_device   *us;
+ /* mutex to protect tx and rx */
struct mutexbuf_lock;
u8  tx[ADE7753_MAX_TX] cacheline_aligned;
u8  rx[ADE7753_MAX_RX];
-- 
2.7.4

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


[PATCH] staging: iio: meter: This patch fixes warnings found in ade7753.c

2017-05-07 Thread Harinath Nampally
All below warnings are found and fixed by checkpatch.pl:
CHECK: struct mutex definition without comment
CHECK: Alignment should match open parenthesis
WARNING: Symbolic permissions 'S_IWUSR | S_IRUGO' are not preferred.

Below errors are false positives:
ade7753.c:382: ERROR: Use 4 digit octal (0777) not decimal permissions
ade7753.c:386: ERROR: Use 4 digit octal (0777) not decimal permissions

Signed-off-by: Harinath Nampally 
---
 drivers/staging/iio/meter/ade7753.c | 104 ++--
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/iio/meter/ade7753.c 
b/drivers/staging/iio/meter/ade7753.c
index b71fbd3..2534bd0 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -78,12 +78,13 @@
 /**
  * struct ade7753_state - device instance specific data
  * @us: actual spi_device
+ * @buf_lock:   mutex to protect tx and rx
  * @tx: transmit buffer
  * @rx: receive buffer
- * @buf_lock:   mutex to protect tx and rx
  **/
 struct ade7753_state {
struct spi_device   *us;
+ /* mutex to protect tx and rx */
struct mutexbuf_lock;
u8  tx[ADE7753_MAX_TX] cacheline_aligned;
u8  rx[ADE7753_MAX_RX];
@@ -107,9 +108,8 @@ static int ade7753_spi_write_reg_8(struct device *dev,
return ret;
 }
 
-static int ade7753_spi_write_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 value)
+static int ade7753_spi_write_reg_16(struct device *dev, u8 reg_address,
+   u16 value)
 {
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -126,8 +126,8 @@ static int ade7753_spi_write_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_8(struct device *dev,
-   u8 reg_address,
-   u8 *val)
+ u8 reg_address,
+ u8 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -136,7 +136,7 @@ static int ade7753_spi_read_reg_8(struct device *dev,
ret = spi_w8r8(st->us, ADE7753_READ_REG(reg_address));
if (ret < 0) {
dev_err(&st->us->dev, "problem when reading 8 bit register 
0x%02X",
-   reg_address);
+   reg_address);
return ret;
}
*val = ret;
@@ -145,8 +145,8 @@ static int ade7753_spi_read_reg_8(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_16(struct device *dev,
-   u8 reg_address,
-   u16 *val)
+  u8 reg_address,
+  u16 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -165,8 +165,8 @@ static int ade7753_spi_read_reg_16(struct device *dev,
 }
 
 static int ade7753_spi_read_reg_24(struct device *dev,
-   u8 reg_address,
-   u32 *val)
+  u8 reg_address,
+  u32 *val)
 {
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
@@ -189,7 +189,7 @@ static int ade7753_spi_read_reg_24(struct device *dev,
ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
if (ret) {
dev_err(&st->us->dev, "problem when reading 24 bit register 
0x%02X",
-   reg_address);
+   reg_address);
goto error_ret;
}
*val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
@@ -200,8 +200,8 @@ static int ade7753_spi_read_reg_24(struct device *dev,
 }
 
 static ssize_t ade7753_read_8bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+struct device_attribute *attr,
+char *buf)
 {
int ret;
u8 val;
@@ -215,8 +215,8 @@ static ssize_t ade7753_read_8bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_16bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u16 val;
@@ -230,8 +230,8 @@ static ssize_t ade7753_read_16bit(struct device *dev,
 }
 
 static ssize_t ade7753_read_24bit(struct device *dev,
-   struct device_attribute *attr,
-   char *buf)
+ struct device_attribute *attr,
+ char *buf)
 {
int ret;
u32 val;
@@ -245,9 +245,9 @@ static ssize_t ade7753_read_24bit(struct device *dev,
 }
 
 static ssize_t ade7