Re: [PATCH] Remove explicit return type cast

2017-08-08 Thread hari prasath
On 3 August 2017 at 18:53, Dan Carpenter <dan.carpen...@oracle.com> wrote:
> On Thu, Aug 03, 2017 at 06:23:54PM +0530, hari prasath wrote:
>> On 3 August 2017 at 11:52, kbuild test robot <l...@intel.com> wrote:
>> > Hi Hari,
>> >
>> > [auto build test WARNING on staging/staging-testing]
>> > [also build test WARNING on next-20170802]
>> > [cannot apply to v4.13-rc3]
>> > [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/Hari-Prasath/Remove-explicit-return-type-cast/20170803-080312
>> > config: blackfin-allyesconfig (attached as .config)
>> > compiler: bfin-uclinux-gcc (GCC) 6.2.0
>> > reproduce:
>> > wget 
>> > https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross 
>> > -O ~/bin/make.cross
>> > chmod +x ~/bin/make.cross
>> > # save the attached .config to linux build tree
>> > make.cross ARCH=blackfin
>> >
>>
>> >> I tried these steps, it's giving me build error as below.
>>
>
> You don't need to cross compile on blackfin to get the warning.  Just
> use the normal compiler.
>
> regards,
> dan carpenter
>

> Sorry, I had sent the patch in a hurry. Yes the warning is true. I will try 
> to come up with a v2 of the patch without any warnings. As of now this can be 
> discarded.
>  thanks,
>  hari prasath



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH] Remove explicit return type cast

2017-08-08 Thread hari prasath
On 3 August 2017 at 18:53, Dan Carpenter  wrote:
> On Thu, Aug 03, 2017 at 06:23:54PM +0530, hari prasath wrote:
>> On 3 August 2017 at 11:52, kbuild test robot  wrote:
>> > Hi Hari,
>> >
>> > [auto build test WARNING on staging/staging-testing]
>> > [also build test WARNING on next-20170802]
>> > [cannot apply to v4.13-rc3]
>> > [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/Hari-Prasath/Remove-explicit-return-type-cast/20170803-080312
>> > config: blackfin-allyesconfig (attached as .config)
>> > compiler: bfin-uclinux-gcc (GCC) 6.2.0
>> > reproduce:
>> > wget 
>> > https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross 
>> > -O ~/bin/make.cross
>> > chmod +x ~/bin/make.cross
>> > # save the attached .config to linux build tree
>> > make.cross ARCH=blackfin
>> >
>>
>> >> I tried these steps, it's giving me build error as below.
>>
>
> You don't need to cross compile on blackfin to get the warning.  Just
> use the normal compiler.
>
> regards,
> dan carpenter
>

> Sorry, I had sent the patch in a hurry. Yes the warning is true. I will try 
> to come up with a v2 of the patch without any warnings. As of now this can be 
> discarded.
>  thanks,
>  hari prasath



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH] Remove explicit return type cast

2017-08-03 Thread hari prasath
On 3 August 2017 at 11:52, kbuild test robot <l...@intel.com> wrote:
> Hi Hari,
>
> [auto build test WARNING on staging/staging-testing]
> [also build test WARNING on next-20170802]
> [cannot apply to v4.13-rc3]
> [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/Hari-Prasath/Remove-explicit-return-type-cast/20170803-080312
> config: blackfin-allyesconfig (attached as .config)
> compiler: bfin-uclinux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=blackfin
>

>> I tried these steps, it's giving me build error as below.

  CC  security/selinux/exports.o
  CC  security/apparmor/file.o
fs/ubifs/lpt_commit.c: In function 'next_pnode_to_dirty':
fs/ubifs/lpt_commit.c:617:1: internal compiler error: in
bfin_optimize_loop, at config/bfin/bfin.c:3978
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
scripts/Makefile.build:302: recipe for target 'fs/ubifs/lpt_commit.o' failed
make[2]: *** [fs/ubifs/lpt_commit.o] Error 1
make[2]: *** Waiting for unfinished jobs



> All warnings (new ones prefixed by >>):
>
>drivers/staging/pi433/pi433_if.c: In function 'DIO0_irq_handler':
>>> drivers/staging/pi433/pi433_if.c:154:9: warning: return makes pointer from 
>>> integer without a cast [-Wint-conversion]
>  return IRQ_HANDLED;
> ^~~
>drivers/staging/pi433/pi433_if.c: In function 'DIO1_irq_handler':
>drivers/staging/pi433/pi433_if.c:174:9: warning: return makes pointer from 
> integer without a cast [-Wint-conversion]
>  return IRQ_HANDLED;
> ^~~
>
> vim +154 drivers/staging/pi433/pi433_if.c
>
>129
>130  /* GPIO interrupt handlers */
>131  static irq_handler_t
>132  DIO0_irq_handler(unsigned int irq, void *dev_id, struct pt_regs *regs)
>133  {
>134  struct pi433_device *device = dev_id;
>135
>136  if  (device->irq_state[DIO0] == DIO_PacketSent)
>137  {
>138  device->free_in_fifo = FIFO_SIZE;
>139  printk("DIO0 irq: Packet sent\n"); // TODO: printk() 
> should include KERN_ facility level
>140  wake_up_interruptible(>fifo_wait_queue);
>141  }
>142  else if (device->irq_state[DIO0] == DIO_Rssi_DIO0)
>143  {
>144  printk("DIO0 irq: RSSI level over threshold\n");
>145  wake_up_interruptible(>rx_wait_queue);
>146  }
>147  else if (device->irq_state[DIO0] == DIO_PayloadReady)
>148  {
>149  printk("DIO0 irq: PayloadReady\n");
>150  device->free_in_fifo = 0;
>151  wake_up_interruptible(>fifo_wait_queue);
>152  }
>153
>  > 154  return IRQ_HANDLED;
>155  }
>156
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH] Remove explicit return type cast

2017-08-03 Thread hari prasath
On 3 August 2017 at 11:52, kbuild test robot  wrote:
> Hi Hari,
>
> [auto build test WARNING on staging/staging-testing]
> [also build test WARNING on next-20170802]
> [cannot apply to v4.13-rc3]
> [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/Hari-Prasath/Remove-explicit-return-type-cast/20170803-080312
> config: blackfin-allyesconfig (attached as .config)
> compiler: bfin-uclinux-gcc (GCC) 6.2.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=blackfin
>

>> I tried these steps, it's giving me build error as below.

  CC  security/selinux/exports.o
  CC  security/apparmor/file.o
fs/ubifs/lpt_commit.c: In function 'next_pnode_to_dirty':
fs/ubifs/lpt_commit.c:617:1: internal compiler error: in
bfin_optimize_loop, at config/bfin/bfin.c:3978
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
scripts/Makefile.build:302: recipe for target 'fs/ubifs/lpt_commit.o' failed
make[2]: *** [fs/ubifs/lpt_commit.o] Error 1
make[2]: *** Waiting for unfinished jobs



> All warnings (new ones prefixed by >>):
>
>drivers/staging/pi433/pi433_if.c: In function 'DIO0_irq_handler':
>>> drivers/staging/pi433/pi433_if.c:154:9: warning: return makes pointer from 
>>> integer without a cast [-Wint-conversion]
>  return IRQ_HANDLED;
> ^~~
>drivers/staging/pi433/pi433_if.c: In function 'DIO1_irq_handler':
>drivers/staging/pi433/pi433_if.c:174:9: warning: return makes pointer from 
> integer without a cast [-Wint-conversion]
>  return IRQ_HANDLED;
> ^~~
>
> vim +154 drivers/staging/pi433/pi433_if.c
>
>129
>130  /* GPIO interrupt handlers */
>131  static irq_handler_t
>132  DIO0_irq_handler(unsigned int irq, void *dev_id, struct pt_regs *regs)
>133  {
>134  struct pi433_device *device = dev_id;
>135
>136  if  (device->irq_state[DIO0] == DIO_PacketSent)
>137  {
>138  device->free_in_fifo = FIFO_SIZE;
>139  printk("DIO0 irq: Packet sent\n"); // TODO: printk() 
> should include KERN_ facility level
>140  wake_up_interruptible(>fifo_wait_queue);
>141  }
>142  else if (device->irq_state[DIO0] == DIO_Rssi_DIO0)
>143  {
>144  printk("DIO0 irq: RSSI level over threshold\n");
>145  wake_up_interruptible(>rx_wait_queue);
>146  }
>147  else if (device->irq_state[DIO0] == DIO_PayloadReady)
>148  {
>149  printk("DIO0 irq: PayloadReady\n");
>150  device->free_in_fifo = 0;
>151  wake_up_interruptible(>fifo_wait_queue);
>152  }
>153
>  > 154  return IRQ_HANDLED;
>155  }
>156
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation



-- 
Regards,
G.E.Hari Prasath


[PATCH] Remove explicit return type cast

2017-08-02 Thread Hari Prasath
Remove explicit typecasting of return value in the interrupt handlers.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ed737f4..95f3ef9 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -151,7 +151,7 @@ DIO0_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
wake_up_interruptible(>fifo_wait_queue);
}
 
-   return (irq_handler_t) IRQ_HANDLED;
+   return IRQ_HANDLED;
 }
 
 static irq_handler_t
@@ -171,7 +171,7 @@ DIO1_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
printk("DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); // 
TODO: printk() should include KERN_ facility level
wake_up_interruptible(>fifo_wait_queue);
 
-   return (irq_handler_t) IRQ_HANDLED;
+   return IRQ_HANDLED;
 }
 
 static void *DIO_irq_handler[NUM_DIO] = {
-- 
2.10.0.GIT



[PATCH] Remove explicit return type cast

2017-08-02 Thread Hari Prasath
Remove explicit typecasting of return value in the interrupt handlers.

Signed-off-by: Hari Prasath 
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ed737f4..95f3ef9 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -151,7 +151,7 @@ DIO0_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
wake_up_interruptible(>fifo_wait_queue);
}
 
-   return (irq_handler_t) IRQ_HANDLED;
+   return IRQ_HANDLED;
 }
 
 static irq_handler_t
@@ -171,7 +171,7 @@ DIO1_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
printk("DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); // 
TODO: printk() should include KERN_ facility level
wake_up_interruptible(>fifo_wait_queue);
 
-   return (irq_handler_t) IRQ_HANDLED;
+   return IRQ_HANDLED;
 }
 
 static void *DIO_irq_handler[NUM_DIO] = {
-- 
2.10.0.GIT



[PATCH] staging: iio: adc: add space around substraction operation

2017-07-17 Thread Hari Prasath
Fix checkpatch warning to add space around the substraction operation

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index d5ab83f..d79e774 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -745,14 +745,14 @@ static irqreturn_t ad7280_event_handler(int irq, void 
*private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-   in_voltage-voltage_thresh_low_value,
+   in_voltage - voltage_thresh_low_value,
0644,
ad7280_read_channel_config,
ad7280_write_channel_config,
AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-   in_voltage-voltage_thresh_high_value,
+   in_voltage - voltage_thresh_high_value,
0644,
ad7280_read_channel_config,
ad7280_write_channel_config,
-- 
2.10.0.GIT



[PATCH] staging: iio: adc: add space around substraction operation

2017-07-17 Thread Hari Prasath
Fix checkpatch warning to add space around the substraction operation

Signed-off-by: Hari Prasath 
---
 drivers/staging/iio/adc/ad7280a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index d5ab83f..d79e774 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -745,14 +745,14 @@ static irqreturn_t ad7280_event_handler(int irq, void 
*private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-   in_voltage-voltage_thresh_low_value,
+   in_voltage - voltage_thresh_low_value,
0644,
ad7280_read_channel_config,
ad7280_write_channel_config,
AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-   in_voltage-voltage_thresh_high_value,
+   in_voltage - voltage_thresh_high_value,
0644,
ad7280_read_channel_config,
ad7280_write_channel_config,
-- 
2.10.0.GIT



Re: [PATCHv2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread hari prasath
Hi,

I agree that it's initialized in the core IIO driver. Also I have
screwed up the patch.

Regards,
Hari

On 17 July 2017 at 18:47, Lars-Peter Clausen <l...@metafoo.de> wrote:
> Hi,
>
> The patch seems to be reverted?
>
> Also should this part in the IIO core take care of automatically setting the
> of_node of the IIO device? As far as I can see we don't have to initialize
> it manually.
>
> /* If the calling driver did not initialize of_node, do it here */
> if (!indio_dev->dev.of_node && indio_dev->dev.parent)
> indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
>
> - Lars
>
> On 07/17/2017 02:34 PM, Hari Prasath wrote:
>> Adding missing indio_dev->dev.of_node references to allow iio consumers
>> to access the device channels.
>>
>> Signed-off-by: Hari Prasath <geharipras...@gmail.com>
>> ---
>>   v2: Wrong from mail ID in first version of patch
>> ---
>>  drivers/staging/iio/adc/ad7192.c | 1 -
>>  drivers/staging/iio/adc/ad7780.c | 1 -
>>  2 files changed, 2 deletions(-)
>>
>> diff --git a/drivers/staging/iio/adc/ad7192.c 
>> b/drivers/staging/iio/adc/ad7192.c
>> index 78308a5..d11c6de 100644
>> --- a/drivers/staging/iio/adc/ad7192.c
>> +++ b/drivers/staging/iio/adc/ad7192.c
>> @@ -668,7 +668,6 @@ static int ad7192_probe(struct spi_device *spi)
>>   spi_set_drvdata(spi, indio_dev);
>>   st->devid = spi_get_device_id(spi)->driver_data;
>>   indio_dev->dev.parent = >dev;
>> - indio_dev->dev.of_node = spi->dev.of_node;
>>   indio_dev->name = spi_get_device_id(spi)->name;
>>   indio_dev->modes = INDIO_DIRECT_MODE;
>>
>> diff --git a/drivers/staging/iio/adc/ad7780.c 
>> b/drivers/staging/iio/adc/ad7780.c
>> index e38d2ab9..dec3ba6 100644
>> --- a/drivers/staging/iio/adc/ad7780.c
>> +++ b/drivers/staging/iio/adc/ad7780.c
>> @@ -195,7 +195,6 @@ static int ad7780_probe(struct spi_device *spi)
>>   spi_set_drvdata(spi, indio_dev);
>>
>>   indio_dev->dev.parent = >dev;
>> - indio_dev->dev.of_node = spi->dev.of_node;
>>   indio_dev->name = spi_get_device_id(spi)->name;
>>   indio_dev->modes = INDIO_DIRECT_MODE;
>>   indio_dev->channels = >chip_info->channel;
>>
>



-- 
Regards,
G.E.Hari Prasath


Re: [PATCHv2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread hari prasath
Hi,

I agree that it's initialized in the core IIO driver. Also I have
screwed up the patch.

Regards,
Hari

On 17 July 2017 at 18:47, Lars-Peter Clausen  wrote:
> Hi,
>
> The patch seems to be reverted?
>
> Also should this part in the IIO core take care of automatically setting the
> of_node of the IIO device? As far as I can see we don't have to initialize
> it manually.
>
> /* If the calling driver did not initialize of_node, do it here */
> if (!indio_dev->dev.of_node && indio_dev->dev.parent)
> indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
>
> - Lars
>
> On 07/17/2017 02:34 PM, Hari Prasath wrote:
>> Adding missing indio_dev->dev.of_node references to allow iio consumers
>> to access the device channels.
>>
>> Signed-off-by: Hari Prasath 
>> ---
>>   v2: Wrong from mail ID in first version of patch
>> ---
>>  drivers/staging/iio/adc/ad7192.c | 1 -
>>  drivers/staging/iio/adc/ad7780.c | 1 -
>>  2 files changed, 2 deletions(-)
>>
>> diff --git a/drivers/staging/iio/adc/ad7192.c 
>> b/drivers/staging/iio/adc/ad7192.c
>> index 78308a5..d11c6de 100644
>> --- a/drivers/staging/iio/adc/ad7192.c
>> +++ b/drivers/staging/iio/adc/ad7192.c
>> @@ -668,7 +668,6 @@ static int ad7192_probe(struct spi_device *spi)
>>   spi_set_drvdata(spi, indio_dev);
>>   st->devid = spi_get_device_id(spi)->driver_data;
>>   indio_dev->dev.parent = >dev;
>> - indio_dev->dev.of_node = spi->dev.of_node;
>>   indio_dev->name = spi_get_device_id(spi)->name;
>>   indio_dev->modes = INDIO_DIRECT_MODE;
>>
>> diff --git a/drivers/staging/iio/adc/ad7780.c 
>> b/drivers/staging/iio/adc/ad7780.c
>> index e38d2ab9..dec3ba6 100644
>> --- a/drivers/staging/iio/adc/ad7780.c
>> +++ b/drivers/staging/iio/adc/ad7780.c
>> @@ -195,7 +195,6 @@ static int ad7780_probe(struct spi_device *spi)
>>   spi_set_drvdata(spi, indio_dev);
>>
>>   indio_dev->dev.parent = >dev;
>> - indio_dev->dev.of_node = spi->dev.of_node;
>>   indio_dev->name = spi_get_device_id(spi)->name;
>>   indio_dev->modes = INDIO_DIRECT_MODE;
>>   indio_dev->channels = >chip_info->channel;
>>
>



-- 
Regards,
G.E.Hari Prasath


[PATCHv2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
v2: Wrong from mail ID in first version of patch
---
 drivers/staging/iio/adc/ad7192.c | 1 -
 drivers/staging/iio/adc/ad7780.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 78308a5..d11c6de 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,7 +668,6 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
-   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index e38d2ab9..dec3ba6 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,7 +195,6 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
-   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



[PATCHv2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath 
---
v2: Wrong from mail ID in first version of patch
---
 drivers/staging/iio/adc/ad7192.c | 1 -
 drivers/staging/iio/adc/ad7780.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 78308a5..d11c6de 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,7 +668,6 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
-   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index e38d2ab9..dec3ba6 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,7 +195,6 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
-   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



Re: [PATCH v2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread hari prasath
Kindly discard this patch versions. I will send a new one.

On 17 July 2017 at 17:49, Hari Prasath <geharipras...@gmail.com> wrote:
> Adding missing indio_dev->dev.of_node references to allow iio consumers
> to access the device channels.
>
> Signed-off-by: Hari Prasath <geharipras...@gmail.com>
> ---
> v2: Wrong from email ID in first version of patch
>
> ---
>  drivers/staging/iio/adc/ad7192.c | 1 +
>  drivers/staging/iio/adc/ad7780.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/drivers/staging/iio/adc/ad7192.c 
> b/drivers/staging/iio/adc/ad7192.c
> index d11c6de..78308a5 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
> spi_set_drvdata(spi, indio_dev);
> st->devid = spi_get_device_id(spi)->driver_data;
> indio_dev->dev.parent = >dev;
> +   indio_dev->dev.of_node = spi->dev.of_node;
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> diff --git a/drivers/staging/iio/adc/ad7780.c 
> b/drivers/staging/iio/adc/ad7780.c
> index dec3ba6..e38d2ab9 100644
> --- a/drivers/staging/iio/adc/ad7780.c
> +++ b/drivers/staging/iio/adc/ad7780.c
> @@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
> spi_set_drvdata(spi, indio_dev);
>
> indio_dev->dev.parent = >dev;
> +   indio_dev->dev.of_node = spi->dev.of_node;
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = >chip_info->channel;
> --
> 2.10.0.GIT
>



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH v2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread hari prasath
Kindly discard this patch versions. I will send a new one.

On 17 July 2017 at 17:49, Hari Prasath  wrote:
> Adding missing indio_dev->dev.of_node references to allow iio consumers
> to access the device channels.
>
> Signed-off-by: Hari Prasath 
> ---
> v2: Wrong from email ID in first version of patch
>
> ---
>  drivers/staging/iio/adc/ad7192.c | 1 +
>  drivers/staging/iio/adc/ad7780.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/drivers/staging/iio/adc/ad7192.c 
> b/drivers/staging/iio/adc/ad7192.c
> index d11c6de..78308a5 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
> spi_set_drvdata(spi, indio_dev);
> st->devid = spi_get_device_id(spi)->driver_data;
> indio_dev->dev.parent = >dev;
> +   indio_dev->dev.of_node = spi->dev.of_node;
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> diff --git a/drivers/staging/iio/adc/ad7780.c 
> b/drivers/staging/iio/adc/ad7780.c
> index dec3ba6..e38d2ab9 100644
> --- a/drivers/staging/iio/adc/ad7780.c
> +++ b/drivers/staging/iio/adc/ad7780.c
> @@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
> spi_set_drvdata(spi, indio_dev);
>
> indio_dev->dev.parent = >dev;
> +   indio_dev->dev.of_node = spi->dev.of_node;
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = >chip_info->channel;
> --
> 2.10.0.GIT
>



-- 
Regards,
G.E.Hari Prasath


[PATCH v2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
v2: Wrong from email ID in first version of patch

---
 drivers/staging/iio/adc/ad7192.c | 1 +
 drivers/staging/iio/adc/ad7780.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..78308a5 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6..e38d2ab9 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



[PATCH v2] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath 
---
v2: Wrong from email ID in first version of patch

---
 drivers/staging/iio/adc/ad7192.c | 1 +
 drivers/staging/iio/adc/ad7780.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..78308a5 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6..e38d2ab9 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



[PATCH] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
From: Hari Prasath <hguju...@visteon.com>

Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
 drivers/staging/iio/adc/ad7192.c | 1 +
 drivers/staging/iio/adc/ad7780.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..78308a5 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6..e38d2ab9 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



[PATCH] staging: iio: adc: add missing of_node references to iio_dev

2017-07-17 Thread Hari Prasath
From: Hari Prasath 

Adding missing indio_dev->dev.of_node references to allow iio consumers
to access the device channels.

Signed-off-by: Hari Prasath 
---
 drivers/staging/iio/adc/ad7192.c | 1 +
 drivers/staging/iio/adc/ad7780.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..78308a5 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -668,6 +668,7 @@ static int ad7192_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
st->devid = spi_get_device_id(spi)->driver_data;
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index dec3ba6..e38d2ab9 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -195,6 +195,7 @@ static int ad7780_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
 
indio_dev->dev.parent = >dev;
+   indio_dev->dev.of_node = spi->dev.of_node;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = >chip_info->channel;
-- 
2.10.0.GIT



Re: [PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-10 Thread hari prasath
On 10 July 2017 at 01:22, Sakari Ailus <sakari.ai...@iki.fi> wrote:
> On Sun, Jul 09, 2017 at 05:56:15PM +0530, hari prasath wrote:
>> On 8 July 2017 at 16:31, Sakari Ailus <sakari.ai...@iki.fi> wrote:
>> > Hi Hari,
>> >
>> > On Fri, Jul 07, 2017 at 08:15:21PM +0530, Hari Prasath wrote:
>> >> kstrdup kernel primitive can be used to replace kmalloc followed by
>> >> string copy. This was reported by coccinelle tool
>> >>
>> >> Signed-off-by: Hari Prasath <geharipras...@gmail.com>
>> >> ---
>> >>  .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 
>> >> +++---
>> >>  1 file changed, 3 insertions(+), 7 deletions(-)
>> >>
>> >> diff --git 
>> >> a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
>> >> b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> index 34cc56f..68db87b 100644
>> >> --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> @@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
>> >> ia_css_fw_info *bi, struct ia
>> >>   )
>> >>   {
>> >>   char *namebuffer;
>> >> - int namelength = (int)strlen(name);
>> >> -
>> >> - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
>> >> - if (namebuffer == NULL)
>> >> - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
>> >> -
>> >> - memcpy(namebuffer, name, namelength + 1);
>> >>
>> >> + namebuffer = kstrdup(name, GFP_KERNEL);
>> >> + if (!namebuffer)
>> >> + return -ENOMEM;
>> >
>> > The patch also changes the return value in error cases. I believe the
>> > caller(s) expect to get errors in the IA_CCS_ERR_* range.
>>
>> Hi,
>>
>> In this particular case, the calling function just checks if it's not
>> success defined by a enum. I think returning -ENOMEM would not effect,
>> at least in this case.
>
> It might not, but the function now returns both negative Posix and positive
> CSS error codes. The CSS error codes could well be converted to Posix but
> it should be done consistently and preferrably in a separate patch.


Hi Sakari, Thanks for your comments. I will stick with just replacing
with kstrdup and retain the original error return value. I will send a
v3.

Regards,
Hari

>
> --
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-10 Thread hari prasath
On 10 July 2017 at 01:22, Sakari Ailus  wrote:
> On Sun, Jul 09, 2017 at 05:56:15PM +0530, hari prasath wrote:
>> On 8 July 2017 at 16:31, Sakari Ailus  wrote:
>> > Hi Hari,
>> >
>> > On Fri, Jul 07, 2017 at 08:15:21PM +0530, Hari Prasath wrote:
>> >> kstrdup kernel primitive can be used to replace kmalloc followed by
>> >> string copy. This was reported by coccinelle tool
>> >>
>> >> Signed-off-by: Hari Prasath 
>> >> ---
>> >>  .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 
>> >> +++---
>> >>  1 file changed, 3 insertions(+), 7 deletions(-)
>> >>
>> >> diff --git 
>> >> a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
>> >> b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> index 34cc56f..68db87b 100644
>> >> --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> >> @@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
>> >> ia_css_fw_info *bi, struct ia
>> >>   )
>> >>   {
>> >>   char *namebuffer;
>> >> - int namelength = (int)strlen(name);
>> >> -
>> >> - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
>> >> - if (namebuffer == NULL)
>> >> - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
>> >> -
>> >> - memcpy(namebuffer, name, namelength + 1);
>> >>
>> >> + namebuffer = kstrdup(name, GFP_KERNEL);
>> >> + if (!namebuffer)
>> >> + return -ENOMEM;
>> >
>> > The patch also changes the return value in error cases. I believe the
>> > caller(s) expect to get errors in the IA_CCS_ERR_* range.
>>
>> Hi,
>>
>> In this particular case, the calling function just checks if it's not
>> success defined by a enum. I think returning -ENOMEM would not effect,
>> at least in this case.
>
> It might not, but the function now returns both negative Posix and positive
> CSS error codes. The CSS error codes could well be converted to Posix but
> it should be done consistently and preferrably in a separate patch.


Hi Sakari, Thanks for your comments. I will stick with just replacing
with kstrdup and retain the original error return value. I will send a
v3.

Regards,
Hari

>
> --
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk



-- 
Regards,
G.E.Hari Prasath


[PATCHv3] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-10 Thread Hari Prasath
kstrdup kernel primitive can be used to replace kmalloc followed by
string copy. This was reported by coccinelle tool.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
v1: Replace kmalloc followed by memcpy with kmemdup. Based on
review comments from Alan Cox, this could better be done
using kstrdup.
v2: Replace kmalloc followed by memcpy by kstrdup in this case
as it essentially is a string copy.Review comment recieved
questioning the return value in case of error. Error value
returned should be what the calling function is expecting.
v3: Retain the original error value returned to the calling
function if kstrdup() fails.
---
 .../staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c  | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..5d231ee 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
)
{
char *namebuffer;
-   int namelength = (int)strlen(name);
 
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
-   if (namebuffer == NULL)
+   namebuffer = kstrdup(name, GFP_KERNEL);
+   if (!namebuffer)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-
-   memcpy(namebuffer, name, namelength + 1);
-
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



[PATCHv3] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-10 Thread Hari Prasath
kstrdup kernel primitive can be used to replace kmalloc followed by
string copy. This was reported by coccinelle tool.

Signed-off-by: Hari Prasath 
---
v1: Replace kmalloc followed by memcpy with kmemdup. Based on
review comments from Alan Cox, this could better be done
using kstrdup.
v2: Replace kmalloc followed by memcpy by kstrdup in this case
as it essentially is a string copy.Review comment recieved
questioning the return value in case of error. Error value
returned should be what the calling function is expecting.
v3: Retain the original error value returned to the calling
function if kstrdup() fails.
---
 .../staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c  | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..5d231ee 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
)
{
char *namebuffer;
-   int namelength = (int)strlen(name);
 
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
-   if (namebuffer == NULL)
+   namebuffer = kstrdup(name, GFP_KERNEL);
+   if (!namebuffer)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-
-   memcpy(namebuffer, name, namelength + 1);
-
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



Re: [PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-09 Thread hari prasath
On 8 July 2017 at 16:31, Sakari Ailus <sakari.ai...@iki.fi> wrote:
> Hi Hari,
>
> On Fri, Jul 07, 2017 at 08:15:21PM +0530, Hari Prasath wrote:
>> kstrdup kernel primitive can be used to replace kmalloc followed by
>> string copy. This was reported by coccinelle tool
>>
>> Signed-off-by: Hari Prasath <geharipras...@gmail.com>
>> ---
>>  .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 
>> +++---
>>  1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git 
>> a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> index 34cc56f..68db87b 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> @@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
>> ia_css_fw_info *bi, struct ia
>>   )
>>   {
>>   char *namebuffer;
>> - int namelength = (int)strlen(name);
>> -
>> - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
>> - if (namebuffer == NULL)
>> - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
>> -
>> - memcpy(namebuffer, name, namelength + 1);
>>
>> + namebuffer = kstrdup(name, GFP_KERNEL);
>> + if (!namebuffer)
>> + return -ENOMEM;
>
> The patch also changes the return value in error cases. I believe the
> caller(s) expect to get errors in the IA_CCS_ERR_* range.

Hi,

In this particular case, the calling function just checks if it's not
success defined by a enum. I think returning -ENOMEM would not effect,
at least in this case.

- Hari Prasath


>
>>   bd->name = fw_minibuffer[index].name = namebuffer;
>>   } else {
>>   bd->name = name;
>
> --
> Regards,
>
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk



-- 
Regards,
G.E.Hari Prasath


Re: [PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-09 Thread hari prasath
On 8 July 2017 at 16:31, Sakari Ailus  wrote:
> Hi Hari,
>
> On Fri, Jul 07, 2017 at 08:15:21PM +0530, Hari Prasath wrote:
>> kstrdup kernel primitive can be used to replace kmalloc followed by
>> string copy. This was reported by coccinelle tool
>>
>> Signed-off-by: Hari Prasath 
>> ---
>>  .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 
>> +++---
>>  1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git 
>> a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> index 34cc56f..68db87b 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
>> @@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
>> ia_css_fw_info *bi, struct ia
>>   )
>>   {
>>   char *namebuffer;
>> - int namelength = (int)strlen(name);
>> -
>> - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
>> - if (namebuffer == NULL)
>> - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
>> -
>> - memcpy(namebuffer, name, namelength + 1);
>>
>> + namebuffer = kstrdup(name, GFP_KERNEL);
>> + if (!namebuffer)
>> + return -ENOMEM;
>
> The patch also changes the return value in error cases. I believe the
> caller(s) expect to get errors in the IA_CCS_ERR_* range.

Hi,

In this particular case, the calling function just checks if it's not
success defined by a enum. I think returning -ENOMEM would not effect,
at least in this case.

- Hari Prasath


>
>>   bd->name = fw_minibuffer[index].name = namebuffer;
>>   } else {
>>   bd->name = name;
>
> --
> Regards,
>
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk



-- 
Regards,
G.E.Hari Prasath


[PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-07 Thread Hari Prasath
kstrdup kernel primitive can be used to replace kmalloc followed by
string copy. This was reported by coccinelle tool

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..68db87b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
)
{
char *namebuffer;
-   int namelength = (int)strlen(name);
-
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
-   if (namebuffer == NULL)
-   return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-
-   memcpy(namebuffer, name, namelength + 1);
 
+   namebuffer = kstrdup(name, GFP_KERNEL);
+   if (!namebuffer)
+   return -ENOMEM;
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



[PATCH v2] staging: atomisp: use kstrdup to replace kmalloc and memcpy

2017-07-07 Thread Hari Prasath
kstrdup kernel primitive can be used to replace kmalloc followed by
string copy. This was reported by coccinelle tool

Signed-off-by: Hari Prasath 
---
 .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c   | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..68db87b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -144,14 +144,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
)
{
char *namebuffer;
-   int namelength = (int)strlen(name);
-
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
-   if (namebuffer == NULL)
-   return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-
-   memcpy(namebuffer, name, namelength + 1);
 
+   namebuffer = kstrdup(name, GFP_KERNEL);
+   if (!namebuffer)
+   return -ENOMEM;
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



Re: [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

2017-07-07 Thread hari prasath
On 07-Jul-2017 5:25 PM, "Alan Cox" <a...@linux.intel.com> wrote:

On Fri, 2017-07-07 at 17:20 +0530, Hari Prasath wrote:
> kmemdup can be used to replace kmalloc followed by a memcpy.This was
> pointed out by the coccinelle tool.

And kstrdup could do the job even better I think ?
> Yes & thanks for pointing me that. I will send a v2 version.

-Hari


Re: [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

2017-07-07 Thread hari prasath
On 07-Jul-2017 5:25 PM, "Alan Cox"  wrote:

On Fri, 2017-07-07 at 17:20 +0530, Hari Prasath wrote:
> kmemdup can be used to replace kmalloc followed by a memcpy.This was
> pointed out by the coccinelle tool.

And kstrdup could do the job even better I think ?
> Yes & thanks for pointing me that. I will send a v2 version.

-Hari


[PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

2017-07-07 Thread Hari Prasath
kmemdup can be used to replace kmalloc followed by a memcpy.This was
pointed out by the coccinelle tool.

Signed-off-by: Hari Prasath <geharipras...@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..58d4619 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -146,12 +146,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
char *namebuffer;
int namelength = (int)strlen(name);
 
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
+   namebuffer = (char *)kmemdup(name, namelength + 1, GFP_KERNEL);
if (namebuffer == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
 
-   memcpy(namebuffer, name, namelength + 1);
-
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



[PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

2017-07-07 Thread Hari Prasath
kmemdup can be used to replace kmalloc followed by a memcpy.This was
pointed out by the coccinelle tool.

Signed-off-by: Hari Prasath 
---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..58d4619 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -146,12 +146,10 @@ sh_css_load_blob_info(const char *fw, const struct 
ia_css_fw_info *bi, struct ia
char *namebuffer;
int namelength = (int)strlen(name);
 
-   namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
+   namebuffer = (char *)kmemdup(name, namelength + 1, GFP_KERNEL);
if (namebuffer == NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
 
-   memcpy(namebuffer, name, namelength + 1);
-
bd->name = fw_minibuffer[index].name = namebuffer;
} else {
bd->name = name;
-- 
2.10.0.GIT



[PATCHv2] staging: dgnc: convert to wait_event_interruptible_timeout

2016-02-07 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

This patch makes use of wait_event_interruptible_timeout to achieve
timeout functionality.This is a TODO mentiond in the comment which is also
removed.It also aligns with what the function is supposed to do as in the
comments.

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2: Patch introduced checkpatch warning on the 80 character
limit & it was pointed out by Greg.Hence resubmitting
---
 drivers/staging/dgnc/dgnc_neo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 39c76e7..ee3155b 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1306,10 +1306,10 @@ static int neo_drain(struct tty_struct *tty, uint 
seconds)
/*
 * Go to sleep waiting for the tty layer to wake me back up when
 * the empty flag goes away.
-*
-* NOTE: TODO: Do something with time passed in.
 */
-   rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & 
UN_EMPTY) == 0));
+   rc = wait_event_interruptible_timeout(un->un_flags_wait,
+ ((un->un_flags & UN_EMPTY) == 0),
+ msecs_to_jiffies(seconds * 1000));
 
/* If ret is non-zero, user ctrl-c'ed us */
return rc;
-- 
1.9.1


[PATCHv2] staging: rtl8192e: prefer using eth_broadcast_addr()

2016-02-07 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Prefer using the eth_broadcast_addr() instead of memset to broadcast
address 0xFF to the array.

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2: From email address was missing as pointed by Greg.
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index d0fedb0..2a57640 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -355,9 +355,9 @@ static inline struct sk_buff *rtllib_probe_req(struct 
rtllib_device *ieee)
req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ);
req->header.duration_id = 0;
 
-   memset(req->header.addr1, 0xff, ETH_ALEN);
+   eth_broadcast_addr(req->header.addr1);
ether_addr_copy(req->header.addr2, ieee->dev->dev_addr);
-   memset(req->header.addr3, 0xff, ETH_ALEN);
+   eth_broadcast_addr(req->header.addr3);
 
tag = (u8 *) skb_put(skb, len + 2 + rate_len);
 
-- 
1.9.1


[PATCHv2] staging: rtl8192e: prefer using eth_broadcast_addr()

2016-02-07 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Prefer using the eth_broadcast_addr() instead of memset to broadcast
address 0xFF to the array.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v2: From email address was missing as pointed by Greg.
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c 
b/drivers/staging/rtl8192e/rtllib_softmac.c
index d0fedb0..2a57640 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -355,9 +355,9 @@ static inline struct sk_buff *rtllib_probe_req(struct 
rtllib_device *ieee)
req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ);
req->header.duration_id = 0;
 
-   memset(req->header.addr1, 0xff, ETH_ALEN);
+   eth_broadcast_addr(req->header.addr1);
ether_addr_copy(req->header.addr2, ieee->dev->dev_addr);
-   memset(req->header.addr3, 0xff, ETH_ALEN);
+   eth_broadcast_addr(req->header.addr3);
 
tag = (u8 *) skb_put(skb, len + 2 + rate_len);
 
-- 
1.9.1


[PATCHv2] staging: dgnc: convert to wait_event_interruptible_timeout

2016-02-07 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

This patch makes use of wait_event_interruptible_timeout to achieve
timeout functionality.This is a TODO mentiond in the comment which is also
removed.It also aligns with what the function is supposed to do as in the
comments.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v2: Patch introduced checkpatch warning on the 80 character
limit & it was pointed out by Greg.Hence resubmitting
---
 drivers/staging/dgnc/dgnc_neo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 39c76e7..ee3155b 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1306,10 +1306,10 @@ static int neo_drain(struct tty_struct *tty, uint 
seconds)
/*
 * Go to sleep waiting for the tty layer to wake me back up when
 * the empty flag goes away.
-*
-* NOTE: TODO: Do something with time passed in.
 */
-   rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & 
UN_EMPTY) == 0));
+   rc = wait_event_interruptible_timeout(un->un_flags_wait,
+ ((un->un_flags & UN_EMPTY) == 0),
+ msecs_to_jiffies(seconds * 1000));
 
/* If ret is non-zero, user ctrl-c'ed us */
return rc;
-- 
1.9.1


[PATCHv2] staging: rdma: use setup_timer() api

2016-02-04 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Replace the timer API's to initialize a timer & then assign the callback
function by the setup_timer() API.

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2: Unwanted text present in the commit comments
sections.Removed them
---
 drivers/staging/rdma/ehca/ehca_main.c | 3 +--
 drivers/staging/rdma/hfi1/verbs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/ehca/ehca_main.c 
b/drivers/staging/rdma/ehca/ehca_main.c
index 832f22f..e545712 100644
--- a/drivers/staging/rdma/ehca/ehca_main.c
+++ b/drivers/staging/rdma/ehca/ehca_main.c
@@ -1073,8 +1073,7 @@ static int __init ehca_module_init(void)
ehca_gen_err("WARNING!!!");
ehca_gen_err("It is possible to lose interrupts.");
} else {
-   init_timer(_eqs_timer);
-   poll_eqs_timer.function = ehca_poll_eqs;
+   setup_timer(_eqs_timer, ehca_poll_eqs, 0UL);
poll_eqs_timer.expires = jiffies + HZ;
add_timer(_eqs_timer);
}
diff --git a/drivers/staging/rdma/hfi1/verbs.c 
b/drivers/staging/rdma/hfi1/verbs.c
index 09b8d41..769388d 100644
--- a/drivers/staging/rdma/hfi1/verbs.c
+++ b/drivers/staging/rdma/hfi1/verbs.c
@@ -1926,8 +1926,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
spin_lock_init(>n_qps_lock);
spin_lock_init(>n_srqs_lock);
spin_lock_init(>n_mcast_grps_lock);
-   init_timer(>mem_timer);
-   dev->mem_timer.function = mem_timer;
+   setup_timer(>mem_timer, mem_timer, 0UL);
dev->mem_timer.data = (unsigned long) dev;
 
/*
-- 
1.9.1


[PATCH] staging: rdma: use setup_timer() api

2016-02-04 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Date: Thu, 4 Feb 2016 18:46:31 +0530
Replace the timer API's to initialize a timer & then assign the callback
function by the setup_timer() API.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/rdma/ehca/ehca_main.c | 3 +--
 drivers/staging/rdma/hfi1/verbs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/ehca/ehca_main.c 
b/drivers/staging/rdma/ehca/ehca_main.c
index 832f22f..e545712 100644
--- a/drivers/staging/rdma/ehca/ehca_main.c
+++ b/drivers/staging/rdma/ehca/ehca_main.c
@@ -1073,8 +1073,7 @@ static int __init ehca_module_init(void)
ehca_gen_err("WARNING!!!");
ehca_gen_err("It is possible to lose interrupts.");
} else {
-   init_timer(_eqs_timer);
-   poll_eqs_timer.function = ehca_poll_eqs;
+   setup_timer(_eqs_timer, ehca_poll_eqs, 0UL);
poll_eqs_timer.expires = jiffies + HZ;
add_timer(_eqs_timer);
}
diff --git a/drivers/staging/rdma/hfi1/verbs.c 
b/drivers/staging/rdma/hfi1/verbs.c
index 09b8d41..769388d 100644
--- a/drivers/staging/rdma/hfi1/verbs.c
+++ b/drivers/staging/rdma/hfi1/verbs.c
@@ -1926,8 +1926,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
spin_lock_init(>n_qps_lock);
spin_lock_init(>n_srqs_lock);
spin_lock_init(>n_mcast_grps_lock);
-   init_timer(>mem_timer);
-   dev->mem_timer.function = mem_timer;
+   setup_timer(>mem_timer, mem_timer, 0UL);
dev->mem_timer.data = (unsigned long) dev;
 
/*
-- 
1.9.1


[PATCHv2] staging: rdma: use setup_timer() api

2016-02-04 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Replace the timer API's to initialize a timer & then assign the callback
function by the setup_timer() API.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v2: Unwanted text present in the commit comments
sections.Removed them
---
 drivers/staging/rdma/ehca/ehca_main.c | 3 +--
 drivers/staging/rdma/hfi1/verbs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/ehca/ehca_main.c 
b/drivers/staging/rdma/ehca/ehca_main.c
index 832f22f..e545712 100644
--- a/drivers/staging/rdma/ehca/ehca_main.c
+++ b/drivers/staging/rdma/ehca/ehca_main.c
@@ -1073,8 +1073,7 @@ static int __init ehca_module_init(void)
ehca_gen_err("WARNING!!!");
ehca_gen_err("It is possible to lose interrupts.");
} else {
-   init_timer(_eqs_timer);
-   poll_eqs_timer.function = ehca_poll_eqs;
+   setup_timer(_eqs_timer, ehca_poll_eqs, 0UL);
poll_eqs_timer.expires = jiffies + HZ;
add_timer(_eqs_timer);
}
diff --git a/drivers/staging/rdma/hfi1/verbs.c 
b/drivers/staging/rdma/hfi1/verbs.c
index 09b8d41..769388d 100644
--- a/drivers/staging/rdma/hfi1/verbs.c
+++ b/drivers/staging/rdma/hfi1/verbs.c
@@ -1926,8 +1926,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
spin_lock_init(>n_qps_lock);
spin_lock_init(>n_srqs_lock);
spin_lock_init(>n_mcast_grps_lock);
-   init_timer(>mem_timer);
-   dev->mem_timer.function = mem_timer;
+   setup_timer(>mem_timer, mem_timer, 0UL);
dev->mem_timer.data = (unsigned long) dev;
 
/*
-- 
1.9.1


[PATCH] staging: rdma: use setup_timer() api

2016-02-04 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Date: Thu, 4 Feb 2016 18:46:31 +0530
Replace the timer API's to initialize a timer & then assign the callback
function by the setup_timer() API.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/rdma/ehca/ehca_main.c | 3 +--
 drivers/staging/rdma/hfi1/verbs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/ehca/ehca_main.c 
b/drivers/staging/rdma/ehca/ehca_main.c
index 832f22f..e545712 100644
--- a/drivers/staging/rdma/ehca/ehca_main.c
+++ b/drivers/staging/rdma/ehca/ehca_main.c
@@ -1073,8 +1073,7 @@ static int __init ehca_module_init(void)
ehca_gen_err("WARNING!!!");
ehca_gen_err("It is possible to lose interrupts.");
} else {
-   init_timer(_eqs_timer);
-   poll_eqs_timer.function = ehca_poll_eqs;
+   setup_timer(_eqs_timer, ehca_poll_eqs, 0UL);
poll_eqs_timer.expires = jiffies + HZ;
add_timer(_eqs_timer);
}
diff --git a/drivers/staging/rdma/hfi1/verbs.c 
b/drivers/staging/rdma/hfi1/verbs.c
index 09b8d41..769388d 100644
--- a/drivers/staging/rdma/hfi1/verbs.c
+++ b/drivers/staging/rdma/hfi1/verbs.c
@@ -1926,8 +1926,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
spin_lock_init(>n_qps_lock);
spin_lock_init(>n_srqs_lock);
spin_lock_init(>n_mcast_grps_lock);
-   init_timer(>mem_timer);
-   dev->mem_timer.function = mem_timer;
+   setup_timer(>mem_timer, mem_timer, 0UL);
dev->mem_timer.data = (unsigned long) dev;
 
/*
-- 
1.9.1


Re: [PATCH] staging: wilc1000: Move Macro definition

2016-02-03 Thread Gujulan Elango, Hari Prasath (H.)
On Wed, Feb 03, 2016 at 03:19:50PM -0800, gre...@linuxfoundation.org wrote:
> On Mon, Jan 18, 2016 at 01:42:35PM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > From: Hari Prasath Gujulan Elango 
> > 
> > This patch move's a macro defined in the middle of a structure
> > definition to make it more readable.
> > 
> > Signed-off-by: Hari Prasath Gujulan Elango 
> > ---
> >  drivers/staging/wilc1000/wilc_sdio.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
> > b/drivers/staging/wilc1000/wilc_sdio.c
> > index e961b50..875ea68 100644
> > --- a/drivers/staging/wilc1000/wilc_sdio.c
> > +++ b/drivers/staging/wilc1000/wilc_sdio.c
> > @@ -29,12 +29,12 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
> >  };
> >  
> >  #define WILC_SDIO_BLOCK_SIZE 512
> > +#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in 
> > registers 0xf7, 0xf8 */
> >  
> >  typedef struct {
> > bool irq_gpio;
> > u32 block_size;
> > int nint;
> > -#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in 
> > registers 0xf7, 0xf8 */
> 
> No, this is a very common way to show that this define is for this field
> in the structure, please don't change that.
> 
> sorry,
> 
> greg k-h

Thanks Greg,I got the message clear.Please discard this patch.
Regards,
Hari


Re: [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation

2016-02-03 Thread Gujulan Elango, Hari Prasath (H.)
On Wed, Feb 03, 2016 at 10:11:04AM -0800, Laura Abbott wrote:
> On 02/03/2016 04:03 AM, Robin Murphy wrote:
> >On 03/02/16 06:49, Gujulan Elango, Hari Prasath (H.) wrote:
> >>From: Hari Prasath Gujulan Elango 
> >>
> >>Use the managed version of the dma_alloc_coherent() i.e. the
> >>dmam_alloc_coherent() & accordingly cleanup the error handling
> >>part.Also,remove the references to dma_free_coherent
> >
> >That last aspect looks a bit off to me - the heaps don't seem to be 
> >something that exist for the lifetime of the ION "device", given that these 
> >are specific runtime alloc and free calls, rather than the probe and remove 
> >routines. I don't know if CMA heaps are among those which ION creates and 
> >destroys frequently (enough that it apparently kicks off a whole background 
> >thread to manage the freeing), but this looks like a recipe for leaks. If 
> >the free call doesn't actually free the buffer, it's going to remain hanging 
> >around consuming precious CMA area until the ION device itself is torn down, 
> >which is likely never.
> >
> >I wouldn't say it's necessarily inappropriate to use managed DMA resources 
> >here to cover unexpected failure cases for the ION device itself (I see the 
> >comment in ion_device_remove()), but that means still using 
> >dmam_free_coherent() when naturally releasing allocations for other reasons 
> >(i.e. both cases here). Think Java finalisers, rather than C++ destructors.
> >
> >Robin.
> >
> 
> Yes, Robin is correct. These allocations are not tied to the lifetime of the
> device so it is incorrect to move to the manged APIs. The dma_alloc_coherent
> allocations are done on request.
> 
> Ion isn't a good candidate to look at to switch APIs over to the devm
> interface since it does many things in a non-standard way. You should
> probably focus devm efforts outside of Ion (although if you find a
> potential patch I'll certainly review it)
> 
> Thanks,
> Laura
> 
> >>Signed-off-by: Hari Prasath Gujulan Elango 
> >>---
> >>v2:kbuild test robot reported warnings on ununsed
> >>   variables.Those warnings are fixed.
> >>---
> >>  drivers/staging/android/ion/ion_cma_heap.c | 11 ++-
> >>  1 file changed, 2 insertions(+), 9 deletions(-)
> >>
> >>diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
> >>b/drivers/staging/android/ion/ion_cma_heap.c
> >>index a3446da..8cd720b 100644
> >>--- a/drivers/staging/android/ion/ion_cma_heap.c
> >>+++ b/drivers/staging/android/ion/ion_cma_heap.c
> >>@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>  if (!info)
> >>  return ION_CMA_ALLOCATE_FAILED;
> >>
> >>-info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
> >>+info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
> >>  GFP_HIGHUSER | __GFP_ZERO);
> >>
> >>  if (!info->cpu_addr) {
> >>@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>
> >>  info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
> >>  if (!info->table)
> >>-goto free_mem;
> >>+goto err;
> >>
> >>  if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
> >>  len))
> >>@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>
> >>  free_table:
> >>  kfree(info->table);
> >>-free_mem:
> >>-dma_free_coherent(dev, len, info->cpu_addr, info->handle);
> >>  err:
> >>  kfree(info);
> >>  return ION_CMA_ALLOCATE_FAILED;
> >>@@ -92,13 +90,8 @@ err:
> >>
> >>  static void ion_cma_free(struct ion_buffer *buffer)
> >>  {
> >>-struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
> >>-struct device *dev = cma_heap->dev;
> >>  struct ion_cma_buffer_info *info = buffer->priv_virt;
> >>
> >>-dev_dbg(dev, "Release buffer %p\n", buffer);
> >>-/* release memory */
> >>-dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
> >>  /* release sg table */
> >>  sg_free_table(info->table);
> >>  kfree(info->table);
> >>
> >
> 
Robin & Laura,

Thanks for your review comments & I agreee both of you on this. Let's
drop this patch.

Regards
Hari Prasath


Re: [PATCH] staging: wilc1000: Move Macro definition

2016-02-03 Thread Gujulan Elango, Hari Prasath (H.)
On Wed, Feb 03, 2016 at 03:19:50PM -0800, gre...@linuxfoundation.org wrote:
> On Mon, Jan 18, 2016 at 01:42:35PM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > From: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> > 
> > This patch move's a macro defined in the middle of a structure
> > definition to make it more readable.
> > 
> > Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> > ---
> >  drivers/staging/wilc1000/wilc_sdio.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
> > b/drivers/staging/wilc1000/wilc_sdio.c
> > index e961b50..875ea68 100644
> > --- a/drivers/staging/wilc1000/wilc_sdio.c
> > +++ b/drivers/staging/wilc1000/wilc_sdio.c
> > @@ -29,12 +29,12 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
> >  };
> >  
> >  #define WILC_SDIO_BLOCK_SIZE 512
> > +#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in 
> > registers 0xf7, 0xf8 */
> >  
> >  typedef struct {
> > bool irq_gpio;
> > u32 block_size;
> > int nint;
> > -#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in 
> > registers 0xf7, 0xf8 */
> 
> No, this is a very common way to show that this define is for this field
> in the structure, please don't change that.
> 
> sorry,
> 
> greg k-h

Thanks Greg,I got the message clear.Please discard this patch.
Regards,
Hari


Re: [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation

2016-02-03 Thread Gujulan Elango, Hari Prasath (H.)
On Wed, Feb 03, 2016 at 10:11:04AM -0800, Laura Abbott wrote:
> On 02/03/2016 04:03 AM, Robin Murphy wrote:
> >On 03/02/16 06:49, Gujulan Elango, Hari Prasath (H.) wrote:
> >>From: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> >>
> >>Use the managed version of the dma_alloc_coherent() i.e. the
> >>dmam_alloc_coherent() & accordingly cleanup the error handling
> >>part.Also,remove the references to dma_free_coherent
> >
> >That last aspect looks a bit off to me - the heaps don't seem to be 
> >something that exist for the lifetime of the ION "device", given that these 
> >are specific runtime alloc and free calls, rather than the probe and remove 
> >routines. I don't know if CMA heaps are among those which ION creates and 
> >destroys frequently (enough that it apparently kicks off a whole background 
> >thread to manage the freeing), but this looks like a recipe for leaks. If 
> >the free call doesn't actually free the buffer, it's going to remain hanging 
> >around consuming precious CMA area until the ION device itself is torn down, 
> >which is likely never.
> >
> >I wouldn't say it's necessarily inappropriate to use managed DMA resources 
> >here to cover unexpected failure cases for the ION device itself (I see the 
> >comment in ion_device_remove()), but that means still using 
> >dmam_free_coherent() when naturally releasing allocations for other reasons 
> >(i.e. both cases here). Think Java finalisers, rather than C++ destructors.
> >
> >Robin.
> >
> 
> Yes, Robin is correct. These allocations are not tied to the lifetime of the
> device so it is incorrect to move to the manged APIs. The dma_alloc_coherent
> allocations are done on request.
> 
> Ion isn't a good candidate to look at to switch APIs over to the devm
> interface since it does many things in a non-standard way. You should
> probably focus devm efforts outside of Ion (although if you find a
> potential patch I'll certainly review it)
> 
> Thanks,
> Laura
> 
> >>Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> >>---
> >>v2:kbuild test robot reported warnings on ununsed
> >>   variables.Those warnings are fixed.
> >>---
> >>  drivers/staging/android/ion/ion_cma_heap.c | 11 ++-
> >>  1 file changed, 2 insertions(+), 9 deletions(-)
> >>
> >>diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
> >>b/drivers/staging/android/ion/ion_cma_heap.c
> >>index a3446da..8cd720b 100644
> >>--- a/drivers/staging/android/ion/ion_cma_heap.c
> >>+++ b/drivers/staging/android/ion/ion_cma_heap.c
> >>@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>  if (!info)
> >>  return ION_CMA_ALLOCATE_FAILED;
> >>
> >>-info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
> >>+info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
> >>  GFP_HIGHUSER | __GFP_ZERO);
> >>
> >>  if (!info->cpu_addr) {
> >>@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>
> >>  info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
> >>  if (!info->table)
> >>-goto free_mem;
> >>+goto err;
> >>
> >>  if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
> >>  len))
> >>@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
> >>ion_buffer *buffer,
> >>
> >>  free_table:
> >>  kfree(info->table);
> >>-free_mem:
> >>-dma_free_coherent(dev, len, info->cpu_addr, info->handle);
> >>  err:
> >>  kfree(info);
> >>  return ION_CMA_ALLOCATE_FAILED;
> >>@@ -92,13 +90,8 @@ err:
> >>
> >>  static void ion_cma_free(struct ion_buffer *buffer)
> >>  {
> >>-struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
> >>-struct device *dev = cma_heap->dev;
> >>  struct ion_cma_buffer_info *info = buffer->priv_virt;
> >>
> >>-dev_dbg(dev, "Release buffer %p\n", buffer);
> >>-/* release memory */
> >>-dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
> >>  /* release sg table */
> >>  sg_free_table(info->table);
> >>  kfree(info->table);
> >>
> >
> 
Robin & Laura,

Thanks for your review comments & I agreee both of you on this. Let's
drop this patch.

Regards
Hari Prasath


[PATCHv2] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2:kbuild test robot reported warnings on ununsed
   variables.Those warnings are fixed.
---
 drivers/staging/android/ion/ion_cma_heap.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..8cd720b 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -92,13 +90,8 @@ err:
 
 static void ion_cma_free(struct ion_buffer *buffer)
 {
-   struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
-   struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


[PATCH] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/android/ion/ion_cma_heap.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..88375d9 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -96,9 +94,6 @@ static void ion_cma_free(struct ion_buffer *buffer)
struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


[PATCHv3] staging: iio: replace clk_get() with devm_clk_get()

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
This patch replaces the clk_get() with devm_clk_get().Accordingly,modified
the error paths,rename error labels and removed clk_put() in probe() &
remove functions.

Signed-off-by: Hari Prasath Gujulan Elango 
---
v3: Rename error path labels to suite modified code as reviewd
by Matt Ranostay.
Remove clk_put() from the driver remove method as pointed by
Jonathan Cameron.

v2: From email address was missing as pointed by Dan Carpenter.
---
 drivers/staging/iio/adc/spear_adc.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..f2c0065 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,28 +297,28 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
if (irq <= 0) {
dev_err(dev, "failed getting interrupt resource\n");
ret = -EINVAL;
-   goto errout3;
+   goto errout2;
}
 
ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME,
   st);
if (ret < 0) {
dev_err(dev, "failed requesting interrupt\n");
-   goto errout3;
+   goto errout2;
}
 
if (of_property_read_u32(np, "sampling-frequency",
 >sampling_freq)) {
dev_err(dev, "sampling-frequency missing in DT\n");
ret = -EINVAL;
-   goto errout3;
+   goto errout2;
}
 
/*
@@ -348,16 +348,14 @@ static int spear_adc_probe(struct platform_device *pdev)
 
ret = iio_device_register(indio_dev);
if (ret)
-   goto errout3;
+   goto errout2;
 
dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
 
return 0;
 
-errout3:
-   clk_disable_unprepare(st->clk);
 errout2:
-   clk_put(st->clk);
+   clk_disable_unprepare(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
@@ -370,7 +368,6 @@ static int spear_adc_remove(struct platform_device *pdev)
 
iio_device_unregister(indio_dev);
clk_disable_unprepare(st->clk);
-   clk_put(st->clk);
iounmap(st->adc_base_spear6xx);
 
return 0;
-- 
1.9.1


[PATCH] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/android/ion/ion_cma_heap.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..88375d9 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -96,9 +94,6 @@ static void ion_cma_free(struct ion_buffer *buffer)
struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


[PATCHv2] staging: android: ion: use the manged version of DMA memory allocation

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v2:kbuild test robot reported warnings on ununsed
   variables.Those warnings are fixed.
---
 drivers/staging/android/ion/ion_cma_heap.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c 
b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..8cd720b 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
if (!info)
return ION_CMA_ALLOCATE_FAILED;
 
-   info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+   info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
 
if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
if (!info->table)
-   goto free_mem;
+   goto err;
 
if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct 
ion_buffer *buffer,
 
 free_table:
kfree(info->table);
-free_mem:
-   dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
kfree(info);
return ION_CMA_ALLOCATE_FAILED;
@@ -92,13 +90,8 @@ err:
 
 static void ion_cma_free(struct ion_buffer *buffer)
 {
-   struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
-   struct device *dev = cma_heap->dev;
struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-   dev_dbg(dev, "Release buffer %p\n", buffer);
-   /* release memory */
-   dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
/* release sg table */
sg_free_table(info->table);
kfree(info->table);
-- 
1.9.1


[PATCHv3] staging: iio: replace clk_get() with devm_clk_get()

2016-02-02 Thread Gujulan Elango, Hari Prasath (H.)
This patch replaces the clk_get() with devm_clk_get().Accordingly,modified
the error paths,rename error labels and removed clk_put() in probe() &
remove functions.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v3: Rename error path labels to suite modified code as reviewd
by Matt Ranostay.
Remove clk_put() from the driver remove method as pointed by
Jonathan Cameron.

v2: From email address was missing as pointed by Dan Carpenter.
---
 drivers/staging/iio/adc/spear_adc.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..f2c0065 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,28 +297,28 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
if (irq <= 0) {
dev_err(dev, "failed getting interrupt resource\n");
ret = -EINVAL;
-   goto errout3;
+   goto errout2;
}
 
ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME,
   st);
if (ret < 0) {
dev_err(dev, "failed requesting interrupt\n");
-   goto errout3;
+   goto errout2;
}
 
if (of_property_read_u32(np, "sampling-frequency",
 >sampling_freq)) {
dev_err(dev, "sampling-frequency missing in DT\n");
ret = -EINVAL;
-   goto errout3;
+   goto errout2;
}
 
/*
@@ -348,16 +348,14 @@ static int spear_adc_probe(struct platform_device *pdev)
 
ret = iio_device_register(indio_dev);
if (ret)
-   goto errout3;
+   goto errout2;
 
dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
 
return 0;
 
-errout3:
-   clk_disable_unprepare(st->clk);
 errout2:
-   clk_put(st->clk);
+   clk_disable_unprepare(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
@@ -370,7 +368,6 @@ static int spear_adc_remove(struct platform_device *pdev)
 
iio_device_unregister(indio_dev);
clk_disable_unprepare(st->clk);
-   clk_put(st->clk);
iounmap(st->adc_base_spear6xx);
 
return 0;
-- 
1.9.1


Re: [PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-22 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Jan 21, 2016 at 11:21:53AM -0800, Matt Ranostay wrote:
> On Thu, Jan 21, 2016 at 1:11 AM, Gujulan Elango, Hari Prasath (H.)
>  wrote:
> > From: Hari Prasath Gujulan Elango
> >
> > This patch replaces the clk_get() with devm_clk_get().
> > Accordingly,modified the error paths and removed clk_put() as well.
> >
> > Signed-off-by: Hari Prasath Gujulan Elango 
> > ---
> >  drivers/staging/iio/adc/spear_adc.c | 6 ++
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/iio/adc/spear_adc.c 
> > b/drivers/staging/iio/adc/spear_adc.c
> > index 712cae0..4ac0f54 100644
> > --- a/drivers/staging/iio/adc/spear_adc.c
> > +++ b/drivers/staging/iio/adc/spear_adc.c
> > @@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
> > st->adc_base_spear3xx =
> > (struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
> >
> > -   st->clk = clk_get(dev, NULL);
> > +   st->clk = devm_clk_get(dev, NULL);
> > if (IS_ERR(st->clk)) {
> > dev_err(dev, "failed getting clock\n");
> > goto errout1;
> > @@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
> > ret = clk_prepare_enable(st->clk);
> > if (ret) {
> > dev_err(dev, "failed enabling clock\n");
> > -   goto errout2;
> > +   goto errout1;
> > }
> >
> > irq = platform_get_irq(pdev, 0);
> > @@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
> >
> >  errout3:
> > clk_disable_unprepare(st->clk);
> 
> Shouldn't errout3 now be errout2.. having a gap would seem odd.
> 
I agree with you on this. But as Dan says,I would correct it in a
different patch.
> > -errout2:
> > -   clk_put(st->clk);
> >  errout1:
> > iounmap(st->adc_base_spear6xx);
> > return ret;
> > --
> > 1.9.1


Re: [PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-22 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Jan 21, 2016 at 11:21:53AM -0800, Matt Ranostay wrote:
> On Thu, Jan 21, 2016 at 1:11 AM, Gujulan Elango, Hari Prasath (H.)
> <hguju...@visteon.com> wrote:
> > From: Hari Prasath Gujulan Elango
> >
> > This patch replaces the clk_get() with devm_clk_get().
> > Accordingly,modified the error paths and removed clk_put() as well.
> >
> > Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> > ---
> >  drivers/staging/iio/adc/spear_adc.c | 6 ++
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/iio/adc/spear_adc.c 
> > b/drivers/staging/iio/adc/spear_adc.c
> > index 712cae0..4ac0f54 100644
> > --- a/drivers/staging/iio/adc/spear_adc.c
> > +++ b/drivers/staging/iio/adc/spear_adc.c
> > @@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
> > st->adc_base_spear3xx =
> > (struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
> >
> > -   st->clk = clk_get(dev, NULL);
> > +   st->clk = devm_clk_get(dev, NULL);
> > if (IS_ERR(st->clk)) {
> > dev_err(dev, "failed getting clock\n");
> > goto errout1;
> > @@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
> > ret = clk_prepare_enable(st->clk);
> > if (ret) {
> > dev_err(dev, "failed enabling clock\n");
> > -   goto errout2;
> > +   goto errout1;
> > }
> >
> > irq = platform_get_irq(pdev, 0);
> > @@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
> >
> >  errout3:
> > clk_disable_unprepare(st->clk);
> 
> Shouldn't errout3 now be errout2.. having a gap would seem odd.
> 
I agree with you on this. But as Dan says,I would correct it in a
different patch.
> > -errout2:
> > -   clk_put(st->clk);
> >  errout1:
> > iounmap(st->adc_base_spear6xx);
> > return ret;
> > --
> > 1.9.1


[PATCH] staging: nvec: replace led_classdev_register

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Replace the led_classdev_register() with the platform managed version
devm_led_classdev_register() & henceforth remove the redundant
nvec_paz00_remove() function.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/nvec/nvec_paz00.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/nvec/nvec_paz00.c 
b/drivers/staging/nvec/nvec_paz00.c
index 68146bf..cddbfd2 100644
--- a/drivers/staging/nvec/nvec_paz00.c
+++ b/drivers/staging/nvec/nvec_paz00.c
@@ -63,7 +63,7 @@ static int nvec_paz00_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, led);
 
-   ret = led_classdev_register(>dev, >cdev);
+   ret = devm_led_classdev_register(>dev, >cdev);
if (ret < 0)
return ret;
 
@@ -73,18 +73,8 @@ static int nvec_paz00_probe(struct platform_device *pdev)
return 0;
 }
 
-static int nvec_paz00_remove(struct platform_device *pdev)
-{
-   struct nvec_led *led = platform_get_drvdata(pdev);
-
-   led_classdev_unregister(>cdev);
-
-   return 0;
-}
-
 static struct platform_driver nvec_paz00_driver = {
.probe  = nvec_paz00_probe,
-   .remove = nvec_paz00_remove,
.driver = {
.name  = "nvec-paz00",
},
-- 
1.9.1


[PATCHv2] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

This patch replaces the clk_get() with devm_clk_get().
Accordingly,modified the error paths and removed clk_put() as well.

Signed-off-by: Hari Prasath Gujulan Elango 
---
v2: email address was missing in the From field.
---
 drivers/staging/iio/adc/spear_adc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..4ac0f54 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
@@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 errout3:
clk_disable_unprepare(st->clk);
-errout2:
-   clk_put(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
-- 
1.9.1


Re: [PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Jan 21, 2016 at 12:45:59PM +0300, Dan Carpenter wrote:
> On Thu, Jan 21, 2016 at 09:11:38AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > From: Hari Prasath Gujulan Elango
> > 
> 
> Your email address is missing here.
Hello Dan,
Many thanks for notifying.I am sending a v2.

regards,
Hari Prasath

> 
> regards,
> dan carpenter
> 


[PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango

This patch replaces the clk_get() with devm_clk_get().
Accordingly,modified the error paths and removed clk_put() as well.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/iio/adc/spear_adc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..4ac0f54 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
@@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 errout3:
clk_disable_unprepare(st->clk);
-errout2:
-   clk_put(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
-- 
1.9.1


Re: [PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Jan 21, 2016 at 12:45:59PM +0300, Dan Carpenter wrote:
> On Thu, Jan 21, 2016 at 09:11:38AM +, Gujulan Elango, Hari Prasath (H.) 
> wrote:
> > From: Hari Prasath Gujulan Elango
> > 
> 
> Your email address is missing here.
Hello Dan,
Many thanks for notifying.I am sending a v2.

regards,
Hari Prasath

> 
> regards,
> dan carpenter
> 


[PATCH] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango

This patch replaces the clk_get() with devm_clk_get().
Accordingly,modified the error paths and removed clk_put() as well.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/iio/adc/spear_adc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..4ac0f54 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
@@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 errout3:
clk_disable_unprepare(st->clk);
-errout2:
-   clk_put(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
-- 
1.9.1


[PATCH] staging: nvec: replace led_classdev_register

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Replace the led_classdev_register() with the platform managed version
devm_led_classdev_register() & henceforth remove the redundant
nvec_paz00_remove() function.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/nvec/nvec_paz00.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/nvec/nvec_paz00.c 
b/drivers/staging/nvec/nvec_paz00.c
index 68146bf..cddbfd2 100644
--- a/drivers/staging/nvec/nvec_paz00.c
+++ b/drivers/staging/nvec/nvec_paz00.c
@@ -63,7 +63,7 @@ static int nvec_paz00_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, led);
 
-   ret = led_classdev_register(>dev, >cdev);
+   ret = devm_led_classdev_register(>dev, >cdev);
if (ret < 0)
return ret;
 
@@ -73,18 +73,8 @@ static int nvec_paz00_probe(struct platform_device *pdev)
return 0;
 }
 
-static int nvec_paz00_remove(struct platform_device *pdev)
-{
-   struct nvec_led *led = platform_get_drvdata(pdev);
-
-   led_classdev_unregister(>cdev);
-
-   return 0;
-}
-
 static struct platform_driver nvec_paz00_driver = {
.probe  = nvec_paz00_probe,
-   .remove = nvec_paz00_remove,
.driver = {
.name  = "nvec-paz00",
},
-- 
1.9.1


[PATCHv2] staging: iio: replace clk_get() with devm_clk_get()

2016-01-21 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

This patch replaces the clk_get() with devm_clk_get().
Accordingly,modified the error paths and removed clk_put() as well.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
v2: email address was missing in the From field.
---
 drivers/staging/iio/adc/spear_adc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
index 712cae0..4ac0f54 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -288,7 +288,7 @@ static int spear_adc_probe(struct platform_device *pdev)
st->adc_base_spear3xx =
(struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx;
 
-   st->clk = clk_get(dev, NULL);
+   st->clk = devm_clk_get(dev, NULL);
if (IS_ERR(st->clk)) {
dev_err(dev, "failed getting clock\n");
goto errout1;
@@ -297,7 +297,7 @@ static int spear_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(st->clk);
if (ret) {
dev_err(dev, "failed enabling clock\n");
-   goto errout2;
+   goto errout1;
}
 
irq = platform_get_irq(pdev, 0);
@@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 errout3:
clk_disable_unprepare(st->clk);
-errout2:
-   clk_put(st->clk);
 errout1:
iounmap(st->adc_base_spear6xx);
return ret;
-- 
1.9.1


Re: [PATCH] staging: most: replace multiple if..else with table lookup

2015-12-30 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Dec 24, 2015 at 08:06:26AM -0800, Joe Perches wrote:
> On Thu, 2015-12-24 at 10:49 +, Gujulan Elango, Hari Prasath (H.) wrote:
> > From: Hari Prasath Gujulan Elango 
> > 
> > Replace multiple if..else if..statements with simple table lookup in two
> > functions.
> > 
> > Signed-off-by: Hari Prasath Gujulan Elango 
> > ---
> >  drivers/staging/most/mostcore/core.c | 39 
> > 
> >  1 file changed, 22 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/staging/most/mostcore/core.c 
> > b/drivers/staging/most/mostcore/core.c
> > index ed1ed25..7b4636b 100644
> > --- a/drivers/staging/most/mostcore/core.c
> > +++ b/drivers/staging/most/mostcore/core.c
> > @@ -82,6 +82,14 @@ struct most_inst_obj {
> >     struct list_head list;
> >  };
> >  
> > +static const struct {
> > +   int most_ch_data_type;
> > +   char *name;
> > +} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
> > +   { MOST_CH_ASYNC, "async\n" },
> > +   { MOST_CH_SYNC, "sync\n" },
> > +   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
> > +
> >  #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
> >  
> >  /**
> > @@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
> >      struct most_c_attr *attr,
> >      char *buf)
> >  {
> > -   if (c->cfg.data_type & MOST_CH_CONTROL)
> > -   return snprintf(buf, PAGE_SIZE, "control\n");
> > -   else if (c->cfg.data_type & MOST_CH_ASYNC)
> > -   return snprintf(buf, PAGE_SIZE, "async\n");
> > -   else if (c->cfg.data_type & MOST_CH_SYNC)
> > -   return snprintf(buf, PAGE_SIZE, "sync\n");
> > -   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
> > -   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
> > +   int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
> > +   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
> > +   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
> > +   }
> >     return snprintf(buf, PAGE_SIZE, "unconfigured\n");
> >  }
> >  
> > @@ -430,15 +436,14 @@ static ssize_t store_set_datatype(struct most_c_obj 
> > *c,
> >       const char *buf,
> >       size_t count)
> >  {
> > -   if (!strcmp(buf, "control\n")) {
> > -   c->cfg.data_type = MOST_CH_CONTROL;
> > -   } else if (!strcmp(buf, "async\n")) {
> > -   c->cfg.data_type = MOST_CH_ASYNC;
> > -   } else if (!strcmp(buf, "sync\n")) {
> > -   c->cfg.data_type = MOST_CH_SYNC;
> > -   } else if (!strcmp(buf, "isoc_avp\n")) {
> > -   c->cfg.data_type = MOST_CH_ISOC_AVP;
> > -   } else {
> > +   int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
> > +   if (!strcmp(buf, ch_data_type[i].name))
> > +   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
> 
> Missing braces and break;
> 
> > +   }
> > +
> > +   if (i == ARRAY_SIZE(ch_data_type)) {
> >     pr_info("WARN: invalid attribute settings\n");
> >     return -EINVAL;
> >     }
> 
> This seems like a lot of code for a simple test.
> 
Hello Joe,
I have sent a v2 for this patch with corrections made.

Regards,
Hari Prasath--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: most: replace multiple if..else with table lookup

2015-12-30 Thread Gujulan Elango, Hari Prasath (H.)
On Thu, Dec 24, 2015 at 08:06:26AM -0800, Joe Perches wrote:
> On Thu, 2015-12-24 at 10:49 +, Gujulan Elango, Hari Prasath (H.) wrote:
> > From: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> > 
> > Replace multiple if..else if..statements with simple table lookup in two
> > functions.
> > 
> > Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
> > ---
> >  drivers/staging/most/mostcore/core.c | 39 
> > 
> >  1 file changed, 22 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/staging/most/mostcore/core.c 
> > b/drivers/staging/most/mostcore/core.c
> > index ed1ed25..7b4636b 100644
> > --- a/drivers/staging/most/mostcore/core.c
> > +++ b/drivers/staging/most/mostcore/core.c
> > @@ -82,6 +82,14 @@ struct most_inst_obj {
> >     struct list_head list;
> >  };
> >  
> > +static const struct {
> > +   int most_ch_data_type;
> > +   char *name;
> > +} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
> > +   { MOST_CH_ASYNC, "async\n" },
> > +   { MOST_CH_SYNC, "sync\n" },
> > +   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
> > +
> >  #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
> >  
> >  /**
> > @@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
> >      struct most_c_attr *attr,
> >      char *buf)
> >  {
> > -   if (c->cfg.data_type & MOST_CH_CONTROL)
> > -   return snprintf(buf, PAGE_SIZE, "control\n");
> > -   else if (c->cfg.data_type & MOST_CH_ASYNC)
> > -   return snprintf(buf, PAGE_SIZE, "async\n");
> > -   else if (c->cfg.data_type & MOST_CH_SYNC)
> > -   return snprintf(buf, PAGE_SIZE, "sync\n");
> > -   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
> > -   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
> > +   int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
> > +   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
> > +   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
> > +   }
> >     return snprintf(buf, PAGE_SIZE, "unconfigured\n");
> >  }
> >  
> > @@ -430,15 +436,14 @@ static ssize_t store_set_datatype(struct most_c_obj 
> > *c,
> >       const char *buf,
> >       size_t count)
> >  {
> > -   if (!strcmp(buf, "control\n")) {
> > -   c->cfg.data_type = MOST_CH_CONTROL;
> > -   } else if (!strcmp(buf, "async\n")) {
> > -   c->cfg.data_type = MOST_CH_ASYNC;
> > -   } else if (!strcmp(buf, "sync\n")) {
> > -   c->cfg.data_type = MOST_CH_SYNC;
> > -   } else if (!strcmp(buf, "isoc_avp\n")) {
> > -   c->cfg.data_type = MOST_CH_ISOC_AVP;
> > -   } else {
> > +   int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
> > +   if (!strcmp(buf, ch_data_type[i].name))
> > +   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
> 
> Missing braces and break;
> 
> > +   }
> > +
> > +   if (i == ARRAY_SIZE(ch_data_type)) {
> >     pr_info("WARN: invalid attribute settings\n");
> >     return -EINVAL;
> >     }
> 
> This seems like a lot of code for a simple test.
> 
Hello Joe,
I have sent a v2 for this patch with corrections made.

Regards,
Hari Prasath--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] staging: most: replace multiple if..else with table lookup

2015-12-28 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Replace multiple if..else if..statements with simple table lookup in two
functions.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/most/mostcore/core.c | 41 +---
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c 
b/drivers/staging/most/mostcore/core.c
index ed1ed25..fe6705a 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -82,6 +82,14 @@ struct most_inst_obj {
struct list_head list;
 };
 
+static const struct {
+   int most_ch_data_type;
+   char *name;
+} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
+   { MOST_CH_ASYNC, "async\n" },
+   { MOST_CH_SYNC, "sync\n" },
+   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
+
 #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
 
 /**
@@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
 struct most_c_attr *attr,
 char *buf)
 {
-   if (c->cfg.data_type & MOST_CH_CONTROL)
-   return snprintf(buf, PAGE_SIZE, "control\n");
-   else if (c->cfg.data_type & MOST_CH_ASYNC)
-   return snprintf(buf, PAGE_SIZE, "async\n");
-   else if (c->cfg.data_type & MOST_CH_SYNC)
-   return snprintf(buf, PAGE_SIZE, "sync\n");
-   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
-   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
+   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
+   }
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
@@ -430,15 +436,16 @@ static ssize_t store_set_datatype(struct most_c_obj *c,
  const char *buf,
  size_t count)
 {
-   if (!strcmp(buf, "control\n")) {
-   c->cfg.data_type = MOST_CH_CONTROL;
-   } else if (!strcmp(buf, "async\n")) {
-   c->cfg.data_type = MOST_CH_ASYNC;
-   } else if (!strcmp(buf, "sync\n")) {
-   c->cfg.data_type = MOST_CH_SYNC;
-   } else if (!strcmp(buf, "isoc_avp\n")) {
-   c->cfg.data_type = MOST_CH_ISOC_AVP;
-   } else {
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (!strcmp(buf, ch_data_type[i].name)) {
+   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
+   break;
+   }
+   }
+
+   if (i == ARRAY_SIZE(ch_data_type)) {
pr_info("WARN: invalid attribute settings\n");
return -EINVAL;
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] staging: most: replace multiple if..else with table lookup

2015-12-28 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Replace multiple if..else if..statements with simple table lookup in two
functions.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/most/mostcore/core.c | 41 +---
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c 
b/drivers/staging/most/mostcore/core.c
index ed1ed25..fe6705a 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -82,6 +82,14 @@ struct most_inst_obj {
struct list_head list;
 };
 
+static const struct {
+   int most_ch_data_type;
+   char *name;
+} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
+   { MOST_CH_ASYNC, "async\n" },
+   { MOST_CH_SYNC, "sync\n" },
+   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
+
 #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
 
 /**
@@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
 struct most_c_attr *attr,
 char *buf)
 {
-   if (c->cfg.data_type & MOST_CH_CONTROL)
-   return snprintf(buf, PAGE_SIZE, "control\n");
-   else if (c->cfg.data_type & MOST_CH_ASYNC)
-   return snprintf(buf, PAGE_SIZE, "async\n");
-   else if (c->cfg.data_type & MOST_CH_SYNC)
-   return snprintf(buf, PAGE_SIZE, "sync\n");
-   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
-   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
+   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
+   }
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
@@ -430,15 +436,16 @@ static ssize_t store_set_datatype(struct most_c_obj *c,
  const char *buf,
  size_t count)
 {
-   if (!strcmp(buf, "control\n")) {
-   c->cfg.data_type = MOST_CH_CONTROL;
-   } else if (!strcmp(buf, "async\n")) {
-   c->cfg.data_type = MOST_CH_ASYNC;
-   } else if (!strcmp(buf, "sync\n")) {
-   c->cfg.data_type = MOST_CH_SYNC;
-   } else if (!strcmp(buf, "isoc_avp\n")) {
-   c->cfg.data_type = MOST_CH_ISOC_AVP;
-   } else {
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (!strcmp(buf, ch_data_type[i].name)) {
+   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
+   break;
+   }
+   }
+
+   if (i == ARRAY_SIZE(ch_data_type)) {
pr_info("WARN: invalid attribute settings\n");
return -EINVAL;
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: dgnc: convert to wait_event_interruptible_timeout

2015-12-24 Thread Gujulan Elango, Hari Prasath (H.)
This patch makes use of wait_event_interruptible_timeout to achieve timeout
functionality.This is a TODO mentiond in the comment which is also removed.
It also aligns with what the function is supposed to do as in the
comments.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/dgnc/dgnc_neo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 39c76e7..7d9efe0 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1306,10 +1306,8 @@ static int neo_drain(struct tty_struct *tty, uint 
seconds)
/*
 * Go to sleep waiting for the tty layer to wake me back up when
 * the empty flag goes away.
-*
-* NOTE: TODO: Do something with time passed in.
 */
-   rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & 
UN_EMPTY) == 0));
+   rc = wait_event_interruptible_timeout(un->un_flags_wait, ((un->un_flags 
& UN_EMPTY) == 0), msecs_to_jiffies(seconds * 1000));
 
/* If ret is non-zero, user ctrl-c'ed us */
return rc;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: most: replace multiple if..else with table lookup

2015-12-24 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango 

Replace multiple if..else if..statements with simple table lookup in two
functions.

Signed-off-by: Hari Prasath Gujulan Elango 
---
 drivers/staging/most/mostcore/core.c | 39 
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c 
b/drivers/staging/most/mostcore/core.c
index ed1ed25..7b4636b 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -82,6 +82,14 @@ struct most_inst_obj {
struct list_head list;
 };
 
+static const struct {
+   int most_ch_data_type;
+   char *name;
+} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
+   { MOST_CH_ASYNC, "async\n" },
+   { MOST_CH_SYNC, "sync\n" },
+   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
+
 #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
 
 /**
@@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
 struct most_c_attr *attr,
 char *buf)
 {
-   if (c->cfg.data_type & MOST_CH_CONTROL)
-   return snprintf(buf, PAGE_SIZE, "control\n");
-   else if (c->cfg.data_type & MOST_CH_ASYNC)
-   return snprintf(buf, PAGE_SIZE, "async\n");
-   else if (c->cfg.data_type & MOST_CH_SYNC)
-   return snprintf(buf, PAGE_SIZE, "sync\n");
-   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
-   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
+   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
+   }
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
@@ -430,15 +436,14 @@ static ssize_t store_set_datatype(struct most_c_obj *c,
  const char *buf,
  size_t count)
 {
-   if (!strcmp(buf, "control\n")) {
-   c->cfg.data_type = MOST_CH_CONTROL;
-   } else if (!strcmp(buf, "async\n")) {
-   c->cfg.data_type = MOST_CH_ASYNC;
-   } else if (!strcmp(buf, "sync\n")) {
-   c->cfg.data_type = MOST_CH_SYNC;
-   } else if (!strcmp(buf, "isoc_avp\n")) {
-   c->cfg.data_type = MOST_CH_ISOC_AVP;
-   } else {
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (!strcmp(buf, ch_data_type[i].name))
+   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
+   }
+
+   if (i == ARRAY_SIZE(ch_data_type)) {
pr_info("WARN: invalid attribute settings\n");
return -EINVAL;
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: most: replace multiple if..else with table lookup

2015-12-24 Thread Gujulan Elango, Hari Prasath (H.)
From: Hari Prasath Gujulan Elango <hguju...@visteon.com>

Replace multiple if..else if..statements with simple table lookup in two
functions.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/most/mostcore/core.c | 39 
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c 
b/drivers/staging/most/mostcore/core.c
index ed1ed25..7b4636b 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -82,6 +82,14 @@ struct most_inst_obj {
struct list_head list;
 };
 
+static const struct {
+   int most_ch_data_type;
+   char *name;
+} ch_data_type[] = { { MOST_CH_CONTROL, "control\n" },
+   { MOST_CH_ASYNC, "async\n" },
+   { MOST_CH_SYNC, "sync\n" },
+   { MOST_CH_ISOC_AVP, "isoc_avp\n"} };
+
 #define to_inst_obj(d) container_of(d, struct most_inst_obj, kobj)
 
 /**
@@ -414,14 +422,12 @@ static ssize_t show_set_datatype(struct most_c_obj *c,
 struct most_c_attr *attr,
 char *buf)
 {
-   if (c->cfg.data_type & MOST_CH_CONTROL)
-   return snprintf(buf, PAGE_SIZE, "control\n");
-   else if (c->cfg.data_type & MOST_CH_ASYNC)
-   return snprintf(buf, PAGE_SIZE, "async\n");
-   else if (c->cfg.data_type & MOST_CH_SYNC)
-   return snprintf(buf, PAGE_SIZE, "sync\n");
-   else if (c->cfg.data_type & MOST_CH_ISOC_AVP)
-   return snprintf(buf, PAGE_SIZE, "isoc_avp\n");
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (c->cfg.data_type & ch_data_type[i].most_ch_data_type)
+   return snprintf(buf, PAGE_SIZE, ch_data_type[i].name);
+   }
return snprintf(buf, PAGE_SIZE, "unconfigured\n");
 }
 
@@ -430,15 +436,14 @@ static ssize_t store_set_datatype(struct most_c_obj *c,
  const char *buf,
  size_t count)
 {
-   if (!strcmp(buf, "control\n")) {
-   c->cfg.data_type = MOST_CH_CONTROL;
-   } else if (!strcmp(buf, "async\n")) {
-   c->cfg.data_type = MOST_CH_ASYNC;
-   } else if (!strcmp(buf, "sync\n")) {
-   c->cfg.data_type = MOST_CH_SYNC;
-   } else if (!strcmp(buf, "isoc_avp\n")) {
-   c->cfg.data_type = MOST_CH_ISOC_AVP;
-   } else {
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) {
+   if (!strcmp(buf, ch_data_type[i].name))
+   c->cfg.data_type = ch_data_type[i].most_ch_data_type;
+   }
+
+   if (i == ARRAY_SIZE(ch_data_type)) {
pr_info("WARN: invalid attribute settings\n");
return -EINVAL;
}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: dgnc: convert to wait_event_interruptible_timeout

2015-12-24 Thread Gujulan Elango, Hari Prasath (H.)
This patch makes use of wait_event_interruptible_timeout to achieve timeout
functionality.This is a TODO mentiond in the comment which is also removed.
It also aligns with what the function is supposed to do as in the
comments.

Signed-off-by: Hari Prasath Gujulan Elango <hguju...@visteon.com>
---
 drivers/staging/dgnc/dgnc_neo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 39c76e7..7d9efe0 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -1306,10 +1306,8 @@ static int neo_drain(struct tty_struct *tty, uint 
seconds)
/*
 * Go to sleep waiting for the tty layer to wake me back up when
 * the empty flag goes away.
-*
-* NOTE: TODO: Do something with time passed in.
 */
-   rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & 
UN_EMPTY) == 0));
+   rc = wait_event_interruptible_timeout(un->un_flags_wait, ((un->un_flags 
& UN_EMPTY) == 0), msecs_to_jiffies(seconds * 1000));
 
/* If ret is non-zero, user ctrl-c'ed us */
return rc;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: i2o: Remove unwanted semicolon

2015-04-30 Thread hari prasath
On 30 April 2015 at 19:44, gre...@linuxfoundation.org
 wrote:
> On Thu, Apr 23, 2015 at 04:09:28PM +0100, Alan Cox wrote:
>> On Thu, 2015-04-23 at 13:43 +, Gujulan Elango, Hari Prasath (H.)
>> wrote:
>> > This patch removes unwanted semicolon around close braces of code blocks
>>
>>
>> The i2o driver moved into staging ready to be deleted unless someone
>> steps up with hardware willing to maintain it (which is rather
>> unlikely).
>
> I think it's now time to delete these, want me to do that for 4.2?  I
> can queue that up in my tree now, so that we don't see any more cleanup
> patches being made for them?
>
> thanks,
>
> greg k-h
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

>>> Greg I am not sure if this needs to go into next release. I send this patch 
>>> as checkpatch was complaining about it. May be the owners of this driver 
>>> can only decide >>> upon it.  Alan cox also mentioned the same point that 
>>> its about to be deleted.

-- 
Regards,
G.E.Hari Prasath
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] staging: i2o: Remove unwanted semicolon

2015-04-30 Thread hari prasath
On 30 April 2015 at 19:44, gre...@linuxfoundation.org
gre...@linuxfoundation.org wrote:
 On Thu, Apr 23, 2015 at 04:09:28PM +0100, Alan Cox wrote:
 On Thu, 2015-04-23 at 13:43 +, Gujulan Elango, Hari Prasath (H.)
 wrote:
  This patch removes unwanted semicolon around close braces of code blocks


 The i2o driver moved into staging ready to be deleted unless someone
 steps up with hardware willing to maintain it (which is rather
 unlikely).

 I think it's now time to delete these, want me to do that for 4.2?  I
 can queue that up in my tree now, so that we don't see any more cleanup
 patches being made for them?

 thanks,

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

 Greg I am not sure if this needs to go into next release. I send this patch 
 as checkpatch was complaining about it. May be the owners of this driver 
 can only decide  upon it.  Alan cox also mentioned the same point that 
 its about to be deleted.

-- 
Regards,
G.E.Hari Prasath
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: i2o: Remove unwanted semicolon

2015-04-23 Thread Gujulan Elango, Hari Prasath (H.)
This patch removes unwanted semicolon around close braces of code blocks

Signed-off-by: Hari Prasath 
---
 drivers/staging/i2o/iop.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c
index 23bdbe4..18dcc34 100644
--- a/drivers/staging/i2o/iop.c
+++ b/drivers/staging/i2o/iop.c
@@ -75,7 +75,7 @@ struct i2o_message *i2o_msg_get_wait(struct i2o_controller 
*c, int wait)
}
 
return msg;
-};
+}
 
 #if BITS_PER_LONG == 64
 /**
@@ -123,7 +123,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context);
 
return entry->context;
-};
+}
 
 /**
  *  i2o_cntxt_list_remove - Remove a pointer from the context list
@@ -159,7 +159,7 @@ u32 i2o_cntxt_list_remove(struct i2o_controller * c, void 
*ptr)
  context, ptr);
 
return context;
-};
+}
 
 /**
  *  i2o_cntxt_list_get - Get a pointer from the context list and remove it
@@ -192,7 +192,7 @@ void *i2o_cntxt_list_get(struct i2o_controller *c, u32 
context)
  ptr);
 
return ptr;
-};
+}
 
 /**
  *  i2o_cntxt_list_get_ptr - Get a context id from the context list
@@ -224,7 +224,7 @@ u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void 
*ptr)
  ptr, context);
 
return context;
-};
+}
 #endif
 
 /**
@@ -245,7 +245,7 @@ struct i2o_controller *i2o_find_iop(int unit)
}
 
return NULL;
-};
+}
 
 /**
  * i2o_iop_find_device - Find a I2O device on an I2O controller
@@ -266,7 +266,7 @@ struct i2o_device *i2o_iop_find_device(struct 
i2o_controller *c, u16 tid)
return dev;
 
return NULL;
-};
+}
 
 /**
  * i2o_quiesce_controller - quiesce controller
@@ -308,7 +308,7 @@ static int i2o_iop_quiesce(struct i2o_controller *c)
i2o_status_get(c);  // Entered READY state
 
return rc;
-};
+}
 
 /**
  * i2o_iop_enable - move controller from ready to OPERATIONAL
@@ -348,7 +348,7 @@ static int i2o_iop_enable(struct i2o_controller *c)
i2o_status_get(c);  // entered OPERATIONAL state
 
return rc;
-};
+}
 
 /**
  * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system
@@ -363,7 +363,7 @@ static inline void i2o_iop_quiesce_all(void)
if (!c->no_quiesce)
i2o_iop_quiesce(c);
}
-};
+}
 
 /**
  * i2o_iop_enable_all - Enables all controllers on the system
@@ -376,7 +376,7 @@ static inline void i2o_iop_enable_all(void)
 
list_for_each_entry_safe(c, tmp, _controllers, list)
i2o_iop_enable(c);
-};
+}
 
 /**
  * i2o_clear_controller - Bring I2O controller into HOLD state
@@ -581,7 +581,7 @@ static int i2o_iop_reset(struct i2o_controller *c)
i2o_iop_enable_all();
 
return rc;
-};
+}
 
 /**
  * i2o_iop_activate - Bring controller up to HOLD
@@ -650,7 +650,7 @@ static int i2o_iop_activate(struct i2o_controller *c)
}
 
return i2o_hrt_get(c);
-};
+}
 
 static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
 {
@@ -779,7 +779,7 @@ static int i2o_iop_online(struct i2o_controller *c)
return rc;
 
return 0;
-};
+}
 
 /**
  * i2o_iop_remove - Remove the I2O controller from the I2O core
@@ -891,7 +891,7 @@ static int i2o_systab_build(void)
systab->num_entries = count;
 
return 0;
-};
+}
 
 /**
  * i2o_parse_hrt - Parse the hardware resource table.
@@ -905,7 +905,7 @@ static int i2o_parse_hrt(struct i2o_controller *c)
 {
i2o_dump_hrt(c);
return 0;
-};
+}
 
 /**
  * i2o_status_get - Get the status block from the I2O controller
@@ -1029,7 +1029,7 @@ static void i2o_iop_release(struct device *dev)
struct i2o_controller *c = to_i2o_controller(dev);
 
i2o_iop_free(c);
-};
+}
 
 /**
  * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
@@ -1062,7 +1062,7 @@ struct i2o_controller *i2o_iop_alloc(void)
 I2O_MSG_INPOOL_MIN)) {
kfree(c);
return ERR_PTR(-ENOMEM);
-   };
+   }
 
INIT_LIST_HEAD(>devices);
spin_lock_init(>lock);
@@ -1081,7 +1081,7 @@ struct i2o_controller *i2o_iop_alloc(void)
 #endif
 
return c;
-};
+}
 
 /**
  * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
@@ -1145,7 +1145,7 @@ int i2o_iop_add(struct i2o_controller *c)
i2o_iop_reset(c);
 
return rc;
-};
+}
 
 /**
  * i2o_event_register - Turn on/off event notification for a I2O device
@@ -1181,7 +1181,7 @@ int i2o_event_register(struct i2o_device *dev, struct 
i2o_driver *drv,
i2o_msg_post(c, msg);
 
return 0;
-};
+}
 
 /**
  * i2o_iop_init - I2O main initialization function
@@ -1231,7 +1231,7 @@ static void __exit i2o_iop_exit(void)
i2o_pc

[PATCH] staging: fsl-mc: Remove redundant initalization of the .owner field

2015-04-23 Thread Gujulan Elango, Hari Prasath (H.)
This patch removes the redundant static initialization of the .owner field from
this driver as it is being overidden by the call from the platform driver 
register

Signed-off-by: Hari Prasath 
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 23512d0..766a659 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -713,7 +713,6 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table);
 static struct platform_driver fsl_mc_bus_driver = {
.driver = {
   .name = "fsl_mc_bus",
-  .owner = THIS_MODULE,
   .pm = NULL,
   .of_match_table = fsl_mc_bus_match_table,
   },
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: fsl-mc: Remove redundant initalization of the .owner field

2015-04-23 Thread Gujulan Elango, Hari Prasath (H.)
This patch removes the redundant static initialization of the .owner field from
this driver as it is being overidden by the call from the platform driver 
register

Signed-off-by: Hari Prasath hguju...@visteon.com
---
 drivers/staging/fsl-mc/bus/mc-bus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c 
b/drivers/staging/fsl-mc/bus/mc-bus.c
index 23512d0..766a659 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -713,7 +713,6 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table);
 static struct platform_driver fsl_mc_bus_driver = {
.driver = {
   .name = fsl_mc_bus,
-  .owner = THIS_MODULE,
   .pm = NULL,
   .of_match_table = fsl_mc_bus_match_table,
   },
-- 
1.9.1
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: i2o: Remove unwanted semicolon

2015-04-23 Thread Gujulan Elango, Hari Prasath (H.)
This patch removes unwanted semicolon around close braces of code blocks

Signed-off-by: Hari Prasath hguju...@visteon.com
---
 drivers/staging/i2o/iop.c | 44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c
index 23bdbe4..18dcc34 100644
--- a/drivers/staging/i2o/iop.c
+++ b/drivers/staging/i2o/iop.c
@@ -75,7 +75,7 @@ struct i2o_message *i2o_msg_get_wait(struct i2o_controller 
*c, int wait)
}
 
return msg;
-};
+}
 
 #if BITS_PER_LONG == 64
 /**
@@ -123,7 +123,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
osm_debug(%s: Add context to list %p - %d\n, c-name, ptr, context);
 
return entry-context;
-};
+}
 
 /**
  *  i2o_cntxt_list_remove - Remove a pointer from the context list
@@ -159,7 +159,7 @@ u32 i2o_cntxt_list_remove(struct i2o_controller * c, void 
*ptr)
  context, ptr);
 
return context;
-};
+}
 
 /**
  *  i2o_cntxt_list_get - Get a pointer from the context list and remove it
@@ -192,7 +192,7 @@ void *i2o_cntxt_list_get(struct i2o_controller *c, u32 
context)
  ptr);
 
return ptr;
-};
+}
 
 /**
  *  i2o_cntxt_list_get_ptr - Get a context id from the context list
@@ -224,7 +224,7 @@ u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void 
*ptr)
  ptr, context);
 
return context;
-};
+}
 #endif
 
 /**
@@ -245,7 +245,7 @@ struct i2o_controller *i2o_find_iop(int unit)
}
 
return NULL;
-};
+}
 
 /**
  * i2o_iop_find_device - Find a I2O device on an I2O controller
@@ -266,7 +266,7 @@ struct i2o_device *i2o_iop_find_device(struct 
i2o_controller *c, u16 tid)
return dev;
 
return NULL;
-};
+}
 
 /**
  * i2o_quiesce_controller - quiesce controller
@@ -308,7 +308,7 @@ static int i2o_iop_quiesce(struct i2o_controller *c)
i2o_status_get(c);  // Entered READY state
 
return rc;
-};
+}
 
 /**
  * i2o_iop_enable - move controller from ready to OPERATIONAL
@@ -348,7 +348,7 @@ static int i2o_iop_enable(struct i2o_controller *c)
i2o_status_get(c);  // entered OPERATIONAL state
 
return rc;
-};
+}
 
 /**
  * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system
@@ -363,7 +363,7 @@ static inline void i2o_iop_quiesce_all(void)
if (!c-no_quiesce)
i2o_iop_quiesce(c);
}
-};
+}
 
 /**
  * i2o_iop_enable_all - Enables all controllers on the system
@@ -376,7 +376,7 @@ static inline void i2o_iop_enable_all(void)
 
list_for_each_entry_safe(c, tmp, i2o_controllers, list)
i2o_iop_enable(c);
-};
+}
 
 /**
  * i2o_clear_controller - Bring I2O controller into HOLD state
@@ -581,7 +581,7 @@ static int i2o_iop_reset(struct i2o_controller *c)
i2o_iop_enable_all();
 
return rc;
-};
+}
 
 /**
  * i2o_iop_activate - Bring controller up to HOLD
@@ -650,7 +650,7 @@ static int i2o_iop_activate(struct i2o_controller *c)
}
 
return i2o_hrt_get(c);
-};
+}
 
 static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
 {
@@ -779,7 +779,7 @@ static int i2o_iop_online(struct i2o_controller *c)
return rc;
 
return 0;
-};
+}
 
 /**
  * i2o_iop_remove - Remove the I2O controller from the I2O core
@@ -891,7 +891,7 @@ static int i2o_systab_build(void)
systab-num_entries = count;
 
return 0;
-};
+}
 
 /**
  * i2o_parse_hrt - Parse the hardware resource table.
@@ -905,7 +905,7 @@ static int i2o_parse_hrt(struct i2o_controller *c)
 {
i2o_dump_hrt(c);
return 0;
-};
+}
 
 /**
  * i2o_status_get - Get the status block from the I2O controller
@@ -1029,7 +1029,7 @@ static void i2o_iop_release(struct device *dev)
struct i2o_controller *c = to_i2o_controller(dev);
 
i2o_iop_free(c);
-};
+}
 
 /**
  * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
@@ -1062,7 +1062,7 @@ struct i2o_controller *i2o_iop_alloc(void)
 I2O_MSG_INPOOL_MIN)) {
kfree(c);
return ERR_PTR(-ENOMEM);
-   };
+   }
 
INIT_LIST_HEAD(c-devices);
spin_lock_init(c-lock);
@@ -1081,7 +1081,7 @@ struct i2o_controller *i2o_iop_alloc(void)
 #endif
 
return c;
-};
+}
 
 /**
  * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
@@ -1145,7 +1145,7 @@ int i2o_iop_add(struct i2o_controller *c)
i2o_iop_reset(c);
 
return rc;
-};
+}
 
 /**
  * i2o_event_register - Turn on/off event notification for a I2O device
@@ -1181,7 +1181,7 @@ int i2o_event_register(struct i2o_device *dev, struct 
i2o_driver *drv,
i2o_msg_post(c, msg);
 
return 0;
-};
+}
 
 /**
  * i2o_iop_init - I2O main initialization function
@@ -1231,7 +1231,7 @@ static void __exit i2o_iop_exit(void)
i2o_pci_exit