Re: [PATCH 2/3] staging: lustre: Add blank line after variable declaration

2015-08-12 Thread Joe Perches
On Wed, 2015-08-12 at 10:30 +0530, Sudip Mukherjee wrote:
> On Tue, Aug 11, 2015 at 09:32:30PM +0800, Swee Hua Law wrote:
> > Add blank line after variable declaration
[]
> > diff --git a/drivers/staging/lustre/lustre/llite/lloop.c 
> > b/drivers/staging/lustre/lustre/llite/lloop.c
[]
> > @@ -372,9 +372,11 @@ err:
> >  static inline void loop_handle_bio(struct lloop_device *lo, struct bio 
> > *bio)
> >  {
> > int ret;
> > +
> > ret = do_bio_lustrebacked(lo, bio);
> > while (bio) {
> > struct bio *tmp = bio->bi_next;
> > +
> > bio->bi_next = NULL;
> > bio_endio(bio);
> This patch will not apply. I am not sure how your tree got
> bio_endio(bio) but in the staging tree this line is bio_endio(bio, ret);

And besides that, why do only this file/location?

There are several hundred possible in lustre.

Using:

$ git ls-files -- "drivers/staging/lustre/*.[ch]" | \
  xargs ./scripts/checkpatch.pl -f --fix-inplace --types=line_spacing

would fix just about all of them.

$ git diff --shortstat drivers/staging/lustre/
 172 files changed, 267 insertions(+), 316 deletions(-)


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


Re: [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name

2015-08-12 Thread Lars-Peter Clausen
On 08/12/2015 10:20 AM, sdliy...@gmail.com wrote:
> From: Yong Li 
> 
> Load the driver using the below command:
> echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device
> 
> In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
> they are inconsistent.
> 
> With this patch, the iio name will be the same as the i2c device name
> 
> Signed-off-by: Yong Li 
> ---
>  drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c 
> b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> index ff08667..3b03644 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
> @@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config 
> = {
>  static int hmc5843_i2c_probe(struct i2c_client *cli,
>const struct i2c_device_id *id)
>  {
> + cli->dev.driver->name = id->name;

You are overwriting a the name of the driver, which is a struct that is
shared between all instances of the device which specific data from one
device. That is most certainly not correct.

Update hmc5843_common_probe() and add a parameter that takes the name for
the device and then pass the id->name when the function is called.

>   return hmc5843_common_probe(&cli->dev,
>   devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
>   id->driver_data);
> 

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


[PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name

2015-08-12 Thread sdliyong
From: Yong Li 

Load the driver using the below command:
echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device

In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
they are inconsistent.

With this patch, the iio name will be the same as the i2c device name

Signed-off-by: Yong Li 
---
 drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c 
b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index ff08667..3b03644 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_i2c_regmap_config = 
{
 static int hmc5843_i2c_probe(struct i2c_client *cli,
 const struct i2c_device_id *id)
 {
+   cli->dev.driver->name = id->name;
return hmc5843_common_probe(&cli->dev,
devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
id->driver_data);
-- 
2.1.0

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


Re: [PATCH v1] staging: iio: hmc5843: Set iio name dynamically based on i2c name

2015-08-12 Thread LIYONG
thanks for your comments. let me submit another one

发自我的 iPhone

> 在 2015年8月12日,16:28,Lars-Peter Clausen  写道:
> 
>> On 08/12/2015 10:20 AM, sdliy...@gmail.com wrote:
>> From: Yong Li 
>> 
>> Load the driver using the below command:
>> echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device
>> 
>> In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
>> they are inconsistent.
>> 
>> With this patch, the iio name will be the same as the i2c device name
>> 
>> Signed-off-by: Yong Li 
>> ---
>> drivers/staging/iio/magnetometer/hmc5843_i2c.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c 
>> b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> index ff08667..3b03644 100644
>> --- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> +++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
>> @@ -59,6 +59,7 @@ static const struct regmap_config 
>> hmc5843_i2c_regmap_config = {
>> static int hmc5843_i2c_probe(struct i2c_client *cli,
>> const struct i2c_device_id *id)
>> {
>> +cli->dev.driver->name = id->name;
> 
> You are overwriting a the name of the driver, which is a struct that is
> shared between all instances of the device which specific data from one
> device. That is most certainly not correct.
> 
> Update hmc5843_common_probe() and add a parameter that takes the name for
> the device and then pass the id->name when the function is called.
> 
>>return hmc5843_common_probe(&cli->dev,
>>devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
>>id->driver_data);
>> 
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl

2015-08-12 Thread Shah, Yash (Y.)
From: Yash Shah 

Fix line over 80 characters warning as detected by checkpatch.pl

Signed-off-by: Yash Shah 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 8bc68e2..d36350e 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, char 
__user *buf,
 
tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index+i+2];
tmpbuf[i+1] = bdev->rds_info.radio_text[bdev->rd_index+i+1];
-   tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i] & 
0xf0) >> 4;
+   tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i]
+& 0xf0) >> 4;
if ((bdev->rds_info.radio_text[bdev->rd_index+i] &
BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE)
tmpbuf[i+2] |= 0x80;
-- 
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl

2015-08-12 Thread Pali Rohár
On Wednesday 12 August 2015 11:12:49 Shah, Yash (Y.) wrote:
> From: Yash Shah 
> 
> Fix line over 80 characters warning as detected by checkpatch.pl
> 
> Signed-off-by: Yash Shah 
> ---
>  drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
> b/drivers/staging/media/bcm2048/radio-bcm2048.c
> index 8bc68e2..d36350e 100644
> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
> @@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, 
> char __user *buf,
>  
>   tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index+i+2];
>   tmpbuf[i+1] = bdev->rds_info.radio_text[bdev->rd_index+i+1];
> - tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i] & 
> 0xf0) >> 4;
> + tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i]
> +  & 0xf0) >> 4;
>   if ((bdev->rds_info.radio_text[bdev->rd_index+i] &
>   BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE)
>   tmpbuf[i+2] |= 0x80;

Hi! I think that code after this change is less readable as before.

-- 
Pali Rohár
pali.ro...@gmail.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dexuan Cui
This fixes the recent commit:
Drivers: hv: vmbus: Further improve CPU affiliation logic

Without the fix, reloading hv_netvsc hangs the guest.

Signed-off-by: Dexuan Cui 
---
 drivers/hv/channel_mgmt.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 2f9aead..f61bd07 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -458,6 +458,19 @@ static void init_vp_index(struct vmbus_channel *channel, 
const uuid_le *type_gui
continue;
}
 
+   if (cpumask_weight(&primary->alloced_cpus_in_node) ==
+   cpumask_weight(cpumask_of_node(primary->numa_node))) {
+   /*
+* We have cycled through all the CPUs in the node;
+* reset the alloced map.
+* This is necessary because we never clear
+* primary->alloced_cpus_in_node in other places.
+* We need this to "break" the loop when reloading
+* hv_netvsc in SMP guest.
+*/
+   cpumask_clear(&primary->alloced_cpus_in_node);
+   }
+
if (!cpumask_test_cpu(cur_cpu,
&primary->alloced_cpus_in_node)) {
cpumask_set_cpu(cur_cpu,
-- 
2.1.0

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


RE: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dexuan Cui
> From: devel [mailto:driverdev-devel-boun...@linuxdriverproject.org] On Behalf
> Of Dexuan Cui
> Sent: Wednesday, August 12, 2015 21:49
> To: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org; driverdev-
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; KY Srinivasan 
> Subject: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading 
> hv_netvsc
> 
> This fixes the recent commit:
> Drivers: hv: vmbus: Further improve CPU affiliation logic
> 
> Without the fix, reloading hv_netvsc hangs the guest.
> 
> Signed-off-by: Dexuan Cui 
> ---
>  drivers/hv/channel_mgmt.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index 2f9aead..f61bd07 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -458,6 +458,19 @@ static void init_vp_index(struct vmbus_channel
> *channel, const uuid_le *type_gui
>   continue;
>   }
> 
> + if (cpumask_weight(&primary->alloced_cpus_in_node) ==
> + cpumask_weight(cpumask_of_node(primary->numa_node))) {
> + /*
> +  * We have cycled through all the CPUs in the node;
> +  * reset the alloced map.
> +  * This is necessary because we never clear
> +  * primary->alloced_cpus_in_node in other places.
> +  * We need this to "break" the loop when reloading
> +  * hv_netvsc in SMP guest.
> +  */
> + cpumask_clear(&primary->alloced_cpus_in_node);
> + }
> +
>   if (!cpumask_test_cpu(cur_cpu,
>   &primary->alloced_cpus_in_node)) {
>   cpumask_set_cpu(cur_cpu,
> --

Sorry, please drop the patch.

I shouldn't simply clear primary->alloced_cpus_in_node -- I didn't realize
reloading hv_netvsc doesn't invoke init_vp_index() for the primary channel.

I'll make a V2 patch.

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


Re: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dan Carpenter
On Wed, Aug 12, 2015 at 12:29:46PM +, Dexuan Cui wrote:
> > This fixes the recent commit:
> > Drivers: hv: vmbus: Further improve CPU affiliation logic

Since you are redoing this anyway, include the git hash so we can look
it up.  In fact, just use the Fixes tag.

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


[PATCH V2] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dexuan Cui
This fixes the recent commit:
Drivers: hv: vmbus: Further improve CPU affiliation logic

Without the fix, reloading hv_netvsc hangs the guest.

Signed-off-by: Dexuan Cui 
---

Change since V1:
clear the related bit(s) in hv_process_channel_removal() rather
than in init_vp_index().

 drivers/hv/channel_mgmt.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 2f9aead..652afd1 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -204,6 +204,8 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
list_del(&channel->listentry);
spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
+
+   primary_channel = channel;
} else {
primary_channel = channel->primary_channel;
spin_lock_irqsave(&primary_channel->lock, flags);
@@ -211,6 +213,14 @@ void hv_process_channel_removal(struct vmbus_channel 
*channel, u32 relid)
primary_channel->num_sc--;
spin_unlock_irqrestore(&primary_channel->lock, flags);
}
+
+   /*
+* We need to free the bit for init_vp_index() to work in the case
+* of sub-channel, when we reload drivers like hv_netvsc.
+*/
+   cpumask_clear_cpu(channel->target_cpu,
+ &primary_channel->alloced_cpus_in_node);
+
free_channel(channel);
 }
 
@@ -458,6 +468,13 @@ static void init_vp_index(struct vmbus_channel *channel, 
const uuid_le *type_gui
continue;
}
 
+   /*
+* NOTE: in the case of sub-channel, we clear the sub-channel
+* related bit(s) in primary->alloced_cpus_in_node in
+* hv_process_channel_removal(), so when we reload drivers
+* like hv_netvsc in SMP guest, here we're able to re-allocate
+* bit from primary->alloced_cpus_in_node.
+*/
if (!cpumask_test_cpu(cur_cpu,
&primary->alloced_cpus_in_node)) {
cpumask_set_cpu(cur_cpu,
-- 
2.1.0

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


[PATCH v2] staging: iio: hmc5843: Set iio name dynamically

2015-08-12 Thread sdliyong
From: Yong Li 

Load the driver using the below command:
echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device

In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
they are inconsistent.

With this patch, the iio name will be the same as the i2c device name

Signed-off-by: Yong Li 
---
 drivers/staging/iio/magnetometer/hmc5843.h  | 2 +-
 drivers/staging/iio/magnetometer/hmc5843_core.c | 4 ++--
 drivers/staging/iio/magnetometer/hmc5843_i2c.c  | 2 +-
 drivers/staging/iio/magnetometer/hmc5843_spi.c  | 3 ++-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/hmc5843.h 
b/drivers/staging/iio/magnetometer/hmc5843.h
index f3d0da2..06f35d3 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.h
+++ b/drivers/staging/iio/magnetometer/hmc5843.h
@@ -48,7 +48,7 @@ struct hmc5843_data {
 };
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-enum hmc5843_ids id);
+enum hmc5843_ids id, const char *name);
 int hmc5843_common_remove(struct device *dev);
 
 int hmc5843_common_suspend(struct device *dev);
diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c 
b/drivers/staging/iio/magnetometer/hmc5843_core.c
index fffca3a..4aab022 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_core.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_core.c
@@ -577,7 +577,7 @@ int hmc5843_common_resume(struct device *dev)
 EXPORT_SYMBOL(hmc5843_common_resume);
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-enum hmc5843_ids id)
+enum hmc5843_ids id, const char *name)
 {
struct hmc5843_data *data;
struct iio_dev *indio_dev;
@@ -597,7 +597,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap 
*regmap,
mutex_init(&data->lock);
 
indio_dev->dev.parent = dev;
-   indio_dev->name = dev->driver->name;
+   indio_dev->name = name;
indio_dev->info = &hmc5843_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = data->variant->channels;
diff --git a/drivers/staging/iio/magnetometer/hmc5843_i2c.c 
b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
index ff08667..3e06ceb 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_i2c.c
@@ -61,7 +61,7 @@ static int hmc5843_i2c_probe(struct i2c_client *cli,
 {
return hmc5843_common_probe(&cli->dev,
devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
-   id->driver_data);
+   id->driver_data, id->name);
 }
 
 static int hmc5843_i2c_remove(struct i2c_client *client)
diff --git a/drivers/staging/iio/magnetometer/hmc5843_spi.c 
b/drivers/staging/iio/magnetometer/hmc5843_spi.c
index 8e658f7..8a80d01 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_spi.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_spi.c
@@ -59,6 +59,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = 
{
 static int hmc5843_spi_probe(struct spi_device *spi)
 {
int ret;
+   const struct spi_device_id *id = spi_get_device_id(spi);
 
spi->mode = SPI_MODE_3;
spi->max_speed_hz = 800;
@@ -69,7 +70,7 @@ static int hmc5843_spi_probe(struct spi_device *spi)
 
return hmc5843_common_probe(&spi->dev,
devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config),
-   HMC5983_ID);
+   id->driver_data, id->name);
 }
 
 static int hmc5843_spi_remove(struct spi_device *spi)
-- 
2.1.0

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


Re: [PATCH] Staging: media/bcm2048: Fix line over 80 characters warning as detected by checkpatch.pl

2015-08-12 Thread Frans Klaver
On Wed, Aug 12, 2015 at 1:19 PM, Pali Rohár  wrote:
> On Wednesday 12 August 2015 11:12:49 Shah, Yash (Y.) wrote:
>> From: Yash Shah 
>>
>> Fix line over 80 characters warning as detected by checkpatch.pl
>>
>> Signed-off-by: Yash Shah 
>> ---
>>  drivers/staging/media/bcm2048/radio-bcm2048.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
>> b/drivers/staging/media/bcm2048/radio-bcm2048.c
>> index 8bc68e2..d36350e 100644
>> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
>> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
>> @@ -2243,7 +2243,8 @@ static ssize_t bcm2048_fops_read(struct file *file, 
>> char __user *buf,
>>
>>   tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index+i+2];
>>   tmpbuf[i+1] = bdev->rds_info.radio_text[bdev->rd_index+i+1];
>> - tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i] & 
>> 0xf0) >> 4;
>> + tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i]
>> +  & 0xf0) >> 4;
>>   if ((bdev->rds_info.radio_text[bdev->rd_index+i] &
>>   BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE)
>>   tmpbuf[i+2] |= 0x80;
>
> Hi! I think that code after this change is less readable as before.

I agree. I would do something about 'bdev->rds_info.radio_text'
instead and shorten all three lines.

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


RE: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dexuan Cui
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Wednesday, August 12, 2015 21:06
> To: Dexuan Cui 
> Cc: gre...@linuxfoundation.org; linux-ker...@vger.kernel.org; driverdev-
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; KY Srinivasan 
> Subject: Re: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading
> hv_netvsc
> 
> On Wed, Aug 12, 2015 at 12:29:46PM +, Dexuan Cui wrote:
> > > This fixes the recent commit:
> > > Drivers: hv: vmbus: Further improve CPU affiliation logic
> 
> Since you are redoing this anyway, include the git hash so we can look
> it up.  In fact, just use the Fixes tag.
> 
> dan carpenter

Hmm, I didn't read your mail in time and sent out V2 just now... :-)

I'm working on the latest linux-next (next-20150810).
I didn't add the git hash ID because I think the hash of the patch of the
same content can be different in different trees (like Greg's tree and
linux-next)? 

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


Re: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dan Carpenter
On Wed, Aug 12, 2015 at 01:35:07PM +, Dexuan Cui wrote:
> > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > On Wed, Aug 12, 2015 at 12:29:46PM +, Dexuan Cui wrote:
> > > > This fixes the recent commit:
> > > > Drivers: hv: vmbus: Further improve CPU affiliation logic
> > 
> > Since you are redoing this anyway, include the git hash so we can look
> > it up.  In fact, just use the Fixes tag.
> > 
> > dan carpenter
> 
> Hmm, I didn't read your mail in time and sent out V2 just now... :-)
> 
> I'm working on the latest linux-next (next-20150810).
> I didn't add the git hash ID because I think the hash of the patch of the
> same content can be different in different trees (like Greg's tree and
> linux-next)?

Sometimes it can change, but mostly it doesn't.  In this case it didn't.

The commit hash is based on the tree, the parent, and the content of the
patch description.  If we rebase, add a new signed-off-by or merge
the patch through a different tree then the hash changes.

regards,
dan carpenter

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


[PATCH] staging: media:lirc: Added a newline character after declaration

2015-08-12 Thread Aparna Karuthodi
Added a newline character to remove a coding style warning detected
by checkpatch.

The warning is given below:
drivers/staging/media/lirc/lirc_serial.c:1169: WARNING: quoted string split
across lines

Signed-off-by: Aparna Karuthodi 
---
 drivers/staging/media/lirc/lirc_serial.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/lirc/lirc_serial.c 
b/drivers/staging/media/lirc/lirc_serial.c
index 19628d0..628577f 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -1165,7 +1165,7 @@ module_init(lirc_serial_init_module);
 module_exit(lirc_serial_exit_module);
 
 MODULE_DESCRIPTION("Infra-red receiver driver for serial ports.");
-MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff, "
+MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff,\n"
  "Christoph Bartelmus, Andrei Tanas");
 MODULE_LICENSE("GPL");
 
-- 
1.7.9.5

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


Re: [PATCH v2] staging: iio: hmc5843: Set iio name dynamically

2015-08-12 Thread Lars-Peter Clausen
On 08/12/2015 03:25 PM, sdliy...@gmail.com wrote:
> From: Yong Li 
> 
> Load the driver using the below command:
> echo hmc5983 0x1e > /sys/bus/i2c/devices/i2c-?/new_device
> 
> In sysfs, the iio name is hmc5843, however the i2c name is hmc5983,
> they are inconsistent.
> 
> With this patch, the iio name will be the same as the i2c device name
> 
> Signed-off-by: Yong Li 

Looks good.

Reviewed-by: Lars-Peter Clausen 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: media:lirc: Added a newline character after declaration

2015-08-12 Thread Greg KH
On Wed, Aug 12, 2015 at 08:41:42PM +0530, Aparna Karuthodi wrote:
> Added a newline character to remove a coding style warning detected
> by checkpatch.
> 
> The warning is given below:
> drivers/staging/media/lirc/lirc_serial.c:1169: WARNING: quoted string split
> across lines
> 
> Signed-off-by: Aparna Karuthodi 
> ---
>  drivers/staging/media/lirc/lirc_serial.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/lirc/lirc_serial.c 
> b/drivers/staging/media/lirc/lirc_serial.c
> index 19628d0..628577f 100644
> --- a/drivers/staging/media/lirc/lirc_serial.c
> +++ b/drivers/staging/media/lirc/lirc_serial.c
> @@ -1165,7 +1165,7 @@ module_init(lirc_serial_init_module);
>  module_exit(lirc_serial_exit_module);
>  
>  MODULE_DESCRIPTION("Infra-red receiver driver for serial ports.");
> -MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff, "
> +MODULE_AUTHOR("Ralph Metzler, Trent Piepho, Ben Pfaff,\n"
> "Christoph Bartelmus, Andrei Tanas");

No, you just changed the way this string looks, that's not ok at all.

This is fine the way it is, you can ignore it.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading hv_netvsc

2015-08-12 Thread Dexuan Cui
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Wednesday, August 12, 2015 22:11
> To: Dexuan Cui 
> Cc: o...@aepfle.de; gre...@linuxfoundation.org; jasow...@redhat.com;
> driverdev-devel@linuxdriverproject.org; linux-ker...@vger.kernel.org;
> a...@canonical.com
> Subject: Re: [PATCH] Drivers: hv: vmbus: fix init_vp_index() for reloading
> hv_netvsc
> 
> On Wed, Aug 12, 2015 at 01:35:07PM +, Dexuan Cui wrote:
> > > From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> > > On Wed, Aug 12, 2015 at 12:29:46PM +, Dexuan Cui wrote:
> > > > > This fixes the recent commit:
> > > > > Drivers: hv: vmbus: Further improve CPU affiliation logic
> > >
> > > Since you are redoing this anyway, include the git hash so we can look
> > > it up.  In fact, just use the Fixes tag.
> > >
> > > dan carpenter
> >
> > Hmm, I didn't read your mail in time and sent out V2 just now... :-)
> >
> > I'm working on the latest linux-next (next-20150810).
> > I didn't add the git hash ID because I think the hash of the patch of the
> > same content can be different in different trees (like Greg's tree and
> > linux-next)?
> 
> Sometimes it can change, but mostly it doesn't.  In this case it didn't.
> 
> The commit hash is based on the tree, the parent, and the content of the
> patch description.  If we rebase, add a new signed-off-by or merge
> the patch through a different tree then the hash changes.
> 
> regards,
> dan carpenter

Thanks a lot for the explanation, Dan!

I'll remember to add the hash in future.

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


RE: [PATCH] staging: comedi: Use monotonic clock

2015-08-12 Thread Hartley Sweeten
On Tuesday, August 11, 2015 7:32 AM, Abhilash Jindal wrote:
> Subject: [PATCH] staging: comedi: Use monotonic clock

Nitpick... The subject above should have the driver name in it.

" staging: comedi: serial2002: Use monotonic clock"

The current subject makes this commit appear to effect all of comedi.

Other than that...
Reviewed-by: H Hartley Sweeten 

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


[PATCH] staging: comedi: comedi_fops: fix possible overflow in do_chaninfo_ioctl()

2015-08-12 Thread H Hartley Sweeten
The copy_to_user() that returns the subdevice 'maxdata_list' in this
function has the possibility of overflowing due to the calculation
of the size of the copy. In reality this should never happen but add
a sanity check just to be safe.

Reported-by: coverity (CID 143110)
Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_fops.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 0e8a451..ad483e1 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1061,6 +1061,14 @@ static int do_chaninfo_ioctl(struct comedi_device *dev,
if (it.maxdata_list) {
if (s->maxdata || !s->maxdata_list)
return -EINVAL;
+   /*
+* s->n_chan is usually <= 32 but _some_ comedi drivers
+* do have more. Do a simple sanity check to make sure
+* copy_to_user() does not overflow. In reality this
+* should never fail...
+*/
+   if (s->n_chan > (0x / sizeof(unsigned int)))
+   return -EINVAL;
if (copy_to_user(it.maxdata_list, s->maxdata_list,
 s->n_chan * sizeof(unsigned int)))
return -EFAULT;
-- 
2.4.3

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


[PATCH] staging: wilc1000: Process WARN, INFO options of debug levels from user

2015-08-12 Thread Chandra S Gorentla
This patch enables setting the module's debug options WARN and INFO in the
debugfs file 'wilc_debug_level'.  This enables the user to enable logging
of warning and other information.  Before this change writes to this debugfs
file sets only one option DGB.  This is additional to the default option
ERR.

As a side effect, this patch removes the 'sparse' warning -
'warning: incorrect type in argument 2 (different address spaces)'.

Signed-off-by: Chandra S Gorentla 
---
 drivers/staging/wilc1000/wilc_debugfs.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_debugfs.c 
b/drivers/staging/wilc1000/wilc_debugfs.c
index be2e901..3934e8b 100644
--- a/drivers/staging/wilc1000/wilc_debugfs.c
+++ b/drivers/staging/wilc1000/wilc_debugfs.c
@@ -48,29 +48,26 @@ static ssize_t wilc_debug_level_read(struct file *file, 
char __user *userbuf, si
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
 }
 
-static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, 
size_t count, loff_t *ppos)
+static ssize_t wilc_debug_level_write(struct file *filp, const char __user 
*buf,
+   size_t count, loff_t *ppos)
 {
-   char buffer[128] = {};
+   char buffer[2] = {};  /* One character for 'level' + one for null */
int flag = 0;
+   int ret;
 
if (count > sizeof(buffer))
return -EINVAL;
 
-   if (copy_from_user(buffer, buf, count)) {
+   ret = simple_write_to_buffer(buffer, sizeof(buffer), ppos, buf, count);
+   if (ret != count)
return -EFAULT;
-   }
-
-   flag = buffer[0] - '0';
 
-   if (flag > 0)
-   flag = DEBUG | ERR;
-   else if (flag < 0)
-   flag = 100;
+   ret = kstrtoint(buffer, 16, &flag);
+   if (ret)
+   return -EINVAL;
 
-   if (flag > DBG_LEVEL_ALL) {
-   printk("%s, value (0x%08x) is out of range, stay previous flag 
(0x%08x)\n", __func__, flag, atomic_read(&DEBUG_LEVEL));
-   return -EFAULT;
-   }
+   if (flag > DBG_LEVEL_ALL)
+   return -EINVAL;
 
atomic_set(&DEBUG_LEVEL, (int)flag);
 
@@ -78,6 +75,7 @@ static ssize_t wilc_debug_level_write(struct file *filp, 
const char *buf, size_t
printk("Debug-level disabled\n");
else
printk("Debug-level enabled\n");
+
return count;
 }
 
-- 
2.5.0

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


Re: [PATCH] staging: comedi: comedi_fops: fix possible overflow in do_chaninfo_ioctl()

2015-08-12 Thread Dan Carpenter
On Wed, Aug 12, 2015 at 10:30:47AM -0700, H Hartley Sweeten wrote:
> @@ -1061,6 +1061,14 @@ static int do_chaninfo_ioctl(struct comedi_device *dev,
>   if (it.maxdata_list) {
>   if (s->maxdata || !s->maxdata_list)
>   return -EINVAL;
> + /*
> +  * s->n_chan is usually <= 32 but _some_ comedi drivers
> +  * do have more. Do a simple sanity check to make sure
> +  * copy_to_user() does not overflow. In reality this
> +  * should never fail...
> +  */
> + if (s->n_chan > (0x / sizeof(unsigned int)))
> + return -EINVAL;
>   if (copy_to_user(it.maxdata_list, s->maxdata_list,
>s->n_chan * sizeof(unsigned int)))


This change doesn't make sense because an integer overflow here would be
basically harmless.  I don't like silencing false positives in this way.
It's better to ignore the warning.

The bounds err in ni6501_port_command() was a false positive too, but
the fix for that made to code more readable so it was a good thing.

regards,
dan carpenter

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


[PATCH] staging: rtl8192e: Fix log spamming in rtl8192_hard_data_xmit

2015-08-12 Thread Mateusz Kulikowski
This patch fixes issue generated by commit ca93dcba3a92
("staging: rtl8192e: Remove assert() macro")

One negation was missed in conversion, therefore
asserted message was always printed.
For 1MB file downloaded via http, ~500 messages
were generated.

Signed-off-by: Mateusz Kulikowski 
---

Notes:
This patch (probably) doesn't have to be applied urgently.
Modern distros are not outputting kernel log to console,
so even though driver would spam dmesg, it should not cause
performance drawbacks.

Target tested and verified that performance in fact improves,
at least on my configuration (logs are printed on console
and via netconsole).

Sorry I didn't catch that earlier - either during original
submission or later on - I didn't checked transmission
speeds as my area has some heavy wifi pollution.

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

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index c868cb37..d6b46df 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1642,8 +1642,8 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, 
struct net_device *dev,
return;
}
 
-   if (queue_index != TXCMD_QUEUE)
-   netdev_warn(dev, "%s(): queue index != TXCMD_QUEUE\n",
+   if (queue_index == TXCMD_QUEUE)
+   netdev_warn(dev, "%s(): queue index == TXCMD_QUEUE\n",
__func__);
 
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
-- 
1.8.4.1

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


[PATCH RFC v3 10/16] media: rename link source/sink to pad0_source/pad1_sink

2015-08-12 Thread Mauro Carvalho Chehab
Change the internal namespace for links between two pads to
have the "pad" there.

We're also numbering it, as a common constructor is to do
things like:

if (link->port1.type != MEDIA_GRAPH_PAD)
continue;
if (link->pad1_sink->entity == entity)
/* do something */

by preserving the number, we keep consistency between
port1 and pad1_sink, and port0 and pad0_source.

This was generated via this script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find 
drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type 
f) ; do sed "s,link->sink,link->pad1_sink,g; 
s,link->source,link->pad0_source,g;" <$i >a && mv a $i; done

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 3c97ebdf9f2a..e673f6f7c398 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -637,7 +637,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
link = &entity->links[i];
if (link->port1.type != MEDIA_GRAPH_PAD)
continue;
-   if (link->sink->entity == entity) {
+   if (link->pad1_sink->entity == entity) {
found_link = link;
n_links++;
if (link->flags & MEDIA_LNK_FL_ENABLED)
@@ -660,7 +660,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
return -EINVAL;
}
 
-   source = found_link->source->entity;
+   source = found_link->pad0_source->entity;
fepriv->pipe_start_entity = source;
for (i = 0; i < source->num_links; i++) {
struct media_entity *sink;
@@ -669,7 +669,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
link = &source->links[i];
if (link->port1.type != MEDIA_GRAPH_PAD)
continue;
-   sink = link->sink->entity;
+   sink = link->pad1_sink->entity;
 
if (sink == entity)
flags = MEDIA_LNK_FL_ENABLED;
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index b4bd718ad736..2c29c4600c3a 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -160,13 +160,13 @@ static long __media_device_enum_links(struct media_device 
*mdev,
ent_link->port1->type != MEDIA_GRAPH_PAD)
continue;
/* Ignore backlinks. */
-   if (ent_link->source->entity != entity)
+   if (ent_link->pad0_source->entity != entity)
continue;
 
memset(&link, 0, sizeof(link));
-   media_device_kpad_to_upad(ent_link->source,
+   media_device_kpad_to_upad(ent_link->pad0_source,
  &link.source);
-   media_device_kpad_to_upad(ent_link->sink,
+   media_device_kpad_to_upad(ent_link->pad1_sink,
  &link.sink);
link.flags = ent_link->flags;
if (copy_to_user(ulink, &link, sizeof(*ulink)))
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index fc2e4886c830..aafa1119fba7 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -125,10 +125,10 @@ media_entity_other(struct media_entity *entity, struct 
media_link *link)
if (link->port0->type != MEDIA_GRAPH_PAD ||
link->port1->type != MEDIA_GRAPH_PAD)
return NULL;
-   if (link->source->entity == entity)
-   return link->sink->entity;
+   if (link->pad0_source->entity == entity)
+   return link->pad1_sink->entity;
else
-   return link->source->entity;
+   return link->pad0_source->entity;
 }
 
 /* push an entity to traversal stack */
@@ -299,8 +299,8 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
if (link->port0->type != MEDIA_GRAPH_PAD)
continue;
 
-   pad = link->sink->entity == entity
-   ? link->sink : link->source;
+   pad = link->pad1_sink->entity == entity
+   ? link->pad1_sink : link->pad0_source;
 
/* Mark that a pad is connected by a link. */
bitmap_clear(has_no_links, pad->index, 1);
@@ -318,7 +318,7 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
 * Link validation will only take place for
 * sink ends of the link that are enabled.
 */
-  

[PATCH RFC v3 11/16] media: rename the function that create pad links

2015-08-12 Thread Mauro Carvalho Chehab
Now that a link can be either between two different graph
objects, we'll need to add more functions to create links.
So, rename the existing one that create links only between
two pads as media_create_pad_link().

No functional changes.

This patch was created via this shell script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find 
drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type 
f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a 
$i; done

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 2fdcbb5f000a..65f59f2124b4 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -412,16 +412,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap)
}
 
if (tuner && fe)
-   media_entity_create_link(tuner, 0, fe, 0, 0);
+   media_create_pad_link(tuner, 0, fe, 0, 0);
 
if (fe && demux)
-   media_entity_create_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
+   media_create_pad_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED);
 
if (demux && dvr)
-   media_entity_create_link(demux, 1, dvr, 0, 
MEDIA_LNK_FL_ENABLED);
+   media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED);
 
if (demux && ca)
-   media_entity_create_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
+   media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED);
 }
 EXPORT_SYMBOL_GPL(dvb_create_media_graph);
 #endif
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 6d167428727d..c81bfbfea32f 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1482,11 +1482,11 @@ static int s5c73m3_oif_registered(struct v4l2_subdev 
*sd)
return ret;
}
 
-   ret = media_entity_create_link(&state->sensor_sd.entity,
+   ret = media_create_pad_link(&state->sensor_sd.entity,
S5C73M3_ISP_PAD, &state->oif_sd.entity, OIF_ISP_PAD,
MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
 
-   ret = media_entity_create_link(&state->sensor_sd.entity,
+   ret = media_create_pad_link(&state->sensor_sd.entity,
S5C73M3_JPEG_PAD, &state->oif_sd.entity, OIF_JPEG_PAD,
MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
 
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 30a9ca62e034..d3bff30bcb6f 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1756,7 +1756,7 @@ static int s5k5baf_registered(struct v4l2_subdev *sd)
v4l2_err(sd, "failed to register subdev %s\n",
 state->cis_sd.name);
else
-   ret = media_entity_create_link(&state->cis_sd.entity, PAD_CIS,
+   ret = media_create_pad_link(&state->cis_sd.entity, PAD_CIS,
   &state->sd.entity, PAD_CIS,
   MEDIA_LNK_FL_IMMUTABLE |
   MEDIA_LNK_FL_ENABLED);
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 308613ea0aed..5aa49eb393a9 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2495,7 +2495,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor 
*sensor)
return rval;
}
 
-   rval = media_entity_create_link(&this->sd.entity,
+   rval = media_create_pad_link(&this->sd.entity,
this->source_pad,
&last->sd.entity,
last->sink_pad,
@@ -2503,7 +2503,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor 
*sensor)
MEDIA_LNK_FL_IMMUTABLE);
if (rval) {
dev_err(&client->dev,
-   "media_entity_create_link failed\n");
+   "media_create_pad_link failed\n");
return rval;
}
 
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index aafa1119fba7..03c0ebdd8026 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -479,7 +479,7 @@ static void __media_entity_remove_link(struct media_entity 
*entity,
   struct media_link *link);
 
 int
-media_entity_create_link(struct media_entity *source, u16 source_pad,
+media_create_pad_link(struct media_entity *source, u16 source_pad,
 struct media_entity *sink, u16 sink_pad, u32 flags)
 {
struct media_link *link;
@@ -517,7

[PATCH RFC v3 07/16] media: get rid of unused "extra_links" param on media_entity_init()

2015-08-12 Thread Mauro Carvalho Chehab
Currently, media_entity_init() creates an array with the links,
allocated at init time. It provides a parameter (extra_links)
that would allocate more links than the current needs, but this
is not used by any driver.

As we want to be able to do dynamic link allocation/removal,
we'll need to change the implementation of the links. So,
before doing that, let's first remove that extra unused
parameter, in order to cleanup the interface first.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/Documentation/media-framework.txt 
b/Documentation/media-framework.txt
index f552a75c0e70..2cc6019f7147 100644
--- a/Documentation/media-framework.txt
+++ b/Documentation/media-framework.txt
@@ -104,7 +104,7 @@ although drivers can allocate entities directly.
 Drivers initialize entities by calling
 
media_entity_init(struct media_entity *entity, u16 num_pads,
- struct media_pad *pads, u16 extra_links);
+ struct media_pad *pads);
 
 The media_entity name, type, flags, revision and group_id fields can be
 initialized before or after calling media_entity_init. Entities embedded in
diff --git a/Documentation/video4linux/v4l2-framework.txt 
b/Documentation/video4linux/v4l2-framework.txt
index 75d5c18d689a..109cc3792534 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -300,7 +300,7 @@ calling media_entity_init():
struct media_pad *pads = &my_sd->pads;
int err;
 
-   err = media_entity_init(&sd->entity, npads, pads, 0);
+   err = media_entity_init(&sd->entity, npads, pads);
 
 The pads array must have been previously initialized. There is no need to
 manually set the struct media_entity type and name fields, but the revision
@@ -700,7 +700,7 @@ calling media_entity_init():
struct media_pad *pad = &my_vdev->pad;
int err;
 
-   err = media_entity_init(&vdev->entity, 1, pad, 0);
+   err = media_entity_init(&vdev->entity, 1, pad);
 
 The pads array must have been previously initialized. There is no need to
 manually set the struct media_entity type and name fields.
diff --git a/Documentation/zh_CN/video4linux/v4l2-framework.txt 
b/Documentation/zh_CN/video4linux/v4l2-framework.txt
index 2b828e631e31..ff815cb92031 100644
--- a/Documentation/zh_CN/video4linux/v4l2-framework.txt
+++ b/Documentation/zh_CN/video4linux/v4l2-framework.txt
@@ -295,7 +295,7 @@ owner ??? i2c 
?
struct media_pad *pads = &my_sd->pads;
int err;
 
-   err = media_entity_init(&sd->entity, npads, pads, 0);
+   err = media_entity_init(&sd->entity, npads, pads);
 
 pads  media_entity ??? type ???
 name revision ?
@@ -602,7 +602,7 @@ v4l2_file_operations  file_operations 
???
struct media_pad *pad = &my_vdev->pad;
int err;
 
-   err = media_entity_init(&vdev->entity, 1, pad, 0);
+   err = media_entity_init(&vdev->entity, 1, pad);
 
 pads ?? media_entity ??? 
type ???
 name ??
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 13bb57f0457f..2fdcbb5f000a 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -249,7 +249,7 @@ static void dvb_register_media_device(struct dvb_device 
*dvbdev,
}
 
if (npads)
-   ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads, 0);
+   ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads);
if (!ret)
ret = media_device_register_entity(dvbdev->adapter->mdev,
   dvbdev->entity);
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 69094ab047b1..39d6ee681aeb 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const 
struct i2c_device_id *
state->rgb_quantization_range_ctrl->is_private = true;
 
state->pad.flags = MEDIA_PAD_FL_SINK;
-   err = media_entity_init(&sd->entity, 1, &state->pad, 0);
+   err = media_entity_init(&sd->entity, 1, &state->pad);
if (err)
goto err_hdl;
 
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index c70ababce954..5f76997f6e07 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client,
if (ret)
goto free_and_quit;
 
-   ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);
+   ret = media_entity_init(&flash->subdev.entity, 0, NULL);
if (ret < 0)
goto free_and_quit;
 
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index

[PATCH 01/15] staging: comedi: hwdrv_apci3501: remove useless read/mask to stop watchdog

2015-08-12 Thread H Hartley Sweeten
The watchdog is stopped in apci3501_write_insn_timer() by writing a 0 to
the timer control register. There is no need to read the register first
and mask it (as done when the timer is used as a timer).

Reported-by: coverity (CID 1227052)
Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 1f2f781..e12b2bc 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -102,8 +102,6 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
/* Enable the Watchdog */
outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
} else if (data[1] == 0) { /* Stop The Watchdog */
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = ul_Command1 & 0xF9FEUL;
outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
} else if (data[1] == 2) {
ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-- 
2.4.3

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


[PATCH 02/15] staging: comedi: addi_apci_3501: rename private data 'b_TimerSelectMode'

2015-08-12 Thread H Hartley Sweeten
Rename this CamelCase member of the private data.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3501.c| 16 
 drivers/staging/comedi/drivers/addi_apci_3501.c  |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index e12b2bc..33fcd19 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -27,7 +27,7 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
devpriv->tsk_Current = current;
if (data[0] == ADDIDATA_WATCHDOG) {
 
-   devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;
+   devpriv->timer_mode = ADDIDATA_WATCHDOG;
/* Disable the watchdog */
outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
@@ -52,7 +52,7 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
ul_Command1 = ul_Command1 & 0xF9FEUL;
outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
+   devpriv->timer_mode = ADDIDATA_TIMER;
if (data[1] == 1) {
/* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES 
*/
outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG);
@@ -94,7 +94,7 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
struct apci3501_private *devpriv = dev->private;
unsigned int ul_Command1 = 0;
 
-   if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
 
if (data[1] == 1) {
ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
@@ -110,7 +110,7 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
}
}
 
-   if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
+   if (devpriv->timer_mode == ADDIDATA_TIMER) {
if (data[1] == 1) {
 
ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
@@ -153,18 +153,18 @@ static int apci3501_read_insn_timer(struct comedi_device 
*dev,
 {
struct apci3501_private *devpriv = dev->private;
 
-   if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
}
 
-   else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
+   else if (devpriv->timer_mode == ADDIDATA_TIMER) {
data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
}
 
-   else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER)
-   && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)) {
+   else if (devpriv->timer_mode != ADDIDATA_TIMER &&
+devpriv->timer_mode != ADDIDATA_WATCHDOG) {
dev_err(dev->class_dev, "Invalid subdevice.\n");
}
return insn->n;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 73786a3..6dd7e3d 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -74,7 +74,7 @@
 struct apci3501_private {
int i_IobaseAmcc;
struct task_struct *tsk_Current;
-   unsigned char b_TimerSelectMode;
+   unsigned char timer_mode;
 };
 
 static struct comedi_lrange apci3501_ao_range = {
-- 
2.4.3

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


[PATCH 00/15] staging: comedi: hwdrv_apci3501: tidy up code

2015-08-12 Thread H Hartley Sweeten
The hwdrv_apci3501.c file is included by the addi_apci_3501 driver to provide
the support code for the timer subdevice. The code in this file is broken with
respect to how comedi works with subdevices.

Tidy it up so that it can be fixed.

H Hartley Sweeten (15):
  staging: comedi: hwdrv_apci3501: remove useless read/mask to stop watchdog
  staging: comedi: addi_apci_3501: rename private data 'b_TimerSelectMode'
  staging: comedi: hwdrv_apci3501: rename 'ul_Command1' in 
apci3501_write_insn_timer()
  staging: comedi: hwdrv_apci3501: refactor apci3501_write_insn_timer()
  staging: comedi: hwdrv_apci3501: refactor apci3501_read_insn_timer()
  staging: comedi: hwdrv_apci3501: rename 'ul_Command1' in 
apci3501_config_insn_timer()
  staging: comedi: hwdrv_apci3501: refactor apci3501_config_insn_timer()
  staging: comedi: addi_apci_3501: rename private data 'i_IobaseAmcc'
  staging: comedi: addi_apci_3501: prefer using the BIT macro
  staging: comedi: addi_apci_3501: rename CamelCase vars in apci3501_interrupt()
  staging: comedi: addi_apci_3501: use addi_tcw.h for the timer registers
  staging: comedi: addi_apci_3501: remove "magic" numbers in 
apci3501_interrupt()
  staging: comedi: hwdrv_apci3501: remove "magic" numbers in 
apci3501_config_insn_timer()
  staging: comedi: hwdrv_apci3501: remove "magic" numbers in 
apci3501_write_insn_timer()
  staging: comedi: hwdrv_apci3501: remove "magic" numbers in 
apci3501_read_insn_timer()

 .../comedi/drivers/addi-data/hwdrv_apci3501.c  | 154 -
 drivers/staging/comedi/drivers/addi_apci_3501.c|  60 
 2 files changed, 90 insertions(+), 124 deletions(-)

-- 
2.4.3

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


[PATCH 03/15] staging: comedi: hwdrv_apci3501: rename 'ul_Command1' in apci3501_write_insn_timer()

2015-08-12 Thread H Hartley Sweeten
Rename this CamelCase local variable.

For aesthetics, split the mask/set operations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c  | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 33fcd19..306309e 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -92,43 +92,45 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
 unsigned int *data)
 {
struct apci3501_private *devpriv = dev->private;
-   unsigned int ul_Command1 = 0;
+   unsigned int ctrl = 0;
 
if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
-
if (data[1] == 1) {
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = (ul_Command1 & 0xF9FFUL) | 0x1UL;
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9ff;
+   ctrl |= 0x1;
/* Enable the Watchdog */
-   outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
} else if (data[1] == 0) { /* Stop The Watchdog */
outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
} else if (data[1] == 2) {
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = (ul_Command1 & 0xF9FFUL) | 0x200UL;
-   outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9ff;
+   ctrl |= 0x200;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
}
 
if (devpriv->timer_mode == ADDIDATA_TIMER) {
if (data[1] == 1) {
-
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = (ul_Command1 & 0xF9FFUL) | 0x1UL;
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9ff;
+   ctrl |= 0x1;
/* Enable the Timer */
-   outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
} else if (data[1] == 0) {
/* Stop The Timer */
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = ul_Command1 & 0xF9FEUL;
-   outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9fe;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
 
else if (data[1] == 2) {
/* Trigger the Timer */
-   ul_Command1 = inl(dev->iobase + 
APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = (ul_Command1 & 0xF9FFUL) | 0x200UL;
-   outl(ul_Command1, dev->iobase + 
APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9ff;
+   ctrl |= 0x200;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
}
 
-- 
2.4.3

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


[PATCH 06/15] staging: comedi: hwdrv_apci3501: rename 'ul_Command1' in apci3501_config_insn_timer()

2015-08-12 Thread H Hartley Sweeten
Rename this CamelCase local variable.

For aesthetics, split the mask/set operations.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c   | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 4828c73..47c6bc1 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -22,7 +22,7 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
  unsigned int *data)
 {
struct apci3501_private *devpriv = dev->private;
-   unsigned int ul_Command1 = 0;
+   unsigned int ctrl = 0;
 
devpriv->tsk_Current = current;
if (data[0] == ADDIDATA_WATCHDOG) {
@@ -43,15 +43,16 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
 
/* Set the mode (e2->e0) */
-   ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG) | 
0xFFF819E0UL;
-   outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl |= 0xfff819e0;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
 
else if (data[0] == ADDIDATA_TIMER) {
/* First Stop The Timer */
-   ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = ul_Command1 & 0xF9FEUL;
-   outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9fe;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
devpriv->timer_mode = ADDIDATA_TIMER;
if (data[1] == 1) {
/* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES 
*/
@@ -65,10 +66,10 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
 
/* mode 2 */
-   ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ul_Command1 =
-   (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
-   outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xfff719e2;
+   ctrl |= (2 << 13) | 0x10;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
 
return insn->n;
-- 
2.4.3

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


[PATCH 05/15] staging: comedi: hwdrv_apci3501: refactor apci3501_read_insn_timer()

2015-08-12 Thread H Hartley Sweeten
The handling of the ADDIDATA_WATCHDOG and ADDIDATA_TIMER is identical.
Refactor this function to use a common code path for both timer modes.

Remove the incorrect dev_err() noise. The subdevice is valid but the
timer_mode is not supported.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3501.c   | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 6d0cf6d..4828c73 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -133,19 +133,12 @@ static int apci3501_read_insn_timer(struct comedi_device 
*dev,
 {
struct apci3501_private *devpriv = dev->private;
 
-   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
-   data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
-   data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
-   }
+   if (devpriv->timer_mode != ADDIDATA_TIMER &&
+   devpriv->timer_mode != ADDIDATA_WATCHDOG)
+   return -EINVAL;
 
-   else if (devpriv->timer_mode == ADDIDATA_TIMER) {
-   data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
-   data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
-   }
+   data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
+   data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
 
-   else if (devpriv->timer_mode != ADDIDATA_TIMER &&
-devpriv->timer_mode != ADDIDATA_WATCHDOG) {
-   dev_err(dev->class_dev, "Invalid subdevice.\n");
-   }
return insn->n;
 }
-- 
2.4.3

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


[PATCH 04/15] staging: comedi: hwdrv_apci3501: refactor apci3501_write_insn_timer()

2015-08-12 Thread H Hartley Sweeten
The handling of the ADDIDATA_WATCHDOG and ADDIDATA_TIMER is identical
except for the "stop" operation. Refactor this function to use a common
code path for both timer modes.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c  | 48 ++
 1 file changed, 13 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 306309e..6d0cf6d 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -92,46 +92,24 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
 unsigned int *data)
 {
struct apci3501_private *devpriv = dev->private;
-   unsigned int ctrl = 0;
+   unsigned int ctrl;
 
-   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
-   if (data[1] == 1) {
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9ff;
-   ctrl |= 0x1;
-   /* Enable the Watchdog */
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   } else if (data[1] == 0) { /* Stop The Watchdog */
-   outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   } else if (data[1] == 2) {
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9ff;
-   ctrl |= 0x200;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   }
-   }
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG ||
+   devpriv->timer_mode == ADDIDATA_TIMER) {
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9ff;
 
-   if (devpriv->timer_mode == ADDIDATA_TIMER) {
-   if (data[1] == 1) {
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9ff;
+   if (data[1] == 1) { /* enable */
ctrl |= 0x1;
-   /* Enable the Timer */
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   } else if (data[1] == 0) {
-   /* Stop The Timer */
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9fe;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   }
-
-   else if (data[1] == 2) {
-   /* Trigger the Timer */
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9ff;
+   } else if (data[1] == 0) {  /* stop */
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG)
+   ctrl = 0;
+   else
+   ctrl &= ~0x1;
+   } else if (data[1] == 2) {  /* trigger */
ctrl |= 0x200;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
 
inl(dev->iobase + APCI3501_TIMER_STATUS_REG);
-- 
2.4.3

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


[PATCH 07/15] staging: comedi: hwdrv_apci3501: refactor apci3501_config_insn_timer()

2015-08-12 Thread H Hartley Sweeten
The handling for the watchdog and timer modes is very similar. Refactor
this function to use a common code path for both modes.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c  | 59 +-
 1 file changed, 23 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 47c6bc1..e5209eb 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -22,55 +22,42 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
  unsigned int *data)
 {
struct apci3501_private *devpriv = dev->private;
-   unsigned int ctrl = 0;
+   unsigned int ctrl;
+
+   if (data[0] != ADDIDATA_WATCHDOG &&
+   data[0] != ADDIDATA_TIMER)
+   return -EINVAL;
 
devpriv->tsk_Current = current;
-   if (data[0] == ADDIDATA_WATCHDOG) {
-
-   devpriv->timer_mode = ADDIDATA_WATCHDOG;
-   /* Disable the watchdog */
-   outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
-
-   if (data[1] == 1) {
-   /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES 
*/
-   outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   } else {
-   /* disable Timer interrupt */
-   outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   }
 
-   outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
-   outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
+   devpriv->timer_mode = data[0];
 
-   /* Set the mode (e2->e0) */
+   /* first, disable the watchdog or stop the timer */
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
+   ctrl = 0;
+   } else {
ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl |= 0xfff819e0;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9fe;
}
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
-   else if (data[0] == ADDIDATA_TIMER) {
-   /* First Stop The Timer */
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ctrl &= 0xf9fe;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   devpriv->timer_mode = ADDIDATA_TIMER;
-   if (data[1] == 1) {
-   /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES 
*/
-   outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   } else {
-   /* disable Timer interrupt */
-   outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
-   }
+   /* enable/disable the timer interrupt */
+   ctrl = (data[1] == 1) ? 0x2 : 0;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
-   outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
-   outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
+   outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
+   outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
 
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
+   /* Set the mode (e2->e0) NOTE: this doesn't look correct */
+   ctrl |= 0xfff819e0;
+   } else {
/* mode 2 */
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
ctrl &= 0xfff719e2;
ctrl |= (2 << 13) | 0x10;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
return insn->n;
 }
-- 
2.4.3

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


[PATCH 08/15] staging: comedi: addi_apci_3501: rename private data 'i_IobaseAmcc'

2015-08-12 Thread H Hartley Sweeten
Rename this CamelCase member of the private data.

Also, fix the type of the member, it holds a pci_resource_start()
address and should be an unsigned long.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_3501.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 6dd7e3d..c3a1acd 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -72,7 +72,7 @@
 #define EEPROM_TIMER_WATCHDOG_COUNTER  10
 
 struct apci3501_private {
-   int i_IobaseAmcc;
+   unsigned long amcc;
struct task_struct *tsk_Current;
unsigned char timer_mode;
 };
@@ -222,11 +222,10 @@ static unsigned short apci3501_eeprom_readw(unsigned long 
iobase,
 static int apci3501_eeprom_get_ao_n_chan(struct comedi_device *dev)
 {
struct apci3501_private *devpriv = dev->private;
-   unsigned long iobase = devpriv->i_IobaseAmcc;
unsigned char nfuncs;
int i;
 
-   nfuncs = apci3501_eeprom_readw(iobase, 10) & 0xff;
+   nfuncs = apci3501_eeprom_readw(devpriv->amcc, 10) & 0xff;
 
/* Read functionality details */
for (i = 0; i < nfuncs; i++) {
@@ -235,11 +234,11 @@ static int apci3501_eeprom_get_ao_n_chan(struct 
comedi_device *dev)
unsigned char func;
unsigned short val;
 
-   func = apci3501_eeprom_readw(iobase, 12 + offset) & 0x3f;
-   addr = apci3501_eeprom_readw(iobase, 14 + offset);
+   func = apci3501_eeprom_readw(devpriv->amcc, 12 + offset) & 0x3f;
+   addr = apci3501_eeprom_readw(devpriv->amcc, 14 + offset);
 
if (func == EEPROM_ANALOGOUTPUT) {
-   val = apci3501_eeprom_readw(iobase, addr + 10);
+   val = apci3501_eeprom_readw(devpriv->amcc, addr + 10);
return (val >> 4) & 0x3ff;
}
}
@@ -254,7 +253,7 @@ static int apci3501_eeprom_insn_read(struct comedi_device 
*dev,
struct apci3501_private *devpriv = dev->private;
unsigned short addr = CR_CHAN(insn->chanspec);
 
-   data[0] = apci3501_eeprom_readw(devpriv->i_IobaseAmcc, 2 * addr);
+   data[0] = apci3501_eeprom_readw(devpriv->amcc, 2 * addr);
 
return insn->n;
 }
@@ -335,7 +334,7 @@ static int apci3501_auto_attach(struct comedi_device *dev,
return ret;
 
dev->iobase = pci_resource_start(pcidev, 1);
-   devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+   devpriv->amcc = pci_resource_start(pcidev, 0);
 
ao_n_chan = apci3501_eeprom_get_ao_n_chan(dev);
 
-- 
2.4.3

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


[PATCH 09/15] staging: comedi: addi_apci_3501: prefer using the BIT macro

2015-08-12 Thread H Hartley Sweeten
Change the register bit defines to use the BIT macro.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_3501.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index c3a1acd..17b1794 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -33,12 +33,12 @@
  * PCI bar 1 register I/O map
  */
 #define APCI3501_AO_CTRL_STATUS_REG0x00
-#define APCI3501_AO_CTRL_BIPOLAR   (1 << 0)
-#define APCI3501_AO_STATUS_READY   (1 << 8)
+#define APCI3501_AO_CTRL_BIPOLAR   BIT(0)
+#define APCI3501_AO_STATUS_READY   BIT(8)
 #define APCI3501_AO_DATA_REG   0x04
 #define APCI3501_AO_DATA_CHAN(x)   ((x) << 0)
 #define APCI3501_AO_DATA_VAL(x)((x) << 8)
-#define APCI3501_AO_DATA_BIPOLAR   (1 << 31)
+#define APCI3501_AO_DATA_BIPOLAR   BIT(31)
 #define APCI3501_AO_TRIG_SCS_REG   0x08
 #define APCI3501_TIMER_SYNC_REG0x20
 #define APCI3501_TIMER_RELOAD_REG  0x24
-- 
2.4.3

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


[PATCH 10/15] staging: comedi: addi_apci_3501: rename CamelCase vars in apci3501_interrupt()

2015-08-12 Thread H Hartley Sweeten
Rename the CamelCase local variables.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_3501.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 17b1794..16684c0 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -262,25 +262,26 @@ static irqreturn_t apci3501_interrupt(int irq, void *d)
 {
struct comedi_device *dev = d;
struct apci3501_private *devpriv = dev->private;
-   unsigned int ui_Timer_AOWatchdog;
-   unsigned long ul_Command1;
+   unsigned int status;
+   unsigned int ctrl;
 
/*  Disable Interrupt */
-   ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = ul_Command1 & 0xF9FDul;
-   outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9fd;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
-   ui_Timer_AOWatchdog = inl(dev->iobase + APCI3501_TIMER_IRQ_REG) & 0x1;
-   if ((!ui_Timer_AOWatchdog)) {
+   status = inl(dev->iobase + APCI3501_TIMER_IRQ_REG) & 0x1;
+   if (!status) {
dev_err(dev->class_dev, "IRQ from unknown source\n");
return IRQ_NONE;
}
 
/* Enable Interrupt Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
-   ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-   ul_Command1 = (ul_Command1 & 0xF9FDul) | 1 << 1;
-   outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl &= 0xf9fd;
+   ctrl |= 1 << 1;
+   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
inl(dev->iobase + APCI3501_TIMER_STATUS_REG);
 
return IRQ_HANDLED;
-- 
2.4.3

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


[PATCH 11/15] staging: comedi: addi_apci_3501: use addi_tcw.h for the timer registers

2015-08-12 Thread H Hartley Sweeten
The APCI3501_TIMER_* register defines in this driver are that same as
the ADDI_TCW_* defines with an additional offset.

Add a 'tcw' (timer/counter/watchdog) member to the private data to
hold the address for the iobase of the registers. Use that and the
defines from addi_tcw.h to address the registers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../comedi/drivers/addi-data/hwdrv_apci3501.c  | 24 ++--
 drivers/staging/comedi/drivers/addi_apci_3501.c| 26 +-
 2 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index e5209eb..8ba094c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -36,19 +36,19 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
ctrl = 0;
} else {
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
ctrl &= 0xf9fe;
}
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
/* enable/disable the timer interrupt */
ctrl = (data[1] == 1) ? 0x2 : 0;
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
-   outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
-   outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
+   outl(data[2], devpriv->tcw + ADDI_TCW_TIMEBASE_REG);
+   outl(data[3], devpriv->tcw + ADDI_TCW_RELOAD_REG);
 
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
/* Set the mode (e2->e0) NOTE: this doesn't look correct */
ctrl |= 0xfff819e0;
@@ -57,7 +57,7 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
ctrl &= 0xfff719e2;
ctrl |= (2 << 13) | 0x10;
}
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
return insn->n;
 }
@@ -84,7 +84,7 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
 
if (devpriv->timer_mode == ADDIDATA_WATCHDOG ||
devpriv->timer_mode == ADDIDATA_TIMER) {
-   ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+   ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
ctrl &= 0xf9ff;
 
if (data[1] == 1) { /* enable */
@@ -97,10 +97,10 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
} else if (data[1] == 2) {  /* trigger */
ctrl |= 0x200;
}
-   outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
+   outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
}
 
-   inl(dev->iobase + APCI3501_TIMER_STATUS_REG);
+   inl(devpriv->tcw + ADDI_TCW_STATUS_REG);
return insn->n;
 }
 
@@ -125,8 +125,8 @@ static int apci3501_read_insn_timer(struct comedi_device 
*dev,
devpriv->timer_mode != ADDIDATA_WATCHDOG)
return -EINVAL;
 
-   data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
-   data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
+   data[0] = inl(devpriv->tcw + ADDI_TCW_STATUS_REG) & 0x1;
+   data[1] = inl(devpriv->tcw + ADDI_TCW_VAL_REG);
 
return insn->n;
 }
diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 16684c0..4faa23b 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -27,6 +27,7 @@
 #include 
 
 #include "../comedi_pci.h"
+#include "addi_tcw.h"
 #include "amcc_s5933.h"
 
 /*
@@ -40,14 +41,7 @@
 #define APCI3501_AO_DATA_VAL(x)((x) << 8)
 #define APCI3501_AO_DATA_BIPOLAR   BIT(31)
 #define APCI3501_AO_TRIG_SCS_REG   0x08
-#define APCI3501_TIMER_SYNC_REG0x20
-#define APCI3501_TIMER_RELOAD_REG  0x24
-#define APCI3501_TIMER_TIMEBASE_REG0x28
-#define APCI3501_TIMER_CTRL_REG0x2c
-#define APCI3501_TIMER_STATUS_REG  0x30
-#define APCI3501_TIMER_IRQ_REG 0x34
-#define APCI3501_TIMER_WARN_RELOAD_REG 0x38
-#define APCI3501_TIMER_WARN_TIMEBASE_REG   0x3c
+#define APCI3501_TIMER_BASE0x20
 #define APCI3501_DO_REG0x40
 #define APCI3501_DI_REG0x50
 
@@ -73,6 +67,7 @@
 
 struct apci3501_private {
unsi

[PATCH 12/15] staging: comedi: addi_apci_3501: remove "magic" numbers in apci3501_interrupt()

2015-08-12 Thread H Hartley Sweeten
Use register bit defines from addi_tcw.h to remove the "magic" numbers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_3501.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 4faa23b..40ff914 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -262,11 +262,12 @@ static irqreturn_t apci3501_interrupt(int irq, void *d)
 
/*  Disable Interrupt */
ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
-   ctrl &= 0xf9fd;
+   ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+ ADDI_TCW_CTRL_IRQ_ENA);
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
-   status = inl(devpriv->tcw + ADDI_TCW_IRQ_REG) & 0x1;
-   if (!status) {
+   status = inl(devpriv->tcw + ADDI_TCW_IRQ_REG);
+   if (!(status & ADDI_TCW_IRQ)) {
dev_err(dev->class_dev, "IRQ from unknown source\n");
return IRQ_NONE;
}
@@ -274,8 +275,9 @@ static irqreturn_t apci3501_interrupt(int irq, void *d)
/* Enable Interrupt Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
-   ctrl &= 0xf9fd;
-   ctrl |= 1 << 1;
+   ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+ ADDI_TCW_CTRL_IRQ_ENA);
+   ctrl |= ADDI_TCW_CTRL_IRQ_ENA;
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
inl(devpriv->tcw + ADDI_TCW_STATUS_REG);
 
-- 
2.4.3

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


[PATCH 13/15] staging: comedi: hwdrv_apci3501: remove "magic" numbers in apci3501_config_insn_timer()

2015-08-12 Thread H Hartley Sweeten
Use register bit defines from addi_tcw.h to remove the "magic" numbers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3501.c  | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 8ba094c..c4a72a5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -37,12 +37,13 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
ctrl = 0;
} else {
ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
-   ctrl &= 0xf9fe;
+   ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+ ADDI_TCW_CTRL_ENA);
}
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
/* enable/disable the timer interrupt */
-   ctrl = (data[1] == 1) ? 0x2 : 0;
+   ctrl = (data[1] == 1) ? ADDI_TCW_CTRL_IRQ_ENA : 0;
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
outl(data[2], devpriv->tcw + ADDI_TCW_TIMEBASE_REG);
@@ -51,11 +52,18 @@ static int apci3501_config_insn_timer(struct comedi_device 
*dev,
ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
/* Set the mode (e2->e0) NOTE: this doesn't look correct */
-   ctrl |= 0xfff819e0;
+   ctrl |= ~(ADDI_TCW_CTRL_CNT_UP | ADDI_TCW_CTRL_EXT_CLK_MASK |
+ ADDI_TCW_CTRL_MODE_MASK | ADDI_TCW_CTRL_GATE |
+ ADDI_TCW_CTRL_TRIG | ADDI_TCW_CTRL_TIMER_ENA |
+ ADDI_TCW_CTRL_RESET_ENA | ADDI_TCW_CTRL_WARN_ENA |
+ ADDI_TCW_CTRL_IRQ_ENA | ADDI_TCW_CTRL_ENA);
} else {
/* mode 2 */
-   ctrl &= 0xfff719e2;
-   ctrl |= (2 << 13) | 0x10;
+   ctrl &= ~(ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE_MASK |
+ ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+ ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA |
+ ADDI_TCW_CTRL_WARN_ENA | ADDI_TCW_CTRL_ENA);
+   ctrl |= ADDI_TCW_CTRL_MODE(2) | ADDI_TCW_CTRL_TIMER_ENA;
}
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
-- 
2.4.3

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


[PATCH 15/15] staging: comedi: hwdrv_apci3501: remove "magic" numbers in apci3501_read_insn_timer()

2015-08-12 Thread H Hartley Sweeten
Use register bit defines from addi_tcw.h to remove the "magic" numbers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index d971f7a..3757074 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -133,7 +133,8 @@ static int apci3501_read_insn_timer(struct comedi_device 
*dev,
devpriv->timer_mode != ADDIDATA_WATCHDOG)
return -EINVAL;
 
-   data[0] = inl(devpriv->tcw + ADDI_TCW_STATUS_REG) & 0x1;
+   data[0] = inl(devpriv->tcw + ADDI_TCW_STATUS_REG) &
+ ADDI_TCW_STATUS_OVERFLOW;
data[1] = inl(devpriv->tcw + ADDI_TCW_VAL_REG);
 
return insn->n;
-- 
2.4.3

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


[PATCH 14/15] staging: comedi: hwdrv_apci3501: remove "magic" numbers in apci3501_write_insn_timer()

2015-08-12 Thread H Hartley Sweeten
Use register bit defines from addi_tcw.h to remove the "magic" numbers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index c4a72a5..d971f7a 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -93,17 +93,17 @@ static int apci3501_write_insn_timer(struct comedi_device 
*dev,
if (devpriv->timer_mode == ADDIDATA_WATCHDOG ||
devpriv->timer_mode == ADDIDATA_TIMER) {
ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
-   ctrl &= 0xf9ff;
+   ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG);
 
if (data[1] == 1) { /* enable */
-   ctrl |= 0x1;
+   ctrl |= ADDI_TCW_CTRL_ENA;
} else if (data[1] == 0) {  /* stop */
if (devpriv->timer_mode == ADDIDATA_WATCHDOG)
ctrl = 0;
else
-   ctrl &= ~0x1;
+   ctrl &= ~ADDI_TCW_CTRL_ENA;
} else if (data[1] == 2) {  /* trigger */
-   ctrl |= 0x200;
+   ctrl |= ADDI_TCW_CTRL_TRIG;
}
outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
}
-- 
2.4.3

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


[PATCH 0/5] staging: comedi: usbduxsigma: tidy up

2015-08-12 Thread H Hartley Sweeten
Fix some minor checkpatch.pl issues and use the comedi_offset_munge()
helper to do the two's complement to offset binary munging.

H Hartley Sweeten (5):
  staging: comedi: usbduxsigma: add missing spaces
  staging: comedi: usbduxsigma: use prefered kernel types
  staging: comedi: usbduxsigma: tidy up block comments
  staging: comedi: comedidev.h: fix comedi_offset_munge() for values > 
s->maxdata
  staging: comedi: usbduxsigma: use comedi_offset_munge()

 drivers/staging/comedi/comedidev.h   |  2 +-
 drivers/staging/comedi/drivers/usbduxsigma.c | 75 +---
 2 files changed, 35 insertions(+), 42 deletions(-)

-- 
2.4.3

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


[PATCH 1/5] staging: comedi: usbduxsigma: add missing spaces

2015-08-12 Thread H Hartley Sweeten
Add some missing space to quiet the checkpatch.pl issues about:

CHECK: spaces preferred around that '/' (ctx:VxV)
CHECK: spaces preferred around that '+' (ctx:VxV)
CHECK: spaces preferred around that '*' (ctx:VxV)
CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 649cf47..a33b2cb 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -66,10 +66,10 @@
 #define USBDUXSUB_CPUCS 0xE600
 
 /* 300Hz max frequ under PWM */
-#define MIN_PWM_PERIOD  ((long)(1E9/300))
+#define MIN_PWM_PERIOD  ((long)(1E9 / 300))
 
 /* Default PWM frequency */
-#define PWM_DEFAULT_PERIOD ((long)(1E9/100))
+#define PWM_DEFAULT_PERIOD ((long)(1E9 / 100))
 
 /* Number of channels (16 AD and offset)*/
 #define NUMCHANNELS 16
@@ -81,7 +81,7 @@
  * Size of the async input-buffer IN BYTES, the DIO state is transmitted
  * as the first byte.
  */
-#define SIZEINBUF (((NUMCHANNELS+1)*SIZEADIN))
+#define SIZEINBUF (((NUMCHANNELS + 1) * SIZEADIN))
 
 /* 16 bytes. */
 #define SIZEINSNBUF   16
@@ -90,20 +90,20 @@
 #define NUMOUTCHANNELS8
 
 /* size of one value for the D/A converter: channel and value */
-#define SIZEDAOUT  ((sizeof(uint8_t)+sizeof(uint16_t)))
+#define SIZEDAOUT  ((sizeof(uint8_t) + sizeof(uint16_t)))
 
 /*
  * Size of the output-buffer in bytes
  * Actually only the first 4 triplets are used but for the
  * high speed mode we need to pad it to 8 (microframes).
  */
-#define SIZEOUTBUF ((8*SIZEDAOUT))
+#define SIZEOUTBUF ((8 * SIZEDAOUT))
 
 /*
  * Size of the buffer for the dux commands: just now max size is determined
  * by the analogue out + command byte + panic bytes...
  */
-#define SIZEOFDUXBUFFER((8*SIZEDAOUT+2))
+#define SIZEOFDUXBUFFER((8 * SIZEDAOUT + 2))
 
 /* Number of in-URBs which receive the data: min=2 */
 #define NUMOFINBUFFERSFULL 5
@@ -228,7 +228,7 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device 
*dev,
for (i = 0; i < cmd->chanlist_len; i++) {
/* transfer data,
   note first byte is the DIO state */
-   val = be32_to_cpu(devpriv->in_buf[i+1]);
+   val = be32_to_cpu(devpriv->in_buf[i + 1]);
val &= 0x00ff; /* strip status byte */
val ^= 0x0080; /* convert to unsigned */
 
@@ -559,7 +559,7 @@ static void create_adc_command(unsigned int chan,
if (chan < 8)
(*muxsg0) = (*muxsg0) | (1 << chan);
else if (chan < 16)
-   (*muxsg1) = (*muxsg1) | (1 << (chan-8));
+   (*muxsg1) = (*muxsg1) | (1 << (chan - 8));
 }
 
 static int usbbuxsigma_send_cmd(struct comedi_device *dev, int cmd_type)
-- 
2.4.3

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


[PATCH 3/5] staging: comedi: usbduxsigma: tidy up block comments

2015-08-12 Thread H Hartley Sweeten
Merge the two comments and format it in the kernel CodingStyle.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index b348710..8341a57 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -223,11 +223,11 @@ static void usbduxsigma_ai_handle_urb(struct 
comedi_device *dev,
if (devpriv->ai_counter == 0) {
devpriv->ai_counter = devpriv->ai_timer;
 
-   /* get the data from the USB bus
-  and hand it over to comedi */
+   /*
+* Get the data from the USB bus and hand it over
+* to comedi. Note, first byte is the DIO state
+*/
for (i = 0; i < cmd->chanlist_len; i++) {
-   /* transfer data,
-  note first byte is the DIO state */
val = be32_to_cpu(devpriv->in_buf[i + 1]);
val &= 0x00ff; /* strip status byte */
val ^= 0x0080; /* convert to unsigned */
-- 
2.4.3

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


[PATCH 2/5] staging: comedi: usbduxsigma: use prefered kernel types

2015-08-12 Thread H Hartley Sweeten
As suggested by checkpatch.pl:

CHECK: Prefer kernel type 'u8' over 'uint8_t'
CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 39 ++--
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index a33b2cb..b348710 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -75,7 +75,7 @@
 #define NUMCHANNELS 16
 
 /* Size of one A/D value */
-#define SIZEADIN  ((sizeof(uint32_t)))
+#define SIZEADIN  ((sizeof(u32)))
 
 /*
  * Size of the async input-buffer IN BYTES, the DIO state is transmitted
@@ -90,7 +90,7 @@
 #define NUMOUTCHANNELS8
 
 /* size of one value for the D/A converter: channel and value */
-#define SIZEDAOUT  ((sizeof(uint8_t) + sizeof(uint16_t)))
+#define SIZEDAOUT  ((sizeof(u8) + sizeof(uint16_t)))
 
 /*
  * Size of the output-buffer in bytes
@@ -150,13 +150,13 @@ struct usbduxsigma_private {
/* PWM period */
unsigned int pwm_period;
/* PWM internal delay for the GPIF in the FX2 */
-   uint8_t pwm_delay;
+   u8 pwm_delay;
/* size of the PWM buffer which holds the bit pattern */
int pwm_buf_sz;
/* input buffer for the ISO-transfer */
__be32 *in_buf;
/* input buffer for single insn */
-   uint8_t *insn_buf;
+   u8 *insn_buf;
 
unsigned high_speed:1;
unsigned ai_cmd_running:1;
@@ -172,7 +172,7 @@ struct usbduxsigma_private {
/* interval in frames/uframes */
unsigned int ai_interval;
/* commands */
-   uint8_t *dux_commands;
+   u8 *dux_commands;
struct semaphore sem;
 };
 
@@ -214,7 +214,7 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device 
*dev,
struct usbduxsigma_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
-   uint32_t val;
+   u32 val;
int ret;
int i;
 
@@ -341,7 +341,7 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device 
*dev,
struct usbduxsigma_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
-   uint8_t *datap;
+   u8 *datap;
int ret;
int i;
 
@@ -553,8 +553,7 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
  * range is the range value from comedi
  */
 static void create_adc_command(unsigned int chan,
-  uint8_t *muxsg0,
-  uint8_t *muxsg1)
+  u8 *muxsg0, u8 *muxsg1)
 {
if (chan < 8)
(*muxsg0) = (*muxsg0) | (1 << chan);
@@ -634,9 +633,9 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
struct usbduxsigma_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int len = cmd->chanlist_len;
-   uint8_t muxsg0 = 0;
-   uint8_t muxsg1 = 0;
-   uint8_t sysred = 0;
+   u8 muxsg0 = 0;
+   u8 muxsg1 = 0;
+   u8 sysred = 0;
int ret;
int i;
 
@@ -708,9 +707,9 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
 {
struct usbduxsigma_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
-   uint8_t muxsg0 = 0;
-   uint8_t muxsg1 = 0;
-   uint8_t sysred = 0;
+   u8 muxsg0 = 0;
+   u8 muxsg1 = 0;
+   u8 sysred = 0;
int ret;
int i;
 
@@ -738,7 +737,7 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
}
 
for (i = 0; i < insn->n; i++) {
-   uint32_t val;
+   u32 val;
 
ret = usbduxsigma_receive_cmd(dev, USBDUXSIGMA_SINGLE_AD_CMD);
if (ret < 0) {
@@ -1221,8 +1220,8 @@ static int usbduxsigma_pwm_config(struct comedi_device 
*dev,
 static int usbduxsigma_getstatusinfo(struct comedi_device *dev, int chan)
 {
struct usbduxsigma_private *devpriv = dev->private;
-   uint8_t sysred;
-   uint32_t val;
+   u8 sysred;
+   u32 val;
int ret;
 
switch (chan) {
@@ -1274,8 +1273,8 @@ static int usbduxsigma_firmware_upload(struct 
comedi_device *dev,
   unsigned long context)
 {
struct usb_device *usb = comedi_to_usb_dev(dev);
-   uint8_t *buf;
-   uint8_t *tmp;
+   u8 *buf;
+   u8 *tmp;
int ret;
 
if (!data)
-- 
2.4.3

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


[PATCH 4/5] staging: comedi: comedidev.h: fix comedi_offset_munge() for values > s->maxdata

2015-08-12 Thread H Hartley Sweeten
The comedi_offset_munge() helper is used to convert unsigned int data
values from the comedi offset binary format to two's complement values
for hardware that needs the data in that format. The comedi data is
always checked against s->maxdata before writing to the hardware so
the current implementation always works correctly.

It also works to convert the hardware two's complement data into the
offset binary format used by comedi. Unfortunately, some boards
return extra data in the upper bits. The current implementation
ends up leaving these bits in the converted value.

Mask the converted value to ensure that any extra bits are removed.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedidev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index 28a5d3a..1c8ed5d 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -388,7 +388,7 @@ static inline bool comedi_chan_range_is_external(struct 
comedi_subdevice *s,
 static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
   unsigned int val)
 {
-   return val ^ s->maxdata ^ (s->maxdata >> 1);
+   return (val ^ s->maxdata ^ (s->maxdata >> 1)) & s->maxdata;
 }
 
 /**
-- 
2.4.3

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


[PATCH 5/5] staging: comedi: usbduxsigma: use comedi_offset_munge()

2015-08-12 Thread H Hartley Sweeten
Use the comedi_offset_munge() helper to convert the hardware two's
complement values to the offset binary format expected by comedi.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 8341a57..86cbd4c 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -229,9 +229,7 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device 
*dev,
 */
for (i = 0; i < cmd->chanlist_len; i++) {
val = be32_to_cpu(devpriv->in_buf[i + 1]);
-   val &= 0x00ff; /* strip status byte */
-   val ^= 0x0080; /* convert to unsigned */
-
+   val = comedi_offset_munge(s, val);
if (!comedi_buf_write_samples(s, &val, 1))
return;
}
@@ -748,10 +746,7 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
/* 32 bits big endian from the A/D converter */
val = be32_to_cpu(get_unaligned((__be32
 *)(devpriv->insn_buf + 1)));
-   val &= 0x00ff;  /* strip status byte */
-   val ^= 0x0080;  /* convert to unsigned */
-
-   data[i] = val;
+   data[i] = comedi_offset_munge(s, val);
}
up(&devpriv->sem);
 
@@ -1219,6 +1214,7 @@ static int usbduxsigma_pwm_config(struct comedi_device 
*dev,
 
 static int usbduxsigma_getstatusinfo(struct comedi_device *dev, int chan)
 {
+   struct comedi_subdevice *s = dev->read_subdev;
struct usbduxsigma_private *devpriv = dev->private;
u8 sysred;
u32 val;
@@ -1262,10 +1258,8 @@ static int usbduxsigma_getstatusinfo(struct 
comedi_device *dev, int chan)
 
/* 32 bits big endian from the A/D converter */
val = be32_to_cpu(get_unaligned((__be32 *)(devpriv->insn_buf + 1)));
-   val &= 0x00ff;  /* strip status byte */
-   val ^= 0x0080;  /* convert to unsigned */
 
-   return (int)val;
+   return (int)comedi_offset_munge(s, val);
 }
 
 static int usbduxsigma_firmware_upload(struct comedi_device *dev,
-- 
2.4.3

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


[PATCH 0/5] staging: wilc1000: 64bit build patch

2015-08-12 Thread Tony Cho
This series of patch includes new design for 64 bits. The driver uses the
redundant typecasting to communicate with the chipset, which causes several
compile warnings.

However, this patch uses the real data type and removes unnecessary typecasting.
Also, the driver allocates the ID value to the pointer address representing
the handlers and adds it into the data frames instead of the pointer address.
In results, the driver sends and gets the data frame to/from the chipset
together with ID value instead of pointer address as a handler. This series of
patch removes the warnings which 64 bit issues cause as well.

change log

- v2
 This version 2 updated only "use id value as argument" patch
 : Add return error code in newly added function.
 : Add error handling as the return error code
 : Remove ++ operrator

Johnny Kim (5):
  staging: wilc1000: replace WILC_WFIDrvHandle by tstrWILC_WFIDrv
  staging: wilc1000: change void pointer type to real type
  staging: wilc1000: clarify the argument type
  staging: wilc1000: use the real data type
  staging: wilc1000: use id value as argument

 drivers/staging/wilc1000/host_interface.c | 471 ++
 drivers/staging/wilc1000/host_interface.h | 109 ++---
 drivers/staging/wilc1000/linux_wlan.c |  16 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  22 +-
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   5 +-
 5 files changed, 372 insertions(+), 251 deletions(-)

-- 
1.9.1

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


[PATCH 2/5] staging: wilc1000: change void pointer type to real type

2015-08-12 Thread Tony Cho
From: Johnny Kim 

This patch changes the void pointer member of the tstrHostIFmsg to the
real data type because the void pointer type is ambiguous and not
readable.

Signed-off-by: Johnny Kim 
Signed-off-by: Tony Cho 
---
 drivers/staging/wilc1000/host_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 20a554f..b5afc82 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -466,7 +466,7 @@ typedef union _tuniHostIFmsgBody {
 typedef struct _tstrHostIFmsg {
u16 u16MsgId;   /*!< Message ID 
*/
tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
-   void *drvHandler;
+   tstrWILC_WFIDrv *drvHandler;
 } tstrHostIFmsg;
 
 #ifdef CONNECT_DIRECT
-- 
1.9.1

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


[PATCH 1/5] staging: wilc1000: replace WILC_WFIDrvHandle by tstrWILC_WFIDrv

2015-08-12 Thread Tony Cho
From: Johnny Kim 

The structure, WILC_WFIDrvHandle is used to save the pointer address
for the driver handler which is used throughout the driver but it's
not easy to understand what it means. In addition, it doesn't support
the 64 bit machine and also causes the warnings for the 64 bit build.

This patch replaces the WILC_WFIDrvHandle by the tstrWILC_WFIDrv
because the tstrWILC_WFIDrv is real structure to represent the driver
handler and reduces the 64 bit compile warnings. Also, typecasting to
WILC_WFIDrvHandle is not needed by using tstrWILC_WFIDrv as is.

Signed-off-by: Johnny Kim 
Signed-off-by: Tony Cho 
---
 drivers/staging/wilc1000/host_interface.c | 126 +++---
 drivers/staging/wilc1000/host_interface.h | 104 +-
 drivers/staging/wilc1000/linux_wlan.c |  16 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  22 ++--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   4 +-
 5 files changed, 136 insertions(+), 136 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index cc549c2..20a554f 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -751,7 +751,7 @@ s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, 
u8 idx)
 
 
 
-   host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, 
firmwareIPAddress, idx);
+   host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
 
if (s32Error) {
PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
@@ -801,7 +801,7 @@ s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, 
u8 idx)
WILC_FREE(strWID.ps8WidVal);
 
if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
-   host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, 
gs8SetIP[idx], idx);
+   host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
 
if (s32Error != WILC_SUCCESS) {
PRINT_ER("Failed to get IP address\n");
@@ -1497,7 +1497,7 @@ static s32 Handle_Connect(void *drvHandler, 
tstrHostIFconnectAttr *pstrHostIFcon
 
 
PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
-   s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv,
+   s32Err = host_int_get_site_survey_results(pstrWFIDrv,
  gapu8RcvdSurveyResults,
  MAX_SURVEY_RESULT_FRAG_SIZE);
if (s32Err) {
@@ -2402,7 +2402,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, 
tstrRcvdGnrlAsyncInfo *pst
if (u8MacStatus == MAC_CONNECTED) {
memset(gapu8RcvdAssocResp, 0, 
MAX_ASSOC_RESP_FRAME_SIZE);
 
-   
host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv,
+   host_int_get_assoc_res_info(pstrWFIDrv,
gapu8RcvdAssocResp,

MAX_ASSOC_RESP_FRAME_SIZE,

&u32RcvdAssocRespInfoLen);
@@ -2492,7 +2492,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, 
tstrRcvdGnrlAsyncInfo *pst
(strConnectInfo.u16ConnectStatus == 
SUCCESSFUL_STATUSCODE)) {
#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
 
-   
host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+   host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
#endif
 
PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED 
and Connect Status : Successful\n");
@@ -2568,7 +2568,7 @@ static s32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, 
tstrRcvdGnrlAsyncInfo *pst
#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
 
g_obtainingIP = false;
-   
host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+   host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
#endif
 

pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
@@ -3047,7 +3047,7 @@ static void Handle_Disconnect(void *drvHandler)
#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
 
g_obtainingIP = false;
-   host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+   host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
#endif
 
memset(u8ConnectedSSID, 0, ETH_ALEN);
@@ -3148,7 +3148,7 @@ void resolve_disconnect_aberration(void *drvHandler)
return;
if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || 
(pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplican

[PATCH 4/5] staging: wilc1000: use the real data type

2015-08-12 Thread Tony Cho
From: Johnny Kim 

This patch changes the type of gu8FlushedJoinReqDrvHandler with his real
data type becasue typecasting is not necessary. In result, typecasting
which is not necessary and some building warnings is removed.

Signed-off-by: Johnny Kim 
Signed-off-by: Tony Cho 
---
 drivers/staging/wilc1000/host_interface.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 1c2d924..c4e27c7 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -578,7 +578,7 @@ u8 gu8Flushed11iMode;
 u8 gu8FlushedAuthType;
 u32 gu32FlushedJoinReqSize;
 u32 gu32FlushedInfoElemAsocSize;
-u32 gu8FlushedJoinReqDrvHandler;
+tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
 #define REAL_JOIN_REQ 0
 #define FLUSHED_JOIN_REQ 1
 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in 
the flushed request */
@@ -1940,7 +1940,7 @@ static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, 
tstrHostIFconnectAttr *ps
/*BugID_5137*/
if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
-   gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
+   gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
}
 
PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
@@ -2191,11 +2191,11 @@ static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv 
*drvHandler)
memset(u8ConnectedSSID, 0, ETH_ALEN);
/*BugID_5213*/
/*Freeing flushed join request params on connect timeout*/
-   if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == 
(u32)drvHandler) {
+   if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == 
drvHandler) {
WILC_FREE(gu8FlushedJoinReq);
gu8FlushedJoinReq = NULL;
}
-   if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == 
(u32)drvHandler) {
+   if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == 
drvHandler) {
WILC_FREE(gu8FlushedInfoElemAsoc);
gu8FlushedInfoElemAsoc = NULL;
}
@@ -2616,11 +2616,11 @@ static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv 
*drvHandler, tstrRcvdGnrlAsy
/*BugID_5213*/
/*Freeing flushed join request params on receiving*/
/*MAC_DISCONNECTED while connected*/
-   if (gu8FlushedJoinReq != NULL && 
gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
+   if (gu8FlushedJoinReq != NULL && 
gu8FlushedJoinReqDrvHandler == drvHandler) {
WILC_FREE(gu8FlushedJoinReq);
gu8FlushedJoinReq = NULL;
}
-   if (gu8FlushedInfoElemAsoc != NULL && 
gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
+   if (gu8FlushedInfoElemAsoc != NULL && 
gu8FlushedJoinReqDrvHandler == drvHandler) {
WILC_FREE(gu8FlushedInfoElemAsoc);
gu8FlushedInfoElemAsoc = NULL;
}
@@ -3116,11 +3116,11 @@ static void Handle_Disconnect(tstrWILC_WFIDrv 
*drvHandler)
 
 
/*BugID_5137*/
-   if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == 
(u32)drvHandler) {
+   if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == 
drvHandler) {
WILC_FREE(gu8FlushedJoinReq);
gu8FlushedJoinReq = NULL;
}
-   if (gu8FlushedInfoElemAsoc != NULL && 
gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
+   if (gu8FlushedInfoElemAsoc != NULL && 
gu8FlushedJoinReqDrvHandler == drvHandler) {
WILC_FREE(gu8FlushedInfoElemAsoc);
gu8FlushedInfoElemAsoc = NULL;
}
-- 
1.9.1

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


[PATCH 3/5] staging: wilc1000: clarify the argument type

2015-08-12 Thread Tony Cho
From: Johnny Kim 

This patch replaces the void pointer type in the host interface
functions which process the message from host thread by the real data
type, tstrWILC_WFIDrv because the void pointer type as the arguments
is not clear and concise. In addition, typecasting to the void pointer
type is removed becasue it is not necessary.

Signed-off-by: Johnny Kim 
Signed-off-by: Tony Cho 
---
 drivers/staging/wilc1000/host_interface.c | 78 +++
 drivers/staging/wilc1000/host_interface.h |  4 +-
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index b5afc82..1c2d924 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -601,7 +601,7 @@ extern int linux_wlan_get_num_conn_ifcs(void);
  *  @date
  *  @version   1.0
  */
-static s32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan 
*pstrHostIFSetChan)
+static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan 
*pstrHostIFSetChan)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -681,7 +681,7 @@ static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler 
*pstrHostIfSetDrvHand
  *  @date
  *  @version   1.0
  */
-static s32 Handle_SetOperationMode(void *drvHandler, 
tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
+static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, 
tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -726,7 +726,7 @@ static s32 Handle_SetOperationMode(void *drvHandler, 
tstrHostIfSetOperationMode
  *  @date
  *  @version   1.0
  */
-s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
+s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -778,7 +778,7 @@ s32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, 
u8 idx)
  *  @date
  *  @version   1.0
  */
-s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
+s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -831,7 +831,7 @@ s32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, 
u8 idx)
  *  @date  November 2013
  *  @version   7.0
  */
-static s32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress 
*pstrHostIfSetMacAddress)
+static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, 
tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -877,7 +877,7 @@ static s32 Handle_SetMacAddress(void *drvHandler, 
tstrHostIfSetMacAddress *pstrH
  *  @date  JAN 2013
  *  @version   8.0
  */
-static s32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress 
*pstrHostIfGetMacAddress)
+static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, 
tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
 {
 
s32 s32Error = WILC_SUCCESS;
@@ -914,7 +914,7 @@ static s32 Handle_GetMacAddress(void *drvHandler, 
tstrHostIfGetMacAddress *pstrH
  *  @date
  *  @version   1.0
  */
-static s32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr 
*strHostIFCfgParamAttr)
+static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr 
*strHostIFCfgParamAttr)
 {
s32 s32Error = WILC_SUCCESS;
tstrWID strWIDList[32];
@@ -1238,7 +1238,7 @@ static s32 Handle_wait_msg_q_empty(void)
  *  @date
  *  @version   1.0
  */
-static s32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr 
*pstrHostIFscanAttr)
+static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr 
*pstrHostIFscanAttr)
 {
s32 s32Error = WILC_SUCCESS;
tstrWID strWIDList[5];
@@ -1408,7 +1408,7 @@ static s32 Handle_Scan(void *drvHandler, 
tstrHostIFscanAttr *pstrHostIFscanAttr)
  *  @date
  *  @version   1.0
  */
-static s32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent)
+static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
 {
s32 s32Error = WILC_SUCCESS;
 
@@ -1468,7 +1468,7 @@ static s32 Handle_ScanDone(void *drvHandler, 
tenuScanEvent enuEvent)
  *  @version   1.0
  */
 u8 u8ConnectedSSID[6] = {0};
-static s32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr 
*pstrHostIFconnectAttr)
+static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr 
*pstrHostIFconnectAttr)
 {
tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
s32 s32Error = WILC_SUCCESS;
@@ -2037,7 +2037,7 @@ static s32 Handle_Connect(void *drvHandler, 
tstrHostIFconnectAttr *pstrHostIFcon
  *  @version   8.0
  */
 
-static s32 Handle_FlushConnect(void *drvHandler)
+static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
 {
s32 s32Error = WILC_SUCCESS;
tstrWID strWIDList[5];
@@ -2104,7 +2104,7 @@ static s32 Handle_FlushConnect(void *drvHandler)
  *  @date
  *  @version   1.0
  */
-static s32 Handle_Conne

[PATCH 5/5] staging: wilc1000: use id value as argument

2015-08-12 Thread Tony Cho
From: Johnny Kim 

The driver communicates with the chipset via the address of handlers
to distinguish async data frame. The SendConfigPkt function gets the
pointer address indicating the handlers as the last argument, but this
requires redundant typecasting and does not support the 64 bit machine.

This patch adds the function which assigns ID values instead of pointer
representing the driver handler to the address and then uses the ID
instead of pointer as the last argument of SendConfigPkt. The driver
also gets the handler's address from the ID in the data frame when it
receives them.

Signed-off-by: Johnny Kim 
Signed-off-by: Tony Cho 
---
 drivers/staging/wilc1000/host_interface.c | 249 +++---
 drivers/staging/wilc1000/host_interface.h |   1 +
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   1 -
 3 files changed, 186 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c4e27c7..9ffb39e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -532,7 +532,7 @@ typedef enum {
 /* 
 */
 /*/
 
-
+static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC];
 tstrWILC_WFIDrv *terminated_handle;
 tstrWILC_WFIDrv *gWFiDrvHandle;
 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
@@ -592,6 +592,67 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo 
*ptstrNetworkInfo);
 extern void chip_sleep_manually(u32 u32SleepTime);
 extern int linux_wlan_get_num_conn_ifcs(void);
 
+static int add_handler_in_list(tstrWILC_WFIDrv *handler)
+{
+   int index;
+
+   for (index = 0; index < NUM_CONCURRENT_IFC; index++) {
+   if (!wfidrv_list[index]) {
+   wfidrv_list[index] = handler;
+   break;
+   }
+   }
+
+   if (index >= NUM_CONCURRENT_IFC)
+   return -ENOBUFS;
+
+   return 0;
+}
+
+static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
+{
+   int index;
+
+   for (index = 0; index < NUM_CONCURRENT_IFC; index++) {
+   if (wfidrv_list[index] == handler) {
+   wfidrv_list[index] = NULL;
+   break;
+   }
+   }
+
+if (index >= NUM_CONCURRENT_IFC)
+return -EINVAL;
+
+   return 0;
+}
+
+static u32 get_id_from_handler(tstrWILC_WFIDrv *handler)
+{
+   u32 id;
+
+   if (!handler)
+   return 0;
+
+   for (id = 0; id < NUM_CONCURRENT_IFC; id++) {
+   if (wfidrv_list[id] == handler) {
+   id += 1;
+   break;
+   }
+   }
+
+   if (id > NUM_CONCURRENT_IFC)
+   return 0;
+   else
+   return id;
+}
+
+static tstrWILC_WFIDrv *get_handler_from_id(u32 id)
+{
+   if (id > 0 && id <= NUM_CONCURRENT_IFC)
+   return wfidrv_list[id - 1];
+   else
+   return NULL;
+}
 /**
  *  @brief Handle_SetChannel
  *  @detailsSending config packet to firmware to set channel
@@ -616,7 +677,8 @@ static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, 
tstrHostIFSetChan *pst
 
PRINT_D(HOSTINF_DBG, "Setting channel\n");
/*Sending Cfg*/
-   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
+   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
+get_id_from_handler(pstrWFIDrv));
if (s32Error) {
PRINT_ER("Failed to set channel\n");
WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
@@ -653,7 +715,8 @@ static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler 
*pstrHostIfSetDrvHand
 
/*Sending Cfg*/
 
-   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
+   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
+pstrHostIfSetDrvHandler->u32Address);
 
 
if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
@@ -698,7 +761,8 @@ static s32 Handle_SetOperationMode(tstrWILC_WFIDrv 
*drvHandler, tstrHostIfSetOpe
/*Sending Cfg*/
PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
 
-   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
+   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
+get_id_from_handler(pstrWFIDrv));
 
 
if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
@@ -747,8 +811,8 @@ s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 
*pu8IPAddr, u8 idx)
strWID.ps8WidVal = (u8 *)pu8IPAddr;
strWID.s32ValueSize = IP_ALEN;
 
-   s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
-
+   s32Error = SendC