[PATCH] staging/rtl8188eu/core/rtw_cmd: Fixes semaphore locking

2016-08-09 Thread Lidza Louina
The code did not lock the >terminate_cmdthread_sema before using it.
The code had an up() where a down() should've been. This patch fixes that.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c 
b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 7748523..16f0b19 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -162,7 +162,7 @@ int rtw_cmd_thread(void *context)
    allow_signal(SIGTERM);
 
    pcmdpriv->cmdthd_running = true;
-   up(>terminate_cmdthread_sema);
+   down(>terminate_cmdthread_sema);
 
    RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x 
rtw_cmd_thread \n"));
 
-- 
2.7.4

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


Re: [lustre-devel] [PATCH v2] staging/lustre/lnet: changes value to correct type for assignment

2016-06-23 Thread Lidza Louina

- Original Message -
From: oleg.dro...@intel.com
To: lidza.lou...@oracle.com
Cc: de...@driverdev.osuosl.org, gre...@linuxfoundation.org, 
lustre-de...@lists.lustre.org
Sent: Thursday, June 23, 2016 12:50:01 PM GMT -08:00 US/Canada Pacific
Subject: Re: [lustre-devel] [PATCH v2] staging/lustre/lnet: changes value to 
correct type for assignment


On Jun 23, 2016, at 3:27 PM, Lidza Louina wrote:

> 
> - Original Message -
> From: oleg.dro...@intel.com
> To: lidza.lou...@oracle.com
> Cc: gre...@linuxfoundation.org, lustre-de...@lists.lustre.org, 
> de...@driverdev.osuosl.org, andreas.dil...@intel.com
> Sent: Thursday, June 23, 2016 12:14:28 PM GMT -08:00 US/Canada Pacific
> Subject: Re: [lustre-devel] [PATCH v2] staging/lustre/lnet: changes value to 
> correct type for assignment
> 
> 
> On Jun 23, 2016, at 2:56 PM, Lidza Louina wrote:
> 
>> The code attempted to add an unsigned int to a an unsigned 64-bit
>> integer. This patch makes the code use the correct type of int to
>> suppress a smatch warning.
> 
> I think you might want to update the commit message too, because
> it does not really make much sense now.
> 
> How about
> 
> "The patch changes a value's type so it can be assigned correctly. 
> This problem was caught by smatch."

I think that still does not convey the idea of teh change, also there's no
assignment going on here.
Perhaps
To make the shift safer, have it operate on a 64 bit integer instead of
default 32bit?
There's no bug yet, so this is just for future-proofing.
This potential problem was caught by smatch.

Also you'll need to update the patch subject.


I didn't want to copy you word-for-word:

[PATCH v3] staging/lustre/lnet: changes type for safer shift

The shift was potentially unsafe because of conflicting types. 

This patch changes the regular int (1) to an unsigned long long int because 
rec->rec_lh_cookie is an unsigned 64-bit value. This could be a problem down
the line. 

This was caught by smatch.


> 
>> 
>> Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
>> ---
>> drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c 
>> b/drivers/staging/lustre/lnet/lnet/api-ni.c
>> index 346db89..fc5b763 100644
>> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
>> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
>> @@ -513,7 +513,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, 
>> lnet_libhandle_t *lh)
>>  unsigned int hash;
>> 
>>  lh->lh_cookie = rec->rec_lh_cookie;
>> -rec->rec_lh_cookie += 1 << ibits;
>> +rec->rec_lh_cookie += (1ULL << ibits);
>> 
>>  hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
>> 
>> -- 
>> 1.9.1
>> 
>> 
>> 
>> ___
>> lustre-devel mailing list
>> lustre-de...@lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
> 
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

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


Re: [lustre-devel] [PATCH v2] staging/lustre/lnet: changes value to correct type for assignment

2016-06-23 Thread Lidza Louina

- Original Message -
From: oleg.dro...@intel.com
To: lidza.lou...@oracle.com
Cc: gre...@linuxfoundation.org, lustre-de...@lists.lustre.org, 
de...@driverdev.osuosl.org, andreas.dil...@intel.com
Sent: Thursday, June 23, 2016 12:14:28 PM GMT -08:00 US/Canada Pacific
Subject: Re: [lustre-devel] [PATCH v2] staging/lustre/lnet: changes value to 
correct type for assignment


On Jun 23, 2016, at 2:56 PM, Lidza Louina wrote:

> The code attempted to add an unsigned int to a an unsigned 64-bit
> integer. This patch makes the code use the correct type of int to
> suppress a smatch warning.

I think you might want to update the commit message too, because
it does not really make much sense now.

How about

"The patch changes a value's type so it can be assigned correctly. 
This problem was caught by smatch."

> 
> Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
> ---
> drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c 
> b/drivers/staging/lustre/lnet/lnet/api-ni.c
> index 346db89..fc5b763 100644
> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
> @@ -513,7 +513,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, 
> lnet_libhandle_t *lh)
>   unsigned int hash;
> 
>   lh->lh_cookie = rec->rec_lh_cookie;
> - rec->rec_lh_cookie += 1 << ibits;
> + rec->rec_lh_cookie += (1ULL << ibits);
> 
>   hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
> 
> -- 
> 1.9.1
> 
> 
> 
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

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


[PATCH v2] staging/lustre/lnet: changes value to correct type for assignment

2016-06-23 Thread Lidza Louina
The code attempted to add an unsigned int to a an unsigned 64-bit
integer. This patch makes the code use the correct type of int to
suppress a smatch warning.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c 
b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 346db89..fc5b763 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -513,7 +513,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, 
lnet_libhandle_t *lh)
unsigned int hash;
 
lh->lh_cookie = rec->rec_lh_cookie;
-   rec->rec_lh_cookie += 1 << ibits;
+   rec->rec_lh_cookie += (1ULL << ibits);
 
hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
 
-- 
1.9.1



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


Re: [lustre-devel] [PATCH] staging/lustre/lnet: correctly casts value for arithmetic

2016-06-23 Thread Lidza Louina

- Original Message -
From: oleg.dro...@intel.com
To: lidza.lou...@oracle.com
Cc: de...@driverdev.osuosl.org, andreas.dil...@intel.com, 
lustre-de...@lists.lustre.org, gre...@linuxfoundation.org
Sent: Thursday, June 23, 2016 11:11:06 AM GMT -08:00 US/Canada Pacific
Subject: Re: [lustre-devel] [PATCH] staging/lustre/lnet: correctly casts value 
for arithmetic


On Jun 23, 2016, at 2:07 PM, Lidza Louina wrote:

> The smatch warning was "drivers/staging/lustre/lnet/lnet/api-ni.c:516 
> lnet_res_lh_initialize() warn: should '1 << ibits' be a 64 bit type?"

I think you misinterpreted it, it has nothing to do with the addition.

What it actually means is:
1 is a 32bit integer, you do a right shift by some variable number
of bits. So please check if there's risk to overflow the 32 bits
unexpectedly.
The way to fix this warning is to replace 1 with 1ULL (unsigned long long)
and that is fine to do as a way of future proofing this stuff even if it's
not yet broken yet, I guess.

Ahh, okay, I see what you're saying and I see what I did wrong.

I'm going to update the patch to:

-rec->rec_lh_cookie += 1 << ibits;
+rec->rec_lh_cookie += (1ULL << ibits);

Lidza

> 
>> 
>>  hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
>> 
>> -- 
>> 1.9.1
>> 
>> 
>> 
>> ___
>> lustre-devel mailing list
>> lustre-de...@lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
> 

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


Re: [lustre-devel] [PATCH] staging/lustre/lnet: correctly casts value for arithmetic

2016-06-23 Thread Lidza Louina

- Original Message -
From: oleg.dro...@intel.com
To: lidza.lou...@oracle.com
Cc: gre...@linuxfoundation.org, lustre-de...@lists.lustre.org, 
de...@driverdev.osuosl.org, andreas.dil...@intel.com
Sent: Thursday, June 23, 2016 10:52:24 AM GMT -08:00 US/Canada Pacific
Subject: Re: [lustre-devel] [PATCH] staging/lustre/lnet: correctly casts value 
for arithmetic

NAK.

On Jun 23, 2016, at 1:24 PM, Lidza Louina wrote:

> The code attempted to add an unsigned int to a an unsigned 64-bit
> integer. This patch casts the unsigned regular int to suppress
> smatch warnings.
> 
> Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
> ---
> drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c 
> b/drivers/staging/lustre/lnet/lnet/api-ni.c
> index 346db89..5ecb2c7 100644
> --- a/drivers/staging/lustre/lnet/lnet/api-ni.c
> +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
> @@ -513,7 +513,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, 
> lnet_libhandle_t *lh)
>   unsigned int hash;
> 
>   lh->lh_cookie = rec->rec_lh_cookie;
> - rec->rec_lh_cookie += 1 << ibits;
> + rec->rec_lh_cookie += (__u64)(1 << ibits);

This does not do what you think it does?

You want to convert 1 into 1ULL so that the value you are shifting
if already wide enough bit-wise?

But in fact ibits is: LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS
LNET_COOKIE_TYPE_BITS is 2 and LNET_CPT_BITS is at max 8,
so 10 in total, this should fit into a regular 32 bit integer with zero
problems.
So we should be fine I imagine either way.

And adding 32bit int to 64bit int should always be ok anyway, right?
Is it that the addition of signed to unsigned is problematic?

Or what was the smatch warning?

The smatch warning had to do with the type of value rec->rec_1h_cookie 
was expecting. It's expecting it to be an unsigned 64 bit integer (I 
realize I didn't make that clear in my log). The math is correct, it's 
just the assignment that should be cast. 

The smatch warning was "drivers/staging/lustre/lnet/lnet/api-ni.c:516 
lnet_res_lh_initialize() warn: should '1 << ibits' be a 64 bit type?"

> 
>   hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
> 
> -- 
> 1.9.1
> 
> 
> 
> ___
> lustre-devel mailing list
> lustre-de...@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

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


[PATCH] staging/lustre/lnet: correctly casts value for arithmetic

2016-06-23 Thread Lidza Louina
The code attempted to add an unsigned int to a an unsigned 64-bit
integer. This patch casts the unsigned regular int to suppress
smatch warnings.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c 
b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 346db89..5ecb2c7 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -513,7 +513,7 @@ lnet_res_lh_initialize(struct lnet_res_container *rec, 
lnet_libhandle_t *lh)
unsigned int hash;
 
lh->lh_cookie = rec->rec_lh_cookie;
-   rec->rec_lh_cookie += 1 << ibits;
+   rec->rec_lh_cookie += (__u64)(1 << ibits);
 
hash = (lh->lh_cookie >> ibits) & LNET_LH_HASH_MASK;
 
-- 
1.9.1



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


Re: [PATCH] staging/wilc1000: fixes kzalloc call

2016-05-27 Thread Lidza Louina



On 05/27/2016 02:07 PM, Joe Perches wrote:

On Fri, 2016-05-27 at 13:51 -0400, Lidza Louina wrote:

The wl pointer was initialized as a pointer to a struct wilc and
assigned to a piece of memory the size of the pointer. It should be the
size of struct wilc.

This isn't necessary.

The code in question is:

struct wilc *wl;

sema_init(_exit_sync, 0);

wl = kzalloc(sizeof(*wl), GFP_KERNEL);
if (!wl)
return -ENOMEM;

*wilc = wl;

so this isn't any real change and the generally desired form for
allocations from CodingStyle (Chapter 14: Allocating Memory) is:

The preferred form for passing a size of a struct is the following: p = 
kmalloc(sizeof(*p), ...);


Ahh, okay. I see that in the documentation. Thanks.

Lidza




diff --git a/drivers/staging/wilc1000/linux_wlan.c

[]

@@ -1260,7 +1260,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device 
*dev, int io_type,
  
  	sema_init(_exit_sync, 0);
  
-	wl = kzalloc(sizeof(*wl), GFP_KERNEL);

+   wl = kzalloc(sizeof(struct wilc), GFP_KERNEL);
if (!wl)
return -ENOMEM;


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


[PATCH] staging/wilc1000: fixes kzalloc call

2016-05-27 Thread Lidza Louina
The wl pointer was initialized as a pointer to a struct wilc and
assigned to a piece of memory the size of the pointer. It should be the
size of struct wilc.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/wilc1000/linux_wlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 4f93c11..d1853f6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1260,7 +1260,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device 
*dev, int io_type,
 
sema_init(_exit_sync, 0);
 
-   wl = kzalloc(sizeof(*wl), GFP_KERNEL);
+   wl = kzalloc(sizeof(struct wilc), GFP_KERNEL);
if (!wl)
return -ENOMEM;
 
-- 
1.9.1

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


Re: [lustre-devel] [PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-17 Thread Lidza Louina



On 05/17/2016 02:53 AM, Dan Carpenter wrote:

When I read the code, I just assumed desc was a pointer and it should
have been:

if (!desc)
return NULL;

For me, "if (rc) " is way more readable than "if (rc != 0) ".  So
readability could go either way depending on what you're used to, I
suppose.

It should definitely == 0 and != 0 if you are talking about the actual
number zero instead of success/fail like we are here.  Also it helps to
use == 0 with strcmp() and friends (although half of the kernel does not
know that trick yet).

The other thing which I have noticed recently is that a lot of
subsystems use a mix of "if (rc) " and "if (rc < 0) ".  It's annoying
for Smatch because say a function only returns zero but the some of the
callers check for < 0 and some check for != 0.  We can't know for sure
that they are equivalent.

regards,
dan carpenter


Hey Dan,

if (rc < 0) and if (rc) pretty much translates to the same thing. It'll 
only return a negative error value if there are problems and 0 if it 
succeeds. I feel like the first way is more explicit, since negative 
numbers are usually used for errors. I've sent a 3rd version of the 
patch with (rc < 0).


And I'm not sure about the way other subsystems use return values. Here 
it should only either be less than or equal to 0 so it makes sense to  
me in this circumstance.


I ran smatch on my patched file `../smatch/smatch_scripts/kchecker 
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c` and it didn't find any 
issues with it.


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


[PATCH v3] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-16 Thread Lidza Louina
The lustre_msg_buf method could return NULL. Subsequent code didn't
check if it's null before using it. This patch adds two checks.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/lustre/lustre/ptlrpc/sec.c   | 3 +++
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 8 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 187fd1d..657b41f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2196,6 +2196,9 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int 
offset)
 
pud = lustre_msg_buf(msg, offset, 0);
 
+   if (!pud)
+   return -EINVAL;
+
pud->pud_uid = from_kuid(_user_ns, current_uid());
pud->pud_gid = from_kgid(_user_ns, current_gid());
pud->pud_fsuid = from_kuid(_user_ns, current_fsuid());
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 37c9f4c..ec8edbf 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -574,8 +574,12 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
lustre_init_msg_v2(req->rq_reqbuf, PLAIN_PACK_SEGMENTS, buflens, NULL);
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0);
 
-   if (req->rq_pack_udesc)
-   sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF);
+   if (req->rq_pack_udesc) {
+   int rc = sptlrpc_pack_user_desc(req->rq_reqbuf,
+ PLAIN_PACK_USER_OFF);
+   if (rc < 0)
+   return rc;
+   }
 
return 0;
 }
-- 
1.9.1

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


Re: [lustre-devel] [PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-16 Thread Lidza Louina



On 05/16/2016 02:35 PM, Dilger, Andreas wrote:

On 2016/05/16, 12:16, "James Simmons" <jsimm...@infradead.org> wrote:


This looks wrong - You return -EINVAL from sptlrpc_pack_user_desc, but then
the caller checks "!desc".  Desc will not be null, since you've returned
-EINVAL.

Actually 'if (!desc)' is equal to 'if (desc != 0). Yes it can be confusing.

Very confusing indeed. :-)  "if (!desc)" actually means "if (desc == 0)"...

That is the main reason why I don't like those shortcuts since they require
an extra mental step by the reader to determine the logic.  Having the
explicit comparisons like "if (desc == 0)" or "if (desc != 0)" makes the
code more clear, and doesn't make the compiled binary any slower.


I recommend 'if (desc < 0)' instead to make it clearer what is being
tested for.

That would actually fix the problem.  Patrick is correct that the current
patch is broken, since it is either returning zero "if (!desc)" is true,
or zero at the end of the function.  The error is never returned.

Lidza,
to improve this patch further, the function should really use "rc" to hold
the error return instead of "desc", since "rc" is typically used for error
returns, and "desc" is normally a pointer to a bulk descriptor in this code.

Also, as Oleg previously mentioned, please declare "int rc;" inside the
"if (req->rq_pack_udesc)" block instead of at the top of the function,
since it isn't used anywhere else.

Cheers, Andreas


Definitely, will do.

I'll  change desc to rc and update the if statement and send another 
patch now.


Lidza



- Patrick

On 05/16/2016 09:17 AM, Lidza Louina wrote:

The lustre_msg_buf method could return NULL. Subsequent code didn't
check if it's null before using it. This patch adds two checks.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
   drivers/staging/lustre/lustre/ptlrpc/sec.c   | 2 ++
   drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 9 +++--
   2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 187fd1d..e6fedc3 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2195,6 +2195,8 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int
offset)
struct ptlrpc_user_desc *pud;
   
   	pud = lustre_msg_buf(msg, offset, 0);

+   if (!pud)
+   return -EINVAL;
   
pud->pud_uid = from_kuid(_user_ns, current_uid());

pud->pud_gid = from_kgid(_user_ns, current_gid());
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 37c9f4c..51741c8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -542,6 +542,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
   {
__u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
int alloc_len;
+   int desc;
   
buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header);

buflens[PLAIN_PACK_MSG_OFF] = msgsize;
@@ -574,8 +575,12 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
lustre_init_msg_v2(req->rq_reqbuf, PLAIN_PACK_SEGMENTS, buflens, NULL);
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0);
   -if (req->rq_pack_udesc)
-   sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF);
+   if (req->rq_pack_udesc) {
+   desc = sptlrpc_pack_user_desc(req->rq_reqbuf,
+ PLAIN_PACK_USER_OFF);
+   if (!desc)
+   return desc;
+   }
   
   	return 0;

   }

___
lustre-devel mailing list
lustre-de...@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org



Cheers, Andreas


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


[PATCH v2] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-16 Thread Lidza Louina
The lustre_msg_buf method could return NULL. Subsequent code didn't
check if it's null before using it. This patch adds two checks.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>
---
 drivers/staging/lustre/lustre/ptlrpc/sec.c   | 2 ++
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 9 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 187fd1d..e6fedc3 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2195,6 +2195,8 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int 
offset)
struct ptlrpc_user_desc *pud;
 
pud = lustre_msg_buf(msg, offset, 0);
+   if (!pud)
+   return -EINVAL;
 
pud->pud_uid = from_kuid(_user_ns, current_uid());
pud->pud_gid = from_kgid(_user_ns, current_gid());
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 37c9f4c..51741c8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -542,6 +542,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
 {
__u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
int alloc_len;
+   int desc;
 
buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header);
buflens[PLAIN_PACK_MSG_OFF] = msgsize;
@@ -574,8 +575,12 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
lustre_init_msg_v2(req->rq_reqbuf, PLAIN_PACK_SEGMENTS, buflens, NULL);
req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0);
 
-   if (req->rq_pack_udesc)
-   sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF);
+   if (req->rq_pack_udesc) {
+   desc = sptlrpc_pack_user_desc(req->rq_reqbuf,
+ PLAIN_PACK_USER_OFF);
+   if (!desc)
+   return desc;
+   }
 
return 0;
 }
-- 
1.9.1

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


[PATCH] staging/lustre/ptlrpc: Removes potential null dereference

2016-05-12 Thread Lidza Louina
The lustre_msg_buf method could return NULL. Subsequent code didn't
check if it's null before using it. This patch adds two checks.

Signed-off-by: Lidza Louina <lidza.lou...@oracle.com>

diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 187fd1d..e6fedc3 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2195,6 +2195,8 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int 
offset)
    struct ptlrpc_user_desc *pud;
 
    pud = lustre_msg_buf(msg, offset, 0);
+   if (!pud)
+   return -EINVAL;
 
    pud->pud_uid = from_kuid(_user_ns, current_uid());
    pud->pud_gid = from_kgid(_user_ns, current_gid());
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 37c9f4c..7736aa9 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -542,6 +542,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
 {
    __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
    int alloc_len;
+   int desc;
 
    buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header);
    buflens[PLAIN_PACK_MSG_OFF] = msgsize;
@@ -575,7 +576,10 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec,
    req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0);
 
    if (req->rq_pack_udesc)
-   sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF);
+   desc = sptlrpc_pack_user_desc(req->rq_reqbuf, 
PLAIN_PACK_USER_OFF);
+   if (!desc){
+   return desc;
+   }
 
    return 0;
 }
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/8] staging: dgap: Fix trailing whitespace in digi.h

2014-01-17 Thread Lidza Louina
Acked-by: Lidza Louina lidza.lou...@gmail.com

On Tue, Jan 14, 2014 at 10:40 AM, Masanari Iida standby2...@gmail.com wrote:
 This patch fixed trailing whitespace error found by
 checkpatch.pl in dgap/digi.h

 Signed-off-by: Masanari Iida standby2...@gmail.com
 ---
  drivers/staging/dgap/digi.h | 24 
  1 file changed, 12 insertions(+), 12 deletions(-)

 diff --git a/drivers/staging/dgap/digi.h b/drivers/staging/dgap/digi.h
 index bcea4f7..fe87903 100644
 --- a/drivers/staging/dgap/digi.h
 +++ b/drivers/staging/dgap/digi.h
 @@ -43,7 +43,7 @@
  #defineTIOCMODG('d'8) | 250  /* get modem ctrl 
 state */
  #defineTIOCMODS('d'8) | 251  /* set modem ctrl 
 state */

 -#ifndef TIOCM_LE
 +#ifndef TIOCM_LE
  #defineTIOCM_LE0x01/* line enable
   */
  #defineTIOCM_DTR   0x02/* data terminal 
 ready  */
  #defineTIOCM_RTS   0x04/* request to send
   */
 @@ -122,7 +122,7 @@ struct  digiflow_t {
  #endif

  /
 - * Values for digi_flags
 + * Values for digi_flags
   /
  #define DIGI_IXON  0x0001  /* Handle IXON in the FEP   */
  #define DIGI_FAST  0x0002  /* Fast baud rates  */
 @@ -193,8 +193,8 @@ struct rw_t {
  #define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */

  /* Non-Zero Result codes. */
 -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config 
 installed */
 -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
 +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config 
 installed */
 +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
  #define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
  #define RESULT_TOOSML  4 /* Too small an area to shrink.  */
  #define RESULT_NOCHAN  5 /* Channel structure for the board was not found */
 @@ -205,7 +205,7 @@ struct shrink_buf_struct {
 unsigned long   shrink_buf_bseg;/* Amount of board memory */
 unsigned long   shrink_buf_hseg;/* '186 Beginning of 
 Dual-Port */

 -   unsigned long   shrink_buf_lseg;/* '186 Beginning of freed 
 memory   */
 +   unsigned long   shrink_buf_lseg;/* '186 Beginning of freed 
 memory   */
 unsigned long   shrink_buf_mseg;/* Linear address from start 
 of
dual-port were freed memory
begins, host viewpoint. */
 @@ -220,18 +220,18 @@ struct shrink_buf_struct {

 unsigned char   shrink_buf_result;  /* Reason for call failing
Zero is Good return */
 -   unsigned char   shrink_buf_init;/* Non-Zero if it caused an
 +   unsigned char   shrink_buf_init;/* Non-Zero if it caused an
xxinit call. */

 unsigned char   shrink_buf_anports; /* Number of async ports  */
 unsigned char   shrink_buf_snports; /* Number of sync  ports */
 unsigned char   shrink_buf_type;/* Board type 1 = PC/Xi,
   2 = PC/Xm,
 - 3 = PC/Xe
 - 4 = MC/Xi
 + 3 = PC/Xe
 + 4 = MC/Xi
   5 = COMX/i */
 unsigned char   shrink_buf_card;/* Card number */
 -
 +
  };

  /
 @@ -244,7 +244,7 @@ struct digi_dinfo {
  };

  #defineDIGI_GETDD  ('d'8) | 248  /* get driver info
   */
 -
 +
  /
   * Structure used with ioctl commands for per-board information
   *
 @@ -264,7 +264,7 @@ struct digi_info {
  };

  #defineDIGI_GETBD  ('d'8) | 249  /* get board info 
  */
 -
 +
  struct digi_stat {
 unsigned intinfo_chan;  /* Channel number (0 based)  
 */
 unsigned intinfo_brd;   /* Board number (0 based)  */
 @@ -299,7 +299,7 @@ struct digi_ch {
  };

  /*
 -* This structure is used with the DIGI_FEPCMD ioctl to
 +* This structure is used with the DIGI_FEPCMD ioctl to
  * tell the driver which port to send the command for.
  */
  struct digi_cmd

Re: [PATCH 1/2] staging: dgap: removes KERNEL_VERSION conditionals

2014-01-17 Thread Lidza Louina
I'll try this patchset again after Masanari Iida's patches are accepted after
the merge window.

Lidza

On Fri, Jan 17, 2014 at 11:01 AM, Lidza Louina lidza.lou...@gmail.com wrote:
 This patch removes the KERNEL_VERSION conditionals.
 The driver is built for this kernel version, so the
 conditionals are not needed.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgap/dgap_driver.h |4 
  drivers/staging/dgap/dgap_fep5.c   |   36 
 +---
  drivers/staging/dgap/dgap_tty.c|   25 +
  3 files changed, 2 insertions(+), 63 deletions(-)

 diff --git a/drivers/staging/dgap/dgap_driver.h 
 b/drivers/staging/dgap/dgap_driver.h
 index 2f7a55a7..8c1b46a 100644
 --- a/drivers/staging/dgap/dgap_driver.h
 +++ b/drivers/staging/dgap/dgap_driver.h
 @@ -396,10 +396,6 @@ struct board_t
 u32 dgap_Serial_Major;
 u32 dgap_TransparentPrint_Major;

 -#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
 -   u32 TtyRefCnt;
 -#endif
 -
 struct bs_t *bd_bs; /* Base structure pointer 
   */

 char*flipbuf;   /* Our flip buffer, alloced if board 
 is found */
 diff --git a/drivers/staging/dgap/dgap_fep5.c 
 b/drivers/staging/dgap/dgap_fep5.c
 index f75831a..0556f48 100644
 --- a/drivers/staging/dgap/dgap_fep5.c
 +++ b/drivers/staging/dgap/dgap_fep5.c
 @@ -30,10 +30,7 @@
  #include linux/tty.h
  #include linux/tty_flip.h/* For tty_schedule_flip */
  #include linux/slab.h
 -
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
  #include linux/sched.h
 -#endif

  #include dgap_driver.h
  #include dgap_pci.h
 @@ -1805,19 +1802,11 @@ static int dgap_event(struct board_t *bd)
 if (ch-ch_tun.un_flags  UN_ISOPEN) {
 if ((ch-ch_tun.un_tty-flags 
(1  TTY_DO_WRITE_WAKEUP)) 
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,31)
 
 ch-ch_tun.un_tty-ldisc-ops-write_wakeup)
 -#else
 -   
 ch-ch_tun.un_tty-ldisc.ops-write_wakeup)
 -#endif
 {
 DGAP_UNLOCK(ch-ch_lock, 
 lock_flags2);
 DGAP_UNLOCK(bd-bd_lock, 
 lock_flags);
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,31)
 
 (ch-ch_tun.un_tty-ldisc-ops-write_wakeup)(ch-ch_tun.un_tty);
 -#else
 -   
 (ch-ch_tun.un_tty-ldisc.ops-write_wakeup)(ch-ch_tun.un_tty);
 -#endif
 DGAP_LOCK(bd-bd_lock, 
 lock_flags);
 DGAP_LOCK(ch-ch_lock, 
 lock_flags2);
 }
 @@ -1833,19 +1822,11 @@ static int dgap_event(struct board_t *bd)
 if (ch-ch_pun.un_flags  UN_ISOPEN) {
 if ((ch-ch_pun.un_tty-flags 
(1  TTY_DO_WRITE_WAKEUP)) 
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,31)
 
 ch-ch_pun.un_tty-ldisc-ops-write_wakeup)
 -#else
 -   
 ch-ch_pun.un_tty-ldisc.ops-write_wakeup)
 -#endif
 {
 DGAP_UNLOCK(ch-ch_lock, 
 lock_flags2);
 DGAP_UNLOCK(bd-bd_lock, 
 lock_flags);
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,31)
 
 (ch-ch_pun.un_tty-ldisc-ops-write_wakeup)(ch-ch_pun.un_tty);
 -#else
 -   
 (ch-ch_pun.un_tty-ldisc.ops-write_wakeup)(ch-ch_pun.un_tty);
 -#endif
 DGAP_LOCK(bd-bd_lock, 
 lock_flags);
 DGAP_LOCK(ch-ch_lock, 
 lock_flags2);
 }
 @@ -1871,19 +1852,12 @@ static int dgap_event(struct board_t *bd)
 if (ch-ch_tun.un_flags  UN_ISOPEN) {
 if ((ch-ch_tun.un_tty-flags 
(1  TTY_DO_WRITE_WAKEUP)) 
 -#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,31)
 
 ch-ch_tun.un_tty-ldisc-ops-write_wakeup)
 -#else
 -   
 ch-ch_tun.un_tty-ldisc.ops-write_wakeup)
 -#endif
 {
 DGAP_UNLOCK(ch-ch_lock, 
 lock_flags2);
 DGAP_UNLOCK(bd-bd_lock, 
 lock_flags);
 -#if LINUX_VERSION_CODE

[PATCH] staging: dgap: uses kzalloc for allocating memory

2013-12-19 Thread Lidza Louina
Originally, this driver created it's own allocating
function. This patch removes that function and calls
kzalloc directly.

This patch affects:
 - driver.c
 - driver.h
 - fep5.c
 - tty.c

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c |   18 ++
 drivers/staging/dgap/dgap_driver.h |1 -
 drivers/staging/dgap/dgap_fep5.c   |6 +++---
 drivers/staging/dgap/dgap_tty.c|6 +++---
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index 4c1515e..089d017 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -506,7 +506,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgap_Board[dgap_NumBoards] =
-   (struct board_t *) dgap_driver_kzmalloc(sizeof(struct board_t), 
GFP_KERNEL);
+   (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return(-ENOMEM);
@@ -514,7 +514,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   (char *) dgap_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL);
+   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if(!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
@@ -925,20 +925,6 @@ static void dgap_init_globals(void)
 
 
 /*
- * dgap_driver_kzmalloc()
- *
- * Malloc and clear memory,
- */
-void *dgap_driver_kzmalloc(size_t size, int priority)
-{
-   void *p = kmalloc(size, priority);
-   if(p)
-   memset(p, 0, size);
-   return(p);
-}
-
-
-/*
  * dgap_mbuf()
  *
  * Used to print to the message buffer during board init.
diff --git a/drivers/staging/dgap/dgap_driver.h 
b/drivers/staging/dgap/dgap_driver.h
index 7d631e8..2f7a55a7 100644
--- a/drivers/staging/dgap/dgap_driver.h
+++ b/drivers/staging/dgap/dgap_driver.h
@@ -578,7 +578,6 @@ struct channel_t {
  */
 
 extern int dgap_ms_sleep(ulong ms);
-extern void*dgap_driver_kzmalloc(size_t size, int priority);
 extern char*dgap_ioctl_name(int cmd);
 extern voiddgap_do_bios_load(struct board_t *brd, uchar __user 
*ubios, int len);
 extern voiddgap_do_fep_load(struct board_t *brd, uchar __user 
*ufep, int len);
diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c
index 794cf9d..15f9a85 100644
--- a/drivers/staging/dgap/dgap_fep5.c
+++ b/drivers/staging/dgap/dgap_fep5.c
@@ -75,7 +75,7 @@ void dgap_do_config_load(uchar __user *uaddr, int len)
char buf[U2BSIZE];
int n;
 
-   to_addr = dgap_config_buf = dgap_driver_kzmalloc(len + 1, GFP_ATOMIC);
+   to_addr = dgap_config_buf = kzalloc(len + 1, GFP_ATOMIC);
if (!dgap_config_buf) {
DPR_INIT((dgap_do_config_load - unable to allocate memory for 
file\n));
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
@@ -130,8 +130,8 @@ int dgap_after_config_loaded(void)
/*
 * allocate flip buffer for board.
 */
-   dgap_Board[i]-flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, 
GFP_ATOMIC);
-   dgap_Board[i]-flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, 
GFP_ATOMIC);
+   dgap_Board[i]-flipbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC);
+   dgap_Board[i]-flipflagbuf = kzalloc(MYFLIPLEN, GFP_ATOMIC);
}
 
return rc;
diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index c64296f..39fb4df 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -233,7 +233,7 @@ int dgap_tty_register(struct board_t *brd)
brd-SerialDriver-flags = (TTY_DRIVER_REAL_RAW | 
TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
 
/* The kernel wants space to store pointers to tty_structs */
-   brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-SerialDriver-ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct 
*), GFP_KERNEL);
if (!brd-SerialDriver-ttys)
return(-ENOMEM);
 
@@ -266,7 +266,7 @@ int dgap_tty_register(struct board_t *brd)
brd-PrintDriver-flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV 
| TTY_DRIVER_HARDWARE_BREAK);
 
/* The kernel wants space to store pointers to tty_structs */
-   brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-PrintDriver-ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct 
*), GFP_KERNEL);
if (!brd-PrintDriver-ttys

[PATCH] staging: dgnc: changes arguments in sizeof

2013-10-04 Thread Lidza Louina
The arguments that were passed into sizeof were
generic. This patch changes this by putting
the actual item that we need a size of instead.

For example:
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(*brd), GFP_KERNEL);

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c |  4 ++--
 drivers/staging/dgnc/dgnc_mgmt.c   |  2 +-
 drivers/staging/dgnc/dgnc_tty.c| 24 
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index c398193..4271fa3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -487,7 +487,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return -ENOMEM;
@@ -495,7 +495,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index bb39f5d..354458c 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -209,7 +209,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
uint board = 0;
uint channel = 0;
 
-   if (copy_from_user(ni, uarg, sizeof(struct ni_info))) {
+   if (copy_from_user(ni, uarg, sizeof(ni))) {
return -EFAULT;
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1350d62..c6fee11 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -200,8 +200,8 @@ int dgnc_tty_register(struct dgnc_board *brd)
 
DPR_INIT((tty_register start\n));
 
-   memset(brd-SerialDriver, 0, sizeof(struct tty_driver));
-   memset(brd-PrintDriver, 0, sizeof(struct tty_driver));
+   memset(brd-SerialDriver, 0, sizeof(brd-SerialDriver));
+   memset(brd-PrintDriver, 0, sizeof(brd-PrintDriver));
 
brd-SerialDriver.magic = TTY_DRIVER_MAGIC;
 
@@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-SerialDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
kref_init(brd-SerialDriver.kref);
-   brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.termios), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
@@ -271,11 +271,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * tty_struct's and termios's.  Must be separated from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-PrintDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.ttys), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return -ENOMEM;
kref_init(brd-PrintDriver.kref);
-   brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.termios), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return -ENOMEM;
 
@@ -341,7 +341,7 @@ int dgnc_tty_init(struct dgnc_board *brd)
 * Okay to malloc with GFP_KERNEL, we are not at
 * interrupt context, and there are no locks held.
 */
-   brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
+   brd-channels[i] = kzalloc(sizeof(*brd-channels[i]), 
GFP_KERNEL);
if (!brd-channels[i]) {
DPR_CORE((%s:%d Unable to allocate memory for 
channel struct\n,
__FILE__, __LINE__));
@@ -2664,7 +2664,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, 
struct digi_t __user *new_i
if (!bd || bd-magic

Re: [PATCH v4 1/2] staging: dgap: tty.c: adds error handing in tty driver allocations

2013-10-03 Thread Lidza Louina
On Thu, Oct 3, 2013 at 1:23 AM, Greg KH gre...@linuxfoundation.org wrote:
 On Tue, Oct 01, 2013 at 12:54:20PM -0400, Lidza Louina wrote:
 + return 0;
 +
 +err_unregister_serial:
 +tty_unregister_driver(brd-SerialDriver);
 +err_free_print_ttys:
 +kfree(brd-PrintDriver-ttys);
 +err_put_tty_print:
 +put_tty_driver(brd-PrintDriver);
 +err_free_serial_ttys:
 +kfree(brd-SerialDriver-ttys);
 +err_put_tty_serial:
 +put_tty_driver(brd-SerialDriver);
   return (rc);

 You forgot to run this patch through checkpatch.pl :(

 This series has been a major pain, why not set it aside for a few days
 and do something easier before picking it up and trying it again?

 thanks,

 greg I need a vacation too k-h

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


[PATCH v3 2/2] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-10-01 Thread Lidza Louina
This patch removes this smatch warning:
unsigned '--un-un_open_count' is never less than zero

The code decremented the un_open_count variable
and tested to see if it was less than zero. Because
un_open_count is unsigned and can't be below zero,
this test didn't work.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 501071f..57a2354 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -1456,12 +1456,13 @@ static void dgap_tty_close(struct tty_struct *tty, 
struct file *file)
un-un_open_count = 1;
}  
 
-   if (--un-un_open_count  0) {
+   if (--un-un_open_count == 0) {
APR((bad serial port open count of %d\n, un-un_open_count));
-   un-un_open_count = 0;
+   un-un_open_count = 1;
}
 
ch-ch_open_count--;
+   un-un_open_count--;
 
if (ch-ch_open_count  un-un_open_count) {
DPR_CLOSE((dgap_tty_close: not last close ch: %d un:%d\n,
-- 
1.8.1.2

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


[PATCH v3 1/2] staging: dgap: tty.c: adds error handing in tty driver allocations

2013-10-01 Thread Lidza Louina
This patch adds error handling to the
tty_driver allocations in dgap_tty_register.

Now the code handles the possibility of an
alloc_tty_driver, a tty_register_driver, and
a brd-SerialDriver-ttys or brd-PrintDriver-ttys
allocation failure.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 37 -
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 924e2bf..501071f 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -220,6 +220,8 @@ int dgap_tty_register(struct board_t *brd)
DPR_INIT((tty_register start));
 
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
+   if (!brd-SerialDriver)
+   return -ENOMEM;
 
snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, brd-boardnum);
brd-SerialDriver-name = brd-SerialName;
@@ -234,9 +236,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-SerialDriver-ttys)
-   return(-ENOMEM);
-
+   if (!brd-SerialDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_serial;
+   }
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-SerialDriver-refcount = brd-TtyRefCnt;
 #endif
@@ -253,7 +256,10 @@ int dgap_tty_register(struct board_t *brd)
 * we are when we get into the dgap_tty_open() routine.
 */
brd-PrintDriver = alloc_tty_driver(MAXPORTS);
-
+   if (!brd-PrintDriver) {
+   rc = -ENOMEM;
+   goto err_free_serial_ttys;
+   }
snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, brd-boardnum);
brd-PrintDriver-name = brd-PrintName;
brd-PrintDriver-name_base = 0;
@@ -267,8 +273,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-PrintDriver-ttys)
-   return(-ENOMEM);
+   if (!brd-PrintDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_print;
+   }
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-PrintDriver-refcount = brd-TtyRefCnt;
@@ -285,7 +293,8 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-SerialDriver);
if (rc  0) {
APR((Can't register tty device (%d)\n, rc));
-   return(rc);
+   goto err_put_tty_serial;
+   goto err_free_print_ttys;
}
brd-dgap_Major_Serial_Registered = TRUE;
dgap_BoardsByMajor[brd-SerialDriver-major] = brd;
@@ -297,7 +306,8 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-PrintDriver);
if (rc  0) {
APR((Can't register Transparent Print device (%d)\n, 
rc));
-   return(rc);
+   goto err_put_tty_print;
+   goto err_unregister_serial;
}
brd-dgap_Major_TransparentPrint_Registered = TRUE;
dgap_BoardsByMajor[brd-PrintDriver-major] = brd;
@@ -306,7 +316,16 @@ int dgap_tty_register(struct board_t *brd)
 
DPR_INIT((DGAP REGISTER TTY: MAJORS: %d %d\n, 
brd-SerialDriver-major,
brd-PrintDriver-major));
-
+err_unregister_serial:
+tty_unregister_driver(brd-SerialDriver);
+err_free_print_ttys:
+kfree(brd-PrintDriver-ttys);
+err_put_tty_print:
+put_tty_driver(brd-PrintDriver);
+err_free_serial_ttys:
+kfree(brd-SerialDriver-ttys);
+err_put_tty_serial:
+put_tty_driver(brd-SerialDriver);
return (rc);
 }
 
-- 
1.8.1.2

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


[PATCH v4 2/2] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-10-01 Thread Lidza Louina
This patch removes this smatch warning:
unsigned '--un-un_open_count' is never less than zero

The code decremented the un_open_count variable
and tested to see if it was less than zero. Because
un_open_count is unsigned and can't be below zero,
this test didn't work.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 015bccf..58cdcf9 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -1458,12 +1458,14 @@ static void dgap_tty_close(struct tty_struct *tty, 
struct file *file)
un-un_open_count = 1;
}  
 
-   if (--un-un_open_count  0) {
+   if (--un-un_open_count == 0) {
APR((bad serial port open count of %d\n, un-un_open_count));
-   un-un_open_count = 0;
+   un-un_open_count = 1;
}
 
ch-ch_open_count--;
+   un-un_open_count--;
+
 
if (ch-ch_open_count  un-un_open_count) {
DPR_CLOSE((dgap_tty_close: not last close ch: %d un:%d\n,
-- 
1.8.1.2

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


[PATCH v4 1/2] staging: dgap: tty.c: adds error handing in tty driver allocations

2013-10-01 Thread Lidza Louina
This patch adds error handling to the
tty_driver allocations in dgap_tty_register.

Now the code handles the possibility of an
alloc_tty_driver, a tty_register_driver, and
a brd-SerialDriver-ttys or brd-PrintDriver-ttys
allocation failure.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 39 ++-
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 924e2bf..015bccf 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -220,6 +220,8 @@ int dgap_tty_register(struct board_t *brd)
DPR_INIT((tty_register start));
 
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
+   if (!brd-SerialDriver)
+   return -ENOMEM;
 
snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, brd-boardnum);
brd-SerialDriver-name = brd-SerialName;
@@ -234,9 +236,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-SerialDriver-ttys)
-   return(-ENOMEM);
-
+   if (!brd-SerialDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_serial;
+   }
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-SerialDriver-refcount = brd-TtyRefCnt;
 #endif
@@ -253,7 +256,10 @@ int dgap_tty_register(struct board_t *brd)
 * we are when we get into the dgap_tty_open() routine.
 */
brd-PrintDriver = alloc_tty_driver(MAXPORTS);
-
+   if (!brd-PrintDriver) {
+   rc = -ENOMEM;
+   goto err_free_serial_ttys;
+   }
snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, brd-boardnum);
brd-PrintDriver-name = brd-PrintName;
brd-PrintDriver-name_base = 0;
@@ -267,8 +273,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-PrintDriver-ttys)
-   return(-ENOMEM);
+   if (!brd-PrintDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_print;
+   }
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-PrintDriver-refcount = brd-TtyRefCnt;
@@ -285,7 +293,8 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-SerialDriver);
if (rc  0) {
APR((Can't register tty device (%d)\n, rc));
-   return(rc);
+   goto err_put_tty_serial;
+   goto err_free_print_ttys;
}
brd-dgap_Major_Serial_Registered = TRUE;
dgap_BoardsByMajor[brd-SerialDriver-major] = brd;
@@ -297,7 +306,8 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-PrintDriver);
if (rc  0) {
APR((Can't register Transparent Print device (%d)\n, 
rc));
-   return(rc);
+   goto err_put_tty_print;
+   goto err_unregister_serial;
}
brd-dgap_Major_TransparentPrint_Registered = TRUE;
dgap_BoardsByMajor[brd-PrintDriver-major] = brd;
@@ -306,7 +316,18 @@ int dgap_tty_register(struct board_t *brd)
 
DPR_INIT((DGAP REGISTER TTY: MAJORS: %d %d\n, 
brd-SerialDriver-major,
brd-PrintDriver-major));
-
+   return 0;
+
+err_unregister_serial:
+tty_unregister_driver(brd-SerialDriver);
+err_free_print_ttys:
+kfree(brd-PrintDriver-ttys);
+err_put_tty_print:
+put_tty_driver(brd-PrintDriver);
+err_free_serial_ttys:
+kfree(brd-SerialDriver-ttys);
+err_put_tty_serial:
+put_tty_driver(brd-SerialDriver);
return (rc);
 }
 
-- 
1.8.1.2

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


Re: [PATCH 1/1] staging: dgnc: Remove KERNEL_VERSION check

2013-10-01 Thread Lidza Louina
On Mon, Sep 30, 2013 at 9:46 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Fri, Sep 27, 2013 at 07:11:47AM -0400, Lidza Louina wrote:
 On Fri, Sep 27, 2013 at 5:50 AM, Sachin Kamat sachin.ka...@linaro.org 
 wrote:
  This check is not required.
 
  Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
  Cc: Lidza Louina lidza.lou...@gmail.com
  ---
   drivers/staging/dgnc/dgnc_kcompat.h |5 -
   1 file changed, 5 deletions(-)
 
  diff --git a/drivers/staging/dgnc/dgnc_kcompat.h 
  b/drivers/staging/dgnc/dgnc_kcompat.h
  index ed85152..eaec7e6 100644
  --- a/drivers/staging/dgnc/dgnc_kcompat.h
  +++ b/drivers/staging/dgnc/dgnc_kcompat.h
  @@ -28,11 +28,6 @@
   #ifndef __DGNC_KCOMPAT_H
   #define __DGNC_KCOMPAT_H
 
  -# ifndef KERNEL_VERSION
  -#  define KERNEL_VERSION(a,b,c)  (((a)  16) + ((b)  8) + (c))
  -# endif
  -
  -
   #if !defined(TTY_FLIPBUF_SIZE)
   # define TTY_FLIPBUF_SIZE 512
   #endif
  --
  1.7.9.5
 

 This looks great. Thanks. :)

 So, is that your implied ack?  :)

 In the future, for patches you review and want me to apply, you can say:
 Acked-by: Yourname email
 or, even better, as you are the maintainer, and I should be getting your
 signed off for all patches for the driver:
 Signed-off-by: Yourname email

 I'll just take this one for am implied ack for now, but in the future,
 it would be good to have an explicit one :)

 thanks,

 greg k-h

Okay, gotcha. I'll make it explicit next time. :)

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


Re: [PATCH v2 4/5] staging: dgap: tty.c: changes error handing to tty driver allocations

2013-09-26 Thread Lidza Louina
On Thu, Sep 26, 2013 at 6:19 AM, Dan Carpenter dan.carpen...@oracle.com wrote:
 This one is not right.

 On Wed, Sep 25, 2013 at 07:08:53PM -0400, Lidza Louina wrote:
 This patch changes error handling to the
 tty_driver allocations in dgap_tty_register.

 Before, it didn't handle the possibility of an
 alloc_tty_driver failure. This patch makes
 dgap_register_driver return -ENOMEM if that fails.

 This patch also adds handling to the possibility that
 the brd-SerialDriver-ttys or brd-PrintDriver-ttys
 allocation will fail. It now calls put_tty_driver on
 that driver after it fails and returns -ENOMEM.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgap/dgap_tty.c | 26 ++
  1 file changed, 18 insertions(+), 8 deletions(-)

 diff --git a/drivers/staging/dgap/dgap_tty.c 
 b/drivers/staging/dgap/dgap_tty.c
 index 59fda2e..3e12ddb 100644
 --- a/drivers/staging/dgap/dgap_tty.c
 +++ b/drivers/staging/dgap/dgap_tty.c
 @@ -220,6 +220,8 @@ int dgap_tty_register(struct board_t *brd)
   DPR_INIT((tty_register start));

   brd-SerialDriver = alloc_tty_driver(MAXPORTS);
 + if (!brd-SerialDriver)
 + return -ENOMEM;

   snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, 
 brd-boardnum);
   brd-SerialDriver-name = brd-SerialName;
 @@ -234,9 +236,10 @@ int dgap_tty_register(struct board_t *brd)

   /* The kernel wants space to store pointers to tty_structs */
   brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * 
 sizeof(struct tty_struct *), GFP_KERNEL);
 - if (!brd-SerialDriver-ttys)
 - return(-ENOMEM);
 -
 + if (!brd-SerialDriver-ttys){
 + rc = -ENOMEM;
 + goto err_put_tty_serial;
 + }
  #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
   brd-SerialDriver-refcount = brd-TtyRefCnt;
  #endif
 @@ -253,6 +256,8 @@ int dgap_tty_register(struct board_t *brd)
* we are when we get into the dgap_tty_open() routine.
*/
   brd-PrintDriver = alloc_tty_driver(MAXPORTS);
 + if (!brd-PrintDriver)
 + return -ENOMEM;

 if (!brd-PrintDriver) {
 rc = -ENOMEM:
 goto err_free_serial_ttys;
 }


   snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, brd-boardnum);
   brd-PrintDriver-name = brd-PrintName;
 @@ -267,9 +272,10 @@ int dgap_tty_register(struct board_t *brd)

   /* The kernel wants space to store pointers to tty_structs */
   brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
 tty_struct *), GFP_KERNEL);
 - if (!brd-PrintDriver-ttys)
 - return(-ENOMEM);
 -
 + if (!brd-PrintDriver-ttys){
 + rc = -ENOMEM;
 + goto err_put_tty_print;
 + }
  #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
   brd-PrintDriver-refcount = brd-TtyRefCnt;
  #endif
 @@ -285,7 +291,7 @@ int dgap_tty_register(struct board_t *brd)
   rc = tty_register_driver(brd-SerialDriver);
   if (rc  0) {
   APR((Can't register tty device (%d)\n, rc));
 - return(rc);
 + goto err_put_tty_serial;

 goto err_free_print_ttys;

   }
   brd-dgap_Major_Serial_Registered = TRUE;
   dgap_BoardsByMajor[brd-SerialDriver-major] = brd;
 @@ -297,7 +303,7 @@ int dgap_tty_register(struct board_t *brd)
   rc = tty_register_driver(brd-PrintDriver);
   if (rc  0) {
   APR((Can't register Transparent Print device (%d)\n, 
 rc));
 - return(rc);
 + goto err_put_tty_print;

 goto err_unregister_serial;

   }
   brd-dgap_Major_TransparentPrint_Registered = TRUE;
   dgap_BoardsByMajor[brd-PrintDriver-major] = brd;
 @@ -307,6 +313,10 @@ int dgap_tty_register(struct board_t *brd)
   DPR_INIT((DGAP REGISTER TTY: MAJORS: %d %d\n, 
 brd-SerialDriver-major,
   brd-PrintDriver-major));

 Your patch frees everything by mistake on the success path.  It should
 be:

 return 0;

 err_unregister_serial:
 tty_unregister_driver(brd-SerialDriver);
 err_free_print_ttys:
 kfree(brd-PrintDriver-ttys);
 err_put_tty_print:
 put_tty_driver(brd-PrintDriver);
 err_free_serial_ttys:
 kfree(brd-SerialDriver-ttys);
 err_put_tty_serial:
 put_tty_driver(brd-SerialDriver);

 return rc;
 }

 regards,
 dan carpenter

Okay, I'll resend this patch. Thanks.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 5/5] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-09-26 Thread Lidza Louina
On Thu, Sep 26, 2013 at 6:22 AM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Sep 25, 2013 at 07:08:54PM -0400, Lidza Louina wrote:
 This patch removes this smatch warning:
 unsigned '--un-un_open_count' is never less than zero

 The code decremented the un_open_count variable
 and tested to see if it was less than zero. Because
 un_open_count is unsigned and can't be below zero,
 this test didn't work.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgap/dgap_tty.c | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

 diff --git a/drivers/staging/dgap/dgap_tty.c 
 b/drivers/staging/dgap/dgap_tty.c
 index 3e12ddb..c0258db 100644
 --- a/drivers/staging/dgap/dgap_tty.c
 +++ b/drivers/staging/dgap/dgap_tty.c
 @@ -1446,13 +1446,11 @@ static void dgap_tty_close(struct tty_struct *tty, 
 struct file *file)
   APR((tty-count is 1, un open count is %d\n, 
 un-un_open_count));
   un-un_open_count = 1;
   }
 -
 - if (--un-un_open_count  0) {
 + if (un-un_open_count == 0) {
   APR((bad serial port open count of %d\n, un-un_open_count));
 - un-un_open_count = 0;
 + un-un_open_count = 1;
   }
 -
 - ch-ch_open_count--;

 Wait?  Don't delete this line.  We need to decrement both.

 + un-un_open_count--;

 regards,
 dan carpenter



Ahh, I see. I'll resend this patch.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] staging: dgap: tty.c: removes smatch warnings potential null dereference

2013-09-25 Thread Lidza Louina
On Tue, Sep 24, 2013 at 3:20 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Tue, Sep 24, 2013 at 02:40:10PM -0400, Lidza Louina wrote:
 Instead of writing:
 brd-SerialDriver = alloc_tty_driver(MAXPORTS);
 if (!brd-SerialDriver){
 goto free_stuff;
 return -ENOMEM;
 }

 Would it correct if I wrote:
 brd-SerialDriver = alloc_tty_driver((MAXPORTS);
 if (!brd-SerialDriver){
 kfree(brd-SerialDriver);
 return -ENOMEM;
 }

 Just to avoid writing goto statements? _

 No.  The problem with doing it that way is that we end up with multiple
 calls to kfree(brd-SerialDriver);.  The error handling becomes more
 complex and error prone.

 This is explained in Documentation/CodingStyle.

Okay, I read that. Thanks.

 It should be written in mirror format.  All the resources are freed in
 the reverse order that they are allocated.

 one = kmalloc();
 if (!one)
 return -ENOMEM;

 two = kmalloc();
 if (!two) {
 ret = -ENOMEM;
 goto err_free_one;
 }

 three = kmalloc();
 if (!three) {
 ret = -ENOMEM;
 goto err_free_two;
 }
 ret = frob();
 if (ret)
 goto err_free_three;


 err_free_three:
 kfree(three);
 err_free_two:
 kfree(two);
 err_free_one:
 kfree(one);

 return ret;

I looked at other uses of the function alloc_tty_driver() in
the kernel and none of them seem to follow up with a
call to kfree(). Are they supposed to? I realize that
because the allocation failed, I wouldn't need to call
kfree afterward. _ So this should be enough:

if(!brd-PrintDriver){
rc = -ENOMEM;
}

The code then returns rc at the end of the function.

Is this code supposed to include a call to kfree? If so,
what makes this driver different from the others?

 Most of the time, there shouldn't be any if statements in the cleanup.

 A common mistake is to use GW-BASIC names.
 err_1:
 kfree(foo);
 err_2:
 kfree(bar);

 That's not useful because it doesn't describe what happens at the label.

 Another mistake is to choose label names based on the goto location.

 if (kmalloc_failed)
 goto err_kmalloc_failed;

 I already know kmalloc failed so the label name is totally useless.

Okay, thanks for the tip. I'll keep that in mind
whenever I use goto statements. :)

 Once you have your error handling cleanup block at the end of the
 function, then that should almost match the release() function.  Btw, I
 notice this dgap_tty_register() function doesn't have a matching
 unregister function and actually dgap_tty_register() is never called.
 :P

Hmm, ok, I'll do that next on this driver. _ Add
dgap_tty_unregister() and make sure it and
dgap_tty_register() get called.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] staging: dgap: tty.c: removes smatch warnings potential null dereference

2013-09-25 Thread Lidza Louina
On Wed, Sep 25, 2013 at 2:34 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Sep 25, 2013 at 01:22:08PM -0400, Lidza Louina wrote:

 I looked at other uses of the function alloc_tty_driver() in
 the kernel and none of them seem to follow up with a
 call to kfree().

 Read my first response again.  I showed how to do this.  Your setting
 up a bunch of things in a line.  If any of them fail you need to
 cleanup by releasing any allocations.

 If you have an allocation from alloc_tty_driver() then you can't release
 it with kfree() you need to use put_tty_driver().

Alrighty.

These are the examples I'd found in the kernel.

Case 1: tty/synclink.c: mgsl_init_tty(): The serial_driver is
allocated, it checks for an error and returns -ENOMEM:

serial_driver = alloc_tty_driver(128);
if (!serial_driver)
return -ENOMEM;

The code doesn't call put_tty_driver until synclink_cleanup() is
called. In synclink, the put_tty_driver only gets called when
serial_driver is not null:

if (serial_driver) {
if ((rc = tty_unregister_driver(serial_driver)))
printk(%s(%d) failed to unregister tty driver err=%d\n,
 __FILE__,__LINE__,rc);
put_tty_driver(serial_driver);
}

This is the case for most of the drivers I found, it returns -ENOMEM
when the alloc fails, and calls put_tty_driver when something fails
afterward (like when registering the device fails).

Case 2: tty/rocket.c: rp_init(): rocket_driver is allocated using
alloc_tty_driver, and we return ret:
int ret = -ENOMEM, pci_boards_found, isa_boards_found, i;

rocket_driver = alloc_tty_driver(MAX_RP_PORTS);
if (!rocket_driver)
goto err;
.(some code).
err:
return ret;

put_tty_driver() gets called when we can't find an IO region:

if (controller  (!request_region(controller, 4, Comtrol RocketPort))) {
printk(KERN_ERR Unable to reserve IO region for first 
configured ISA RocketPort controller 0x%lx.  
Driver exiting\n, controller);
ret = -EBUSY;
goto err_tty;
}
.(some code).
err_tty:
put_tty_driver(rocket_driver);

And after setting rocket_driver's flags, termios info, type, subtype,
etc., it tries to register the driver:

ret = tty_register_driver(rocket_driver);
if (ret  0) {
printk(KERN_ERR Couldn't install tty RocketPort driver\n);
goto err_controller;
}
.(some code).
err_controller:
if (controller)
release_region(controller, 4);

I would think that err_controller would have a call to put_tty_driver.
Also I'd think that err_tty would go with the failed register_driver()
call and the err_controller would math the failed request_region. Bad
names? _

Case 3: tty/serial/msm_smd_tty.c: smd_tty_init(): This doesn't have a
matching put_tty_driver after alloc_tty_driver.

Case 4: tty/vt/vt.c: vty_init(): This code allocates the driver, then
calls a panic function:

console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
if (!console_driver)
panic(Couldn't allocate console driver\n);

The code doesn't call put_tty_driver at any time, and I'm not sure
what the panic function does. I grepped thru the tty drivers and
couldn't find a declaration or definition for it.

There are more drivers I didn't look at, but I figured this would be
enough for now.

Out of the 18 drivers I checked:
- Most of them returned -ENOMEM when allocating failed and most used
put_tty_driver when registering, requesting a region, or using kthread
failed (not all)
- One called put_tty_driver when the module_exit function was being
called: tty/hvc/hvc_console.c
- One had no put_tty_driver call after it was allocated
- One had a panic function when it encountered an error and I don't
know what panic() does, but it doesnt seem to call put_tty_driver

I think I was just looking at the bad ones. _ Do the ones I caught
need fixing? :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] staging: dgap: tty.c: removes smatch warnings potential null dereference

2013-09-25 Thread Lidza Louina
On Wed, Sep 25, 2013 at 6:29 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Sep 25, 2013 at 06:13:47PM -0400, Lidza Louina wrote:
 On Wed, Sep 25, 2013 at 2:34 PM, Dan Carpenter dan.carpen...@oracle.com 
 wrote:
  On Wed, Sep 25, 2013 at 01:22:08PM -0400, Lidza Louina wrote:
 
  I looked at other uses of the function alloc_tty_driver() in
  the kernel and none of them seem to follow up with a
  call to kfree().
 
  Read my first response again.  I showed how to do this.  Your setting
  up a bunch of things in a line.  If any of them fail you need to
  cleanup by releasing any allocations.
 
  If you have an allocation from alloc_tty_driver() then you can't release
  it with kfree() you need to use put_tty_driver().

 Alrighty.

 These are the examples I'd found in the kernel.

 Case 1: tty/synclink.c: mgsl_init_tty(): The serial_driver is
 allocated, it checks for an error and returns -ENOMEM:

 serial_driver = alloc_tty_driver(128);
 if (!serial_driver)
 return -ENOMEM;


 It's not allocated, the allocation failed.  It does call
 put_tty_driver() if the tty_register_driver() call fails so this
 function is correct.


 The code doesn't call put_tty_driver until synclink_cleanup() is
 called. In synclink, the put_tty_driver only gets called when
 serial_driver is not null:

 if (serial_driver) {
 if ((rc = tty_unregister_driver(serial_driver)))
 printk(%s(%d) failed to unregister tty driver err=%d\n,
  __FILE__,__LINE__,rc);
 put_tty_driver(serial_driver);
 }

 This is the case for most of the drivers I found, it returns -ENOMEM
 when the alloc fails, and calls put_tty_driver when something fails
 afterward (like when registering the device fails).

 Yes.  That's correct.


 Case 2: tty/rocket.c: rp_init(): rocket_driver is allocated using
 alloc_tty_driver, and we return ret:
 int ret = -ENOMEM, pci_boards_found, isa_boards_found, i;

 rocket_driver = alloc_tty_driver(MAX_RP_PORTS);
 if (!rocket_driver)
 goto err;
 .(some code).
 err:
 return ret;

 put_tty_driver() gets called when we can't find an IO region:

 if (controller  (!request_region(controller, 4, Comtrol 
 RocketPort))) {
 printk(KERN_ERR Unable to reserve IO region for first 
 configured ISA RocketPort controller 0x%lx.  
 Driver exiting\n, controller);
 ret = -EBUSY;
 goto err_tty;
 }
 .(some code).
 err_tty:
 put_tty_driver(rocket_driver);

 And after setting rocket_driver's flags, termios info, type, subtype,
 etc., it tries to register the driver:

 ret = tty_register_driver(rocket_driver);
 if (ret  0) {
 printk(KERN_ERR Couldn't install tty RocketPort driver\n);
 goto err_controller;
 }
 .(some code).
 err_controller:
 if (controller)
 release_region(controller, 4);

 I would think that err_controller would have a call to put_tty_driver.
 Also I'd think that err_tty would go with the failed register_driver()
 call and the err_controller would math the failed request_region. Bad
 names? _

 This function is also fine.  The names ok-ish.

 err_tty puts the tty.
 err_controller releases the controller region.
 err_ttyu unregisters the tty.

 The names are not great.  ttyu is a too short and who would know that
 the 'u' stands for unregister?  It would be better to use
 err_unregister_tty:


 Case 3: tty/serial/msm_smd_tty.c: smd_tty_init(): This doesn't have a
 matching put_tty_driver after alloc_tty_driver.


 This one is buggy.  If tty_register_driver() fails then it should call
 put_tty_driver().

 Case 4: tty/vt/vt.c: vty_init(): This code allocates the driver, then
 calls a panic function:

 console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
 if (!console_driver)
 panic(Couldn't allocate console driver\n);

 The code doesn't call put_tty_driver at any time, and I'm not sure
 what the panic function does. I grepped thru the tty drivers and
 couldn't find a declaration or definition for it.


 panic() means the kernel dies.  If you can't load the vt module then
 there is no point in continueing and nothing you can do to recover.
 vt is special and essential.

 There are more drivers I didn't look at, but I figured this would be
 enough for now.

 Out of the 18 drivers I checked:
 - Most of them returned -ENOMEM when allocating failed and most used
 put_tty_driver when registering, requesting a region, or using kthread
 failed (not all)
 - One called put_tty_driver when the module_exit function was being
 called: tty/hvc/hvc_console.c

 The hvc_console.c driver is fine.

 - One had no put_tty_driver call after it was allocated
 - One had a panic function when it encountered an error and I don't
 know what panic() does, but it doesnt seem to call put_tty_driver

 I think I was just looking at the bad ones. _ Do

[PATCH v2 1/5] staging: dgap: driver.c: removes smatch warning redundant null check

2013-09-25 Thread Lidza Louina
This patch removes these smatch warnings from dgap_driver.c:

redundant null check on dgap_config_buf calling kfree()
redundant null check on brd-flipbuf calling kfree()
redundant null check on brd-flipflagbuf calling kfree()

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index a3fa6a8..4c1515e 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -416,8 +416,7 @@ void dgap_cleanup_module(void)
unregister_chrdev(DIGI_DGAP_MAJOR, dgap);
}
 
-   if (dgap_config_buf)
-   kfree(dgap_config_buf);
+   kfree(dgap_config_buf);
 
for (i = 0; i  dgap_NumBoards; ++i) {
dgap_remove_ports_sysfiles(dgap_Board[i]);
@@ -484,10 +483,8 @@ static void dgap_cleanup_board(struct board_t *brd)
}
}
 
-   if (brd-flipbuf)
-   kfree(brd-flipbuf);
-   if (brd-flipflagbuf)
-   kfree(brd-flipflagbuf);
+   kfree(brd-flipbuf);
+   kfree(brd-flipflagbuf);
 
dgap_Board[brd-boardnum] = NULL;
 
-- 
1.8.1.2

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


[PATCH v2 4/5] staging: dgap: tty.c: changes error handing to tty driver allocations

2013-09-25 Thread Lidza Louina
This patch changes error handling to the
tty_driver allocations in dgap_tty_register.

Before, it didn't handle the possibility of an
alloc_tty_driver failure. This patch makes
dgap_register_driver return -ENOMEM if that fails.

This patch also adds handling to the possibility that
the brd-SerialDriver-ttys or brd-PrintDriver-ttys
allocation will fail. It now calls put_tty_driver on
that driver after it fails and returns -ENOMEM.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 59fda2e..3e12ddb 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -220,6 +220,8 @@ int dgap_tty_register(struct board_t *brd)
DPR_INIT((tty_register start));
 
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
+   if (!brd-SerialDriver)
+   return -ENOMEM;
 
snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, brd-boardnum);
brd-SerialDriver-name = brd-SerialName;
@@ -234,9 +236,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-SerialDriver-ttys)
-   return(-ENOMEM);
-
+   if (!brd-SerialDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_serial;
+   }
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-SerialDriver-refcount = brd-TtyRefCnt;
 #endif
@@ -253,6 +256,8 @@ int dgap_tty_register(struct board_t *brd)
 * we are when we get into the dgap_tty_open() routine.
 */
brd-PrintDriver = alloc_tty_driver(MAXPORTS);
+   if (!brd-PrintDriver)
+   return -ENOMEM;
 
snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, brd-boardnum);
brd-PrintDriver-name = brd-PrintName;
@@ -267,9 +272,10 @@ int dgap_tty_register(struct board_t *brd)
 
/* The kernel wants space to store pointers to tty_structs */
brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-PrintDriver-ttys)
-   return(-ENOMEM);
-
+   if (!brd-PrintDriver-ttys){
+   rc = -ENOMEM;
+   goto err_put_tty_print;
+   }
 #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
brd-PrintDriver-refcount = brd-TtyRefCnt;
 #endif
@@ -285,7 +291,7 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-SerialDriver);
if (rc  0) {
APR((Can't register tty device (%d)\n, rc));
-   return(rc);
+   goto err_put_tty_serial;
}
brd-dgap_Major_Serial_Registered = TRUE;
dgap_BoardsByMajor[brd-SerialDriver-major] = brd;
@@ -297,7 +303,7 @@ int dgap_tty_register(struct board_t *brd)
rc = tty_register_driver(brd-PrintDriver);
if (rc  0) {
APR((Can't register Transparent Print device (%d)\n, 
rc));
-   return(rc);
+   goto err_put_tty_print;
}
brd-dgap_Major_TransparentPrint_Registered = TRUE;
dgap_BoardsByMajor[brd-PrintDriver-major] = brd;
@@ -307,6 +313,10 @@ int dgap_tty_register(struct board_t *brd)
DPR_INIT((DGAP REGISTER TTY: MAJORS: %d %d\n, 
brd-SerialDriver-major,
brd-PrintDriver-major));
 
+err_put_tty_serial:
+   put_tty_driver(brd-SerialDriver);
+err_put_tty_print:
+   put_tty_driver(brd-PrintDriver);
return (rc);
 }
 
-- 
1.8.1.2

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


Re: [PATCH v3 6/7] staging: dgnc: changes arguments in sizeof

2013-09-25 Thread Lidza Louina
On Wed, Sep 25, 2013 at 7:08 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Mon, Sep 09, 2013 at 03:01:27PM -0400, Lidza Louina wrote:
 The arguments that were passed into sizeof were
 generic. This patch changes this by putting
 the actual item that we need a size of instead.

 For example:
 -   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
 +   kzalloc(sizeof(*brd), GFP_KERNEL);

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 Reviewed-by: Dan Carpenter dan.carpen...@oracle.com

 This no longer applies :(

 Can you refresh it and resend please?

Yes, I can. :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 5/5] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-09-25 Thread Lidza Louina
This patch removes this smatch warning:
unsigned '--un-un_open_count' is never less than zero

The code decremented the un_open_count variable
and tested to see if it was less than zero. Because
un_open_count is unsigned and can't be below zero,
this test didn't work.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 3e12ddb..c0258db 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -1446,13 +1446,11 @@ static void dgap_tty_close(struct tty_struct *tty, 
struct file *file)
APR((tty-count is 1, un open count is %d\n, 
un-un_open_count));
un-un_open_count = 1;
}  
-
-   if (--un-un_open_count  0) {
+   if (un-un_open_count == 0) {
APR((bad serial port open count of %d\n, un-un_open_count));
-   un-un_open_count = 0;
+   un-un_open_count = 1;
}
-
-   ch-ch_open_count--;
+   un-un_open_count--;
 
if (ch-ch_open_count  un-un_open_count) {
DPR_CLOSE((dgap_tty_close: not last close ch: %d un:%d\n,
-- 
1.8.1.2

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


Re: [PATCH 6/6] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-09-24 Thread Lidza Louina
On Mon, Sep 23, 2013 at 8:00 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Mon, Sep 23, 2013 at 06:47:17PM -0400, Lidza Louina wrote:
 This patch removes this smatch warning:
 unsigned '--un-un_open_count' is never less than zero

 The code decremented the un_open_count variable
 and tested to see if it was less than zero. Because
 un_open_count is unsigned and can't be below zero,
 this test doesn't work. This patch tests
 un_open_count against 0 without decrementing it.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgap/dgap_tty.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/staging/dgap/dgap_tty.c 
 b/drivers/staging/dgap/dgap_tty.c
 index 8f0a824..f496710 100644
 --- a/drivers/staging/dgap/dgap_tty.c
 +++ b/drivers/staging/dgap/dgap_tty.c
 @@ -1442,7 +1442,7 @@ static void dgap_tty_close(struct tty_struct *tty, 
 struct file *file)
   un-un_open_count = 1;
   }

 - if (--un-un_open_count  0) {
 + if (un-un_open_count == 0) {
   APR((bad serial port open count of %d\n, un-un_open_count));
   un-un_open_count = 0;
   }

 This fix isn't right.  We still need the decrement.  Probably the best
 thing is to audit all the driver and make sure that un-un_open_count
 can never be == 0.  But the next best, and still totally reasonable
 thing to do is this:

 if (un-un_open_count == 0) {
 APR((bad serial port open count of %d\n, 
 un-un_open_count));
 un-un_open_count = 1;
 }
 un-un_open_count--;

 regards,
 dan carpenter


Okay, I see why, I'll resend this.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/6] staging: dgap: fep5.c: removes smatch warning missing break? reassigning 'ch-pscan_state'

2013-09-24 Thread Lidza Louina
On Mon, Sep 23, 2013 at 8:10 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Tue, Sep 24, 2013 at 03:06:06AM +0300, Dan Carpenter wrote:
 On Mon, Sep 23, 2013 at 06:47:13PM -0400, Lidza Louina wrote:
  This patch removes this smatch warning:
  warn: missing break? reassigning 'ch-pscan_state'

 I would just leave this one as is.


 Yes.  Actually, the fix isn't right.  Let's drop this one.

 regards,
 dan carpenter


The switch statement this code refers to has the
default behavior first then all the different cases. Isn't
it supposed to be the other way around where
the different cases are presented before the default?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/6] staging: dgap: tty.c: removes smatch warnings potential null dereference

2013-09-24 Thread Lidza Louina
On Mon, Sep 23, 2013 at 8:27 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Mon, Sep 23, 2013 at 06:47:16PM -0400, Lidza Louina wrote:
 This patch removes these warnings:
 potential null dereference 'brd-SerialDriver'. (alloc_tty_driver returns 
 null)
 potential null dereference 'brd-PrintDriver'. (alloc_tty_driver returns 
 null)

 This warning popped up because there wasn't a check
 to make sure that the serial and print drivers were
 allocated and not null before being initialized. This
 patch adds that check.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgap/dgap_tty.c | 103 
 +---
  1 file changed, 54 insertions(+), 49 deletions(-)

 diff --git a/drivers/staging/dgap/dgap_tty.c 
 b/drivers/staging/dgap/dgap_tty.c
 index 924e2bf..8f0a824 100644
 --- a/drivers/staging/dgap/dgap_tty.c
 +++ b/drivers/staging/dgap/dgap_tty.c
 @@ -220,66 +220,71 @@ int dgap_tty_register(struct board_t *brd)
   DPR_INIT((tty_register start));

   brd-SerialDriver = alloc_tty_driver(MAXPORTS);
 + if(brd-SerialDriver){

 Don't do it that way, flip it around.

 brd-SerialDriver = alloc_tty_driver(MAXPORTS);
 if (!brd-SerialDriver)
 return -ENOMEM;

 snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, 
 brd-boardnum);
 brd-SerialDriver-name = brd-SerialName;

 That way has fewer indents.

 When you're writing code, you want it to read in a straight line going
 down.  You don't want long if statement blocks or spaghetti code.  If
 you hit an error deal with it immediately and continue with the story in
 a straight line going down.

 +
 + /* The kernel wants space to store pointers to tty_structs */
 + brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * 
 sizeof(struct tty_struct *), GFP_KERNEL);
 + if (!brd-SerialDriver-ttys)
 + return(-ENOMEM);

 On this if statement it's a little bit more complicated because you have
 to free the memory you allocated earlier before returning.  This one
 should look like:

 brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * 
 sizeof(struct tty_struct *), GFP_KERNEL);
 if (!brd-SerialDriver-ttys) {
 ret = -ENOMEM;
 goto err_put_driver;
 }
 tty_set_operations(brd-SerialDriver, dgap_tty_ops);


 At the end of the function there will be something like:

 return 0;

 err_release_foo:
 release_foo();
 err_free_something:
 free_some_more_stuff();
 err_put_driver:
 put_tty_driver(brd-SerialDriver);

 return ret;
 }

Instead of writing:
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
if (!brd-SerialDriver){
goto free_stuff;
return -ENOMEM;
}

Would it correct if I wrote:
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
if (!brd-SerialDriver){
kfree(brd-SerialDriver);
return -ENOMEM;
}

Just to avoid writing goto statements? _
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] MAINTAINERS: staging: dgnc and dgap drivers: add maintainer

2013-09-23 Thread Lidza Louina
This patch adds the staging/dgnc [DIGI NEO AND CLASSIC
PCI PRODUCTS] and staging/dgap [DIGI EPCA PCI PRODUCTS]
drivers to the MAINTAINERS file. I am listed as the
maintainer and the driverdev-devel list is the mailing
list for these drivers.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 MAINTAINERS | 12 
 1 file changed, 12 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index e8ee569..8f75595 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2639,6 +2639,18 @@ F:   include/linux/device-mapper.h
 F: include/linux/dm-*.h
 F: include/uapi/linux/dm-*.h
 
+DIGI NEO AND CLASSIC PCI PRODUCTS
+M: Lidza Louina lidza.lou...@gmail.com
+L: driverdev-devel@linuxdriverproject.org
+S: Maintained
+F: drivers/staging/dgnc/
+
+DIGI EPCA PCI PRODUCTS
+M: Lidza Louina lidza.lou...@gmail.com
+L: driverdev-devel@linuxdriverproject.org
+S: Maintained
+F: drivers/staging/dgap/
+
 DIOLAN U2C-12 I2C DRIVER
 M: Guenter Roeck li...@roeck-us.net
 L: linux-...@vger.kernel.org
-- 
1.8.1.2

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


Re: [PATCH] MAINTAINERS: staging: dgnc and dgap drivers: add maintainer

2013-09-23 Thread Lidza Louina
On Mon, Sep 23, 2013 at 4:16 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Mon, Sep 23, 2013 at 04:13:15PM -0400, Lidza Louina wrote:
 This patch adds the staging/dgnc [DIGI NEO AND CLASSIC
 PCI PRODUCTS] and staging/dgap [DIGI EPCA PCI PRODUCTS]
 drivers to the MAINTAINERS file. I am listed as the
 maintainer and the driverdev-devel list is the mailing
 list for these drivers.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  MAINTAINERS | 12 
  1 file changed, 12 insertions(+)

 Ah, sorry about forgetting to ask you to add these.  I'll queue these up
 for 3.12-rc3 or so.

 thanks,

 greg k-h

Awesome, thanks.

Btw, are will still in the merge window? Do you need me to send out
fixes for warnings (sparse or smatch) or can I send things like TODO
updates or checkpatch fixes?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/6] staging: dgap: tty.c: removes smatch warnings redundant null check

2013-09-23 Thread Lidza Louina
This patch removes these smatch warnings:
redundant null check on dgap_TmpWriteBuf calling kfree()
redundant null check on brd-SerialDriver-ttys calling kfree()
redundant null check on brd-PrintDriver-ttys calling kfree()

The code checked to see if these variables are null
before freeing. This check isn't needed.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 7f909b8..924e2bf 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -497,10 +497,8 @@ int dgap_tty_init(struct board_t *brd)
  */
 void dgap_tty_post_uninit(void)
 {
-   if (dgap_TmpWriteBuf) {
-   kfree(dgap_TmpWriteBuf);
-   dgap_TmpWriteBuf = NULL;
-   }
+   kfree(dgap_TmpWriteBuf);
+   dgap_TmpWriteBuf = NULL;
 }
 
 
@@ -522,10 +520,8 @@ void dgap_tty_uninit(struct board_t *brd)
tty_unregister_device(brd-SerialDriver, i);
}
tty_unregister_driver(brd-SerialDriver);
-   if (brd-SerialDriver-ttys) {
-   kfree(brd-SerialDriver-ttys);
-   brd-SerialDriver-ttys = NULL;
-   }
+   kfree(brd-SerialDriver-ttys);
+   brd-SerialDriver-ttys = NULL;
put_tty_driver(brd-SerialDriver);
brd-dgap_Major_Serial_Registered = FALSE;
}
@@ -538,10 +534,8 @@ void dgap_tty_uninit(struct board_t *brd)
tty_unregister_device(brd-PrintDriver, i);
}
tty_unregister_driver(brd-PrintDriver);
-   if (brd-PrintDriver-ttys) {
-   kfree(brd-PrintDriver-ttys);
-   brd-PrintDriver-ttys = NULL;
-   }
+   kfree(brd-PrintDriver-ttys);
+   brd-PrintDriver-ttys = NULL;
put_tty_driver(brd-PrintDriver);
brd-dgap_Major_TransparentPrint_Registered = FALSE;
}
-- 
1.8.1.2

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


[PATCH 2/6] staging: dgap: fep5.c: removes smatch warning missing break? reassigning 'ch-pscan_state'

2013-09-23 Thread Lidza Louina
This patch removes this smatch warning:
warn: missing break? reassigning 'ch-pscan_state'

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_fep5.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c
index 4464f02..29de349 100644
--- a/drivers/staging/dgap/dgap_fep5.c
+++ b/drivers/staging/dgap/dgap_fep5.c
@@ -1587,10 +1587,6 @@ void dgap_parity_scan(struct channel_t *ch, unsigned 
char *cbuf, unsigned char *
while (l--) {
c = *in++;
switch (ch-pscan_state) {
-   default:
-   /* reset to sanity and fall through */
-   ch-pscan_state = 0;
-
case 0:
/* No FF seen yet */
if (c == (unsigned char) '\377') {
@@ -1642,6 +1638,11 @@ void dgap_parity_scan(struct channel_t *ch, unsigned 
char *cbuf, unsigned char *
 
count += 1;
ch-pscan_state = 0;
+   break;
+   default:
+   /* reset to sanity and fall through */
+   ch-pscan_state = 0;
+   break;
}   
}
*len = count;
-- 
1.8.1.2

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


[PATCH 1/6] staging: dgap: driver.c: removes smatch warning redundant null check

2013-09-23 Thread Lidza Louina
This patch removes these smatch warnings from dgap_driver.c:

redundant null check on dgap_config_buf calling kfree()
redundant null check on brd-flipbuf calling kfree()
redundant null check on brd-flipflagbuf calling kfree()

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index 65d7ee0..c0dd119 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -416,8 +416,7 @@ void dgap_cleanup_module(void)
unregister_chrdev(DIGI_DGAP_MAJOR, dgap);
}
 
-   if (dgap_config_buf)
-   kfree(dgap_config_buf);
+   kfree(dgap_config_buf);
 
for (i = 0; i  dgap_NumBoards; ++i) {
dgap_remove_ports_sysfiles(dgap_Board[i]);
@@ -484,10 +483,8 @@ static void dgap_cleanup_board(struct board_t *brd)
}
}
 
-   if (brd-flipbuf)
-   kfree(brd-flipbuf);
-   if (brd-flipflagbuf)
-   kfree(brd-flipflagbuf);
+   kfree(brd-flipbuf);
+   kfree(brd-flipflagbuf);
 
dgap_Board[brd-boardnum] = NULL;
 
-- 
1.8.1.2

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


[PATCH 3/6] staging: dgap: tty.c: removes smatch warning ignoring unreachable code

2013-09-23 Thread Lidza Louina
This patch removes this smatch warning:
info: ignoring unreachable code.

There were instances where there was extra code after
the default action in switch statements. These default
actions ended with a break so the code wasn't being run
at anytime. This patch removes that extra code.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 2b26152..7f909b8 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -3513,10 +3513,6 @@ static int dgap_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
return(-EINVAL);
}
 
-   DGAP_UNLOCK(ch-ch_lock, lock_flags2);
-   DGAP_UNLOCK(bd-bd_lock, lock_flags);
-   return(-ENOIOCTLCMD);
-
case DIGI_GETA:
/* get information for ditty */
DGAP_UNLOCK(ch-ch_lock, lock_flags2);
@@ -3586,12 +3582,4 @@ static int dgap_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
 
return(-ENOIOCTLCMD);
}
-
-   DGAP_UNLOCK(ch-ch_lock, lock_flags2);
-   DGAP_UNLOCK(bd-bd_lock, lock_flags);
-
-   DPR_IOCTL((dgap_tty_ioctl end - cmd %s (%x), arg %lx\n, 
-   dgap_ioctl_name(cmd), cmd, arg));
-
-   return(0);
 }
-- 
1.8.1.2

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


[PATCH 6/6] staging: dgap: tty.c: removes smatch warning unsigned '--un-un_open_count' is never less than zero

2013-09-23 Thread Lidza Louina
This patch removes this smatch warning:
unsigned '--un-un_open_count' is never less than zero

The code decremented the un_open_count variable
and tested to see if it was less than zero. Because
un_open_count is unsigned and can't be below zero,
this test doesn't work. This patch tests
un_open_count against 0 without decrementing it.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 8f0a824..f496710 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -1442,7 +1442,7 @@ static void dgap_tty_close(struct tty_struct *tty, struct 
file *file)
un-un_open_count = 1;
}  
 
-   if (--un-un_open_count  0) {
+   if (un-un_open_count == 0) {
APR((bad serial port open count of %d\n, un-un_open_count));
un-un_open_count = 0;
}
-- 
1.8.1.2

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


[PATCH 5/6] staging: dgap: tty.c: removes smatch warnings potential null dereference

2013-09-23 Thread Lidza Louina
This patch removes these warnings:
potential null dereference 'brd-SerialDriver'. (alloc_tty_driver returns null)
potential null dereference 'brd-PrintDriver'. (alloc_tty_driver returns null)

This warning popped up because there wasn't a check
to make sure that the serial and print drivers were
allocated and not null before being initialized. This
patch adds that check.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c | 103 +---
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 924e2bf..8f0a824 100644
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -220,66 +220,71 @@ int dgap_tty_register(struct board_t *brd)
DPR_INIT((tty_register start));
 
brd-SerialDriver = alloc_tty_driver(MAXPORTS);
+   if(brd-SerialDriver){
+   snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, 
brd-boardnum);
+   brd-SerialDriver-name = brd-SerialName;
+   brd-SerialDriver-name_base = 0;
+   brd-SerialDriver-major = 0;
+   brd-SerialDriver-minor_start = 0;
+   brd-SerialDriver-type = TTY_DRIVER_TYPE_SERIAL; 
+   brd-SerialDriver-subtype = SERIAL_TYPE_NORMAL;   
+   brd-SerialDriver-init_termios = DgapDefaultTermios;
+   brd-SerialDriver-driver_name = DRVSTR;
+   brd-SerialDriver-flags = (TTY_DRIVER_REAL_RAW | 
TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+
+   /* The kernel wants space to store pointers to tty_structs */
+   brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   if (!brd-SerialDriver-ttys)
+   return(-ENOMEM);
+
+   #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
+   brd-SerialDriver-refcount = brd-TtyRefCnt;
+   #endif
 
-   snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgap_%d_, brd-boardnum);
-   brd-SerialDriver-name = brd-SerialName;
-   brd-SerialDriver-name_base = 0;
-   brd-SerialDriver-major = 0;
-   brd-SerialDriver-minor_start = 0;
-   brd-SerialDriver-type = TTY_DRIVER_TYPE_SERIAL; 
-   brd-SerialDriver-subtype = SERIAL_TYPE_NORMAL;   
-   brd-SerialDriver-init_termios = DgapDefaultTermios;
-   brd-SerialDriver-driver_name = DRVSTR;
-   brd-SerialDriver-flags = (TTY_DRIVER_REAL_RAW | 
TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
-
-   /* The kernel wants space to store pointers to tty_structs */
-   brd-SerialDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct 
tty_struct *), GFP_KERNEL);
-   if (!brd-SerialDriver-ttys)
+   /*
+* Entry points for driver.  Called by the kernel from
+* tty_io.c and n_tty.c.
+*/
+   tty_set_operations(brd-SerialDriver, dgap_tty_ops);
+   }
+   else
return(-ENOMEM);
 
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
-   brd-SerialDriver-refcount = brd-TtyRefCnt;
-#endif
-
-   /*
-* Entry points for driver.  Called by the kernel from
-* tty_io.c and n_tty.c.
-*/
-   tty_set_operations(brd-SerialDriver, dgap_tty_ops);
-
/*
 * If we're doing transparent print, we have to do all of the above
 * again, separately so we don't get the LD confused about what major
 * we are when we get into the dgap_tty_open() routine.
 */
brd-PrintDriver = alloc_tty_driver(MAXPORTS);
+   if(brd-PrintDriver){
+   snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, 
brd-boardnum);
+   brd-PrintDriver-name = brd-PrintName;
+   brd-PrintDriver-name_base = 0;
+   brd-PrintDriver-major = 0;
+   brd-PrintDriver-minor_start = 0;
+   brd-PrintDriver-type = TTY_DRIVER_TYPE_SERIAL;   
+   brd-PrintDriver-subtype = SERIAL_TYPE_NORMAL;
+   brd-PrintDriver-init_termios = DgapDefaultTermios;
+   brd-PrintDriver-driver_name = DRVSTR;
+   brd-PrintDriver-flags = (TTY_DRIVER_REAL_RAW | 
TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+
+   /* The kernel wants space to store pointers to tty_structs */
+   brd-PrintDriver-ttys = dgap_driver_kzmalloc(MAXPORTS * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   if (!brd-PrintDriver-ttys)
+   return(-ENOMEM);
+
+   #if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
+   brd-PrintDriver-refcount = brd-TtyRefCnt;
+   #endif
 
-   snprintf(brd-PrintName, MAXTTYNAMELEN, pr_dgap_%d_, brd-boardnum);
-   brd-PrintDriver-name = brd-PrintName;
-   brd-PrintDriver-name_base = 0;
-   brd-PrintDriver-major = 0;
-   brd-PrintDriver-minor_start = 0;
-   brd

Re: [PATCH] MAINTAINERS: staging: dgnc and dgap drivers: add maintainer

2013-09-23 Thread Lidza Louina
On Mon, Sep 23, 2013 at 6:16 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Mon, Sep 23, 2013 at 04:22:10PM -0400, Lidza Louina wrote:
 Awesome, thanks.

 Btw, are will still in the merge window? Do you need me to send out
 fixes for warnings (sparse or smatch) or can I send things like TODO
 updates or checkpatch fixes?

 The merge window ends when -rc1 is released.

Okay

 Probably sparse and smatch fixes are not appropriate for 3.12.  Although
 sometimes those checkers do find serious bugs.

Okay

 I don't want to speak for Greg but generally you can send any sort of
 patch any time.  It's just that it's going to sit in Greg's inbox if you
 send it during the merge window.

 Normally when -rc1 is released and Greg starts merging patches there are
 some that conflict and have to be redone.  It's not the end of the world
 to redo a patch submit.

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


Re: [PATCH v3 1/7] staging: dgnc: renames board_t to dgnc_board

2013-09-12 Thread Lidza Louina
On Tue, Sep 10, 2013 at 6:12 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Mon, Sep 09, 2013 at 03:01:22PM -0400, Lidza Louina wrote:
 This patch renames the struct board_t to dgnc_board. board_t
 wasn't a good name for it since the _t suffix is for typedefs.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com

 These were fine before.  There was no need to resend the first five
 patches.  If no one comments then that means the patch is ok.  If we
 ask you to redo [patch 3/10] then maybe some of the others which depend
 on it will have to be redone.  In this case, it was only the last patch
 which needed a fix.

Okay, I'll remember that for future patches.

 Greg is busy because the merge window is open, and he's won't look at
 these until after the -rc1 release is out.

Alrighty, I'll hold off until then.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 7/7] staging: dgnc: tty.c: replaces kzalloc with kcalloc for arrays

2013-09-12 Thread Lidza Louina
On Tue, Sep 10, 2013 at 6:05 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 This one is not right.

 On Mon, Sep 09, 2013 at 03:01:28PM -0400, Lidza Louina wrote:
 This patch replaces kzalloc with kcalloc when using
 arrays. kcalloc is better suited for arrays because
 it has overflow protection.

 Reported-by: Dan Carpenter dan.carpen...@oracle.com
 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_tty.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

 diff --git a/drivers/staging/dgnc/dgnc_tty.c 
 b/drivers/staging/dgnc/dgnc_tty.c
 index 07b79be..18705f9 100644
 --- a/drivers/staging/dgnc/dgnc_tty.c
 +++ b/drivers/staging/dgnc/dgnc_tty.c
 @@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
* The kernel wants space to store pointers to
* tty_struct's and termios's.
*/
 - brd-SerialDriver.ttys = kzalloc(brd-maxports * 
 sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);
 + brd-SerialDriver.ttys = kcalloc(brd-SerialDriver.num, brd-maxports 
 * sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);


 This should be:

 brd-SerialDriver.ttys = kcalloc(brd-maxports, 
 sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);

 Btw, are you using vim with cscope set up?

 make cscope
 vim -t kcalloc
 Move to the kmalloc_array() call and hit CTRL-]

I had never heard of cscope. I wish I would've known
about it before, it would've saved me a ton of grepping
thru source code... _ Thanks for the tip.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 3/7] staging: dgnc: removes casting around kzalloc

2013-09-12 Thread Lidza Louina
On Thu, Sep 12, 2013 at 6:00 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Mon, Sep 09, 2013 at 03:01:24PM -0400, Lidza Louina wrote:
 This patch removes casting around kzalloc calls.
 The casts aren't needed because kzalloc returns
 a void pointer.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_driver.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/drivers/staging/dgnc/dgnc_driver.c 
 b/drivers/staging/dgnc/dgnc_driver.c
 index 89c332f..3717d86 100644
 --- a/drivers/staging/dgnc/dgnc_driver.c
 +++ b/drivers/staging/dgnc/dgnc_driver.c
 @@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)

   /* get the board structure and prep it */
   brd = dgnc_Board[dgnc_NumBoards] =
 - (struct dgnc_board *) kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
 + kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);

 Very odd indentation, this should be:
 brd = dgnc_Board[dgnc_NumBoards] = kzalloc(sizeof(struct dgnc_board),
GFP_KERNEL);

 right?

 I've gotten patches from 2 others for this same type of fix, it seems
 people are going through the whole tree for this issue at the moment.

Okay, that's really awesome. :)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 6/6] staging: dgnc: changes arguments in sizeof

2013-09-10 Thread Lidza Louina
On Fri, Sep 6, 2013 at 5:45 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Fri, Sep 06, 2013 at 04:48:32PM -0400, Lidza Louina wrote:
 The arguments that are passed into sizeof were
 generic. This patch changes this by putting
 the actual item that we need a size of instead.

 For example:
 -   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
 +   kzalloc(sizeof(brd), GFP_KERNEL);

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_driver.c |  4 ++--
  drivers/staging/dgnc/dgnc_mgmt.c   |  2 +-
  drivers/staging/dgnc/dgnc_tty.c| 24 
  3 files changed, 15 insertions(+), 15 deletions(-)

 diff --git a/drivers/staging/dgnc/dgnc_driver.c 
 b/drivers/staging/dgnc/dgnc_driver.c
 index 5b4d799..a1b24b5 100644
 --- a/drivers/staging/dgnc/dgnc_driver.c
 +++ b/drivers/staging/dgnc/dgnc_driver.c
 @@ -487,14 +487,14 @@ static int dgnc_found_board(struct pci_dev *pdev, int 
 id)

   /* get the board structure and prep it */
   brd = dgnc_Board[dgnc_NumBoards] =
 - kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
 + kzalloc(sizeof(brd), GFP_KERNEL);

 Still not right.

 sizeof(*brd);

 I'm always creating test small test programs:

 struct foo {
 char buf[42]; regards,
 dan carpenter

 };

 int main(void)
 {
 struct foo *p;

 printf(%ld %ld\n, sizeof(p), sizeof(*p));

 return 0;
 }

Okay, I see that the sizeof the *p is larger than
the sizeof p.

   if (!brd) {
   return -ENOMEM;
   }

   /* make a temporary message buffer for the boot messages */
   brd-msgbuf = brd-msgbuf_head =
 - kzalloc(sizeof(char) * 8192, GFP_KERNEL);
 + kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
   if (!brd-msgbuf) {
   kfree(brd);
   return -ENOMEM;
 diff --git a/drivers/staging/dgnc/dgnc_mgmt.c 
 b/drivers/staging/dgnc/dgnc_mgmt.c
 index bb39f5d..354458c 100644
 --- a/drivers/staging/dgnc/dgnc_mgmt.c
 +++ b/drivers/staging/dgnc/dgnc_mgmt.c
 @@ -209,7 +209,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int 
 cmd, unsigned long arg)
   uint board = 0;
   uint channel = 0;

 - if (copy_from_user(ni, uarg, sizeof(struct ni_info))) {
 + if (copy_from_user(ni, uarg, sizeof(ni))) {
   return -EFAULT;
   }

 diff --git a/drivers/staging/dgnc/dgnc_tty.c 
 b/drivers/staging/dgnc/dgnc_tty.c
 index fe38529..894b7df 100644
 --- a/drivers/staging/dgnc/dgnc_tty.c
 +++ b/drivers/staging/dgnc/dgnc_tty.c
 @@ -200,8 +200,8 @@ int dgnc_tty_register(struct dgnc_board *brd)

   DPR_INIT((tty_register start\n));

 - memset(brd-SerialDriver, 0, sizeof(struct tty_driver));
 - memset(brd-PrintDriver, 0, sizeof(struct tty_driver));
 + memset(brd-SerialDriver, 0, sizeof(brd-SerialDriver));
 + memset(brd-PrintDriver, 0, sizeof(brd-PrintDriver));

   brd-SerialDriver.magic = TTY_DRIVER_MAGIC;

 @@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
* The kernel wants space to store pointers to
* tty_struct's and termios's.
*/
 - brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
 tty_struct *), GFP_KERNEL);
 + brd-SerialDriver.ttys = kzalloc(brd-maxports * 
 sizeof(brd-SerialDriver.ttys), GFP_KERNEL);

 ttys is a pointer to a pointer.  What you have works but it would be
 better to say. sizeof(*brd-SerialDriver.ttys).  For this one kcalloc()
 is actually better than kzalloc().  It's cleaner and it has overflow
 protection built in.


   if (!brd-SerialDriver.ttys)
   return -ENOMEM;

   kref_init(brd-SerialDriver.kref);
 - brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
 ktermios *), GFP_KERNEL);
 + brd-SerialDriver.termios = kzalloc(brd-maxports * 
 sizeof(brd-SerialDriver.termios), GFP_KERNEL);

 Same.

   if (!brd-SerialDriver.termios)
   return -ENOMEM;

 @@ -271,11 +271,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
* tty_struct's and termios's.  Must be seperate from
* the Serial Driver so we don't get confused
*/
 - brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
 tty_struct *), GFP_KERNEL);
 + brd-PrintDriver.ttys = kzalloc(brd-maxports * 
 sizeof(brd-PrintDriver.ttys), GFP_KERNEL);

 Same.

   if (!brd-PrintDriver.ttys)
   return -ENOMEM;
   kref_init(brd-PrintDriver.kref);
 - brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
 ktermios *), GFP_KERNEL);
 + brd-PrintDriver.termios = kzalloc(brd-maxports * 
 sizeof(brd-PrintDriver.termios), GFP_KERNEL);

 Same.


   if (!brd-PrintDriver.termios)
   return -ENOMEM;

 @@ -341,7 +341,7 @@ int dgnc_tty_init(struct dgnc_board *brd)
* Okay to malloc with GFP_KERNEL, we are not at
* interrupt context, and there are no locks held

Re: [PATCH v2 4/6] staging: dgnc: removes kzalloc error messages

2013-09-10 Thread Lidza Louina
On Fri, Sep 6, 2013 at 5:50 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Fri, Sep 06, 2013 at 04:48:30PM -0400, Lidza Louina wrote:
 This patch removes the error messages associated
 with errors in kzalloc. The driver doesn't need to
 add the error message because kzalloc already prints
 a more useful message.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_driver.c | 2 --
  drivers/staging/dgnc/dgnc_tty.c| 4 
  2 files changed, 6 deletions(-)

 diff --git a/drivers/staging/dgnc/dgnc_driver.c 
 b/drivers/staging/dgnc/dgnc_driver.c
 index 3717d86..6bc944d 100644
 --- a/drivers/staging/dgnc/dgnc_driver.c
 +++ b/drivers/staging/dgnc/dgnc_driver.c
 @@ -501,7 +501,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
   brd = dgnc_Board[dgnc_NumBoards] =
   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
   if (!brd) {
 - APR((memory allocation for board structure failed\n));
   return -ENOMEM;
   }

 This patch should remove the curly braces as well.  Fix it in a later
 patch.  It's not worth resending just for that.

I'll send it out when I work on checkpatch warnings.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 7/7] staging: dgnc: tty.c: replaces kzalloc with kcalloc for arrays

2013-09-10 Thread Lidza Louina
This patch replaces kzalloc with kcalloc when using
arrays. kcalloc is better suited for arrays because
it has overflow protection.

Reported-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_tty.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 07b79be..18705f9 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);
+   brd-SerialDriver.ttys = kcalloc(brd-SerialDriver.num, brd-maxports * 
sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
kref_init(brd-SerialDriver.kref);
-   brd-SerialDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.termios), GFP_KERNEL);
+   brd-SerialDriver.termios = kcalloc(brd-SerialDriver.num, 
brd-maxports * sizeof(*brd-SerialDriver.termios), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
@@ -271,11 +271,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * tty_struct's and termios's.  Must be seperate from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.ttys), GFP_KERNEL);
+   brd-PrintDriver.ttys = kcalloc(brd-PrintDriver.num, brd-maxports * 
sizeof(*brd-PrintDriver.ttys), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return -ENOMEM;
kref_init(brd-PrintDriver.kref);
-   brd-PrintDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.termios), GFP_KERNEL);
+   brd-PrintDriver.termios = kcalloc(brd-PrintDriver.num, brd-maxports 
* sizeof(*brd-PrintDriver.termios), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return -ENOMEM;
 
-- 
1.8.1.2

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


[PATCH v3 1/7] staging: dgnc: renames board_t to dgnc_board

2013-09-10 Thread Lidza Louina
This patch renames the struct board_t to dgnc_board. board_t
wasn't a good name for it since the _t suffix is for typedefs.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_cls.c| 14 +--
 drivers/staging/dgnc/dgnc_driver.c | 20 +++
 drivers/staging/dgnc/dgnc_driver.h | 10 
 drivers/staging/dgnc/dgnc_neo.c| 20 +++
 drivers/staging/dgnc/dgnc_sysfs.c  | 50 +++---
 drivers/staging/dgnc/dgnc_sysfs.h  |  6 ++---
 drivers/staging/dgnc/dgnc_tty.c| 38 ++---
 drivers/staging/dgnc/dgnc_tty.h|  6 ++---
 8 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 117e158..22875c1 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -43,7 +43,7 @@
 #include dgnc_tty.h
 #include dgnc_trace.h
 
-static inline void cls_parse_isr(struct board_t *brd, uint port);
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port);
 static inline void cls_clear_break(struct channel_t *ch, int force);
 static inline void cls_set_cts_flow_control(struct channel_t *ch);
 static inline void cls_set_rts_flow_control(struct channel_t *ch);
@@ -53,7 +53,7 @@ static inline void cls_set_no_output_flow_control(struct 
channel_t *ch);
 static inline void cls_set_no_input_flow_control(struct channel_t *ch);
 static void cls_parse_modem(struct channel_t *ch, uchar signals);
 static void cls_tasklet(unsigned long data);
-static void cls_vpd(struct board_t *brd);
+static void cls_vpd(struct dgnc_board *brd);
 static void cls_uart_init(struct channel_t *ch);
 static void cls_uart_off(struct channel_t *ch);
 static int cls_drain(struct tty_struct *tty, uint seconds);
@@ -393,7 +393,7 @@ static inline void cls_clear_break(struct channel_t *ch, 
int force)
 
 
 /* Parse the ISR register for the specific port */
-static inline void cls_parse_isr(struct board_t *brd, uint port)
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
 {
struct channel_t *ch;
uchar isr = 0;
@@ -477,7 +477,7 @@ static void cls_param(struct tty_struct *tty)
uchar uart_ier = 0;
 uint baud = 9600;
int quot = 0;
-struct board_t *bd;
+struct dgnc_board *bd;
struct channel_t *ch;
 struct un_t   *un;
 
@@ -725,7 +725,7 @@ static void cls_param(struct tty_struct *tty)
  */
 static void cls_tasklet(unsigned long data)
 {
-struct board_t *bd = (struct board_t *) data;
+struct dgnc_board *bd = (struct dgnc_board *) data;
struct channel_t *ch;
ulong  lock_flags;
int i;
@@ -802,7 +802,7 @@ static void cls_tasklet(unsigned long data)
  */
 static irqreturn_t cls_intr(int irq, void *voidbrd)
 {
-   struct board_t *brd = (struct board_t *) voidbrd;
+   struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
uint i = 0;
uchar poll_reg;
unsigned long lock_flags;
@@ -1378,7 +1378,7 @@ static void cls_send_immediate_char(struct channel_t *ch, 
unsigned char c)
writeb(c, ch-ch_cls_uart-txrx);
 }
 
-static void cls_vpd(struct board_t *brd)
+static void cls_vpd(struct dgnc_board *brd)
 {
 ulong   vpdbase;/* Start of io base of the card */
 u8 __iomem   *re_map_vpdbase;/* Remapped memory of the card */
diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index f8c1e22..5b35291 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -71,16 +71,16 @@ PARM_INT(trcbuf_size,   0x10,   0644,   
Debugging trace buffer size.);
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct board_t *brd);
+static int dgnc_finalize_board_init(struct dgnc_board *brd);
 static voiddgnc_init_globals(void);
 static int dgnc_found_board(struct pci_dev *pdev, int id);
-static voiddgnc_cleanup_board(struct board_t *brd);
+static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_pci(void);
 static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 static voiddgnc_remove_one(struct pci_dev *dev);
 static int dgnc_probe1(struct pci_dev *pdev, int card_type);
-static voiddgnc_do_remap(struct board_t *brd);
+static voiddgnc_do_remap(struct dgnc_board *brd);
 
 /* Driver load/unload functions */
 intdgnc_init_module(void);
@@ -106,7 +106,7 @@ static struct file_operations dgnc_BoardFops =
  * Globals
  */
 uint   dgnc_NumBoards;
-struct board_t *dgnc_Board[MAXBOARDS];
+struct dgnc_board  *dgnc_Board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
 int

[PATCH v3 6/7] staging: dgnc: changes arguments in sizeof

2013-09-10 Thread Lidza Louina
The arguments that were passed into sizeof were
generic. This patch changes this by putting
the actual item that we need a size of instead.

For example:
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(*brd), GFP_KERNEL);

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c |  4 ++--
 drivers/staging/dgnc/dgnc_mgmt.c   |  2 +-
 drivers/staging/dgnc/dgnc_tty.c| 24 
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 5b4d799..56b5d4a 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -487,14 +487,14 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd) {
return -ENOMEM;
}
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
return -ENOMEM;
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index bb39f5d..354458c 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -209,7 +209,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
uint board = 0;
uint channel = 0;
 
-   if (copy_from_user(ni, uarg, sizeof(struct ni_info))) {
+   if (copy_from_user(ni, uarg, sizeof(ni))) {
return -EFAULT;
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index fe38529..07b79be 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -200,8 +200,8 @@ int dgnc_tty_register(struct dgnc_board *brd)
 
DPR_INIT((tty_register start\n));
 
-   memset(brd-SerialDriver, 0, sizeof(struct tty_driver));
-   memset(brd-PrintDriver, 0, sizeof(struct tty_driver));
+   memset(brd-SerialDriver, 0, sizeof(brd-SerialDriver));
+   memset(brd-PrintDriver, 0, sizeof(brd-PrintDriver));
 
brd-SerialDriver.magic = TTY_DRIVER_MAGIC;
 
@@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-SerialDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.ttys), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
kref_init(brd-SerialDriver.kref);
-   brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-SerialDriver.termios), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
@@ -271,11 +271,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * tty_struct's and termios's.  Must be seperate from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-PrintDriver.ttys = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.ttys), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return -ENOMEM;
kref_init(brd-PrintDriver.kref);
-   brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios = kzalloc(brd-maxports * 
sizeof(*brd-PrintDriver.termios), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return -ENOMEM;
 
@@ -341,7 +341,7 @@ int dgnc_tty_init(struct dgnc_board *brd)
 * Okay to malloc with GFP_KERNEL, we are not at
 * interrupt context, and there are no locks held.
 */
-   brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
+   brd-channels[i] = kzalloc(sizeof(*brd-channels[i]), 
GFP_KERNEL);
}
}
 
@@ -2660,7 +2660,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, 
struct digi_t __user *new_i
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
return -EFAULT;
 
-   if (copy_from_user(new_digi, new_info, sizeof(struct digi_t))) {
+   if (copy_from_user(new_digi, new_info, sizeof(new_digi))) {
DPR_IOCTL((DIGI_SETA failed copy_from_user\n));
return -EFAULT;
}
@@ -2683,7 +2683,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty

[PATCH v3 3/7] staging: dgnc: removes casting around kzalloc

2013-09-10 Thread Lidza Louina
This patch removes casting around kzalloc calls.
The casts aren't needed because kzalloc returns
a void pointer.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 89c332f..3717d86 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   (struct dgnc_board *) kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return -ENOMEM;
@@ -507,7 +507,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
-- 
1.8.1.2

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


[PATCH v3 5/7] staging: dgnc: removes LINUX_VERSION_CODE conditionals

2013-09-10 Thread Lidza Louina
This patch removes the conditionals that make sure
the driver supports various versions of the kernel.
They aren't needed.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c  | 12 
 drivers/staging/dgnc/dgnc_kcompat.h | 24 ---
 drivers/staging/dgnc/dgnc_tty.c | 61 ++---
 3 files changed, 2 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 6bc944d..5b4d799 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -31,15 +31,10 @@
 
 
 #include linux/kernel.h
-#include linux/version.h
 #include linux/module.h
 #include linux/pci.h
 #include linux/slab.h
-
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
 #include linux/sched.h
-#endif
-
 #include dgnc_driver.h
 #include dgnc_pci.h
 #include dpacompat.h
@@ -291,16 +286,9 @@ static int dgnc_start(void)
dgnc_Major = rc;
 
dgnc_class = class_create(THIS_MODULE, dgnc_mgmt);
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
-   device_create_drvdata(dgnc_class, NULL,
-   MKDEV(dgnc_Major, 0),
-   NULL, dgnc_mgmt);
-#else
device_create(dgnc_class, NULL,
MKDEV(dgnc_Major, 0),
NULL, dgnc_mgmt);
-#endif
-
dgnc_Major_Control_Registered = TRUE;
}
 
diff --git a/drivers/staging/dgnc/dgnc_kcompat.h 
b/drivers/staging/dgnc/dgnc_kcompat.h
index 00f589a..ed85152 100644
--- a/drivers/staging/dgnc/dgnc_kcompat.h
+++ b/drivers/staging/dgnc/dgnc_kcompat.h
@@ -28,8 +28,6 @@
 #ifndef __DGNC_KCOMPAT_H
 #define __DGNC_KCOMPAT_H
 
-#include linux/version.h
-
 # ifndef KERNEL_VERSION
 #  define KERNEL_VERSION(a,b,c)  (((a)  16) + ((b)  8) + (c))
 # endif
@@ -68,26 +66,4 @@
module_param(VAR, long, PERM); \
MODULE_PARM_DESC(VAR, DESC);
 
-
-
-
-
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,27)
-
-
-
-/* NOTHING YET */
-
-
-
-# else
-
-
-
-# error this driver does not support anything below the 2.6.27 kernel series.
-
-
-
-# endif
-
 #endif /* ! __DGNC_KCOMPAT_H */
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1f2d611..fe38529 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -38,7 +38,6 @@
  */
 
 #include linux/kernel.h
-#include linux/version.h
 #include linux/sched.h   /* For jiffies, task states */
 #include linux/interrupt.h   /* For tasklet and interrupt structs/defines */
 #include linux/module.h
@@ -60,11 +59,9 @@
 #include dpacompat.h
 #include dgnc_sysfs.h
 
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,37)
 #define init_MUTEX(sem) sema_init(sem, 1)
 #define DECLARE_MUTEX(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
 
 /*
  * internal variables
@@ -126,13 +123,8 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty);
 static void dgnc_tty_hangup(struct tty_struct *tty);
 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, 
unsigned int __user *value);
 static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user 
*value);
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
 static int dgnc_tty_tiocmget(struct tty_struct *tty);
 static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, 
unsigned int clear);
-#else
-static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file);
-static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, 
unsigned int set, unsigned int clear);
-#endif
 static int dgnc_tty_send_break(struct tty_struct *tty, int msec);
 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
 static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, 
int count);
@@ -234,21 +226,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
-   brd-SerialDriver.refcount = brd-TtyRefCnt;
-#else
kref_init(brd-SerialDriver.kref);
-#endif
-
brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
-#if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-SerialDriver.termios_locked = kzalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
-   if (!brd-SerialDriver.termios_locked)
-   return -ENOMEM;
-#endif
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
@@ -292,23 +274,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd

[PATCH v3 4/7] staging: dgnc: removes kzalloc error messages

2013-09-10 Thread Lidza Louina
This patch removes the error messages associated
with errors in kzalloc. The driver doesn't need to
add the error message because kzalloc already prints
a more useful message.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 2 --
 drivers/staging/dgnc/dgnc_tty.c| 4 
 2 files changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 3717d86..6bc944d 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -501,7 +501,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd = dgnc_Board[dgnc_NumBoards] =
kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
if (!brd) {
-   APR((memory allocation for board structure failed\n));
return -ENOMEM;
}
 
@@ -510,7 +509,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
-   APR((memory allocation for board msgbuf failed\n));
return -ENOMEM;
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a0af01d..1f2d611 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -372,10 +372,6 @@ int dgnc_tty_init(struct dgnc_board *brd)
 * interrupt context, and there are no locks held.
 */
brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
-   if (!brd-channels[i]) {
-   DPR_CORE((%s:%d Unable to allocate memory for 
channel struct\n,
-   __FILE__, __LINE__));
-   }
}
}
 
-- 
1.8.1.2

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


[PATCH v3 2/7] staging: dgnc: removes parentheses around return statements

2013-09-10 Thread Lidza Louina
This patch removes parentheses around return
statements. They aren't needed.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_cls.c|   8 +-
 drivers/staging/dgnc/dgnc_driver.c | 106 +--
 drivers/staging/dgnc/dgnc_mgmt.c   |  22 ++--
 drivers/staging/dgnc/dgnc_neo.c|   8 +-
 drivers/staging/dgnc/dgnc_sysfs.c  | 116 ++--
 drivers/staging/dgnc/dgnc_tty.c| 212 ++---
 6 files changed, 236 insertions(+), 236 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 22875c1..fa1bb63 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -976,17 +976,17 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
int rc = 0;
 
if (!tty || tty-magic != TTY_MAGIC) {
-   return (-ENXIO);
+   return -ENXIO;
}
 
un = (struct un_t *) tty-driver_data;
if (!un || un-magic != DGNC_UNIT_MAGIC) {
-   return (-ENXIO);
+   return -ENXIO;
}
 
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC) {
-   return (-ENXIO);
+   return -ENXIO;
}
 
DGNC_LOCK(ch-ch_lock, lock_flags);
@@ -1002,7 +1002,7 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
if (rc)
DPR_IOCTL((%d Drain - User ctrl c'ed\n, __LINE__));
 
-return (rc);
+return rc;
 }
 
 
diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 5b35291..89c332f 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -225,7 +225,7 @@ int dgnc_init_module(void)
rc = dgnc_start();
 
if (rc  0) {
-   return(rc);
+   return rc;
}
 
/*
@@ -250,7 +250,7 @@ int dgnc_init_module(void)
}
 
DPR_INIT((Finished init_module. Returning %d\n, rc));
-   return (rc);
+   return rc;
 }
 
 
@@ -286,7 +286,7 @@ static int dgnc_start(void)
if (rc = 0) {
APR((Can't register dgnc driver device 
(%d)\n, rc));
rc = -ENXIO;
-   return(rc);
+   return rc;
}
dgnc_Major = rc;
 
@@ -311,7 +311,7 @@ static int dgnc_start(void)
 
if (rc  0) {
APR((tty preinit - not enough memory (%d)\n, rc));
-   return(rc);
+   return rc;
}
 
/* Start the poller */
@@ -328,7 +328,7 @@ static int dgnc_start(void)
dgnc_driver_state = DRIVER_READY;
}
 
-   return(rc);
+   return rc;
 }
 
 /*
@@ -502,7 +502,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
(struct dgnc_board *) kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
-   return(-ENOMEM);
+   return -ENOMEM;
}
 
/* make a temporary message buffer for the boot messages */
@@ -511,7 +511,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
-   return(-ENOMEM);
+   return -ENOMEM;
}
 
/* store the info for the board we've found */
@@ -663,7 +663,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
default:
APR((Did not find any compatible Neo or Classic PCI boards in 
system.\n));
-   return (-ENXIO);
+   return -ENXIO;
 
}
 
@@ -725,11 +725,11 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(brd-state_wait);
 
-   return(0);
+   return 0;
 
 failed:
 
-   return (-ENXIO);
+   return -ENXIO;
 
 }
 
@@ -740,7 +740,7 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) 
{
DPR_INIT((dgnc_finalize_board_init() - start\n));
 
if (!brd || brd-magic != DGNC_BOARD_MAGIC)
-   return(-ENODEV);
+   return -ENODEV;
 
DPR_INIT((dgnc_finalize_board_init() - start #2\n));
 
@@ -756,7 +756,7 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) 
{
DPR_INIT((Requested and received usage of IRQ %d\n, 
brd-irq));
}
}
-   return(rc);
+   return rc;
 }
 
 /*
@@ -900,7 +900,7 @@ int dgnc_ms_sleep(ulong ms)
 {
current-state = TASK_INTERRUPTIBLE;
schedule_timeout((ms * HZ) / 1000);
-   return (signal_pending(current));
+   return signal_pending(current);
 }
 
 
@@ -912,47 +912,47 @@ char *dgnc_ioctl_name(int cmd)
 {
switch(cmd) {
 
-   case

[PATCH v2 1/6] staging: dgnc: renames board_t to dgnc_board

2013-09-06 Thread Lidza Louina
This patch renames the struct board_t to dgnc_board. board_t
wasn't a good name for it since the _t suffix is for typedefs.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_cls.c| 14 +--
 drivers/staging/dgnc/dgnc_driver.c | 20 +++
 drivers/staging/dgnc/dgnc_driver.h | 10 
 drivers/staging/dgnc/dgnc_neo.c| 20 +++
 drivers/staging/dgnc/dgnc_sysfs.c  | 50 +++---
 drivers/staging/dgnc/dgnc_sysfs.h  |  6 ++---
 drivers/staging/dgnc/dgnc_tty.c| 38 ++---
 drivers/staging/dgnc/dgnc_tty.h|  6 ++---
 8 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 117e158..22875c1 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -43,7 +43,7 @@
 #include dgnc_tty.h
 #include dgnc_trace.h
 
-static inline void cls_parse_isr(struct board_t *brd, uint port);
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port);
 static inline void cls_clear_break(struct channel_t *ch, int force);
 static inline void cls_set_cts_flow_control(struct channel_t *ch);
 static inline void cls_set_rts_flow_control(struct channel_t *ch);
@@ -53,7 +53,7 @@ static inline void cls_set_no_output_flow_control(struct 
channel_t *ch);
 static inline void cls_set_no_input_flow_control(struct channel_t *ch);
 static void cls_parse_modem(struct channel_t *ch, uchar signals);
 static void cls_tasklet(unsigned long data);
-static void cls_vpd(struct board_t *brd);
+static void cls_vpd(struct dgnc_board *brd);
 static void cls_uart_init(struct channel_t *ch);
 static void cls_uart_off(struct channel_t *ch);
 static int cls_drain(struct tty_struct *tty, uint seconds);
@@ -393,7 +393,7 @@ static inline void cls_clear_break(struct channel_t *ch, 
int force)
 
 
 /* Parse the ISR register for the specific port */
-static inline void cls_parse_isr(struct board_t *brd, uint port)
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
 {
struct channel_t *ch;
uchar isr = 0;
@@ -477,7 +477,7 @@ static void cls_param(struct tty_struct *tty)
uchar uart_ier = 0;
 uint baud = 9600;
int quot = 0;
-struct board_t *bd;
+struct dgnc_board *bd;
struct channel_t *ch;
 struct un_t   *un;
 
@@ -725,7 +725,7 @@ static void cls_param(struct tty_struct *tty)
  */
 static void cls_tasklet(unsigned long data)
 {
-struct board_t *bd = (struct board_t *) data;
+struct dgnc_board *bd = (struct dgnc_board *) data;
struct channel_t *ch;
ulong  lock_flags;
int i;
@@ -802,7 +802,7 @@ static void cls_tasklet(unsigned long data)
  */
 static irqreturn_t cls_intr(int irq, void *voidbrd)
 {
-   struct board_t *brd = (struct board_t *) voidbrd;
+   struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
uint i = 0;
uchar poll_reg;
unsigned long lock_flags;
@@ -1378,7 +1378,7 @@ static void cls_send_immediate_char(struct channel_t *ch, 
unsigned char c)
writeb(c, ch-ch_cls_uart-txrx);
 }
 
-static void cls_vpd(struct board_t *brd)
+static void cls_vpd(struct dgnc_board *brd)
 {
 ulong   vpdbase;/* Start of io base of the card */
 u8 __iomem   *re_map_vpdbase;/* Remapped memory of the card */
diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index f8c1e22..5b35291 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -71,16 +71,16 @@ PARM_INT(trcbuf_size,   0x10,   0644,   
Debugging trace buffer size.);
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct board_t *brd);
+static int dgnc_finalize_board_init(struct dgnc_board *brd);
 static voiddgnc_init_globals(void);
 static int dgnc_found_board(struct pci_dev *pdev, int id);
-static voiddgnc_cleanup_board(struct board_t *brd);
+static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_pci(void);
 static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 static voiddgnc_remove_one(struct pci_dev *dev);
 static int dgnc_probe1(struct pci_dev *pdev, int card_type);
-static voiddgnc_do_remap(struct board_t *brd);
+static voiddgnc_do_remap(struct dgnc_board *brd);
 
 /* Driver load/unload functions */
 intdgnc_init_module(void);
@@ -106,7 +106,7 @@ static struct file_operations dgnc_BoardFops =
  * Globals
  */
 uint   dgnc_NumBoards;
-struct board_t *dgnc_Board[MAXBOARDS];
+struct dgnc_board  *dgnc_Board[MAXBOARDS];
 DEFINE_SPINLOCK(dgnc_global_lock);
 int

[PATCH v2 6/6] staging: dgnc: changes arguments in sizeof

2013-09-06 Thread Lidza Louina
The arguments that are passed into sizeof were
generic. This patch changes this by putting
the actual item that we need a size of instead.

For example:
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(brd), GFP_KERNEL);

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c |  4 ++--
 drivers/staging/dgnc/dgnc_mgmt.c   |  2 +-
 drivers/staging/dgnc/dgnc_tty.c| 24 
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 5b4d799..a1b24b5 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -487,14 +487,14 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(brd), GFP_KERNEL);
if (!brd) {
return -ENOMEM;
}
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
return -ENOMEM;
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index bb39f5d..354458c 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -209,7 +209,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
uint board = 0;
uint channel = 0;
 
-   if (copy_from_user(ni, uarg, sizeof(struct ni_info))) {
+   if (copy_from_user(ni, uarg, sizeof(ni))) {
return -EFAULT;
}
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index fe38529..894b7df 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -200,8 +200,8 @@ int dgnc_tty_register(struct dgnc_board *brd)
 
DPR_INIT((tty_register start\n));
 
-   memset(brd-SerialDriver, 0, sizeof(struct tty_driver));
-   memset(brd-PrintDriver, 0, sizeof(struct tty_driver));
+   memset(brd-SerialDriver, 0, sizeof(brd-SerialDriver));
+   memset(brd-PrintDriver, 0, sizeof(brd-PrintDriver));
 
brd-SerialDriver.magic = TTY_DRIVER_MAGIC;
 
@@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-SerialDriver.ttys = kzalloc(brd-maxports * 
sizeof(brd-SerialDriver.ttys), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
kref_init(brd-SerialDriver.kref);
-   brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios = kzalloc(brd-maxports * 
sizeof(brd-SerialDriver.termios), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
@@ -271,11 +271,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
 * tty_struct's and termios's.  Must be seperate from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
+   brd-PrintDriver.ttys = kzalloc(brd-maxports * 
sizeof(brd-PrintDriver.ttys), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return -ENOMEM;
kref_init(brd-PrintDriver.kref);
-   brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios = kzalloc(brd-maxports * 
sizeof(brd-PrintDriver.termios), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return -ENOMEM;
 
@@ -341,7 +341,7 @@ int dgnc_tty_init(struct dgnc_board *brd)
 * Okay to malloc with GFP_KERNEL, we are not at
 * interrupt context, and there are no locks held.
 */
-   brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
+   brd-channels[i] = kzalloc(sizeof(brd-channels[i]), 
GFP_KERNEL);
}
}
 
@@ -2660,7 +2660,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, 
struct digi_t __user *new_i
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
return -EFAULT;
 
-   if (copy_from_user(new_digi, new_info, sizeof(struct digi_t))) {
+   if (copy_from_user(new_digi, new_info, sizeof(new_digi))) {
DPR_IOCTL((DIGI_SETA failed copy_from_user\n));
return -EFAULT;
}
@@ -2683,7 +2683,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty

[PATCH v2 3/6] staging: dgnc: removes casting around kzalloc

2013-09-06 Thread Lidza Louina
This patch removes casting around kzalloc calls.
The casts aren't needed because kzalloc returns
a void pointer.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 89c332f..3717d86 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   (struct dgnc_board *) kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
+   kzalloc(sizeof(struct dgnc_board), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return -ENOMEM;
@@ -507,7 +507,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+   kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
-- 
1.8.1.2

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


[PATCH v2 5/6] staging: dgnc: removes LINUX_VERSION_CODE conditionals

2013-09-06 Thread Lidza Louina
This patch removes the conditionals that make sure
the driver supports various versions of the kernel.
They aren't needed.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c  | 12 
 drivers/staging/dgnc/dgnc_kcompat.h | 24 ---
 drivers/staging/dgnc/dgnc_tty.c | 61 ++---
 3 files changed, 2 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 6bc944d..5b4d799 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -31,15 +31,10 @@
 
 
 #include linux/kernel.h
-#include linux/version.h
 #include linux/module.h
 #include linux/pci.h
 #include linux/slab.h
-
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
 #include linux/sched.h
-#endif
-
 #include dgnc_driver.h
 #include dgnc_pci.h
 #include dpacompat.h
@@ -291,16 +286,9 @@ static int dgnc_start(void)
dgnc_Major = rc;
 
dgnc_class = class_create(THIS_MODULE, dgnc_mgmt);
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
-   device_create_drvdata(dgnc_class, NULL,
-   MKDEV(dgnc_Major, 0),
-   NULL, dgnc_mgmt);
-#else
device_create(dgnc_class, NULL,
MKDEV(dgnc_Major, 0),
NULL, dgnc_mgmt);
-#endif
-
dgnc_Major_Control_Registered = TRUE;
}
 
diff --git a/drivers/staging/dgnc/dgnc_kcompat.h 
b/drivers/staging/dgnc/dgnc_kcompat.h
index 00f589a..ed85152 100644
--- a/drivers/staging/dgnc/dgnc_kcompat.h
+++ b/drivers/staging/dgnc/dgnc_kcompat.h
@@ -28,8 +28,6 @@
 #ifndef __DGNC_KCOMPAT_H
 #define __DGNC_KCOMPAT_H
 
-#include linux/version.h
-
 # ifndef KERNEL_VERSION
 #  define KERNEL_VERSION(a,b,c)  (((a)  16) + ((b)  8) + (c))
 # endif
@@ -68,26 +66,4 @@
module_param(VAR, long, PERM); \
MODULE_PARM_DESC(VAR, DESC);
 
-
-
-
-
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,27)
-
-
-
-/* NOTHING YET */
-
-
-
-# else
-
-
-
-# error this driver does not support anything below the 2.6.27 kernel series.
-
-
-
-# endif
-
 #endif /* ! __DGNC_KCOMPAT_H */
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1f2d611..fe38529 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -38,7 +38,6 @@
  */
 
 #include linux/kernel.h
-#include linux/version.h
 #include linux/sched.h   /* For jiffies, task states */
 #include linux/interrupt.h   /* For tasklet and interrupt structs/defines */
 #include linux/module.h
@@ -60,11 +59,9 @@
 #include dpacompat.h
 #include dgnc_sysfs.h
 
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,37)
 #define init_MUTEX(sem) sema_init(sem, 1)
 #define DECLARE_MUTEX(name) \
struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
 
 /*
  * internal variables
@@ -126,13 +123,8 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty);
 static void dgnc_tty_hangup(struct tty_struct *tty);
 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, 
unsigned int __user *value);
 static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user 
*value);
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
 static int dgnc_tty_tiocmget(struct tty_struct *tty);
 static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, 
unsigned int clear);
-#else
-static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file);
-static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, 
unsigned int set, unsigned int clear);
-#endif
 static int dgnc_tty_send_break(struct tty_struct *tty, int msec);
 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
 static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, 
int count);
@@ -234,21 +226,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
if (!brd-SerialDriver.ttys)
return -ENOMEM;
 
-#if LINUX_VERSION_CODE  KERNEL_VERSION(2,6,28)
-   brd-SerialDriver.refcount = brd-TtyRefCnt;
-#else
kref_init(brd-SerialDriver.kref);
-#endif
-
brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return -ENOMEM;
 
-#if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-SerialDriver.termios_locked = kzalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
-   if (!brd-SerialDriver.termios_locked)
-   return -ENOMEM;
-#endif
/*
 * Entry points for driver.  Called by the kernel from
 * tty_io.c and n_tty.c.
@@ -292,23 +274,11 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd

Re: [PATCH 03/12] staging: dgnc: driver.h: adds struct dgnc_board

2013-09-03 Thread Lidza Louina
On Sun, Sep 1, 2013 at 8:07 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Sat, Aug 31, 2013 at 06:19:11PM -0400, Lidza Louina wrote:
 This patch adds the dgnc_board struct to driver.h.
 This struct will replace board_t in this driver.


 So on this one patches 3, 4 and 5 should just be one patch.  It should
 rename board_t to dgnc_board in the .h file and change all the .c files
 in one patch.

Alrighty. I thought that I needed to break it up.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 06/12] staging: dgnc: removes kzalloc error statements

2013-09-03 Thread Lidza Louina
On Sun, Sep 1, 2013 at 8:14 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 The point I was trying to make earlier was that I don't like knee jerk
 error messages.  Some people put an error message after every line
 without thinking about it.  It's a very common source of bugs is to
 have a NULL dereference like:

 if (!dev) {
 pr_err(no device %s, dev-name);
 return -EINVAL;
 }

 It's a pet peeve of mine.  It should just be:

 if (!dev)
 return -EINVAL;


 But in the future I will be more careful in how I say it.  Sorry again.

Its okay, its my fault. I had a feeling that I was doing it wrong, but
did it anyway. _

I'll keep the return values but remove the error messages.

Your emails and feedback have been clear and helpful thus far,
so thank you.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: adds TODO

2013-08-31 Thread Lidza Louina
On Fri, Aug 30, 2013 at 2:28 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Thu, Aug 29, 2013 at 07:00:37PM -0400, Lidza Louina wrote:
 This patchs adds a TODO for the driver.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/TODO | 17 +
  1 file changed, 17 insertions(+)
  create mode 100644 drivers/staging/dgnc/TODO

 That's great, thanks.  Can you also send a patch adding you to the
 MAINTAINERS file for this driver, and the other one, so that people
 using 'scripts/get_maintainer.pl' know to cc: you as well?

Yes, I can. =]
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/12] staging: dgnc: mgmt.c: checkpatch: removes parentheses around return statements

2013-08-31 Thread Lidza Louina
This patch removes this checkpatch warning:
ERROR: return is not a function, parentheses are not
required.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_mgmt.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index dcab2a8..354458c 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -74,13 +74,13 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
/* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) {
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
-   return (-EBUSY);
+   return -EBUSY;
}
dgnc_mgmt_in_use[minor]++;
}
else {
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
-   return (-ENXIO);
+   return -ENXIO;
}
 
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
@@ -154,7 +154,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
ddi.dinfo_nboards, ddi.dinfo_version));
 
if (copy_to_user(uarg, ddi, sizeof (ddi)))
-   return(-EFAULT);
+   return -EFAULT;
 
break;
}
@@ -166,13 +166,13 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
struct digi_info di;
 
if (copy_from_user(brd, uarg, sizeof(int))) {
-   return(-EFAULT);
+   return -EFAULT;
}
 
DPR_MGMT((DIGI_GETBD asking about board: %d\n, brd));
 
if ((brd  0) || (brd  dgnc_NumBoards) || (dgnc_NumBoards == 
0))
-   return (-ENODEV);
+   return -ENODEV;
 
memset(di, 0, sizeof(di));
 
@@ -196,7 +196,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
di.info_bdtype, di.info_bdstate, di.info_nports, 
di.info_physsize));
 
if (copy_to_user(uarg, di, sizeof (di)))
-   return (-EFAULT);
+   return -EFAULT;
 
break;
}
@@ -210,7 +210,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
uint channel = 0;
 
if (copy_from_user(ni, uarg, sizeof(ni))) {
-   return(-EFAULT);
+   return -EFAULT;
}
 
DPR_MGMT((DIGI_GETBD asking about board: %d channel: %d\n,
@@ -221,16 +221,16 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
 
/* Verify boundaries on board */
if ((board  0) || (board  dgnc_NumBoards) || (dgnc_NumBoards 
== 0))
-   return (-ENODEV);
+   return -ENODEV;
 
/* Verify boundaries on channel */
if ((channel  0) || (channel  dgnc_Board[board]-nasync))
-   return (-ENODEV);
+   return -ENODEV;
 
ch = dgnc_Board[board]-channels[channel];
 
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (-ENODEV);
+   return -ENODEV;
 
memset(ni, 0, sizeof(ni));
ni.board = board;
@@ -291,7 +291,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
DGNC_UNLOCK(ch-ch_lock, lock_flags);
 
if (copy_to_user(uarg, ni, sizeof(ni)))
-   return (-EFAULT);
+   return -EFAULT;
 
break;
}
-- 
1.8.1.2

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


[PATCH 11/12] staging: dgnc: sysfs.c: checkpatch: removes parentheses around return statements

2013-08-31 Thread Lidza Louina
This patch removes this checkpatch warning:
ERROR: return is not a function, parentheses are not
required.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_sysfs.c | 116 +++---
 1 file changed, 58 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_sysfs.c 
b/drivers/staging/dgnc/dgnc_sysfs.c
index 03d3e2f..5834e0c 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -152,13 +152,13 @@ void dgnc_remove_driver_sysfiles(struct pci_driver 
*dgnc_driver)
 
 #define DGNC_VERIFY_BOARD(p, bd)   \
if (!p) \
-   return (0); \
+   return 0;   \
\
bd = dev_get_drvdata(p);\
if (!bd || bd-magic != DGNC_BOARD_MAGIC)   \
-   return (0); \
+   return 0;   \
if (bd-state != BOARD_READY)   \
-   return (0); \
+   return 0;   \
 
 
 
@@ -432,18 +432,18 @@ static ssize_t dgnc_tty_state_show(struct device *d, 
struct device_attribute *at
struct un_t *un;
 
if (!d)
-   return (0);
+   return 0;
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un-magic != DGNC_UNIT_MAGIC)
-   return (0);
+   return 0;
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (0);
+   return 0;
bd = ch-ch_bd;
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
-   return (0);
+   return 0;
if (bd-state != BOARD_READY)
-   return (0);
+   return 0;
 
return snprintf(buf, PAGE_SIZE, %s, un-un_open_count ? Open : 
Closed);
 }
@@ -457,18 +457,18 @@ static ssize_t dgnc_tty_baud_show(struct device *d, 
struct device_attribute *att
struct un_t *un;
 
if (!d)
-   return (0);
+   return 0;
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un-magic != DGNC_UNIT_MAGIC)
-   return (0);
+   return 0;
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (0);
+   return 0;
bd = ch-ch_bd;
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
-   return (0);
+   return 0;
if (bd-state != BOARD_READY)
-   return (0);
+   return 0;
 
return snprintf(buf, PAGE_SIZE, %d\n, ch-ch_old_baud);
 }
@@ -482,18 +482,18 @@ static ssize_t dgnc_tty_msignals_show(struct device *d, 
struct device_attribute
struct un_t *un;
 
if (!d)
-   return (0);
+   return 0;
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un-magic != DGNC_UNIT_MAGIC)
-   return (0);
+   return 0;
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (0);
+   return 0;
bd = ch-ch_bd;
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
-   return (0);
+   return 0;
if (bd-state != BOARD_READY)
-   return (0);
+   return 0;
 
if (ch-ch_open_count) {
return snprintf(buf, PAGE_SIZE, %s %s %s %s %s %s\n,
@@ -516,18 +516,18 @@ static ssize_t dgnc_tty_iflag_show(struct device *d, 
struct device_attribute *at
struct un_t *un;
 
if (!d)
-   return (0);
+   return 0;
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un-magic != DGNC_UNIT_MAGIC)
-   return (0);
+   return 0;
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (0);
+   return 0;
bd = ch-ch_bd;
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
-   return (0);
+   return 0;
if (bd-state != BOARD_READY)
-   return (0);
+   return 0;
 
return snprintf(buf, PAGE_SIZE, %x\n, ch-ch_c_iflag);
 }
@@ -541,18 +541,18 @@ static ssize_t dgnc_tty_cflag_show(struct device *d, 
struct device_attribute *at
struct un_t *un;
 
if (!d)
-   return (0);
+   return 0;
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un-magic != DGNC_UNIT_MAGIC)
-   return (0);
+   return 0;
ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
-   return (0);
+   return 0;
bd = ch-ch_bd;
if (!bd || bd-magic != DGNC_BOARD_MAGIC)
-   return (0);
+   return 0

[PATCH 04/12] staging: dgnc: replaces struct board_t with dgnc_board

2013-08-31 Thread Lidza Louina
This patch replaces struct board_t with dgnc_board.
It contains the exact same information as board_t.
This change was made because board_t isn't descriptive
and the _t denotes a typedef, which it is not.

Reported-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_cls.c| 14 +--
 drivers/staging/dgnc/dgnc_driver.c | 18 +++---
 drivers/staging/dgnc/dgnc_driver.h |  8 +++---
 drivers/staging/dgnc/dgnc_neo.c| 20 +++
 drivers/staging/dgnc/dgnc_sysfs.c  | 50 +++---
 drivers/staging/dgnc/dgnc_sysfs.h  |  6 ++---
 drivers/staging/dgnc/dgnc_tty.c| 38 ++---
 drivers/staging/dgnc/dgnc_tty.h|  6 ++---
 8 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 117e158..22875c1 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -43,7 +43,7 @@
 #include dgnc_tty.h
 #include dgnc_trace.h
 
-static inline void cls_parse_isr(struct board_t *brd, uint port);
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port);
 static inline void cls_clear_break(struct channel_t *ch, int force);
 static inline void cls_set_cts_flow_control(struct channel_t *ch);
 static inline void cls_set_rts_flow_control(struct channel_t *ch);
@@ -53,7 +53,7 @@ static inline void cls_set_no_output_flow_control(struct 
channel_t *ch);
 static inline void cls_set_no_input_flow_control(struct channel_t *ch);
 static void cls_parse_modem(struct channel_t *ch, uchar signals);
 static void cls_tasklet(unsigned long data);
-static void cls_vpd(struct board_t *brd);
+static void cls_vpd(struct dgnc_board *brd);
 static void cls_uart_init(struct channel_t *ch);
 static void cls_uart_off(struct channel_t *ch);
 static int cls_drain(struct tty_struct *tty, uint seconds);
@@ -393,7 +393,7 @@ static inline void cls_clear_break(struct channel_t *ch, 
int force)
 
 
 /* Parse the ISR register for the specific port */
-static inline void cls_parse_isr(struct board_t *brd, uint port)
+static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
 {
struct channel_t *ch;
uchar isr = 0;
@@ -477,7 +477,7 @@ static void cls_param(struct tty_struct *tty)
uchar uart_ier = 0;
 uint baud = 9600;
int quot = 0;
-struct board_t *bd;
+struct dgnc_board *bd;
struct channel_t *ch;
 struct un_t   *un;
 
@@ -725,7 +725,7 @@ static void cls_param(struct tty_struct *tty)
  */
 static void cls_tasklet(unsigned long data)
 {
-struct board_t *bd = (struct board_t *) data;
+struct dgnc_board *bd = (struct dgnc_board *) data;
struct channel_t *ch;
ulong  lock_flags;
int i;
@@ -802,7 +802,7 @@ static void cls_tasklet(unsigned long data)
  */
 static irqreturn_t cls_intr(int irq, void *voidbrd)
 {
-   struct board_t *brd = (struct board_t *) voidbrd;
+   struct dgnc_board *brd = (struct dgnc_board *) voidbrd;
uint i = 0;
uchar poll_reg;
unsigned long lock_flags;
@@ -1378,7 +1378,7 @@ static void cls_send_immediate_char(struct channel_t *ch, 
unsigned char c)
writeb(c, ch-ch_cls_uart-txrx);
 }
 
-static void cls_vpd(struct board_t *brd)
+static void cls_vpd(struct dgnc_board *brd)
 {
 ulong   vpdbase;/* Start of io base of the card */
 u8 __iomem   *re_map_vpdbase;/* Remapped memory of the card */
diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 9dee64c..4d90ba3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -71,16 +71,16 @@ PARM_INT(trcbuf_size,   0x10,   0644,   
Debugging trace buffer size.);
  *
  */
 static int dgnc_start(void);
-static int dgnc_finalize_board_init(struct board_t *brd);
+static int dgnc_finalize_board_init(struct dgnc_board *brd);
 static voiddgnc_init_globals(void);
 static int dgnc_found_board(struct pci_dev *pdev, int id);
-static voiddgnc_cleanup_board(struct board_t *brd);
+static voiddgnc_cleanup_board(struct dgnc_board *brd);
 static voiddgnc_poll_handler(ulong dummy);
 static int dgnc_init_pci(void);
 static int dgnc_init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent);
 static voiddgnc_remove_one(struct pci_dev *dev);
 static int dgnc_probe1(struct pci_dev *pdev, int card_type);
-static voiddgnc_do_remap(struct board_t *brd);
+static voiddgnc_do_remap(struct dgnc_board *brd);
 
 /* Driver load/unload functions */
 intdgnc_init_module(void);
@@ -106,7 +106,7 @@ static struct file_operations dgnc_BoardFops =
  * Globals
  */
 uint   dgnc_NumBoards;
-struct board_t

[PATCH 08/12] staging: dgnc: driver.c: checkpatch: removes parentheses around return statements

2013-08-31 Thread Lidza Louina
This patch removes this checkpatch warning:
ERROR: return is not a function, parentheses are not
required.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 102 ++---
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 15896b0..88e252e 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -225,7 +225,7 @@ int dgnc_init_module(void)
rc = dgnc_start();
 
if (rc  0) {
-   return(rc);
+   return rc;
}
 
/*
@@ -250,7 +250,7 @@ int dgnc_init_module(void)
}
 
DPR_INIT((Finished init_module. Returning %d\n, rc));
-   return (rc);
+   return rc;
 }
 
 
@@ -286,7 +286,7 @@ static int dgnc_start(void)
if (rc = 0) {
APR((Can't register dgnc driver device 
(%d)\n, rc));
rc = -ENXIO;
-   return(rc);
+   return rc;
}
dgnc_Major = rc;
 
@@ -311,7 +311,7 @@ static int dgnc_start(void)
 
if (rc  0) {
APR((tty preinit - not enough memory (%d)\n, rc));
-   return(rc);
+   return rc;
}
 
/* Start the poller */
@@ -328,7 +328,7 @@ static int dgnc_start(void)
dgnc_driver_state = DRIVER_READY;
}
 
-   return(rc);
+   return rc;
 }
 
 /*
@@ -653,7 +653,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
default:
APR((Did not find any compatible Neo or Classic PCI boards in 
system.\n));
-   return (-ENXIO);
+   return -ENXIO;
 
}
 
@@ -715,11 +715,11 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(brd-state_wait);
 
-   return(0);
+   return 0;
 
 failed:
 
-   return (-ENXIO);
+   return -ENXIO;
 
 }
 
@@ -730,7 +730,7 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) 
{
DPR_INIT((dgnc_finalize_board_init() - start\n));
 
if (!brd || brd-magic != DGNC_BOARD_MAGIC)
-   return(-ENODEV);
+   return -ENODEV;
 
DPR_INIT((dgnc_finalize_board_init() - start #2\n));
 
@@ -746,7 +746,7 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) 
{
DPR_INIT((Requested and received usage of IRQ %d\n, 
brd-irq));
}
}
-   return(rc);
+   return rc;
 }
 
 /*
@@ -890,7 +890,7 @@ int dgnc_ms_sleep(ulong ms)
 {
current-state = TASK_INTERRUPTIBLE;
schedule_timeout((ms * HZ) / 1000);
-   return (signal_pending(current));
+   return signal_pending(current);
 }
 
 
@@ -902,47 +902,47 @@ char *dgnc_ioctl_name(int cmd)
 {
switch(cmd) {
 
-   case TCGETA:return(TCGETA);
-   case TCGETS:return(TCGETS);
-   case TCSETA:return(TCSETA);
-   case TCSETS:return(TCSETS);
-   case TCSETAW:   return(TCSETAW);
-   case TCSETSW:   return(TCSETSW);
-   case TCSETAF:   return(TCSETAF);
-   case TCSETSF:   return(TCSETSF);
-   case TCSBRK:return(TCSBRK);
-   case TCXONC:return(TCXONC);
-   case TCFLSH:return(TCFLSH);
-   case TIOCGSID:  return(TIOCGSID);
-
-   case TIOCGETD:  return(TIOCGETD);
-   case TIOCSETD:  return(TIOCSETD);
-   case TIOCGWINSZ:return(TIOCGWINSZ);
-   case TIOCSWINSZ:return(TIOCSWINSZ);
-
-   case TIOCMGET:  return(TIOCMGET);
-   case TIOCMSET:  return(TIOCMSET);
-   case TIOCMBIS:  return(TIOCMBIS);
-   case TIOCMBIC:  return(TIOCMBIC);
+   case TCGETA:return TCGETA;
+   case TCGETS:return TCGETS;
+   case TCSETA:return TCSETA;
+   case TCSETS:return TCSETS;
+   case TCSETAW:   return TCSETAW;
+   case TCSETSW:   return TCSETSW;
+   case TCSETAF:   return TCSETAF;
+   case TCSETSF:   return TCSETSF;
+   case TCSBRK:return TCSBRK;
+   case TCXONC:return TCXONC;
+   case TCFLSH:return TCFLSH;
+   case TIOCGSID:  return TIOCGSID;
+
+   case TIOCGETD:  return TIOCGETD;
+   case TIOCSETD:  return TIOCSETD;
+   case TIOCGWINSZ:return TIOCGWINSZ;
+   case TIOCSWINSZ:return TIOCSWINSZ;
+
+   case TIOCMGET:  return TIOCMGET;
+   case TIOCMSET:  return TIOCMSET;
+   case TIOCMBIS:  return TIOCMBIS;
+   case TIOCMBIC:  return TIOCMBIC

[PATCH 05/12] staging: dgnc: driver.h: removes struct board_t

2013-08-31 Thread Lidza Louina
This patch removes the struct board_t. This struct
was replaced with dgnc_board in a previous patch.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.h | 85 --
 1 file changed, 85 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 3d0394d..d4a830b 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -282,91 +282,6 @@ struct board_ops {
 /*
  * Per-board information
  */
-struct board_t {
-   int magic;  /* Board Magic number.  */
-   int boardnum;   /* Board number: 0-32 */
-
-   int type;   /* Type of board */
-   char*name;  /* Product Name */
-   struct pci_dev  *pdev;  /* Pointer to the pci_dev struct */
-   unsigned long   bd_flags;   /* Board flags */
-   u16 vendor; /* PCI vendor ID */
-   u16 device; /* PCI device ID */
-   u16 subvendor;  /* PCI subsystem vendor ID */
-   u16 subdevice;  /* PCI subsystem device ID */
-   uchar   rev;/* PCI revision ID */
-   uintpci_bus;/* PCI bus value */
-   uintpci_slot;   /* PCI slot value */
-   uintmaxports;   /* MAX ports this board can handle */
-   uchar   dvid;   /* Board specific device id */
-   uchar   vpd[128];   /* VPD of board, if found */
-   uchar   serial_num[20]; /* Serial number of board, if found in 
VPD */
-
-   spinlock_t  bd_lock;/* Used to protect board */
-
-   spinlock_t  bd_intr_lock;   /* Used to protect the poller tasklet 
and
-* the interrupt routine from each 
other.
-*/
-
-   uintstate;  /* State of card. */
-   wait_queue_head_t state_wait;   /* Place to sleep on for state change */
-
-   struct  tasklet_struct helper_tasklet; /* Poll helper tasklet */
-
-   uintnasync; /* Number of ports on card */
-
-   uintirq;/* Interrupt request number */
-   ulong   intr_count; /* Count of interrupts */
-   ulong   intr_modem; /* Count of interrupts */
-   ulong   intr_tx;/* Count of interrupts */
-   ulong   intr_rx;/* Count of interrupts */
-
-   ulong   membase;/* Start of base memory of the card */
-   ulong   membase_end;/* End of base memory of the card */
-
-   u8 __iomem  *re_map_membase;/* Remapped memory of the card 
*/
-
-   ulong   iobase; /* Start of io base of the card */
-   ulong   iobase_end; /* End of io base of the card */
-
-   uintbd_uart_offset; /* Space between each UART */
-
-   struct channel_t *channels[MAXPORTS]; /* array of pointers to our 
channels. */
-
-   struct tty_driver   SerialDriver;
-   charSerialName[200];
-   struct tty_driver   PrintDriver;
-   charPrintName[200];
-
-   uintdgnc_Major_Serial_Registered;
-   uintdgnc_Major_TransparentPrint_Registered;
-
-   uintdgnc_Serial_Major;
-   uintdgnc_TransparentPrint_Major;
-
-   uintTtyRefCnt;
-
-   char*flipbuf;   /* Our flip buffer, alloced if board is 
found */
-
-   u16 dpatype;/* The board type, as defined by DPA 
*/
-   u16 dpastatus;  /* The board status, as defined by 
DPA */
-
-   /*
-*  Mgmt data.
-*/
-   char*msgbuf_head;
-   char*msgbuf;
-
-   uintbd_dividend;/* Board/UARTs specific dividend */
-
-   struct board_ops *bd_ops;
-
-   /* /proc/board entries */
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_board_table;
-
-};
-
 struct dgnc_board {
int magic;  /* Board Magic number.  */
int boardnum;   /* Board number: 0-32 */
-- 
1.8.1.2

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


[PATCH] staging: dgnc: adds TODO

2013-08-29 Thread Lidza Louina
This patchs adds a TODO for the driver.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/TODO | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 drivers/staging/dgnc/TODO

diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO
new file mode 100644
index 000..1ff2d18
--- /dev/null
+++ b/drivers/staging/dgnc/TODO
@@ -0,0 +1,17 @@
+* remove kzalloc casts
+* checkpatch fixes
+* sparse fixes
+* fix use of sizeof(). Example replace sizeof(struct board_t) 
+  with sizeof(*brd) and remove sizeof(char)
+* change name of board_t to dgnc_board
+* split two assignments into the two assignments on two lines;
+  don't use two equals signs
+* remove unecessary comments
+* remove unecessary error messages. Example kzalloc() has its 
+  own error message. Adding an extra one is useless.
+* use goto statements for error handling when appropriate
+* there is a lot of unecessary code in the driver. It was 
+  originally a standalone driver. Remove uneeded code.
+
+Please send patches to Greg Kroah-Hartman g...@kroah.com and 
+Cc: Lidza Louina lidza.lou...@gmail.com
-- 
1.8.1.2

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


Re: [PATCH v2 3/3] staging: dgnc: driver.c and .h: removes dgnc_driver_kzmalloc func

2013-08-28 Thread Lidza Louina
On Wed, Aug 28, 2013 at 12:57 AM, Greg KH gre...@linuxfoundation.org wrote:
 On Tue, Aug 27, 2013 at 10:13:28PM -0400, Lidza Louina wrote:
 This patch removes the dgnc_driver_kzmalloc function from
 driver.c and driver.h. A previous patch replaced all
 dgnc_driver_kzmalloc function calls with kzalloc.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_driver.c | 15 ---
  drivers/staging/dgnc/dgnc_driver.h |  1 -
  2 files changed, 16 deletions(-)

 This patch had to be edited by hand, due to some fuzz in it when
 applying to my tree.  That means I think we are out of sync again with
 what you have sent, and what I have applied.

 Can you resync on my tree again and resend anything I haven't applied,
 and then work from there, to make sure I didn't accidentally drop
 something you thought I applied?

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


Re: [PATCH v2 3/3] staging: dgnc: driver.c and .h: removes dgnc_driver_kzmalloc func

2013-08-28 Thread Lidza Louina
On Wed, Aug 28, 2013 at 6:34 PM, Lidza Louina lidza.lou...@gmail.com wrote:
 On Wed, Aug 28, 2013 at 12:57 AM, Greg KH gre...@linuxfoundation.org wrote:
 On Tue, Aug 27, 2013 at 10:13:28PM -0400, Lidza Louina wrote:
 This patch removes the dgnc_driver_kzmalloc function from
 driver.c and driver.h. A previous patch replaced all
 dgnc_driver_kzmalloc function calls with kzalloc.

 Signed-off-by: Lidza Louina lidza.lou...@gmail.com
 ---
  drivers/staging/dgnc/dgnc_driver.c | 15 ---
  drivers/staging/dgnc/dgnc_driver.h |  1 -
  2 files changed, 16 deletions(-)

 This patch had to be edited by hand, due to some fuzz in it when
 applying to my tree.  That means I think we are out of sync again with
 what you have sent, and what I have applied.

 Can you resync on my tree again and resend anything I haven't applied,
 and then work from there, to make sure I didn't accidentally drop
 something you thought I applied?

 Absolutely.

I just checked the branch and it seems that those three patches
were applied. I got an email about them too. Do you still need me
to resend them?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/3] staging: dgnc: driver.c and tty.c: replaces dgnc_driver_kzmalloc with kzalloc

2013-08-28 Thread Lidza Louina
On Wed, Aug 28, 2013 at 12:54 AM, Greg KH gre...@linuxfoundation.org wrote:
 I'll take this for now, but all of these casts of the kzalloc() call
 need to go away, as they are pointless (kzalloc() returns a void *,
 which automatically can be assigned to any pointer type, no need to be
 explicit about it.)

 So that means you'll get another patch accepted modifying these same
 lines now :)

Alrighty, I'll send patch with this change.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/3] staging: dgnc: driver.c and tty.c: replaces dgnc_driver_kzmalloc with kzalloc

2013-08-28 Thread Lidza Louina
On Wed, Aug 28, 2013 at 4:30 AM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Tue, Aug 27, 2013 at 10:13:27PM -0400, Lidza Louina wrote:
 @@ -501,7 +501,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)

   /* get the board structure and prep it */
   brd = dgnc_Board[dgnc_NumBoards] =
 - (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), 
 GFP_KERNEL);
 + (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
   if (!brd) {
   APR((memory allocation for board structure failed\n));
   return(-ENOMEM);

 So you didn't introduce this, but here are the style problems in this
 section, in case you want to fix them in a later patch.

 1) Bad indenting.

I'll fix this when I work on checkpatch warnings.

 2) Unneeded casting.

I'll send a patch for this soon.

 3) Use sizeof(*brd) instead of sizeof(struct board_t).

Okay.

 4) board_t is a bad and wrong name for this data type.  board is too
generic, and _t means typedef but this is a not a typedef.

Okay, I'll change it to dgnc_board.

 5) Put the two assignments on two lines.  First assign brd and then
initialize dgnc_Board[dgnc_NumBoards] after allocating
brd-msgbuf.

Okay.

 6) Comment is obvious and at the same time wrong.  It means allocate
the board structure instead of get.  Delete.

Okay.

 7) kmalloc() has its own error message which is much more useful.  No
need to print a useless error message.  Also this error will never
occur in real life so adding code for something which will never
happen and it's a waste of time for people reading the code.

Okay, I'll remove that.

 8) No parenthesis around the return.

Okay, I'll fix this when I work on checkpatch warnings.

 @@ -509,7 +509,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)

   /* make a temporary message buffer for the boot messages */
   brd-msgbuf = brd-msgbuf_head =
 - (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL);
 + (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
   if (!brd-msgbuf) {
   kfree(brd);
   APR((memory allocation for board msgbuf failed\n));

 9)  I think we know the sizeof(char)...  If we want to keep that then
 use kcalloc() instead of kzalloc().  But it's simplest to just say:

 brd-msgbuf = kzalloc(8192, GFP_KERNEL);

Okay.

 10) The error handling should be:

 if (!brd-msgbuf) {
 ret = -ENOMEM;
 goto err_free_brd;
 }

 [snip code in the middle]

 return 0;

 err_free_brd:
 kfree(brd);

 return ret;

 We leak memory later on in this function...

Okay, I'll replace error handling with goto statements
where it is appropriate.

Thanks for the feedback.

I'm going to be making a TODO for this driver. If there's
anything else I can do to fix it, let me know.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 08/12] staging: dgap: tty.c: fixes ioctl param list

2013-08-27 Thread Lidza Louina
On Fri, Aug 23, 2013 at 4:23 PM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Aug 21, 2013 at 09:48:38PM -0400, Lidza Louina wrote:
 -static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, 
 unsigned int cmd,
 +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
   unsigned long arg)

 Btw, now that this file compiles I see it in my static checker runs.

 dgap_tty_ioctl() takes a lock but always returns before unlocking.

  {
   struct board_t *bd;
 @@ -3423,41 +3423,6 @@ static int dgap_tty_ioctl(struct tty_struct *tty, 
 struct file *file, unsigned in

   return(-ENOIOCTLCMD);

 In other words, these return statements should be breaks so we hit
 the call to:

 DGNC_UNLOCK(ch-ch_lock, lock_flags);

Hmm, I looked thru the code a few times, and it seems like
it unlocks before every return. Can you paste an example
where it does this?

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


Re: [PATCH 08/12] staging: dgap: tty.c: fixes ioctl param list

2013-08-27 Thread Lidza Louina
On Tue, Aug 27, 2013 at 1:25 PM, Mark Hounschell ma...@compro.net wrote:
 On 08/27/2013 01:20 PM, Lidza Louina wrote:

 On Fri, Aug 23, 2013 at 4:23 PM, Dan Carpenter dan.carpen...@oracle.com
 wrote:

 On Wed, Aug 21, 2013 at 09:48:38PM -0400, Lidza Louina wrote:

 -static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file,
 unsigned int cmd,
 +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
unsigned long arg)


 Btw, now that this file compiles I see it in my static checker runs.

 dgap_tty_ioctl() takes a lock but always returns before unlocking.

   {
struct board_t *bd;
 @@ -3423,41 +3423,6 @@ static int dgap_tty_ioctl(struct tty_struct *tty,
 struct file *file, unsigned in

return(-ENOIOCTLCMD);


 In other words, these return statements should be breaks so we hit
 the call to:

  DGNC_UNLOCK(ch-ch_lock, lock_flags);


 Hmm, I looked thru the code a few times, and it seems like
 it unlocks before every return. Can you paste an example
 where it does this?


 FYI, there is no DGNC_UNLOCK in the dgap driver? Maybe he was looking at the
 dgnc while commenting on the dgap??? Just a guess.

 Mark

Ah, ok, I don't see anything unusual in that file either. I'll wait
to see what he was talking about.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: tty.c: updates uart_struct declaration for sparse

2013-08-27 Thread Lidza Louina
This patch edits the type casts neo_uart_struct and
cls_uart_struct. A previous patch added the marker __iomem
to these structs. This patch ensures that the change to
the marker is consistent. This also removes these
sparse warnings:

warning: incorrect type in assignment (different address spaces)
  expected struct neo_uart_struct [noderef] asn:2*ch_neo_uart
  got struct neo_uart_struct *noident
warning: incorrect type in assignment (different address spaces)
  expected struct cls_uart_struct [noderef] asn:2*ch_cls_uart
  got struct cls_uart_struct *noident

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_tty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a54b829..b4fa29f 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -344,7 +344,7 @@ int dgnc_tty_register(struct board_t *brd)
 int dgnc_tty_init(struct board_t *brd)
 {
int i;
-   u8 __iomem *vaddr;
+   void __iomem *vaddr;
struct channel_t *ch;
 
if (!brd)
@@ -403,9 +403,9 @@ int dgnc_tty_init(struct board_t *brd)
ch-ch_pun.un_dev = i + 128;
 
if (brd-bd_uart_offset == 0x200)
-   ch-ch_neo_uart = (struct neo_uart_struct *) ((ulong) 
vaddr + (brd-bd_uart_offset * i));
+   ch-ch_neo_uart = vaddr + (brd-bd_uart_offset * i);
else
-   ch-ch_cls_uart = (struct cls_uart_struct *) ((ulong) 
vaddr + (brd-bd_uart_offset * i));
+   ch-ch_cls_uart = vaddr + (brd-bd_uart_offset * i);
 
ch-ch_bd = brd;
ch-ch_portnum = i;
-- 
1.8.1.2

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


[PATCH 2/2] staging: dgnc: driver.c and tty.c: replaces dgnc_driver_kzmalloc with kzalloc

2013-08-27 Thread Lidza Louina
This patch replaces dgnc_driver_kzmalloc with kzalloc. A
previous patch removed that function from the code.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c |  6 +++---
 drivers/staging/dgnc/dgnc_tty.c| 20 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index b8a7597..8828dc9 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -501,7 +501,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), 
GFP_KERNEL);
+   (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return(-ENOMEM);
@@ -509,7 +509,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL);
+   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
@@ -727,7 +727,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 * Okay to malloc with GFP_KERNEL, we are not at interrupt
 * context, and there are no locks held.
 */
-   brd-flipbuf = dgnc_driver_kzmalloc(MYFLIPLEN, GFP_KERNEL);
+   brd-flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
 
wake_up_interruptible(brd-state_wait);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index b4fa29f..a7bb6bc 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -230,7 +230,7 @@ int dgnc_tty_register(struct board_t *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return(-ENOMEM);
 
@@ -240,12 +240,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(brd-SerialDriver.kref);
 #endif
 
-   brd-SerialDriver.termios = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return(-ENOMEM);
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-SerialDriver.termios_locked = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios_locked = kzalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios_locked)
return(-ENOMEM);
 #endif
@@ -289,7 +289,7 @@ int dgnc_tty_register(struct board_t *brd)
 * tty_struct's and termios's.  Must be seperate from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return(-ENOMEM);
 
@@ -299,12 +299,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(brd-PrintDriver.kref);
 #endif
 
-   brd-PrintDriver.termios = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return(-ENOMEM);
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-PrintDriver.termios_locked = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios_locked = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-PrintDriver.termios_locked)
return(-ENOMEM);
 #endif
@@ -371,7 +371,7 @@ int dgnc_tty_init(struct board_t *brd)
 * Okay to malloc with GFP_KERNEL, we are not at
 * interrupt context, and there are no locks held.
 */
-   brd-channels[i] = dgnc_driver_kzmalloc(sizeof(struct 
channel_t), GFP_KERNEL);
+   brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
if (!brd-channels[i]) {
DPR_CORE((%s:%d Unable to allocate memory for 
channel

[PATCH v2 2/3] staging: dgnc: driver.c and tty.c: replaces dgnc_driver_kzmalloc with kzalloc

2013-08-27 Thread Lidza Louina
This patch replaces dgnc_driver_kzmalloc with kzalloc.
A patch that follows removes the dgnc_driver_kzmalloc
function.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c |  6 +++---
 drivers/staging/dgnc/dgnc_tty.c| 20 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 8032368..4226f09 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -501,7 +501,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
-   (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), 
GFP_KERNEL);
+   (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
if (!brd) {
APR((memory allocation for board structure failed\n));
return(-ENOMEM);
@@ -509,7 +509,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/* make a temporary message buffer for the boot messages */
brd-msgbuf = brd-msgbuf_head =
-   (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL);
+   (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
if (!brd-msgbuf) {
kfree(brd);
APR((memory allocation for board msgbuf failed\n));
@@ -727,7 +727,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 * Okay to malloc with GFP_KERNEL, we are not at interrupt
 * context, and there are no locks held.
 */
-   brd-flipbuf = dgnc_driver_kzmalloc(MYFLIPLEN, GFP_KERNEL);
+   brd-flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
 
wake_up_interruptible(brd-state_wait);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index b4fa29f..a7bb6bc 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -230,7 +230,7 @@ int dgnc_tty_register(struct board_t *brd)
 * The kernel wants space to store pointers to
 * tty_struct's and termios's.
 */
-   brd-SerialDriver.ttys = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   brd-SerialDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
return(-ENOMEM);
 
@@ -240,12 +240,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(brd-SerialDriver.kref);
 #endif
 
-   brd-SerialDriver.termios = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios)
return(-ENOMEM);
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-SerialDriver.termios_locked = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-SerialDriver.termios_locked = kzalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
if (!brd-SerialDriver.termios_locked)
return(-ENOMEM);
 #endif
@@ -289,7 +289,7 @@ int dgnc_tty_register(struct board_t *brd)
 * tty_struct's and termios's.  Must be seperate from
 * the Serial Driver so we don't get confused
 */
-   brd-PrintDriver.ttys = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct tty_struct *), GFP_KERNEL);
+   brd-PrintDriver.ttys = kzalloc(brd-maxports * sizeof(struct 
tty_struct *), GFP_KERNEL);
if (!brd-PrintDriver.ttys)
return(-ENOMEM);
 
@@ -299,12 +299,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(brd-PrintDriver.kref);
 #endif
 
-   brd-PrintDriver.termios = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-PrintDriver.termios)
return(-ENOMEM);
 
 #if LINUX_VERSION_CODE  KERNEL_VERSION(3,0,0)
-   brd-PrintDriver.termios_locked = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct ktermios *), GFP_KERNEL);
+   brd-PrintDriver.termios_locked = kzalloc(brd-maxports * sizeof(struct 
ktermios *), GFP_KERNEL);
if (!brd-PrintDriver.termios_locked)
return(-ENOMEM);
 #endif
@@ -371,7 +371,7 @@ int dgnc_tty_init(struct board_t *brd)
 * Okay to malloc with GFP_KERNEL, we are not at
 * interrupt context, and there are no locks held.
 */
-   brd-channels[i] = dgnc_driver_kzmalloc(sizeof(struct 
channel_t), GFP_KERNEL);
+   brd-channels[i] = kzalloc(sizeof(struct channel_t), 
GFP_KERNEL);
if (!brd-channels[i]) {
DPR_CORE((%s:%d Unable to allocate memory

[PATCH v2 1/3] staging: dgnc: tty.c: updates uart_struct declaration for sparse

2013-08-27 Thread Lidza Louina
This patch edits the type casts neo_uart_struct and
cls_uart_struct. A previous patch added the marker __iomem
to these structs. This patch ensures that the change to
the marker is consistent. This also removes these
sparse warnings:

warning: incorrect type in assignment (different address spaces)
  expected struct neo_uart_struct [noderef] asn:2*ch_neo_uart
  got struct neo_uart_struct *noident
warning: incorrect type in assignment (different address spaces)
  expected struct cls_uart_struct [noderef] asn:2*ch_cls_uart
  got struct cls_uart_struct *noident

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_tty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a54b829..b4fa29f 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -344,7 +344,7 @@ int dgnc_tty_register(struct board_t *brd)
 int dgnc_tty_init(struct board_t *brd)
 {
int i;
-   u8 __iomem *vaddr;
+   void __iomem *vaddr;
struct channel_t *ch;
 
if (!brd)
@@ -403,9 +403,9 @@ int dgnc_tty_init(struct board_t *brd)
ch-ch_pun.un_dev = i + 128;
 
if (brd-bd_uart_offset == 0x200)
-   ch-ch_neo_uart = (struct neo_uart_struct *) ((ulong) 
vaddr + (brd-bd_uart_offset * i));
+   ch-ch_neo_uart = vaddr + (brd-bd_uart_offset * i);
else
-   ch-ch_cls_uart = (struct cls_uart_struct *) ((ulong) 
vaddr + (brd-bd_uart_offset * i));
+   ch-ch_cls_uart = vaddr + (brd-bd_uart_offset * i);
 
ch-ch_bd = brd;
ch-ch_portnum = i;
-- 
1.8.1.2

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


[PATCH] staging: dgnc: neo_uart_struct: adds marker and changes vars' types for sparse

2013-08-26 Thread Lidza Louina
This patch fixes these warnings found in the neo.c file:

warning: incorrect type in argument 1 (different address spaces)
  expected void const volatile [noderef] asn:2*addr
  got unsigned char volatile *noident
warning: incorrect type in argument 2 (different address spaces)
  expected void volatile [noderef] asn:2*addr
  got unsigned char volatile *noident

The variables passed to readb and writeb need to
be of type u8 with a __iomem marker. These warnings
were popping up everytime the readb and writeb
functions were called with a neo_uart_struct variable.

The change made to the driver.h file adds the marker
to the neo_uart_struct and the changes in neo.h
changes the variables' types.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.h |  2 +-
 drivers/staging/dgnc/dgnc_neo.h| 42 +++---
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 6644e95..953d904 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -480,7 +480,7 @@ struct channel_t {
uchar   ch_mostat;  /* FEP output modem status  */
uchar   ch_mistat;  /* FEP input modem status   */
 
-   struct neo_uart_struct *ch_neo_uart;/* Pointer to the mapped UART 
struct */
+   struct neo_uart_struct __iomem *ch_neo_uart;/* Pointer to the 
mapped UART struct */
struct cls_uart_struct __iomem *ch_cls_uart;/* Pointer to the 
mapped UART struct */
 
uchar   ch_cached_lsr;  /* Cached value of the LSR register */
diff --git a/drivers/staging/dgnc/dgnc_neo.h b/drivers/staging/dgnc/dgnc_neo.h
index f7f569b..7ec5710 100644
--- a/drivers/staging/dgnc/dgnc_neo.h
+++ b/drivers/staging/dgnc/dgnc_neo.h
@@ -36,27 +36,27 @@
  /
 
 struct neo_uart_struct {
-   volatile uchar txrx;/* WR  RHR/THR - Holding Reg */
-   volatile uchar ier; /* WR  IER - Interrupt Enable Reg */
-   volatile uchar isr_fcr; /* WR  ISR/FCR - Interrupt Status 
Reg/Fifo Control Reg */
-   volatile uchar lcr; /* WR  LCR - Line Control Reg */
-   volatile uchar mcr; /* WR  MCR - Modem Control Reg */
-   volatile uchar lsr; /* WR  LSR - Line Status Reg */
-   volatile uchar msr; /* WR  MSR - Modem Status Reg */
-   volatile uchar spr; /* WR  SPR - Scratch Pad Reg */
-   volatile uchar fctr;/* WR  FCTR - Feature Control Reg */
-   volatile uchar efr; /* WR  EFR - Enhanced Function Reg */
-   volatile uchar tfifo;   /* WR  TXCNT/TXTRG - Transmit FIFO Reg 
*/
-   volatile uchar rfifo;   /* WR  RXCNT/RXTRG - Recieve  FIFO Reg 
*/
-   volatile uchar xoffchar1;   /* WR  XOFF 1 - XOff Character 1 Reg */
-   volatile uchar xoffchar2;   /* WR  XOFF 2 - XOff Character 2 Reg */
-   volatile uchar xonchar1;/* WR  XON 1 - Xon Character 1 Reg */
-   volatile uchar xonchar2;/* WR  XON 2 - XOn Character 2 Reg */
-
-   volatile uchar reserved1[0x2ff - 0x200]; /* U   Reserved by Exar */
-   volatile uchar txrxburst[64];   /* RW  64 bytes of RX/TX FIFO Data */
-   volatile uchar reserved2[0x37f - 0x340]; /* U   Reserved by Exar */
-   volatile uchar rxburst_with_errors[64]; /* R  64 bytes of RX FIFO Data 
+ LSR */
+   u8 txrx;/* WR  RHR/THR - Holding Reg */
+   u8 ier; /* WR  IER - Interrupt Enable Reg */
+   u8 isr_fcr; /* WR  ISR/FCR - Interrupt Status Reg/Fifo 
Control Reg */
+   u8 lcr; /* WR  LCR - Line Control Reg */
+   u8 mcr; /* WR  MCR - Modem Control Reg */
+   u8 lsr; /* WR  LSR - Line Status Reg */
+   u8 msr; /* WR  MSR - Modem Status Reg */
+   u8 spr; /* WR  SPR - Scratch Pad Reg */
+   u8 fctr;/* WR  FCTR - Feature Control Reg */
+   u8 efr; /* WR  EFR - Enhanced Function Reg */
+   u8 tfifo;   /* WR  TXCNT/TXTRG - Transmit FIFO Reg */
+   u8 rfifo;   /* WR  RXCNT/RXTRG - Recieve  FIFO Reg */
+   u8 xoffchar1;   /* WR  XOFF 1 - XOff Character 1 Reg */
+   u8 xoffchar2;   /* WR  XOFF 2 - XOff Character 2 Reg */
+   u8 xonchar1;/* WR  XON 1 - Xon Character 1 Reg */
+   u8 xonchar2;/* WR  XON 2 - XOn Character 2 Reg */
+
+   u8 reserved1[0x2ff - 0x200]; /* U   Reserved by Exar */
+   u8 txrxburst[64];   /* RW  64 bytes of RX/TX FIFO Data */
+   u8 reserved2[0x37f - 0x340]; /* U   Reserved by Exar */
+   u8 rxburst_with_errors[64]; /* R  64 bytes of RX FIFO Data + LSR */
 };
 
 /* Where to read the extended interrupt register (32bits instead of 8bits) */
-- 
1.8.1.2

[PATCH] staging: dgnc: tty.c: edits var in init func for sparse

2013-08-26 Thread Lidza Louina
This patch edits the vaddr variable in dgnc_tty_init.
The variable gets set to board_t-re_map_membase. A
previous patch changed the re_map_membase variable's
marker and type. This patch makes sure that the
changes are consistent and that it doesn't cause
sparse warnings.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f0ecc65..a54b829 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -344,7 +344,7 @@ int dgnc_tty_register(struct board_t *brd)
 int dgnc_tty_init(struct board_t *brd)
 {
int i;
-   uchar *vaddr;
+   u8 __iomem *vaddr;
struct channel_t *ch;
 
if (!brd)
-- 
1.8.1.2

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


[PATCH] staging: dgnc: driver.c: include slab.h

2013-08-24 Thread Lidza Louina
This patch adds the slab.h dependency to driver.c. The code
was causing these errors:

drivers/staging/dgnc/dgnc_driver.c: In function 'dgnc_cleanup_board':
 drivers/staging/dgnc/dgnc_driver.c:461:3: error: implicit declaration
of function 'kfree' [-Werror=implicit-function-declaration]
drivers/staging/dgnc/dgnc_driver.c: In function 'dgnc_driver_kzmalloc':
 drivers/staging/dgnc/dgnc_driver.c:907:3: error: implicit declaration
of function 'kmalloc' [-Werror=implicit-function-declaration]
 drivers/staging/dgnc/dgnc_driver.c:907:13: warning: initialization
makes pointer from integer without a cast [enabled by default]

Reported-by: Fengguang Wu fengguang...@intel.com
Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 2152f31..ff046cc 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -33,6 +33,7 @@
 #include linux/kernel.h
 #include linux/version.h
 #include linux/module.h
+#include linux/slab.h
 #include linux/pci.h
 
 #if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,39)
-- 
1.8.1.2

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


Re: [PATCH 08/12] staging: dgap: tty.c: fixes ioctl param list

2013-08-23 Thread Lidza Louina
On Fri, Aug 23, 2013 at 4:47 AM, Dan Carpenter dan.carpen...@oracle.com wrote:
 On Wed, Aug 21, 2013 at 09:48:38PM -0400, Lidza Louina wrote:
 The declaration for the ioctl function has changed. The previous version
 of this declaration took struct file *file as a parameter and the new
 one does not. This patch removes that parameter.

 It also removes cases for the commands TIOCGETP
 TCGETS and TCGETA.

 These should be in two separate patches.  Normally I would say to
 resend it, but since this driver doesn't compile I don't care very
 much.

Ok, I can see why that's important. I'll break up my future patches
to do just one thing at a time. Also, the driver has been added to
the build.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: driver.c: removes dgnc_mbuf function

2013-08-22 Thread Lidza Louina
This patch removes the dgnc_mbuf function. This function was causing the
errors:

drivers/staging/dgnc/dgnc_driver.c: In function 'dgnc_mbuf.constprop.0':
drivers/staging/dgnc/dgnc_driver.c:945:1: warning: the frame size of 1032
bytes is larger than 1024 bytes [-Wframe-larger-than=]

drivers/staging/dgnc/dgnc_tty.c: In function 'dgnc_sniff_nowait_nolock':
drivers/staging/dgnc/dgnc_tty.c:614:1: warning: the frame size of 1056
bytes is larger than 1024 bytes [-Wframe-larger-than=]

This patch removes it so the kernel won't be making noise when its
device is found on the system.

Reported-by: Fengguang Wu fengguang...@intel.com
Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 40 --
 1 file changed, 40 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index fa4e91a..2152f31 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -80,8 +80,6 @@ static intdgnc_init_one(struct pci_dev *pdev, 
const struct pci_device_id *ent)
 static voiddgnc_remove_one(struct pci_dev *dev);
 static int dgnc_probe1(struct pci_dev *pdev, int card_type);
 static voiddgnc_do_remap(struct board_t *brd);
-static voiddgnc_mbuf(struct board_t *brd, const char *fmt, ...);
-
 
 /* Driver load/unload functions */
 intdgnc_init_module(void);
@@ -708,10 +706,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
/* init our poll helper tasklet */
tasklet_init(brd-helper_tasklet, brd-bd_ops-tasklet, (unsigned 
long) brd);
 
-/* Log the information about the board */
-   dgnc_mbuf(brd, DRVSTR: board %d: %s (rev %d), irq %d\n,
-   dgnc_NumBoards, brd-name, brd-rev, brd-irq);
-
DPR_INIT((dgnc_scan(%d) - printing out the msgbuf\n, i));
DGNC_LOCK(dgnc_global_lock, flags);
brd-msgbuf = NULL;
@@ -910,40 +904,6 @@ void *dgnc_driver_kzmalloc(size_t size, int priority)
 
 
 /*
- * dgnc_mbuf()
- *
- * Used to print to the message buffer during board init.
- */
-static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...) {
-   va_list ap;
-   charbuf[1024];
-   int i;
-   unsigned long   flags;
-
-   DGNC_LOCK(dgnc_global_lock, flags);
-
-   /* Format buf using fmt and arguments contained in ap. */
-   va_start(ap, fmt);
-   i = vsprintf(buf, fmt,  ap);
-   va_end(ap);
-
-   DPR((buf));
-
-   if (!brd || !brd-msgbuf) {
-   printk(buf);
-   DGNC_UNLOCK(dgnc_global_lock, flags);
-   return;
-   }
-
-   memcpy(brd-msgbuf, buf, strlen(buf));
-   brd-msgbuf += strlen(buf);
-   *brd-msgbuf = '\0';
-
-   DGNC_UNLOCK(dgnc_global_lock, flags);
-}
-
-
-/*
  * dgnc_ms_sleep()
  *
  * Put the driver to sleep for x ms's
-- 
1.8.1.2

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


[PATCH 1/3] staging: dgap: removes references to mgmt code

2013-08-22 Thread Lidza Louina
This patch removes references to mgmt functions from
the code. The files mgmt.c and mgmt.h will be
removed in the patches that follow.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index 0e09ce3..ed56d02 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -102,9 +102,6 @@ module_exit(dgap_cleanup_module);
 static struct file_operations DgapBoardFops =
 {
.owner  =   THIS_MODULE,
-.unlocked_ioctl =  dgap_mgmt_ioctl,
-   .open   =   dgap_mgmt_open,
-   .release=   dgap_mgmt_close
 };
 
 
-- 
1.8.1.2

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


[PATCH 3/3] staging: dgap: removes mgmt.h

2013-08-22 Thread Lidza Louina
This patch removes mgmt.h and the headers that include
it of files in dgap. This file isn't needed for the
driver to work with the kernel.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c |  1 -
 drivers/staging/dgap/dgap_fep5.c   |  1 -
 drivers/staging/dgap/dgap_mgmt.h   | 33 -
 drivers/staging/dgap/dgap_proc.c   |  1 -
 drivers/staging/dgap/dgap_sysfs.c  |  1 -
 5 files changed, 37 deletions(-)
 delete mode 100644 drivers/staging/dgap/dgap_mgmt.h

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index ed56d02..8e8c1e3 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -49,7 +49,6 @@
 #include dgap_tty.h
 #include dgap_conf.h
 #include dgap_parse.h
-#include dgap_mgmt.h
 #include dgap_trace.h
 #include dgap_sysfs.h
 
diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c
index 2bbbcd3..45b0f28 100644
--- a/drivers/staging/dgap/dgap_fep5.c
+++ b/drivers/staging/dgap/dgap_fep5.c
@@ -51,7 +51,6 @@
 #include dgap_tty.h
 #include dgap_conf.h
 #include dgap_parse.h
-#include dgap_mgmt.h
 #include dgap_trace.h
 
 /*
diff --git a/drivers/staging/dgap/dgap_mgmt.h b/drivers/staging/dgap/dgap_mgmt.h
deleted file mode 100644
index 4b153f2..000
--- a/drivers/staging/dgap/dgap_mgmt.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2003 Digi International (www.digi.com)
- * Scott H Kilau Scott_Kilau at digi dot com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- */
-
-#ifndef __DGAP_MGMT_H
-#define __DGAP_MGMT_H
-
-#define MGMT_MGMT 0
-#define MGMT_DOWNLD 1
-
-int dgap_mgmt_open(struct inode *inode, struct file *file);
-int dgap_mgmt_close(struct inode *inode, struct file *file);
-long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-
-#endif
-
diff --git a/drivers/staging/dgap/dgap_proc.c b/drivers/staging/dgap/dgap_proc.c
index 6950a6c..8c46b24 100644
--- a/drivers/staging/dgap/dgap_proc.c
+++ b/drivers/staging/dgap/dgap_proc.c
@@ -46,7 +46,6 @@
 
 #include dgap_driver.h
 #include dgap_proc.h
-#include dgap_mgmt.h
 #include dgap_conf.h
 #include dgap_parse.h
 #include dgap_fep5.h
diff --git a/drivers/staging/dgap/dgap_sysfs.c 
b/drivers/staging/dgap/dgap_sysfs.c
index 6f98ac6..a35c8ed 100644
--- a/drivers/staging/dgap/dgap_sysfs.c
+++ b/drivers/staging/dgap/dgap_sysfs.c
@@ -45,7 +45,6 @@
   
 #include dgap_driver.h
 #include dgap_proc.h
-#include dgap_mgmt.h
 #include dgap_conf.h
 #include dgap_parse.h
 
-- 
1.8.1.2

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


[PATCH 1/3] staging: dgap: removes references to proc code

2013-08-22 Thread Lidza Louina
This patch removes references to proc functions and
structs in the code. The kernel uses sysfs instead
of proc now.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.h | 8 
 drivers/staging/dgap/dgap_fep5.c   | 2 --
 2 files changed, 10 deletions(-)

diff --git a/drivers/staging/dgap/dgap_driver.h 
b/drivers/staging/dgap/dgap_driver.h
index b76ec3c..b1cf489 100644
--- a/drivers/staging/dgap/dgap_driver.h
+++ b/drivers/staging/dgap/dgap_driver.h
@@ -412,10 +412,6 @@ struct board_t
 */
 char   *msgbuf_head;
 char   *msgbuf;
-
-   /* /proc/board entries */
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgap_proc_entry *dgap_board_table;
 };
 
 
@@ -564,10 +560,6 @@ struct channel_t {
ulong   ch_err_break;   /* Count of breaks on channel   */
ulong   ch_err_overrun; /* Count of overruns on channel */
 
-   /* /proc/board/channel entries */
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgap_proc_entry *dgap_channel_table;
-
uint ch_sniff_in;
uint ch_sniff_out;
char *ch_sniff_buf; /* Sniff buffer for proc */
diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c
index 45b0f28..291b414 100644
--- a/drivers/staging/dgap/dgap_fep5.c
+++ b/drivers/staging/dgap/dgap_fep5.c
@@ -133,8 +133,6 @@ int dgap_after_config_loaded(void)
 */
dgap_Board[i]-flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, 
GFP_ATOMIC);
dgap_Board[i]-flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, 
GFP_ATOMIC);
-
-   //dgap_proc_register_basic_postscan(i);
}
 
return (rc);
-- 
1.8.1.2

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


[PATCH 3/3] staging: dgap: removes proc.h

2013-08-22 Thread Lidza Louina
This patch removes the proc.h file and removes '#include
dgap_proc.h' from headers in the driver.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgap/dgap_driver.c |   1 -
 drivers/staging/dgap/dgap_fep5.c   |   1 -
 drivers/staging/dgap/dgap_proc.h   | 151 -
 drivers/staging/dgap/dgap_sysfs.c  |   1 -
 4 files changed, 154 deletions(-)
 delete mode 100644 drivers/staging/dgap/dgap_proc.h

diff --git a/drivers/staging/dgap/dgap_driver.c 
b/drivers/staging/dgap/dgap_driver.c
index 8e8c1e3..9f777e4 100644
--- a/drivers/staging/dgap/dgap_driver.c
+++ b/drivers/staging/dgap/dgap_driver.c
@@ -44,7 +44,6 @@
 
 #include dgap_driver.h
 #include dgap_pci.h
-#include dgap_proc.h
 #include dgap_fep5.h
 #include dgap_tty.h
 #include dgap_conf.h
diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c
index 291b414..4464f02 100644
--- a/drivers/staging/dgap/dgap_fep5.c
+++ b/drivers/staging/dgap/dgap_fep5.c
@@ -46,7 +46,6 @@
 
 #include dgap_driver.h
 #include dgap_pci.h
-#include dgap_proc.h
 #include dgap_fep5.h
 #include dgap_tty.h
 #include dgap_conf.h
diff --git a/drivers/staging/dgap/dgap_proc.h b/drivers/staging/dgap/dgap_proc.h
deleted file mode 100644
index 9970d28..000
--- a/drivers/staging/dgap/dgap_proc.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2003 Digi International (www.digi.com)
- *  Scott H Kilau Scott_Kilau at digi dot com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- *
- *
- * $Id: dgap_proc.h,v 1.1 2009/10/23 14:01:57 markh Exp $
- *
- *  Description:
- *
- * Describes the private structures used to manipulate the special
- * proc constructs (not read-only) used by the Digi Neo software.
- * The concept is borrowed heavily from the sysctl interface of
- * the kernel.  I decided not to use the structures and functions
- * provided by the kernel for two reasons:
- *
- *   1. Due to the planned use of /proc in the Neo driver, many
- *  of the functions of the sysctl interface would go unused.
- *  A simpler interface will be easier to maintain.
- *
- *   2. I'd rather divorce our added package from the kernel internals.
- *  If the sysctl structures should change, I will be insulated
- *  from those changes.  These /proc entries won't be under the
- *  sys tree anyway, so there is no need to maintain a strict
- *  dependence relationship.
- *
- *  Author:
- *
- * Scott H Kilau
- *
- */
-
-#ifndef _DGAP_RW_PROC_H
-#define _DGAP_RW_PROC_H
-
-/*
- *  The list of DGAP entries with r/w capabilities. 
- *  These magic numbers are used for identification purposes.
- */
-enum {
-   DGAP_INFO = 1,  /* Get info about the running module
*/
-   DGAP_MKNOD = 2, /* Get info about driver devices
*/
-   DGAP_BOARD_INFO = 3,/* Get info about the specific board
*/
-   DGAP_BOARD_VPD = 4, /* Get info about the board's VPD   
*/
-   DGAP_BOARD_VPDDATA = 5, /* Get info about the board's VPD   
*/
-   DGAP_BOARD_TTYSTATS = 6,/* Get info about the board's tty stats 
*/
-   DGAP_BOARD_TTYFLAGS = 7,/* Get info about the board's tty flags 
*/
-   DGAP_BOARD_MKNOD = 8,   /* Get info about board devices 
*/
-   DGAP_PORT_INFO = 9, /* Get info about the specific port 
*/
-   DGAP_PORT_SNIFF = 10,   /* Sniff data in/out of specific port   
*/
-   DGAP_PORT_CUSTOM_TTYNAME = 11,  /* Get info about UDEV tty name 
*/
-   DGAP_PORT_CUSTOM_PRNAME = 12,   /* Get info about UDEV pr name  
*/
-   DGAP_PORT_FEPSTATE = 13,/* Get info about Ports FEP state   
*/
-};
-
-#define DGAP_MAX_PROC_ENTRIES 999
-
-/*
- *  Directions for proc handlers
- */
-enum {
-INBOUND = 1,   /* Data being written to kernel */
-OUTBOUND = 2,  /* Data being read from the kernel */
-};
-
-/*
- *  Each entry in a DGAP proc directory is described with a
- *  dgap_proc_entry structure.  A collection of these
- *  entries (in an array) represents the members associated
- *  with a particular /proc

[PATCH 03/14] staging: dgnc: driver.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dgnc_driver.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_driver.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index 9371347..ad7a8f1 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -6,12 +6,12 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -345,7 +345,7 @@ static int dgnc_init_pci(void)
 
 /* returns count (= 0), or negative on error */
 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
-{   
+{
int rc;
 
/* wake up and enable device */
@@ -516,7 +516,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
APR((memory allocation for board msgbuf failed\n));
return(-ENOMEM);
 }
-
+
/* store the info for the board we've found */
brd-magic = DGNC_BOARD_MAGIC;
brd-boardnum = dgnc_NumBoards;
@@ -566,7 +566,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 * PCI Local Address (i.e. resource number) space
 * 0PLX Memory Mapped Config
 * 1PLX I/O Mapped Config
-* 2I/O Mapped UARTs and Status   
+* 2I/O Mapped UARTs and Status
 * 3Memory Mapped VPD
 * 4Memory Mapped UARTs and Status
 */
@@ -628,7 +628,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
/*
 * This chip is set up 100% when we get to it.
-* No need to enable global interrupts or anything. 
+* No need to enable global interrupts or anything.
 */
if (brd-bd_flags  BD_IS_PCI_EXPRESS)
brd-dpatype = T_NEO_EXPRESS | T_PCIBUS;
@@ -784,23 +784,23 @@ static void dgnc_do_remap(struct board_t *brd)
 /*
 *
 * Function:
-*   
+*
 *dgnc_poll_handler
 *
 * Author:
 *
 *Scott H Kilau
-*   
+*
 * Parameters:
 *
-*dummy -- ignored
+*dummy -- ignored
 *
 * Return Values:
 *
 *none
 *
-* Description:   
-*   
+* Description:
+*
 *As each timer expires, it determines (a) whether the transmit
 *waiter needs to be woken up, and (b) whether the poller needs to
 *be rescheduled.
-- 
1.8.1.2

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


[PATCH 14/14] staging: dgnc: dpacompat.h: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dpacompat.h file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dpacompat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dpacompat.h b/drivers/staging/dgnc/dpacompat.h
index 44379eb..f96963b 100644
--- a/drivers/staging/dgnc/dpacompat.h
+++ b/drivers/staging/dgnc/dpacompat.h
@@ -20,8 +20,8 @@
  */
 
 
-/* 
- * This structure holds data needed for the intelligent -- nonintelligent 
+/*
+ * This structure holds data needed for the intelligent -- nonintelligent
  * DPA translation
  */
  struct ni_info {
-- 
1.8.1.2

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


[PATCH 01/14] staging: dgnc: cls.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dgnc_cls.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_cls.c | 48 -
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 83c0575..cf997be 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -6,12 +6,12 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the 
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -111,7 +111,7 @@ static inline void cls_set_cts_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn on CTS flow control, turn off IXON flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_CTSDSR);
isr_fcr = ~(UART_EXAR654_EFR_IXON);
@@ -153,7 +153,7 @@ static inline void cls_set_ixon_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn on IXON flow control, turn off CTS flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXON);
isr_fcr = ~(UART_EXAR654_EFR_CTSDSR);
@@ -199,7 +199,7 @@ static inline void cls_set_no_output_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn off IXON flow control, turn off CTS flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB);
isr_fcr = ~(UART_EXAR654_EFR_CTSDSR | UART_EXAR654_EFR_IXON);
@@ -243,7 +243,7 @@ static inline void cls_set_rts_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn on RTS flow control, turn off IXOFF flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_RTSDTR);
isr_fcr = ~(UART_EXAR654_EFR_IXOFF);
@@ -286,7 +286,7 @@ static inline void cls_set_ixoff_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn on IXOFF flow control, turn off RTS flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXOFF);
isr_fcr = ~(UART_EXAR654_EFR_RTSDTR);
@@ -331,7 +331,7 @@ static inline void cls_set_no_input_flow_control(struct 
channel_t *ch)
writeb(UART_EXAR654_ENHANCED_REGISTER_SET, ch-ch_cls_uart-lcr);
 
isr_fcr = readb(ch-ch_cls_uart-isr_fcr);
-   
+
/* Turn off IXOFF flow control, turn off RTS flow control */
isr_fcr |= (UART_EXAR654_EFR_ECB);
isr_fcr = ~(UART_EXAR654_EFR_RTSDTR | UART_EXAR654_EFR_IXOFF);
@@ -492,7 +492,7 @@ static void cls_param(struct tty_struct *tty)
return;
}
 
-   ch = un-un_ch;   
+   ch = un-un_ch;
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC) {
return;
}
@@ -581,7 +581,7 @@ static void cls_param(struct tty_struct *tty)
jindex = baud;
 
if ((iindex = 0)  (iindex  4)  (jindex = 0)  (jindex  
16)) {
-   baud = bauds[iindex][jindex];  
+   baud = bauds[iindex][jindex];
} else {
DPR_IOCTL((baud indices were out of range (%d)(%d),
iindex, jindex));
@@ -620,7 +620,7 @@ static void cls_param(struct tty_struct *tty)
 */
 #ifdef CMSPAR
if (ch-ch_c_cflag  CMSPAR)
-   lcr |= UART_LCR_SPAR;
+   lcr |= UART_LCR_SPAR;
 #endif
 
if (ch-ch_c_cflag  CSTOPB)
@@ -663,7 +663,7 @@ static void cls_param(struct tty_struct *tty)
 
if (ch-ch_c_cflag  CREAD) {
ier |= (UART_IER_RDI | UART_IER_RLSI);
-   }   
+   }
else {
ier = ~(UART_IER_RDI | UART_IER_RLSI);
}
@@ -710,7 +710,7 @@ static void cls_param(struct tty_struct *tty)
cls_set_no_input_flow_control(ch

[PATCH 12/14] staging: dgnc: tty.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dgnc_tty.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_tty.c | 178 
 1 file changed, 89 insertions(+), 89 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 2acf934..feb0124 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -17,22 +17,22 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *
- * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE! 
+ * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
  *
  * This is shared code between Digi's CVS archive and the
  * Linux Kernel sources.
  * Changing the source just for reformatting needlessly breaks
  * our CVS diff history.
  *
- * Send any bug fixes/changes to:  Eng.Linux at digi dot com. 
- * Thank you. 
+ * Send any bug fixes/changes to:  Eng.Linux at digi dot com.
+ * Thank you.
  */
 
 /
- * 
+ *
  * This file implements the tty driver functionality for the
  * Neo and ClassicBoard PCI based product lines.
- * 
+ *
  
  *
  * $Id: dgnc_tty.c,v 1.5 2013/04/30 19:18:30 markh Exp $
@@ -165,11 +165,11 @@ static const struct tty_operations dgnc_tty_ops = {
 };
 
 /
- *  
+ *
  * TTY Initialization/Cleanup Functions
- *  
+ *
  /
- 
+
 /*
  * dgnc_tty_preinit()
  *
@@ -213,7 +213,7 @@ int dgnc_tty_register(struct board_t *brd)
memset(brd-PrintDriver, 0, sizeof(struct tty_driver));
 
brd-SerialDriver.magic = TTY_DRIVER_MAGIC;
-   
+
snprintf(brd-SerialName, MAXTTYNAMELEN, tty_dgnc_%d_, brd-boardnum);
 
brd-SerialDriver.name = brd-SerialName;
@@ -221,15 +221,15 @@ int dgnc_tty_register(struct board_t *brd)
brd-SerialDriver.major = 0;
brd-SerialDriver.minor_start = 0;
brd-SerialDriver.num = brd-maxports;
-   brd-SerialDriver.type = TTY_DRIVER_TYPE_SERIAL; 
-   brd-SerialDriver.subtype = SERIAL_TYPE_NORMAL;   
+   brd-SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
+   brd-SerialDriver.subtype = SERIAL_TYPE_NORMAL;
brd-SerialDriver.init_termios = DgncDefaultTermios;
brd-SerialDriver.driver_name = DRVSTR;
brd-SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV 
| TTY_DRIVER_HARDWARE_BREAK);
 
-   /* 
+   /*
 * The kernel wants space to store pointers to
-* tty_struct's and termios's. 
+* tty_struct's and termios's.
 */
brd-SerialDriver.ttys = dgnc_driver_kzmalloc(brd-maxports * 
sizeof(struct tty_struct *), GFP_KERNEL);
if (!brd-SerialDriver.ttys)
@@ -279,7 +279,7 @@ int dgnc_tty_register(struct board_t *brd)
brd-PrintDriver.major = brd-SerialDriver.major;
brd-PrintDriver.minor_start = 0x80;
brd-PrintDriver.num = brd-maxports;
-   brd-PrintDriver.type = TTY_DRIVER_TYPE_SERIAL;   
+   brd-PrintDriver.type = TTY_DRIVER_TYPE_SERIAL;
brd-PrintDriver.subtype = SERIAL_TYPE_NORMAL;
brd-PrintDriver.init_termios = DgncDefaultTermios;
brd-PrintDriver.driver_name = DRVSTR;
@@ -459,7 +459,7 @@ void dgnc_tty_post_uninit(void)
  * dgnc_tty_uninit()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
- * resources. 
+ * resources.
  */
 void dgnc_tty_uninit(struct board_t *brd)
 {
@@ -567,7 +567,7 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar 
*text, uchar *buf, int
if (n == 0) {
return;
}
-   
+
/*
 * Copy as much data as will fit.
 */
@@ -630,7 +630,7 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, 
uint n)
 
if (!ch || ch-magic != DGNC_CHANNEL_MAGIC)
return;
- 
+
head = ch-ch_w_head  WQUEUEMASK;
 
/*
@@ -641,7 +641,7 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, 
uint n)
remain = WQUEUESIZE - head;
 
if (n = remain) {
-   n -= remain;  
+   n -= remain;
memcpy(ch-ch_wqueue + head, buf, remain);
head = 0;
buf += remain;
@@ -666,9 +666,9 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, 
uint n)
 /*===
  *
  *  dgnc_input - Process received data.
- * 
+ *
  *  ch  - Pointer to channel structure.
- * 
+ *
  *===*/
 void dgnc_input(struct channel_t *ch

[PATCH 05/14] staging: dgnc: kcompat.h: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the kcompat.h file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_kcompat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_kcompat.h 
b/drivers/staging/dgnc/dgnc_kcompat.h
index a0f5874..00f589a 100644
--- a/drivers/staging/dgnc/dgnc_kcompat.h
+++ b/drivers/staging/dgnc/dgnc_kcompat.h
@@ -35,8 +35,8 @@
 # endif
 
 
-#if !defined(TTY_FLIPBUF_SIZE)
-# define TTY_FLIPBUF_SIZE 512
+#if !defined(TTY_FLIPBUF_SIZE)
+# define TTY_FLIPBUF_SIZE 512
 #endif
 
 
-- 
1.8.1.2

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


[PATCH 09/14] staging: dgnc: sysfs.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the sysfs.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_sysfs.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_sysfs.c 
b/drivers/staging/dgnc/dgnc_sysfs.c
index f9c167e..1ed456e 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004 Digi International (www.digi.com)
  *  Scott H Kilau Scott_Kilau at digi dot com
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
@@ -9,14 +9,14 @@
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * 
+ *
  *  NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
  *
  *  This is shared code between Digi's CVS archive and the
@@ -28,8 +28,8 @@
  *  Thank you.
  *
  *
- * 
- * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $   
+ *
+ * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
  */
 
 
@@ -41,7 +41,7 @@
 #include linux/device.h
 #include linux/pci.h
 #include linux/kdev_t.h
-  
+
 #include dgnc_driver.h
 #include dgnc_mgmt.h
 
@@ -129,7 +129,7 @@ void dgnc_create_driver_sysfiles(struct pci_driver 
*dgnc_driver)
rc |= driver_create_file(driverfs, driver_attr_boards);
rc |= driver_create_file(driverfs, driver_attr_maxboards);
rc |= driver_create_file(driverfs, driver_attr_debug);
-   rc |= driver_create_file(driverfs, driver_attr_rawreadok); 
+   rc |= driver_create_file(driverfs, driver_attr_rawreadok);
rc |= driver_create_file(driverfs, driver_attr_pollrate);
rc |= driver_create_file(driverfs, driver_attr_pollcounter);
rc |= driver_create_file(driverfs, driver_attr_state);
@@ -720,7 +720,7 @@ static struct attribute *dgnc_sysfs_tty_entries[] = {
dev_attr_msignals.attr,
dev_attr_iflag.attr,
dev_attr_cflag.attr,
-   dev_attr_oflag.attr,  
+   dev_attr_oflag.attr,
dev_attr_lflag.attr,
dev_attr_digi_flag.attr,
dev_attr_rxcount.attr,
@@ -751,7 +751,7 @@ void dgnc_create_tty_sysfs(struct un_t *un, struct device 
*c)
 
 }
 
- 
+
 void dgnc_remove_tty_sysfs(struct device *c)
 {
sysfs_remove_group(c-kobj, dgnc_tty_attribute_group);
-- 
1.8.1.2

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


[PATCH 13/14] staging: dgnc: digi.h: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the digi.h file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/digi.h | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h
index ab90382..8027eab 100644
--- a/drivers/staging/dgnc/digi.h
+++ b/drivers/staging/dgnc/digi.h
@@ -43,7 +43,7 @@
 #defineTIOCMODG('d'8) | 250  /* get modem ctrl state 
*/
 #defineTIOCMODS('d'8) | 251  /* set modem ctrl state 
*/
 
-#ifndef TIOCM_LE 
+#ifndef TIOCM_LE
 #defineTIOCM_LE0x01/* line enable  
*/
 #defineTIOCM_DTR   0x02/* data terminal ready  
*/
 #defineTIOCM_RTS   0x04/* request to send  
*/
@@ -122,7 +122,7 @@ struct  digiflow_t {
 #endif
 
 /
- * Values for digi_flags 
+ * Values for digi_flags
  /
 #define DIGI_IXON  0x0001  /* Handle IXON in the FEP   */
 #define DIGI_FAST  0x0002  /* Fast baud rates  */
@@ -193,8 +193,8 @@ struct rw_t {
 #define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */
 
 /* Non-Zero Result codes. */
-#define RESULT_NOBDFND 1 /* A Digi product at that port is not config 
installed */ 
-#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ 
+#define RESULT_NOBDFND 1 /* A Digi product at that port is not config 
installed */
+#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
 #define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
 #define RESULT_TOOSML  4 /* Too small an area to shrink.  */
 #define RESULT_NOCHAN  5 /* Channel structure for the board was not found */
@@ -205,7 +205,7 @@ struct shrink_buf_struct {
unsigned intshrink_buf_bseg;/* Amount of board memory */
unsigned intshrink_buf_hseg;/* '186 Begining of Dual-Port */
 
-   unsigned intshrink_buf_lseg;/* '186 Begining of freed 
memory */ 
+   unsigned intshrink_buf_lseg;/* '186 Begining of freed 
memory */
unsigned intshrink_buf_mseg;/* Linear address from start of
   dual-port were freed memory
   begins, host viewpoint. */
@@ -220,18 +220,18 @@ struct shrink_buf_struct {
 
unsigned char   shrink_buf_result;  /* Reason for call failing
   Zero is Good return */
-   unsigned char   shrink_buf_init;/* Non-Zero if it caused an 
+   unsigned char   shrink_buf_init;/* Non-Zero if it caused an
   xxinit call. */
 
unsigned char   shrink_buf_anports; /* Number of async ports  */
unsigned char   shrink_buf_snports; /* Number of sync  ports */
unsigned char   shrink_buf_type;/* Board type 1 = PC/Xi,
  2 = PC/Xm,
- 3 = PC/Xe  
- 4 = MC/Xi  
+ 3 = PC/Xe
+ 4 = MC/Xi
  5 = COMX/i */
unsigned char   shrink_buf_card;/* Card number */
-   
+
 };
 
 /
@@ -244,7 +244,7 @@ struct digi_dinfo {
 };
 
 #defineDIGI_GETDD  ('d'8) | 248  /* get driver info  
*/
- 
+
 /
  * Structure used with ioctl commands for per-board information
  *
@@ -264,7 +264,7 @@ struct digi_info {
 };
 
 #defineDIGI_GETBD  ('d'8) | 249  /* get board info   
   */
- 
+
 struct digi_stat {
unsigned intinfo_chan;  /* Channel number (0 based)  */
unsigned intinfo_brd;   /* Board number (0 based)  */
@@ -299,7 +299,7 @@ struct digi_ch {
 };
 
 /*
-* This structure is used with the DIGI_FEPCMD ioctl to 
+* This structure is used with the DIGI_FEPCMD ioctl to
 * tell the driver which port to send the command for.
 */
 struct digi_cmd {
@@ -398,16 +398,16 @@ struct digi_getcounter
 #define DIGI_REALPORT_GETEVENTS ('e'8 ) | 111
 
 #define EV_OPU 0x0001  //!Output paused by client
-#define EV_OPS 0x0002  //!Output paused by reqular sw 
flowctrl  
+#define EV_OPS 0x0002  //!Output paused by reqular sw

[PATCH 06/14] staging: dgnc: mgmt.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dgnc_mgmt.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_mgmt.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 200da36..c863039 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -17,23 +17,23 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *
- * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE! 
+ * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
  *
  * This is shared code between Digi's CVS archive and the
  * Linux Kernel sources.
  * Changing the source just for reformatting needlessly breaks
  * our CVS diff history.
  *
- * Send any bug fixes/changes to:  Eng.Linux at digi dot com. 
- * Thank you. 
+ * Send any bug fixes/changes to:  Eng.Linux at digi dot com.
+ * Thank you.
  *
  */
 
 /
- * 
+ *
  * This file implements the mgmt functionality for the
  * Neo and ClassicBoard based product lines.
- * 
+ *
  
  * $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $
  */
@@ -57,10 +57,10 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
 
 
 /*
- * dgnc_mgmt_open()  
+ * dgnc_mgmt_open()
  *
  * Open the mgmt/downld/dpa device
- */  
+ */
 int dgnc_mgmt_open(struct inode *inode, struct file *file)
 {
unsigned long lock_flags;
@@ -68,23 +68,23 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
 
DPR_MGMT((dgnc_mgmt_open start.\n));
 
-   DGNC_LOCK(dgnc_global_lock, lock_flags); 
+   DGNC_LOCK(dgnc_global_lock, lock_flags);
 
/* mgmt device */
if (minor  MAXMGMTDEVICES) {
/* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) {
-   DGNC_UNLOCK(dgnc_global_lock, lock_flags); 
+   DGNC_UNLOCK(dgnc_global_lock, lock_flags);
return (-EBUSY);
}
dgnc_mgmt_in_use[minor]++;
}
else {
-   DGNC_UNLOCK(dgnc_global_lock, lock_flags); 
+   DGNC_UNLOCK(dgnc_global_lock, lock_flags);
return (-ENXIO);
}
 
-   DGNC_UNLOCK(dgnc_global_lock, lock_flags); 
+   DGNC_UNLOCK(dgnc_global_lock, lock_flags);
 
DPR_MGMT((dgnc_mgmt_open finish.\n));
 
@@ -96,7 +96,7 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
  * dgnc_mgmt_close()
  *
  * Open the mgmt/dpa device
- */  
+ */
 int dgnc_mgmt_close(struct inode *inode, struct file *file)
 {
unsigned long lock_flags;
@@ -104,7 +104,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
 
DPR_MGMT((dgnc_mgmt_close start.\n));
 
-   DGNC_LOCK(dgnc_global_lock, lock_flags); 
+   DGNC_LOCK(dgnc_global_lock, lock_flags);
 
/* mgmt device */
if (minor  MAXMGMTDEVICES) {
@@ -112,7 +112,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
dgnc_mgmt_in_use[minor] = 0;
}
}
-   DGNC_UNLOCK(dgnc_global_lock, lock_flags); 
+   DGNC_UNLOCK(dgnc_global_lock, lock_flags);
 
DPR_MGMT((dgnc_mgmt_close finish.\n));
 
@@ -124,7 +124,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
  * dgnc_mgmt_ioctl()
  *
  * ioctl the mgmt/dpa device
- */  
+ */
 
 long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -144,12 +144,12 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
 */
struct digi_dinfo ddi;
 
-   DGNC_LOCK(dgnc_global_lock, lock_flags); 
+   DGNC_LOCK(dgnc_global_lock, lock_flags);
 
ddi.dinfo_nboards = dgnc_NumBoards;
sprintf(ddi.dinfo_version, %s, DG_PART);
 
-   DGNC_UNLOCK(dgnc_global_lock, lock_flags); 
+   DGNC_UNLOCK(dgnc_global_lock, lock_flags);
 
DPR_MGMT((DIGI_GETDD returning numboards: %d version: %s\n,
ddi.dinfo_nboards, ddi.dinfo_version));
@@ -179,7 +179,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
 
di.info_bdnum = brd;
 
-   DGNC_LOCK(dgnc_Board[brd]-bd_lock, lock_flags); 
+   DGNC_LOCK(dgnc_Board[brd]-bd_lock, lock_flags);
 
di.info_bdtype = dgnc_Board[brd]-dpatype;
di.info_bdstate = dgnc_Board[brd]-dpastatus;
@@ -191,7 +191,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
else
di.info_nports = 0;
 
-   DGNC_UNLOCK(dgnc_Board[brd]-bd_lock, lock_flags

[PATCH 11/14] staging: dgnc: trace.c: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the dgnc_trace.c file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_trace.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_trace.c 
b/drivers/staging/dgnc/dgnc_trace.c
index e613a28..0f00ddc 100644
--- a/drivers/staging/dgnc/dgnc_trace.c
+++ b/drivers/staging/dgnc/dgnc_trace.c
@@ -17,15 +17,15 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *
- * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE! 
+ * NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
  *
  * This is shared code between Digi's CVS archive and the
  * Linux Kernel sources.
  * Changing the source just for reformatting needlessly breaks
  * our CVS diff history.
  *
- * Send any bug fixes/changes to:  Eng.Linux at digi dot com. 
- * Thank you. 
+ * Send any bug fixes/changes to:  Eng.Linux at digi dot com.
+ * Thank you.
  *
  */
 
@@ -107,16 +107,16 @@ void dgnc_tracef(const char *fmt, ...)
dgnc_trcbufi = 0;
initd++;
 
-   printk(dgnc: tracing enabled -  TRC_DTRC 
+   printk(dgnc: tracing enabled -  TRC_DTRC
 0x%lx 0x%x\n,
-   (unsigned long)dgnc_trcbuf, 
+   (unsigned long)dgnc_trcbuf,
dgnc_trcbuf_size);
}
 
 #  if defined(TRC_ON_OVERFLOW_WRAP_AROUND)
/*
 * This is the less CPU-intensive way to do things.  We simply
-* wrap around before we fall off the end of the buffer.  A 
+* wrap around before we fall off the end of the buffer.  A
 * tilde (~) demarcates the current end of the trace.
 *
 * This method should be used if you are concerned about race
@@ -131,14 +131,14 @@ void dgnc_tracef(const char *fmt, ...)
dgnc_trcbufi = 0;
}
 
-   strcpy(dgnc_trcbuf[dgnc_trcbufi], buf);
+   strcpy(dgnc_trcbuf[dgnc_trcbufi], buf);
dgnc_trcbufi += lenbuf;
dgnc_trcbuf[dgnc_trcbufi] = '~';
 
 #  elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER)
/*
 * This is the more CPU-intensive way to do things.  If we
-* venture into the last 1/8 of the buffer, we shift the 
+* venture into the last 1/8 of the buffer, we shift the
 * last 7/8 of the buffer forward, wiping out the first 1/8.
 * Advantage: No wrap-around, only truncation from the
 * beginning.
-- 
1.8.1.2

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


[PATCH 08/14] staging: dgnc: neo.h: removes trailing whitespace

2013-08-21 Thread Lidza Louina
This patch removes trailing whitespace in
the neo.h file.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_neo.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.h b/drivers/staging/dgnc/dgnc_neo.h
index ffb4209..f7f569b 100644
--- a/drivers/staging/dgnc/dgnc_neo.h
+++ b/drivers/staging/dgnc/dgnc_neo.h
@@ -26,12 +26,12 @@
 #include dgnc_types.h
 #include dgnc_driver.h
 
-/ 
+/
  * Per channel/port NEO UART structure *
  
  * Base Structure Entries Usage Meanings to Host   *
  * *
- * W = read write  R = read only   * 
+ * W = read write  R = read only   *
  * U = Unused. *
  /
 
@@ -46,7 +46,7 @@ struct neo_uart_struct {
volatile uchar spr; /* WR  SPR - Scratch Pad Reg */
volatile uchar fctr;/* WR  FCTR - Feature Control Reg */
volatile uchar efr; /* WR  EFR - Enhanced Function Reg */
-   volatile uchar tfifo;   /* WR  TXCNT/TXTRG - Transmit FIFO Reg 
*/   
+   volatile uchar tfifo;   /* WR  TXCNT/TXTRG - Transmit FIFO Reg 
*/
volatile uchar rfifo;   /* WR  RXCNT/RXTRG - Recieve  FIFO Reg 
*/
volatile uchar xoffchar1;   /* WR  XOFF 1 - XOff Character 1 Reg */
volatile uchar xoffchar2;   /* WR  XOFF 2 - XOff Character 2 Reg */
@@ -74,7 +74,7 @@ struct neo_uart_struct {
 #define NEO_EEREG 0x8E /* offset to EEPROM control reg */
 
 
-#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words 
*/   
+#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words */
 #define NEO_VPD_IMAGEBYTES (NEO_VPD_IMAGESIZE * 2)
 
 /*
@@ -111,8 +111,8 @@ struct neo_uart_struct {
 #define UART_17158_FCTR_BIT7   0x80
 
 /* 17158 TX/RX memmapped buffer offsets */
-#define UART_17158_RX_FIFOSIZE 64  
-#define UART_17158_TX_FIFOSIZE 64  
+#define UART_17158_RX_FIFOSIZE 64
+#define UART_17158_TX_FIFOSIZE 64
 
 /* 17158 Extended IIR's */
 #define UART_17158_IIR_RDI_TIMEOUT 0x0C/* Receiver data TIMEOUT */
-- 
1.8.1.2

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


[PATCH 3/5] staging: dgnc: neo.c: fixes code indent error

2013-08-21 Thread Lidza Louina
This patch fixes the error code indent should use
tabs where possible in dgnc_neo.c.

Signed-off-by: Lidza Louina lidza.lou...@gmail.com
---
 drivers/staging/dgnc/dgnc_neo.c | 46 -
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index 7e02780..22c8ce3 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -260,7 +260,7 @@ static inline void neo_set_ixoff_flow_control(struct 
channel_t *ch)
writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), 
ch-ch_neo_uart-fctr);
 
writeb(8, ch-ch_neo_uart-tfifo);
-ch-ch_t_tlevel = 8;
+   ch-ch_t_tlevel = 8;
 
/* Tell UART what start/stop chars it should be looking for */
writeb(ch-ch_startc, ch-ch_neo_uart-xonchar1);
@@ -306,10 +306,10 @@ static inline void neo_set_no_input_flow_control(struct 
channel_t *ch)
ch-ch_r_watermark = 0;
 
writeb(16, ch-ch_neo_uart-tfifo);
-ch-ch_t_tlevel = 16;
+   ch-ch_t_tlevel = 16;
 
writeb(16, ch-ch_neo_uart-rfifo);
-ch-ch_r_tlevel = 16;
+   ch-ch_r_tlevel = 16;
 
writeb(ier, ch-ch_neo_uart-ier);
 
@@ -346,10 +346,10 @@ static inline void neo_set_no_output_flow_control(struct 
channel_t *ch)
ch-ch_r_watermark = 0;
 
writeb(16, ch-ch_neo_uart-tfifo);
-ch-ch_t_tlevel = 16;
+   ch-ch_t_tlevel = 16;
 
writeb(16, ch-ch_neo_uart-rfifo);
-ch-ch_r_tlevel = 16;
+   ch-ch_r_tlevel = 16;
 
writeb(ier, ch-ch_neo_uart-ier);
 
@@ -397,13 +397,13 @@ static inline void neo_clear_break(struct channel_t *ch, 
int force)
if (ch-ch_flags  CH_BREAK_SENDING) {
if ((jiffies = ch-ch_stop_sending_break) || force) {
uchar temp = readb(ch-ch_neo_uart-lcr);
-   writeb((temp  ~UART_LCR_SBC), ch-ch_neo_uart-lcr);
+   writeb((temp  ~UART_LCR_SBC), ch-ch_neo_uart-lcr);
neo_pci_posting_flush(ch-ch_bd);
ch-ch_flags = ~(CH_BREAK_SENDING);
ch-ch_stop_sending_break = 0;
DPR_IOCTL((Finishing UART_LCR_SBC! finished: %lx\n, 
jiffies));
-}
-}
+   }
+   }
DGNC_UNLOCK(ch-ch_lock, lock_flags);
 }
 
@@ -648,11 +648,11 @@ static void neo_param(struct tty_struct *tty)
uchar uart_lcr = 0;
uchar ier = 0;
uchar uart_ier = 0;
-uint baud = 9600;
+   uint baud = 9600;
int quot = 0;
-struct board_t *bd;
+   struct board_t *bd;
struct channel_t *ch;
-struct un_t   *un;
+   struct un_t   *un;
 
if (!tty || tty-magic != TTY_MAGIC) {
return;
@@ -827,7 +827,7 @@ static void neo_param(struct tty_struct *tty)
writeb((quot  0xff), ch-ch_neo_uart-txrx);
writeb((quot  8), ch-ch_neo_uart-ier);
writeb(lcr, ch-ch_neo_uart-lcr);
-}
+   }
 
if (uart_lcr != lcr)
writeb(lcr, ch-ch_neo_uart-lcr);
@@ -911,7 +911,7 @@ static void neo_param(struct tty_struct *tty)
  */
 static void neo_tasklet(unsigned long data)
 {
-struct board_t *bd = (struct board_t *) data;
+   struct board_t *bd = (struct board_t *) data;
struct channel_t *ch;
ulong  lock_flags;
int i;
@@ -1077,7 +1077,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
case UART_17158_RXRDY_TIMEOUT:
/*
 * RXRDY Time-out is cleared by reading data in the
-* RX FIFO until it falls below the trigger level.
+* RX FIFO until it falls below the trigger level.
 */
 
/* Verify the port is in range. */
@@ -1178,11 +1178,11 @@ static void neo_enable_receiver(struct channel_t *ch)
 
 static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
 {
-int qleft = 0;
+   int qleft = 0;
uchar linestatus = 0;
uchar error_mask = 0;
-int n = 0;
-int total = 0;
+   int n = 0;
+   int total = 0;
ushort head;
ushort tail;
ulong lock_flags;
@@ -1400,7 +1400,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
 {
ulong lock_flags;
struct channel_t *ch;
-struct un_t *un;
+   struct un_t *un;
int rc = 0;
 
if (!tty || tty-magic != TTY_MAGIC) {
@@ -1439,7 +1439,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds)
DPR_IOCTL((%d Drain wait finished.\n, __LINE__));
}
 
-return (rc);
+   return (rc);
 }
 
 
@@ -1792,7 +1792,7 @@ static void neo_uart_init(struct channel_t *ch)
writeb(UART_EFR_ECB, ch-ch_neo_uart-efr);
 
 
-/* Clear out UART and FIFO */
+   /* Clear out

  1   2   >