Re: [PATCH 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Sudip Mukherjee
On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> This patch fixes coding style of kmalloc usage found by checkpatch.
> CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
> message)...)
> 
> Signed-off-by: Chaehyun Lim 
> ---
>  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
> b/drivers/staging/wilc1000/wilc_msgqueue.c
> index 7107715..c7a60f4 100644
> --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>   }
>  
>   /* construct a new message */
> - new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> + new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);

This checkpatch error was introduced by 1/27 patch of this series. Maybe
it will be better to fix it in that one.

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


Re: [PATCH] rtlwifi: rtl8821ae: Fix 5G failure when EEPROM is incorrectly encoded

2016-01-21 Thread Kalle Valo
Larry Finger  writes:

> Recently, it has been reported that D-Link DWA-582 cards, which use an
> RTL8812AE chip are not able to scan for 5G networks. The problems started
> with kernel 4.2, which is the first version that had commit d10101a60372
> ("rtlwifi: rtl8821ae: Fix problem with regulatory information"). With this
> patch, the driver went from setting a default channel plan to using
> the value derived from EEPROM.
>
> Bug reports at https://bugzilla.kernel.org/show_bug.cgi?id=111031 and
> https://bugzilla.redhat.com/show_bug.cgi?id=1279653 are examples of this
> problem.
>
> The problem was solved once I learned that the internal country code was
> resulting in a regulatory set with only 2.4 GHz channels. With the RTL8821AE
> chips available to me, the country code was such that both 2.4 and 5 GHz
> channels are allowed. The fix is to allow both bands even when the EEPROM
> is incorrectly encoded.
>
> Fixes: d10101a60372 ("rtlwifi: rtl8821ae: Fix problem with regulatory 
> information")
> Signed-off-by: Larry Finger 
> Cc: littlesmart...@gmail.com
> Cc: g...@codehaus.org
> Cc: Stable  [v4.2+]

I'll queue this to 4.5.

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


Re: [PATCH 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Dan Carpenter
On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> > This patch fixes coding style of kmalloc usage found by checkpatch.
> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
> > message)...)
> > 
> > Signed-off-by: Chaehyun Lim 
> > ---
> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
> > b/drivers/staging/wilc1000/wilc_msgqueue.c
> > index 7107715..c7a60f4 100644
> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
> > }
> >  
> > /* construct a new message */
> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
> 
> This checkpatch error was introduced by 1/27 patch of this series. Maybe
> it will be better to fix it in that one.

The warning was introduced there but the issue went back further it's
just that checkpatch didn't detect it because of other issues.  This
seems fine.

regards,
dan carpenter

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


Re: [PATCH] rtlwifi: rtl8821ae: Fix 5G failure when EEPROM is incorrectly encoded

2016-01-21 Thread Larry Finger

On 01/21/2016 02:52 AM, Kalle Valo wrote:

Larry Finger  writes:


Recently, it has been reported that D-Link DWA-582 cards, which use an
RTL8812AE chip are not able to scan for 5G networks. The problems started
with kernel 4.2, which is the first version that had commit d10101a60372
("rtlwifi: rtl8821ae: Fix problem with regulatory information"). With this
patch, the driver went from setting a default channel plan to using
the value derived from EEPROM.

Bug reports at https://bugzilla.kernel.org/show_bug.cgi?id=111031 and
https://bugzilla.redhat.com/show_bug.cgi?id=1279653 are examples of this
problem.

The problem was solved once I learned that the internal country code was
resulting in a regulatory set with only 2.4 GHz channels. With the RTL8821AE
chips available to me, the country code was such that both 2.4 and 5 GHz
channels are allowed. The fix is to allow both bands even when the EEPROM
is incorrectly encoded.

Fixes: d10101a60372 ("rtlwifi: rtl8821ae: Fix problem with regulatory 
information")
Signed-off-by: Larry Finger 
Cc: littlesmart...@gmail.com
Cc: g...@codehaus.org
Cc: Stable  [v4.2+]


I'll queue this to 4.5.


Thanks.

Larry


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


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

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

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

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

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


Re: [PATCH] Staging: panel: Fix sparse warnings (line length, space after a cast) in panel.c

2016-01-21 Thread Dan Carpenter
These are all checkpatch.pl warnings, not sparse warnings.

regards,
dan carpenter

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


Re: [PATCH] Staging: comedi: s626: Remove unnecessary cast on void pointer

2016-01-21 Thread Dan Carpenter
On Wed, Jan 20, 2016 at 09:48:39PM -0200, Lucas Tanure wrote:
> The conversion from void pointer to any other pointer type is guaranteed by
> the C programming language.
> 
> Signed-off-by: Lucas Tanure 
> ---
>  drivers/staging/comedi/drivers/s626.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/s626.c 
> b/drivers/staging/comedi/drivers/s626.c
> index 35f0f67..13259f0 100644
> --- a/drivers/staging/comedi/drivers/s626.c
> +++ b/drivers/staging/comedi/drivers/s626.c
> @@ -1476,7 +1476,7 @@ static bool s626_handle_eos_interrupt(struct 
> comedi_device *dev)
>* first uint16_t in the buffer because it contains junk data
>* from the final ADC of the previous poll list scan.
>*/
> - uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
> + uint32_t *readaddr = devpriv->ana_buf.logical_base + 1;


No.  This is a bug.  We need the cast for the pointer math to work.
The original code increments by sizeof(uint32_t) the new code by
sizeof(char).

regards,
dan carpenter

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


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

2016-01-21 Thread Dan Carpenter
On Thu, Jan 21, 2016 at 09:11:38AM +, Gujulan Elango, Hari Prasath (H.) 
wrote:
> From: Hari Prasath Gujulan Elango
> 

Your email address is missing here.

regards,
dan carpenter

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


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

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

regards,
Hari Prasath

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


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

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

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

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

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


Re: [PATCH 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Chaehyun Lim
On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter  wrote:
> On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
>> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
>> > This patch fixes coding style of kmalloc usage found by checkpatch.
>> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
>> > message)...)
>> >
>> > Signed-off-by: Chaehyun Lim 
>> > ---
>> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
>> > b/drivers/staging/wilc1000/wilc_msgqueue.c
>> > index 7107715..c7a60f4 100644
>> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
>> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
>> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>> > }
>> >
>> > /* construct a new message */
>> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
>> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
>>
>> This checkpatch error was introduced by 1/27 patch of this series. Maybe
>> it will be better to fix it in that one.
>
> The warning was introduced there but the issue went back further it's
> just that checkpatch didn't detect it because of other issues.  This
> seems fine.

I appreciate for all comment. I will resend it after applying Sudip's review.

regards,
Chaehyun Lim

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


Re: [PATCH 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Dan Carpenter
On Thu, Jan 21, 2016 at 07:01:45PM +0900, Chaehyun Lim wrote:
> On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter  
> wrote:
> > On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
> >> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> >> > This patch fixes coding style of kmalloc usage found by checkpatch.
> >> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
> >> > message)...)
> >> >
> >> > Signed-off-by: Chaehyun Lim 
> >> > ---
> >> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
> >> > b/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > index 7107715..c7a60f4 100644
> >> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
> >> > }
> >> >
> >> > /* construct a new message */
> >> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> >> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
> >>
> >> This checkpatch error was introduced by 1/27 patch of this series. Maybe
> >> it will be better to fix it in that one.
> >
> > The warning was introduced there but the issue went back further it's
> > just that checkpatch didn't detect it because of other issues.  This
> > seems fine.
> 
> I appreciate for all comment. I will resend it after applying Sudip's review.
> 

That's fine too, but the original way is more correct because it only
fixes one thing at a time and is easier to review.

regards,
dan carpenter

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


[PATCH] staging: nvec: replace led_classdev_register

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

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

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

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


Re: [PATCH 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Chaehyun Lim
On Thu, Jan 21, 2016 at 7:04 PM, Dan Carpenter  wrote:
> On Thu, Jan 21, 2016 at 07:01:45PM +0900, Chaehyun Lim wrote:
>> On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter  
>> wrote:
>> > On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
>> >> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
>> >> > This patch fixes coding style of kmalloc usage found by checkpatch.
>> >> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
>> >> > message)...)
>> >> >
>> >> > Signed-off-by: Chaehyun Lim 
>> >> > ---
>> >> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >> >
>> >> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
>> >> > b/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > index 7107715..c7a60f4 100644
>> >> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>> >> > }
>> >> >
>> >> > /* construct a new message */
>> >> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
>> >> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
>> >>
>> >> This checkpatch error was introduced by 1/27 patch of this series. Maybe
>> >> it will be better to fix it in that one.
>> >
>> > The warning was introduced there but the issue went back further it's
>> > just that checkpatch didn't detect it because of other issues.  This
>> > seems fine.
>>
>> I appreciate for all comment. I will resend it after applying Sudip's review.
>>
>
> That's fine too, but the original way is more correct because it only
> fixes one thing at a time and is easier to review.
>
I will keep the original way, even 1/27 patch was introduced a new
checkpatch warning.
I agree that one patch should be changed one thing.

But I need to resend again because I find a wrong variable name at commit title.

regards
Chaehyun Lim

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


[PATCH V2 02/27] staging: wilc1000: rename pvBuffer in struct message

2016-01-21 Thread Chaehyun Lim
This patch renames pvBuffer to buf to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 10 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 9b78fcd..a4e612d 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -76,9 +76,9 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 
pstrMessage->u32Length = u32SendBufferSize;
pstrMessage->pstrNext = NULL;
-   pstrMessage->pvBuffer = kmemdup(pvSendBuffer, u32SendBufferSize,
-   GFP_ATOMIC);
-   if (!pstrMessage->pvBuffer) {
+   pstrMessage->buf = kmemdup(pvSendBuffer, u32SendBufferSize,
+  GFP_ATOMIC);
+   if (!pstrMessage->buf) {
kfree(pstrMessage);
return -ENOMEM;
}
@@ -151,12 +151,12 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
 
/* consume the message */
pHandle->u32ReceiversCount--;
-   memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length);
+   memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->u32Length);
*pu32ReceivedLength = pstrMessage->u32Length;
 
pHandle->pstrMessageList = pstrMessage->pstrNext;
 
-   kfree(pstrMessage->pvBuffer);
+   kfree(pstrMessage->buf);
kfree(pstrMessage);
 
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 1a7c652..848ed82 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -14,7 +14,7 @@
 
 /* Message Queue type is a structure */
 struct message {
-   void *pvBuffer;
+   void *buf;
u32 u32Length;
struct message *pstrNext;
 };
-- 
2.7.0

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


[PATCH V2 01/27] staging: wilc1000: rename struct __Message_struct

2016-01-21 Thread Chaehyun Lim
This patch renames typedef from struct __Message_struct and renames it
to struct message.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 10 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  8 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index abc780c..9b78fcd 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -38,7 +38,7 @@ int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle)
}
 
while (pHandle->pstrMessageList) {
-   Message *pstrMessge = pHandle->pstrMessageList->pstrNext;
+   struct message *pstrMessge = pHandle->pstrMessageList->pstrNext;
 
kfree(pHandle->pstrMessageList);
pHandle->pstrMessageList = pstrMessge;
@@ -57,7 +57,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 const void *pvSendBuffer, u32 u32SendBufferSize)
 {
unsigned long flags;
-   Message *pstrMessage = NULL;
+   struct message *pstrMessage = NULL;
 
if ((!pHandle) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
PRINT_ER("pHandle or pvSendBuffer is null\n");
@@ -70,7 +70,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
}
 
/* construct a new message */
-   pstrMessage = kmalloc(sizeof(Message), GFP_ATOMIC);
+   pstrMessage = kmalloc(sizeof(struct message), GFP_ATOMIC);
if (!pstrMessage)
return -ENOMEM;
 
@@ -89,7 +89,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
if (!pHandle->pstrMessageList) {
pHandle->pstrMessageList  = pstrMessage;
} else {
-   Message *pstrTailMsg = pHandle->pstrMessageList;
+   struct message *pstrTailMsg = pHandle->pstrMessageList;
 
while (pstrTailMsg->pstrNext)
pstrTailMsg = pstrTailMsg->pstrNext;
@@ -114,7 +114,7 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
 void *pvRecvBuffer, u32 u32RecvBufferSize,
 u32 *pu32ReceivedLength)
 {
-   Message *pstrMessage;
+   struct message *pstrMessage;
unsigned long flags;
 
if ((!pHandle) || (u32RecvBufferSize == 0)
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index d7e0328..1a7c652 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -13,18 +13,18 @@
 #include 
 
 /* Message Queue type is a structure */
-typedef struct __Message_struct {
+struct message {
void *pvBuffer;
u32 u32Length;
-   struct __Message_struct *pstrNext;
-} Message;
+   struct message *pstrNext;
+};
 
 typedef struct __MessageQueue_struct {
struct semaphore hSem;
spinlock_t strCriticalSection;
bool bExiting;
u32 u32ReceiversCount;
-   Message *pstrMessageList;
+   struct message *pstrMessageList;
 } WILC_MsgQueueHandle;
 
 /*!
-- 
2.7.0

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


[PATCH V2 07/27] staging: wilc1000: rename strCriticalSection in struct message_queue

2016-01-21 Thread Chaehyun Lim
This patch renames strCriticalSection to lock to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 18 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index b996c47..67bf147 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -13,7 +13,7 @@
  */
 int wilc_mq_create(struct message_queue *pHandle)
 {
-   spin_lock_init(&pHandle->strCriticalSection);
+   spin_lock_init(&pHandle->lock);
sema_init(&pHandle->sem, 0);
pHandle->pstrMessageList = NULL;
pHandle->u32ReceiversCount = 0;
@@ -83,7 +83,7 @@ int wilc_mq_send(struct message_queue *pHandle,
return -ENOMEM;
}
 
-   spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+   spin_lock_irqsave(&pHandle->lock, flags);
 
/* add it to the message queue */
if (!pHandle->pstrMessageList) {
@@ -97,7 +97,7 @@ int wilc_mq_send(struct message_queue *pHandle,
pstrTailMsg->next = pstrMessage;
}
 
-   spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+   spin_unlock_irqrestore(&pHandle->lock, flags);
 
up(&pHandle->sem);
 
@@ -128,22 +128,22 @@ int wilc_mq_recv(struct message_queue *pHandle,
return -EFAULT;
}
 
-   spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+   spin_lock_irqsave(&pHandle->lock, flags);
pHandle->u32ReceiversCount++;
-   spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+   spin_unlock_irqrestore(&pHandle->lock, flags);
 
down(&pHandle->sem);
-   spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+   spin_lock_irqsave(&pHandle->lock, flags);
 
pstrMessage = pHandle->pstrMessageList;
if (!pstrMessage) {
-   spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+   spin_unlock_irqrestore(&pHandle->lock, flags);
PRINT_ER("pstrMessage is null\n");
return -EFAULT;
}
/* check buffer size */
if (u32RecvBufferSize < pstrMessage->len) {
-   spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+   spin_unlock_irqrestore(&pHandle->lock, flags);
up(&pHandle->sem);
PRINT_ER("u32RecvBufferSize overflow\n");
return -EOVERFLOW;
@@ -159,7 +159,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
kfree(pstrMessage->buf);
kfree(pstrMessage);
 
-   spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+   spin_unlock_irqrestore(&pHandle->lock, flags);
 
return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 3ea4068..6cdebbf 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -21,7 +21,7 @@ struct message {
 
 struct message_queue {
struct semaphore sem;
-   spinlock_t strCriticalSection;
+   spinlock_t lock;
bool bExiting;
u32 u32ReceiversCount;
struct message *pstrMessageList;
-- 
2.7.0

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


[PATCH V2 00/27] rename variables in wilc1000 driver

2016-01-21 Thread Chaehyun Lim
V2:
A 18/27 patch of series has a wrong name as tail_msg, which is should be
changed to pstrTailMsg. I fixed it in V2.

Chaehyun Lim (27):
  staging: wilc1000: rename struct __Message_struct
  staging: wilc1000: rename pvBuffer in struct message
  staging: wilc1000: rename u32Length in struct message
  staging: wilc1000: rename pstrNext in struct message
  staging: wilc1000: rename struct WILC_MsgQueueHandle
  staging: wilc1000: rename hSem in struct message_queue
  staging: wilc1000: rename strCriticalSection in struct message_queue
  staging: wilc1000: rename bExiting in struct message_queue
  staging: wilc1000: rename u32ReceiversCount in struct message_queue
  staging: wilc1000: rename pstrMessageList in struct message_queue
  staging: wilc1000: rename pHandle in wilc_mq_create
  staging: wilc1000: rename pHandle in wilc_mq_destroy
  staging: wilc1000: rename pstrMessge in wilc_mq_destroy
  staging: wilc1000: rename pHandle in wilc_mq_send
  staging: wilc1000: rename pvSendBuffer in wilc_mq_send
  staging: wilc1000: rename u32SendBufferSize in wilc_mq_send
  staging: wilc1000: rename pstrMessage in wilc_mq_send
  staging: wilc1000: rename pstrTailMsg in wilc_mq_send
  staging: wilc1000: fix return error code
  staging: wilc1000: rename pHandle in wilc_mq_recv
  staging: wilc1000: rename pvRecvBuffer in wilc_mq_recv
  staging: wilc1000: rename u32RecvBufferSize in wilc_mq_recv
  staging: wilc1000: rename pu32ReceivedLength in wilc_mq_recv
  staging: wilc1000: rename pstrMessage in wilc_mq_recv
  staging: wilc1000: fix coding style of kmalloc usage
  staging: wilc1000: fix logical continuations
  staging: wilc1000: remove over-commenting

 drivers/staging/wilc1000/host_interface.c |   2 +-
 drivers/staging/wilc1000/wilc_msgqueue.c  | 135 +++---
 drivers/staging/wilc1000/wilc_msgqueue.h  | 107 +--
 3 files changed, 87 insertions(+), 157 deletions(-)

-- 
2.7.0

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


[PATCH V2 03/27] staging: wilc1000: rename u32Length in struct message

2016-01-21 Thread Chaehyun Lim
This patch renames u32Length to len to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index a4e612d..0e66a64 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -74,7 +74,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
if (!pstrMessage)
return -ENOMEM;
 
-   pstrMessage->u32Length = u32SendBufferSize;
+   pstrMessage->len = u32SendBufferSize;
pstrMessage->pstrNext = NULL;
pstrMessage->buf = kmemdup(pvSendBuffer, u32SendBufferSize,
   GFP_ATOMIC);
@@ -142,7 +142,7 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
return -EFAULT;
}
/* check buffer size */
-   if (u32RecvBufferSize < pstrMessage->u32Length) {
+   if (u32RecvBufferSize < pstrMessage->len) {
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
up(&pHandle->hSem);
PRINT_ER("u32RecvBufferSize overflow\n");
@@ -151,8 +151,8 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
 
/* consume the message */
pHandle->u32ReceiversCount--;
-   memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->u32Length);
-   *pu32ReceivedLength = pstrMessage->u32Length;
+   memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
+   *pu32ReceivedLength = pstrMessage->len;
 
pHandle->pstrMessageList = pstrMessage->pstrNext;
 
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 848ed82..b0ccd1d 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -15,7 +15,7 @@
 /* Message Queue type is a structure */
 struct message {
void *buf;
-   u32 u32Length;
+   u32 len;
struct message *pstrNext;
 };
 
-- 
2.7.0

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


[PATCH V2 09/27] staging: wilc1000: rename u32ReceiversCount in struct message_queue

2016-01-21 Thread Chaehyun Lim
This patch renames u32ReceiversCount to recv_count to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 10 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 47ba256..363e003 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -16,7 +16,7 @@ int wilc_mq_create(struct message_queue *pHandle)
spin_lock_init(&pHandle->lock);
sema_init(&pHandle->sem, 0);
pHandle->pstrMessageList = NULL;
-   pHandle->u32ReceiversCount = 0;
+   pHandle->recv_count = 0;
pHandle->exiting = false;
return 0;
 }
@@ -32,9 +32,9 @@ int wilc_mq_destroy(struct message_queue *pHandle)
pHandle->exiting = true;
 
/* Release any waiting receiver thread. */
-   while (pHandle->u32ReceiversCount > 0) {
+   while (pHandle->recv_count > 0) {
up(&pHandle->sem);
-   pHandle->u32ReceiversCount--;
+   pHandle->recv_count--;
}
 
while (pHandle->pstrMessageList) {
@@ -129,7 +129,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
}
 
spin_lock_irqsave(&pHandle->lock, flags);
-   pHandle->u32ReceiversCount++;
+   pHandle->recv_count++;
spin_unlock_irqrestore(&pHandle->lock, flags);
 
down(&pHandle->sem);
@@ -150,7 +150,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
}
 
/* consume the message */
-   pHandle->u32ReceiversCount--;
+   pHandle->recv_count--;
memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
*pu32ReceivedLength = pstrMessage->len;
 
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 2c21b3e..dcf54ea 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -23,7 +23,7 @@ struct message_queue {
struct semaphore sem;
spinlock_t lock;
bool exiting;
-   u32 u32ReceiversCount;
+   u32 recv_count;
struct message *pstrMessageList;
 };
 
-- 
2.7.0

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


[PATCH V2 04/27] staging: wilc1000: rename pstrNext in struct message

2016-01-21 Thread Chaehyun Lim
This patch renames pstrNext to next to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 12 ++--
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 0e66a64..4d79a31 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -38,7 +38,7 @@ int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle)
}
 
while (pHandle->pstrMessageList) {
-   struct message *pstrMessge = pHandle->pstrMessageList->pstrNext;
+   struct message *pstrMessge = pHandle->pstrMessageList->next;
 
kfree(pHandle->pstrMessageList);
pHandle->pstrMessageList = pstrMessge;
@@ -75,7 +75,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
return -ENOMEM;
 
pstrMessage->len = u32SendBufferSize;
-   pstrMessage->pstrNext = NULL;
+   pstrMessage->next = NULL;
pstrMessage->buf = kmemdup(pvSendBuffer, u32SendBufferSize,
   GFP_ATOMIC);
if (!pstrMessage->buf) {
@@ -91,10 +91,10 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
} else {
struct message *pstrTailMsg = pHandle->pstrMessageList;
 
-   while (pstrTailMsg->pstrNext)
-   pstrTailMsg = pstrTailMsg->pstrNext;
+   while (pstrTailMsg->next)
+   pstrTailMsg = pstrTailMsg->next;
 
-   pstrTailMsg->pstrNext = pstrMessage;
+   pstrTailMsg->next = pstrMessage;
}
 
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
@@ -154,7 +154,7 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
*pu32ReceivedLength = pstrMessage->len;
 
-   pHandle->pstrMessageList = pstrMessage->pstrNext;
+   pHandle->pstrMessageList = pstrMessage->next;
 
kfree(pstrMessage->buf);
kfree(pstrMessage);
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index b0ccd1d..ec503c3 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -16,7 +16,7 @@
 struct message {
void *buf;
u32 len;
-   struct message *pstrNext;
+   struct message *next;
 };
 
 typedef struct __MessageQueue_struct {
-- 
2.7.0

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


[PATCH V2 22/27] staging: wilc1000: rename u32RecvBufferSize in wilc_mq_recv

2016-01-21 Thread Chaehyun Lim
This patch renames u32RecvBufferSize to recv_buf_size to avoid
camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index b836b2e..c86bd7c 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -110,13 +110,13 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *recv_buf, u32 u32RecvBufferSize,
+void *recv_buf, u32 recv_buf_size,
 u32 *pu32ReceivedLength)
 {
struct message *pstrMessage;
unsigned long flags;
 
-   if ((!mq) || (u32RecvBufferSize == 0)
+   if ((!mq) || (recv_buf_size == 0)
|| (!recv_buf) || (!pu32ReceivedLength)) {
PRINT_ER("mq or recv_buf is null\n");
return -EINVAL;
@@ -141,10 +141,10 @@ int wilc_mq_recv(struct message_queue *mq,
return -EFAULT;
}
/* check buffer size */
-   if (u32RecvBufferSize < pstrMessage->len) {
+   if (recv_buf_size < pstrMessage->len) {
spin_unlock_irqrestore(&mq->lock, flags);
up(&mq->sem);
-   PRINT_ER("u32RecvBufferSize overflow\n");
+   PRINT_ER("recv_buf_size overflow\n");
return -EOVERFLOW;
}
 
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 81b51dd..3804b3b 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -77,7 +77,7 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *recv_buf, u32 u32RecvBufferSize,
+void *recv_buf, u32 recv_buf_size,
 u32 *pu32ReceivedLength);
 
 /*!
-- 
2.7.0

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


[PATCH V2 05/27] staging: wilc1000: rename struct WILC_MsgQueueHandle

2016-01-21 Thread Chaehyun Lim
This patch removes typedef from struct WILC_MsgQueueHandle and renames
it to struct message_queue.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/host_interface.c |  2 +-
 drivers/staging/wilc1000/wilc_msgqueue.c  | 14 +++---
 drivers/staging/wilc1000/wilc_msgqueue.h  | 18 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 5fac516..98627a6 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -229,7 +229,7 @@ struct host_if_drv *terminated_handle;
 bool wilc_optaining_ip;
 static u8 P2P_LISTEN_STATE;
 static struct task_struct *hif_thread_handler;
-static WILC_MsgQueueHandle hif_msg_q;
+static struct message_queue hif_msg_q;
 static struct semaphore hif_sema_thread;
 static struct semaphore hif_sema_driver;
 static struct semaphore hif_sema_wait_response;
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 4d79a31..907bae1 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -11,7 +11,7 @@
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_create(WILC_MsgQueueHandle *pHandle)
+int wilc_mq_create(struct message_queue *pHandle)
 {
spin_lock_init(&pHandle->strCriticalSection);
sema_init(&pHandle->hSem, 0);
@@ -27,7 +27,7 @@ int wilc_mq_create(WILC_MsgQueueHandle *pHandle)
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle)
+int wilc_mq_destroy(struct message_queue *pHandle)
 {
pHandle->bExiting = true;
 
@@ -53,8 +53,8 @@ int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle)
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
-const void *pvSendBuffer, u32 u32SendBufferSize)
+int wilc_mq_send(struct message_queue *pHandle,
+const void *pvSendBuffer, u32 u32SendBufferSize)
 {
unsigned long flags;
struct message *pstrMessage = NULL;
@@ -110,9 +110,9 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
-void *pvRecvBuffer, u32 u32RecvBufferSize,
-u32 *pu32ReceivedLength)
+int wilc_mq_recv(struct message_queue *pHandle,
+void *pvRecvBuffer, u32 u32RecvBufferSize,
+u32 *pu32ReceivedLength)
 {
struct message *pstrMessage;
unsigned long flags;
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index ec503c3..111be46 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -19,13 +19,13 @@ struct message {
struct message *next;
 };
 
-typedef struct __MessageQueue_struct {
+struct message_queue {
struct semaphore hSem;
spinlock_t strCriticalSection;
bool bExiting;
u32 u32ReceiversCount;
struct message *pstrMessageList;
-} WILC_MsgQueueHandle;
+};
 
 /*!
  *  @brief Creates a new Message queue
@@ -40,7 +40,7 @@ typedef struct __MessageQueue_struct {
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_create(WILC_MsgQueueHandle *pHandle);
+int wilc_mq_create(struct message_queue *pHandle);
 
 /*!
  *  @brief Sends a message
@@ -57,8 +57,8 @@ int wilc_mq_create(WILC_MsgQueueHandle *pHandle);
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
-const void *pvSendBuffer, u32 u32SendBufferSize);
+int wilc_mq_send(struct message_queue *pHandle,
+const void *pvSendBuffer, u32 u32SendBufferSize);
 
 /*!
  *  @brief Receives a message
@@ -76,9 +76,9 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
-void *pvRecvBuffer, u32 u32RecvBufferSize,
-u32 *pu32ReceivedLength);
+int wilc_mq_recv(struct message_queue *pHandle,
+void *pvRecvBuffer, u32 u32RecvBufferSize,
+u32 *pu32ReceivedLength);
 
 /*!
  *  @brief Destroys an existing  Message queue
@@ -89,6 +89,6 @@ int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle);
+int wilc_mq_destroy(struct message_queue *pHandle);
 
 #endif
-- 
2.7.0

___
devel mailing

[PATCH V2 14/27] staging: wilc1000: rename pHandle in wilc_mq_send

2016-01-21 Thread Chaehyun Lim
This patch renames pHandle to mq to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 22 +++---
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index a01420a..71ce1f5 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -53,19 +53,19 @@ int wilc_mq_destroy(struct message_queue *mq)
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_send(struct message_queue *pHandle,
+int wilc_mq_send(struct message_queue *mq,
 const void *pvSendBuffer, u32 u32SendBufferSize)
 {
unsigned long flags;
struct message *pstrMessage = NULL;
 
-   if ((!pHandle) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
-   PRINT_ER("pHandle or pvSendBuffer is null\n");
+   if ((!mq) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
+   PRINT_ER("mq or pvSendBuffer is null\n");
return -EFAULT;
}
 
-   if (pHandle->exiting) {
-   PRINT_ER("pHandle fail\n");
+   if (mq->exiting) {
+   PRINT_ER("mq fail\n");
return -EFAULT;
}
 
@@ -83,13 +83,13 @@ int wilc_mq_send(struct message_queue *pHandle,
return -ENOMEM;
}
 
-   spin_lock_irqsave(&pHandle->lock, flags);
+   spin_lock_irqsave(&mq->lock, flags);
 
/* add it to the message queue */
-   if (!pHandle->msg_list) {
-   pHandle->msg_list  = pstrMessage;
+   if (!mq->msg_list) {
+   mq->msg_list  = pstrMessage;
} else {
-   struct message *pstrTailMsg = pHandle->msg_list;
+   struct message *pstrTailMsg = mq->msg_list;
 
while (pstrTailMsg->next)
pstrTailMsg = pstrTailMsg->next;
@@ -97,9 +97,9 @@ int wilc_mq_send(struct message_queue *pHandle,
pstrTailMsg->next = pstrMessage;
}
 
-   spin_unlock_irqrestore(&pHandle->lock, flags);
+   spin_unlock_irqrestore(&mq->lock, flags);
 
-   up(&pHandle->sem);
+   up(&mq->sem);
 
return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index b91822e..e6cdc10 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -57,7 +57,7 @@ int wilc_mq_create(struct message_queue *mq);
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_send(struct message_queue *pHandle,
+int wilc_mq_send(struct message_queue *mq,
 const void *pvSendBuffer, u32 u32SendBufferSize);
 
 /*!
-- 
2.7.0

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


[PATCH V2 15/27] staging: wilc1000: rename pvSendBuffer in wilc_mq_send

2016-01-21 Thread Chaehyun Lim
This patch renames pvSendBuffer to send_buf to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 71ce1f5..5feb87c 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -54,13 +54,13 @@ int wilc_mq_destroy(struct message_queue *mq)
  *  @version   1.0
  */
 int wilc_mq_send(struct message_queue *mq,
-const void *pvSendBuffer, u32 u32SendBufferSize)
+const void *send_buf, u32 u32SendBufferSize)
 {
unsigned long flags;
struct message *pstrMessage = NULL;
 
-   if ((!mq) || (u32SendBufferSize == 0) || (!pvSendBuffer)) {
-   PRINT_ER("mq or pvSendBuffer is null\n");
+   if ((!mq) || (u32SendBufferSize == 0) || (!send_buf)) {
+   PRINT_ER("mq or send_buf is null\n");
return -EFAULT;
}
 
@@ -76,7 +76,7 @@ int wilc_mq_send(struct message_queue *mq,
 
pstrMessage->len = u32SendBufferSize;
pstrMessage->next = NULL;
-   pstrMessage->buf = kmemdup(pvSendBuffer, u32SendBufferSize,
+   pstrMessage->buf = kmemdup(send_buf, u32SendBufferSize,
   GFP_ATOMIC);
if (!pstrMessage->buf) {
kfree(pstrMessage);
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index e6cdc10..3adee90 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -58,7 +58,7 @@ int wilc_mq_create(struct message_queue *mq);
  *  @version   1.0
  */
 int wilc_mq_send(struct message_queue *mq,
-const void *pvSendBuffer, u32 u32SendBufferSize);
+const void *send_buf, u32 u32SendBufferSize);
 
 /*!
  *  @brief Receives a message
-- 
2.7.0

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


[PATCH V2 18/27] staging: wilc1000: rename pstrTailMsg in wilc_mq_send

2016-01-21 Thread Chaehyun Lim
This patch renames pstrTailMsg to tail_msg to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 9a80fe6..764723f 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -88,12 +88,12 @@ int wilc_mq_send(struct message_queue *mq,
if (!mq->msg_list) {
mq->msg_list  = new_msg;
} else {
-   struct message *pstrTailMsg = mq->msg_list;
+   struct message *tail_msg = mq->msg_list;
 
-   while (pstrTailMsg->next)
-   pstrTailMsg = pstrTailMsg->next;
+   while (tail_msg->next)
+   tail_msg = tail_msg->next;
 
-   pstrTailMsg->next = new_msg;
+   tail_msg->next = new_msg;
}
 
spin_unlock_irqrestore(&mq->lock, flags);
-- 
2.7.0

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


[PATCH V2 08/27] staging: wilc1000: rename bExiting in struct message_queue

2016-01-21 Thread Chaehyun Lim
This patch renames bExiting to exiting to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 67bf147..47ba256 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -17,7 +17,7 @@ int wilc_mq_create(struct message_queue *pHandle)
sema_init(&pHandle->sem, 0);
pHandle->pstrMessageList = NULL;
pHandle->u32ReceiversCount = 0;
-   pHandle->bExiting = false;
+   pHandle->exiting = false;
return 0;
 }
 
@@ -29,7 +29,7 @@ int wilc_mq_create(struct message_queue *pHandle)
  */
 int wilc_mq_destroy(struct message_queue *pHandle)
 {
-   pHandle->bExiting = true;
+   pHandle->exiting = true;
 
/* Release any waiting receiver thread. */
while (pHandle->u32ReceiversCount > 0) {
@@ -64,7 +64,7 @@ int wilc_mq_send(struct message_queue *pHandle,
return -EFAULT;
}
 
-   if (pHandle->bExiting) {
+   if (pHandle->exiting) {
PRINT_ER("pHandle fail\n");
return -EFAULT;
}
@@ -123,7 +123,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
return -EINVAL;
}
 
-   if (pHandle->bExiting) {
+   if (pHandle->exiting) {
PRINT_ER("pHandle fail\n");
return -EFAULT;
}
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 6cdebbf..2c21b3e 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -22,7 +22,7 @@ struct message {
 struct message_queue {
struct semaphore sem;
spinlock_t lock;
-   bool bExiting;
+   bool exiting;
u32 u32ReceiversCount;
struct message *pstrMessageList;
 };
-- 
2.7.0

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


[PATCH V2 20/27] staging: wilc1000: rename pHandle in wilc_mq_recv

2016-01-21 Thread Chaehyun Lim
This patch renames pHandle to mq to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 34 
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 361ca8f..d2df179 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -109,56 +109,56 @@ int wilc_mq_send(struct message_queue *mq,
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_recv(struct message_queue *pHandle,
+int wilc_mq_recv(struct message_queue *mq,
 void *pvRecvBuffer, u32 u32RecvBufferSize,
 u32 *pu32ReceivedLength)
 {
struct message *pstrMessage;
unsigned long flags;
 
-   if ((!pHandle) || (u32RecvBufferSize == 0)
+   if ((!mq) || (u32RecvBufferSize == 0)
|| (!pvRecvBuffer) || (!pu32ReceivedLength)) {
-   PRINT_ER("pHandle or pvRecvBuffer is null\n");
+   PRINT_ER("mq or pvRecvBuffer is null\n");
return -EINVAL;
}
 
-   if (pHandle->exiting) {
-   PRINT_ER("pHandle fail\n");
+   if (mq->exiting) {
+   PRINT_ER("mq fail\n");
return -EFAULT;
}
 
-   spin_lock_irqsave(&pHandle->lock, flags);
-   pHandle->recv_count++;
-   spin_unlock_irqrestore(&pHandle->lock, flags);
+   spin_lock_irqsave(&mq->lock, flags);
+   mq->recv_count++;
+   spin_unlock_irqrestore(&mq->lock, flags);
 
-   down(&pHandle->sem);
-   spin_lock_irqsave(&pHandle->lock, flags);
+   down(&mq->sem);
+   spin_lock_irqsave(&mq->lock, flags);
 
-   pstrMessage = pHandle->msg_list;
+   pstrMessage = mq->msg_list;
if (!pstrMessage) {
-   spin_unlock_irqrestore(&pHandle->lock, flags);
+   spin_unlock_irqrestore(&mq->lock, flags);
PRINT_ER("pstrMessage is null\n");
return -EFAULT;
}
/* check buffer size */
if (u32RecvBufferSize < pstrMessage->len) {
-   spin_unlock_irqrestore(&pHandle->lock, flags);
-   up(&pHandle->sem);
+   spin_unlock_irqrestore(&mq->lock, flags);
+   up(&mq->sem);
PRINT_ER("u32RecvBufferSize overflow\n");
return -EOVERFLOW;
}
 
/* consume the message */
-   pHandle->recv_count--;
+   mq->recv_count--;
memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
*pu32ReceivedLength = pstrMessage->len;
 
-   pHandle->msg_list = pstrMessage->next;
+   mq->msg_list = pstrMessage->next;
 
kfree(pstrMessage->buf);
kfree(pstrMessage);
 
-   spin_unlock_irqrestore(&pHandle->lock, flags);
+   spin_unlock_irqrestore(&mq->lock, flags);
 
return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 70e1be1..0c1eead 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -76,7 +76,7 @@ int wilc_mq_send(struct message_queue *mq,
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_recv(struct message_queue *pHandle,
+int wilc_mq_recv(struct message_queue *mq,
 void *pvRecvBuffer, u32 u32RecvBufferSize,
 u32 *pu32ReceivedLength);
 
-- 
2.7.0

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


[PATCH V2 12/27] staging: wilc1000: rename pHandle in wilc_mq_destroy

2016-01-21 Thread Chaehyun Lim
This patch renames pHandle to mq to avoid camelcase

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 18 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 453fa19..103fcfd 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -27,21 +27,21 @@ int wilc_mq_create(struct message_queue *mq)
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_destroy(struct message_queue *pHandle)
+int wilc_mq_destroy(struct message_queue *mq)
 {
-   pHandle->exiting = true;
+   mq->exiting = true;
 
/* Release any waiting receiver thread. */
-   while (pHandle->recv_count > 0) {
-   up(&pHandle->sem);
-   pHandle->recv_count--;
+   while (mq->recv_count > 0) {
+   up(&mq->sem);
+   mq->recv_count--;
}
 
-   while (pHandle->msg_list) {
-   struct message *pstrMessge = pHandle->msg_list->next;
+   while (mq->msg_list) {
+   struct message *pstrMessge = mq->msg_list->next;
 
-   kfree(pHandle->msg_list);
-   pHandle->msg_list = pstrMessge;
+   kfree(mq->msg_list);
+   mq->msg_list = pstrMessge;
}
 
return 0;
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index bfd2347..b91822e 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -89,6 +89,6 @@ int wilc_mq_recv(struct message_queue *pHandle,
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_destroy(struct message_queue *pHandle);
+int wilc_mq_destroy(struct message_queue *mq);
 
 #endif
-- 
2.7.0

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


[PATCH V2 10/27] staging: wilc1000: rename pstrMessageList in struct message_queue

2016-01-21 Thread Chaehyun Lim
This patch renames pstrMessageList to msg_list to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 20 ++--
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 363e003..d13c9a7 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -15,7 +15,7 @@ int wilc_mq_create(struct message_queue *pHandle)
 {
spin_lock_init(&pHandle->lock);
sema_init(&pHandle->sem, 0);
-   pHandle->pstrMessageList = NULL;
+   pHandle->msg_list = NULL;
pHandle->recv_count = 0;
pHandle->exiting = false;
return 0;
@@ -37,11 +37,11 @@ int wilc_mq_destroy(struct message_queue *pHandle)
pHandle->recv_count--;
}
 
-   while (pHandle->pstrMessageList) {
-   struct message *pstrMessge = pHandle->pstrMessageList->next;
+   while (pHandle->msg_list) {
+   struct message *pstrMessge = pHandle->msg_list->next;
 
-   kfree(pHandle->pstrMessageList);
-   pHandle->pstrMessageList = pstrMessge;
+   kfree(pHandle->msg_list);
+   pHandle->msg_list = pstrMessge;
}
 
return 0;
@@ -86,10 +86,10 @@ int wilc_mq_send(struct message_queue *pHandle,
spin_lock_irqsave(&pHandle->lock, flags);
 
/* add it to the message queue */
-   if (!pHandle->pstrMessageList) {
-   pHandle->pstrMessageList  = pstrMessage;
+   if (!pHandle->msg_list) {
+   pHandle->msg_list  = pstrMessage;
} else {
-   struct message *pstrTailMsg = pHandle->pstrMessageList;
+   struct message *pstrTailMsg = pHandle->msg_list;
 
while (pstrTailMsg->next)
pstrTailMsg = pstrTailMsg->next;
@@ -135,7 +135,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
down(&pHandle->sem);
spin_lock_irqsave(&pHandle->lock, flags);
 
-   pstrMessage = pHandle->pstrMessageList;
+   pstrMessage = pHandle->msg_list;
if (!pstrMessage) {
spin_unlock_irqrestore(&pHandle->lock, flags);
PRINT_ER("pstrMessage is null\n");
@@ -154,7 +154,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
*pu32ReceivedLength = pstrMessage->len;
 
-   pHandle->pstrMessageList = pstrMessage->next;
+   pHandle->msg_list = pstrMessage->next;
 
kfree(pstrMessage->buf);
kfree(pstrMessage);
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index dcf54ea..7e7ec06 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -24,7 +24,7 @@ struct message_queue {
spinlock_t lock;
bool exiting;
u32 recv_count;
-   struct message *pstrMessageList;
+   struct message *msg_list;
 };
 
 /*!
-- 
2.7.0

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


[PATCH V2 13/27] staging: wilc1000: rename pstrMessge in wilc_mq_destroy

2016-01-21 Thread Chaehyun Lim
This patch renames pstrMessge to msg to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 103fcfd..a01420a 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -38,10 +38,10 @@ int wilc_mq_destroy(struct message_queue *mq)
}
 
while (mq->msg_list) {
-   struct message *pstrMessge = mq->msg_list->next;
+   struct message *msg = mq->msg_list->next;
 
kfree(mq->msg_list);
-   mq->msg_list = pstrMessge;
+   mq->msg_list = msg;
}
 
return 0;
-- 
2.7.0

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


[PATCH V2 11/27] staging: wilc1000: rename pHandle in wilc_mq_create

2016-01-21 Thread Chaehyun Lim
This patch renames pHandle to mq to avoid camelcase

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 12 ++--
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index d13c9a7..453fa19 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -11,13 +11,13 @@
  *  @note  copied from FLO glue implementatuion
  *  @version   1.0
  */
-int wilc_mq_create(struct message_queue *pHandle)
+int wilc_mq_create(struct message_queue *mq)
 {
-   spin_lock_init(&pHandle->lock);
-   sema_init(&pHandle->sem, 0);
-   pHandle->msg_list = NULL;
-   pHandle->recv_count = 0;
-   pHandle->exiting = false;
+   spin_lock_init(&mq->lock);
+   sema_init(&mq->sem, 0);
+   mq->msg_list = NULL;
+   mq->recv_count = 0;
+   mq->exiting = false;
return 0;
 }
 
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 7e7ec06..bfd2347 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -40,7 +40,7 @@ struct message_queue {
  *  @date  30 Aug 2010
  *  @version   1.0
  */
-int wilc_mq_create(struct message_queue *pHandle);
+int wilc_mq_create(struct message_queue *mq);
 
 /*!
  *  @brief Sends a message
-- 
2.7.0

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


[PATCH V2 16/27] staging: wilc1000: rename u32SendBufferSize in wilc_mq_send

2016-01-21 Thread Chaehyun Lim
This patch renames u32SendBufferSize to send_buf_size to avoid
camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 5feb87c..8e37cff0 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -54,12 +54,12 @@ int wilc_mq_destroy(struct message_queue *mq)
  *  @version   1.0
  */
 int wilc_mq_send(struct message_queue *mq,
-const void *send_buf, u32 u32SendBufferSize)
+const void *send_buf, u32 send_buf_size)
 {
unsigned long flags;
struct message *pstrMessage = NULL;
 
-   if ((!mq) || (u32SendBufferSize == 0) || (!send_buf)) {
+   if ((!mq) || (send_buf_size == 0) || (!send_buf)) {
PRINT_ER("mq or send_buf is null\n");
return -EFAULT;
}
@@ -74,9 +74,9 @@ int wilc_mq_send(struct message_queue *mq,
if (!pstrMessage)
return -ENOMEM;
 
-   pstrMessage->len = u32SendBufferSize;
+   pstrMessage->len = send_buf_size;
pstrMessage->next = NULL;
-   pstrMessage->buf = kmemdup(send_buf, u32SendBufferSize,
+   pstrMessage->buf = kmemdup(send_buf, send_buf_size,
   GFP_ATOMIC);
if (!pstrMessage->buf) {
kfree(pstrMessage);
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 3adee90..70e1be1 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -58,7 +58,7 @@ int wilc_mq_create(struct message_queue *mq);
  *  @version   1.0
  */
 int wilc_mq_send(struct message_queue *mq,
-const void *send_buf, u32 u32SendBufferSize);
+const void *send_buf, u32 send_buf_size);
 
 /*!
  *  @brief Receives a message
-- 
2.7.0

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


[PATCH V2 06/27] staging: wilc1000: rename hSem in struct message_queue

2016-01-21 Thread Chaehyun Lim
This patch renames hSem to sem to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 10 +-
 drivers/staging/wilc1000/wilc_msgqueue.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 907bae1..b996c47 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -14,7 +14,7 @@
 int wilc_mq_create(struct message_queue *pHandle)
 {
spin_lock_init(&pHandle->strCriticalSection);
-   sema_init(&pHandle->hSem, 0);
+   sema_init(&pHandle->sem, 0);
pHandle->pstrMessageList = NULL;
pHandle->u32ReceiversCount = 0;
pHandle->bExiting = false;
@@ -33,7 +33,7 @@ int wilc_mq_destroy(struct message_queue *pHandle)
 
/* Release any waiting receiver thread. */
while (pHandle->u32ReceiversCount > 0) {
-   up(&pHandle->hSem);
+   up(&pHandle->sem);
pHandle->u32ReceiversCount--;
}
 
@@ -99,7 +99,7 @@ int wilc_mq_send(struct message_queue *pHandle,
 
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
 
-   up(&pHandle->hSem);
+   up(&pHandle->sem);
 
return 0;
 }
@@ -132,7 +132,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
pHandle->u32ReceiversCount++;
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
 
-   down(&pHandle->hSem);
+   down(&pHandle->sem);
spin_lock_irqsave(&pHandle->strCriticalSection, flags);
 
pstrMessage = pHandle->pstrMessageList;
@@ -144,7 +144,7 @@ int wilc_mq_recv(struct message_queue *pHandle,
/* check buffer size */
if (u32RecvBufferSize < pstrMessage->len) {
spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
-   up(&pHandle->hSem);
+   up(&pHandle->sem);
PRINT_ER("u32RecvBufferSize overflow\n");
return -EOVERFLOW;
}
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 111be46..3ea4068 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -20,7 +20,7 @@ struct message {
 };
 
 struct message_queue {
-   struct semaphore hSem;
+   struct semaphore sem;
spinlock_t strCriticalSection;
bool bExiting;
u32 u32ReceiversCount;
-- 
2.7.0

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


[PATCH V2 19/27] staging: wilc1000: fix return error code

2016-01-21 Thread Chaehyun Lim
Three argument are checked at the beginning of wilc_mq_send whether
they are valid arguments or not. It is correct to use return error code
as -EINVAL, not -EFAULT.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 764723f..361ca8f 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -61,7 +61,7 @@ int wilc_mq_send(struct message_queue *mq,
 
if ((!mq) || (send_buf_size == 0) || (!send_buf)) {
PRINT_ER("mq or send_buf is null\n");
-   return -EFAULT;
+   return -EINVAL;
}
 
if (mq->exiting) {
-- 
2.7.0

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


[PATCH V2 17/27] staging: wilc1000: rename pstrMessage in wilc_mq_send

2016-01-21 Thread Chaehyun Lim
This patch renames pstrMessage to new_msg to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 8e37cff0..9a80fe6 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -57,7 +57,7 @@ int wilc_mq_send(struct message_queue *mq,
 const void *send_buf, u32 send_buf_size)
 {
unsigned long flags;
-   struct message *pstrMessage = NULL;
+   struct message *new_msg = NULL;
 
if ((!mq) || (send_buf_size == 0) || (!send_buf)) {
PRINT_ER("mq or send_buf is null\n");
@@ -70,16 +70,15 @@ int wilc_mq_send(struct message_queue *mq,
}
 
/* construct a new message */
-   pstrMessage = kmalloc(sizeof(struct message), GFP_ATOMIC);
-   if (!pstrMessage)
+   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
+   if (!new_msg)
return -ENOMEM;
 
-   pstrMessage->len = send_buf_size;
-   pstrMessage->next = NULL;
-   pstrMessage->buf = kmemdup(send_buf, send_buf_size,
-  GFP_ATOMIC);
-   if (!pstrMessage->buf) {
-   kfree(pstrMessage);
+   new_msg->len = send_buf_size;
+   new_msg->next = NULL;
+   new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC);
+   if (!new_msg->buf) {
+   kfree(new_msg);
return -ENOMEM;
}
 
@@ -87,14 +86,14 @@ int wilc_mq_send(struct message_queue *mq,
 
/* add it to the message queue */
if (!mq->msg_list) {
-   mq->msg_list  = pstrMessage;
+   mq->msg_list  = new_msg;
} else {
struct message *pstrTailMsg = mq->msg_list;
 
while (pstrTailMsg->next)
pstrTailMsg = pstrTailMsg->next;
 
-   pstrTailMsg->next = pstrMessage;
+   pstrTailMsg->next = new_msg;
}
 
spin_unlock_irqrestore(&mq->lock, flags);
-- 
2.7.0

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


[PATCH V2 21/27] staging: wilc1000: rename pvRecvBuffer in wilc_mq_recv

2016-01-21 Thread Chaehyun Lim
This patch renames pvRecvBuffer to recv_buf to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 8 
 drivers/staging/wilc1000/wilc_msgqueue.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index d2df179..b836b2e 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -110,15 +110,15 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *pvRecvBuffer, u32 u32RecvBufferSize,
+void *recv_buf, u32 u32RecvBufferSize,
 u32 *pu32ReceivedLength)
 {
struct message *pstrMessage;
unsigned long flags;
 
if ((!mq) || (u32RecvBufferSize == 0)
-   || (!pvRecvBuffer) || (!pu32ReceivedLength)) {
-   PRINT_ER("mq or pvRecvBuffer is null\n");
+   || (!recv_buf) || (!pu32ReceivedLength)) {
+   PRINT_ER("mq or recv_buf is null\n");
return -EINVAL;
}
 
@@ -150,7 +150,7 @@ int wilc_mq_recv(struct message_queue *mq,
 
/* consume the message */
mq->recv_count--;
-   memcpy(pvRecvBuffer, pstrMessage->buf, pstrMessage->len);
+   memcpy(recv_buf, pstrMessage->buf, pstrMessage->len);
*pu32ReceivedLength = pstrMessage->len;
 
mq->msg_list = pstrMessage->next;
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 0c1eead..81b51dd 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -77,7 +77,7 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *pvRecvBuffer, u32 u32RecvBufferSize,
+void *recv_buf, u32 u32RecvBufferSize,
 u32 *pu32ReceivedLength);
 
 /*!
-- 
2.7.0

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


[PATCH V2 27/27] staging: wilc1000: remove over-commenting

2016-01-21 Thread Chaehyun Lim
There are over-commenting in wilc_msgqueue.h file. This comment is not
explain exactly what codes do and make checkpatch warning about "line
over 80 charcters". If necessary, comment will be added later with
preferred coding style.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.h | 66 
 1 file changed, 66 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 4f79ead..ddd09843 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -1,18 +1,8 @@
 #ifndef __WILC_MSG_QUEUE_H__
 #define __WILC_MSG_QUEUE_H__
 
-/*!
- *  @file  wilc_msgqueue.h
- *  @brief Message Queue OS wrapper functionality
- *  @authorsyounan
- *  @sawilc_oswrapper.h top level OS wrapper file
- *  @date  30 Aug 2010
- *  @version   1.0
- */
-
 #include 
 
-/* Message Queue type is a structure */
 struct message {
void *buf;
u32 len;
@@ -27,67 +17,11 @@ struct message_queue {
struct message *msg_list;
 };
 
-/*!
- *  @brief Creates a new Message queue
- *  @details   Creates a new Message queue, if the feature
- *  CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and 
pstrAttrs->pcName
- *  is not Null, then this message queue can be 
used for IPC with
- *  any other message queue having the same name 
in the system
- *  @param[in,out] pHandle handle to the message queue object
- *  @param[in] pstrAttrs Optional attributes, NULL for default
- *  @returnError code indicating success/failure
- *  @authorsyounan
- *  @date  30 Aug 2010
- *  @version   1.0
- */
 int wilc_mq_create(struct message_queue *mq);
-
-/*!
- *  @brief Sends a message
- *  @details   Sends a message, this API will block until the message 
is
- *  actually sent or until it is timedout (as long 
as the feature
- *  CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and 
pstrAttrs->u32Timeout
- *  is not set to WILC_OS_INFINITY), zero timeout 
is a valid value
- *  @param[in] pHandle handle to the message queue object
- *  @param[in] pvSendBuffer pointer to the data to send
- *  @param[in] u32SendBufferSize the size of the data to send
- *  @param[in] pstrAttrs Optional attributes, NULL for default
- *  @returnError code indicating success/failure
- *  @authorsyounan
- *  @date  30 Aug 2010
- *  @version   1.0
- */
 int wilc_mq_send(struct message_queue *mq,
 const void *send_buf, u32 send_buf_size);
-
-/*!
- *  @brief Receives a message
- *  @details   Receives a message, this API will block until a message 
is
- *  received or until it is timedout (as long as 
the feature
- *  CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and 
pstrAttrs->u32Timeout
- *  is not set to WILC_OS_INFINITY), zero timeout 
is a valid value
- *  @param[in] pHandle handle to the message queue object
- *  @param[out]pvRecvBuffer pointer to a buffer to fill with the 
received message
- *  @param[in] u32RecvBufferSize the size of the receive buffer
- *  @param[out]pu32ReceivedLength the length of received data
- *  @param[in] pstrAttrs Optional attributes, NULL for default
- *  @returnError code indicating success/failure
- *  @authorsyounan
- *  @date  30 Aug 2010
- *  @version   1.0
- */
 int wilc_mq_recv(struct message_queue *mq,
 void *recv_buf, u32 recv_buf_size, u32 *recv_len);
-
-/*!
- *  @brief Destroys an existing  Message queue
- *  @param[in] pHandle handle to the message queue object
- *  @param[in] pstrAttrs Optional attributes, NULL for default
- *  @returnError code indicating success/failure
- *  @authorsyounan
- *  @date  30 Aug 2010
- *  @version   1.0
- */
 int wilc_mq_destroy(struct message_queue *mq);
 
 #endif
-- 
2.7.0

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


[PATCH V2 26/27] staging: wilc1000: fix logical continuations

2016-01-21 Thread Chaehyun Lim
This patch fixes logical continuations found by checkpatch
CHECK: Logical continuations should be on the previous line

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index c7a60f4..4493ca9 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -115,8 +115,7 @@ int wilc_mq_recv(struct message_queue *mq,
struct message *msg;
unsigned long flags;
 
-   if ((!mq) || (recv_buf_size == 0)
-   || (!recv_buf) || (!recv_len)) {
+   if ((!mq) || (recv_buf_size == 0) || (!recv_buf) || (!recv_len)) {
PRINT_ER("mq or recv_buf is null\n");
return -EINVAL;
}
-- 
2.7.0

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


[PATCH V2 25/27] staging: wilc1000: fix coding style of kmalloc usage

2016-01-21 Thread Chaehyun Lim
This patch fixes coding style of kmalloc usage found by checkpatch.
CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct 
message)...)

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 7107715..c7a60f4 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
}
 
/* construct a new message */
-   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
+   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
if (!new_msg)
return -ENOMEM;
 
-- 
2.7.0

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


[PATCH V2 23/27] staging: wilc1000: rename pu32ReceivedLength in wilc_mq_recv

2016-01-21 Thread Chaehyun Lim
This patch renames pu32ReceivedLength to recv_len to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 7 +++
 drivers/staging/wilc1000/wilc_msgqueue.h | 3 +--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index c86bd7c..5601de8 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -110,14 +110,13 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *recv_buf, u32 recv_buf_size,
-u32 *pu32ReceivedLength)
+void *recv_buf, u32 recv_buf_size, u32 *recv_len)
 {
struct message *pstrMessage;
unsigned long flags;
 
if ((!mq) || (recv_buf_size == 0)
-   || (!recv_buf) || (!pu32ReceivedLength)) {
+   || (!recv_buf) || (!recv_len)) {
PRINT_ER("mq or recv_buf is null\n");
return -EINVAL;
}
@@ -151,7 +150,7 @@ int wilc_mq_recv(struct message_queue *mq,
/* consume the message */
mq->recv_count--;
memcpy(recv_buf, pstrMessage->buf, pstrMessage->len);
-   *pu32ReceivedLength = pstrMessage->len;
+   *recv_len = pstrMessage->len;
 
mq->msg_list = pstrMessage->next;
 
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h 
b/drivers/staging/wilc1000/wilc_msgqueue.h
index 3804b3b..4f79ead 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.h
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -77,8 +77,7 @@ int wilc_mq_send(struct message_queue *mq,
  *  @version   1.0
  */
 int wilc_mq_recv(struct message_queue *mq,
-void *recv_buf, u32 recv_buf_size,
-u32 *pu32ReceivedLength);
+void *recv_buf, u32 recv_buf_size, u32 *recv_len);
 
 /*!
  *  @brief Destroys an existing  Message queue
-- 
2.7.0

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


[PATCH V2 24/27] staging: wilc1000: rename pstrMessage in wilc_mq_recv

2016-01-21 Thread Chaehyun Lim
This patch renames pstrMessage to msg to avoid camelcase.

Signed-off-by: Chaehyun Lim 
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c 
b/drivers/staging/wilc1000/wilc_msgqueue.c
index 5601de8..7107715 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -112,7 +112,7 @@ int wilc_mq_send(struct message_queue *mq,
 int wilc_mq_recv(struct message_queue *mq,
 void *recv_buf, u32 recv_buf_size, u32 *recv_len)
 {
-   struct message *pstrMessage;
+   struct message *msg;
unsigned long flags;
 
if ((!mq) || (recv_buf_size == 0)
@@ -133,14 +133,14 @@ int wilc_mq_recv(struct message_queue *mq,
down(&mq->sem);
spin_lock_irqsave(&mq->lock, flags);
 
-   pstrMessage = mq->msg_list;
-   if (!pstrMessage) {
+   msg = mq->msg_list;
+   if (!msg) {
spin_unlock_irqrestore(&mq->lock, flags);
-   PRINT_ER("pstrMessage is null\n");
+   PRINT_ER("msg is null\n");
return -EFAULT;
}
/* check buffer size */
-   if (recv_buf_size < pstrMessage->len) {
+   if (recv_buf_size < msg->len) {
spin_unlock_irqrestore(&mq->lock, flags);
up(&mq->sem);
PRINT_ER("recv_buf_size overflow\n");
@@ -149,13 +149,13 @@ int wilc_mq_recv(struct message_queue *mq,
 
/* consume the message */
mq->recv_count--;
-   memcpy(recv_buf, pstrMessage->buf, pstrMessage->len);
-   *recv_len = pstrMessage->len;
+   memcpy(recv_buf, msg->buf, msg->len);
+   *recv_len = msg->len;
 
-   mq->msg_list = pstrMessage->next;
+   mq->msg_list = msg->next;
 
-   kfree(pstrMessage->buf);
-   kfree(pstrMessage);
+   kfree(msg->buf);
+   kfree(msg);
 
spin_unlock_irqrestore(&mq->lock, flags);
 
-- 
2.7.0

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


[PATCH] staging: android: ion: Set the length of the DMA sg entries in buffer

2016-01-21 Thread Jon Medhurst (Tixy)
From: Liviu Dudau 

ion_buffer_create() will allocate a buffer and then create a DMA
mapping for it, but it forgot to set the length of the page entries.

Signed-off-by: Liviu Dudau 
Signed-off-by: Jon Medhurst 
---
 drivers/staging/android/ion/ion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e237e9f..df56021 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -251,8 +251,10 @@ static struct ion_buffer *ion_buffer_create(struct 
ion_heap *heap,
 * memory coming from the heaps is ready for dma, ie if it has a
 * cached mapping that mapping has been invalidated
 */
-   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
+   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) {
sg_dma_address(sg) = sg_phys(sg);
+   sg_dma_len(sg) = sg->length;
+   }
mutex_lock(&dev->buffer_lock);
ion_buffer_add(dev, buffer);
mutex_unlock(&dev->buffer_lock);
-- 
2.1.4



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


Re: [PATCH 1/3] staging: comedi: mite: enable continuous regeneration of finite samples

2016-01-21 Thread Ian Abbott

On 12/01/16 08:17, Spencer E. Olson wrote:

This change enables the mite DMA controller to only transfer the amount of
data needed by a command.  By default, the old behavior of transferring the
entire comedi DMA data buffer is still in effect.  These changes allow a
command to only transmit a limited portion of that data buffer as needed.

This patch begins to reinterprets stop_arg when stop_src == TRIG_NONE to
allow the user to specify the length of the buffer that should be repeated.
The intent is to allow a user to have a specific buffer repeated as-is
indefinitely.  The contents of the DMA buffer can be left static or changed
by the user via mmap access to the DMA buffer.  If the contents are changed
by the user, additional munging is not performed by the driver and only a
single call to comedi_mark_buffer_written should be done.

Signed-off-by: Spencer E. Olson 
---
  drivers/staging/comedi/drivers/mite.c | 72 ++-
  drivers/staging/comedi/drivers/mite.h |  3 ++
  2 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mite.c 
b/drivers/staging/comedi/drivers/mite.c
index fa7ae2c..8f24702 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -297,7 +297,6 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
  {
struct comedi_async *async = s->async;
unsigned int n_links;
-   int i;

if (ring->descriptors) {
dma_free_coherent(ring->hw_dev,
@@ -326,17 +325,58 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
}
ring->n_links = n_links;

-   for (i = 0; i < n_links; i++) {
+   return mite_init_ring_descriptors(ring, s, n_links << PAGE_SHIFT);
+}
+EXPORT_SYMBOL_GPL(mite_buf_change);
+
+/*
+ * initializes the ring buffer descriptors to provide correct DMA transfer 
links
+ * to the exact amount of memory required.  When the ring buffer is allocated 
in
+ * mite_buf_change, the default is to initialize the ring to refer to the 
entire
+ * DMA data buffer.  A command may call this function later to re-initialize 
and
+ * shorten the amount of memory that will be transferred.
+ */
+int mite_init_ring_descriptors(struct mite_dma_descriptor_ring *ring,
+  struct comedi_subdevice *s,
+  unsigned int nbytes)
+{
+   struct comedi_async *async = s->async;
+   unsigned int n_full_links = nbytes >> PAGE_SHIFT;
+   unsigned int remainder = nbytes % PAGE_SIZE;
+   int i;
+
+   dev_dbg(s->device->class_dev,
+   "mite: init ring buffer to %u bytes\n", nbytes);
+
+   if ((n_full_links + (remainder > 0 ? 1 : 0)) > ring->n_links) {
+   dev_err(s->device->class_dev,
+   "mite: ring buffer too small for requested init\n");
+   return -ENOMEM;
+   }
+
+   /* We set the descriptors for all full links. */
+   for (i = 0; i < n_full_links; ++i) {
ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
ring->descriptors[i].addr =
cpu_to_le32(async->buf_map->page_list[i].dma_addr);
ring->descriptors[i].next =
-   cpu_to_le32(ring->descriptors_dma_addr + (i +
- 1) *
-   sizeof(struct mite_dma_descriptor));
+   cpu_to_le32(ring->descriptors_dma_addr +
+   (i + 1) * sizeof(struct mite_dma_descriptor));
}
-   ring->descriptors[n_links - 1].next =
-   cpu_to_le32(ring->descriptors_dma_addr);
+
+   /* the last link is either a remainder or was a full link. */
+   if (remainder > 0) {
+   /* set the lesser count for the remainder link */
+   ring->descriptors[i].count = cpu_to_le32(remainder);
+   ring->descriptors[i].addr =
+   cpu_to_le32(async->buf_map->page_list[i].dma_addr);
+   /* increment i so that assignment below refs last link */
+   ++i;
+   }
+
+   /* Assign the last link->next to point back to the head of the list. */
+   ring->descriptors[i - 1].next = cpu_to_le32(ring->descriptors_dma_addr);
+
/*
 * barrier is meant to insure that all the writes to the dma descriptors
 * have completed before the dma controller is commanded to read them
@@ -344,7 +384,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
smp_wmb();
return 0;
  }
-EXPORT_SYMBOL_GPL(mite_buf_change);
+EXPORT_SYMBOL_GPL(mite_init_ring_descriptors);

  void mite_prep_dma(struct mite_channel *mite_chan,
   unsigned int num_device_bits, unsigned int num_memory_bits)
@@ -552,6 +592,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
unsigned int old_alloc_count = async->buf_read_alloc_count;
u32 nbytes_ub

[PATCH 04/11] staging/android: create a 'sync' dir for debugfs information

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

Creates the 'sync' dir on debugfs root dir and move the 'sync' file
to sync/info. This is the preparation to add more debug info and control.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync_debug.c | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index b366461..ca35f97 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,6 +31,8 @@
 
 #ifdef CONFIG_DEBUG_FS
 
+static struct dentry *dbgfs;
+
 static LIST_HEAD(sync_timeline_list_head);
 static DEFINE_SPINLOCK(sync_timeline_list_lock);
 static LIST_HEAD(sync_fence_list_head);
@@ -193,13 +196,13 @@ static int sync_debugfs_show(struct seq_file *s, void 
*unused)
return 0;
 }
 
-static int sync_debugfs_open(struct inode *inode, struct file *file)
+static int sync_info_debugfs_open(struct inode *inode, struct file *file)
 {
return single_open(file, sync_debugfs_show, inode->i_private);
 }
 
-static const struct file_operations sync_debugfs_fops = {
-   .open   = sync_debugfs_open,
+static const struct file_operations sync_info_debugfs_fops = {
+   .open   = sync_info_debugfs_open,
.read   = seq_read,
.llseek = seq_lseek,
.release= single_release,
@@ -207,11 +210,21 @@ static const struct file_operations sync_debugfs_fops = {
 
 static __init int sync_debugfs_init(void)
 {
-   debugfs_create_file("sync", S_IRUGO, NULL, NULL, &sync_debugfs_fops);
+   dbgfs = debugfs_create_dir("sync", NULL);
+
+   debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops);
+
return 0;
 }
 late_initcall(sync_debugfs_init);
 
+static __exit void sync_debugfs_exit(void)
+{
+   if (dbgfs)
+   debugfs_remove_recursive(dbgfs);
+}
+module_exit(sync_debugfs_exit);
+
 #define DUMP_CHUNK 256
 static char sync_dump_buf[64 * 1024];
 void sync_dump(void)
-- 
2.5.0

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


[PATCH 02/11] staging/android: sync: remove interfaces that are not used

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

These interfaces are not used nor have plans to be used in the near
future so remove them for a cleaner solution before de-staging the sync
framework.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c   | 56 
 drivers/staging/android/sync.h   | 50 
 drivers/staging/android/sync_debug.c | 15 --
 3 files changed, 121 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index ed43796..7a84f88 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -317,62 +317,6 @@ struct sync_fence *sync_fence_merge(const char *name,
 }
 EXPORT_SYMBOL(sync_fence_merge);
 
-int sync_fence_wake_up_wq(wait_queue_t *curr, unsigned mode,
- int wake_flags, void *key)
-{
-   struct sync_fence_waiter *wait;
-
-   wait = container_of(curr, struct sync_fence_waiter, work);
-   list_del_init(&wait->work.task_list);
-
-   wait->callback(wait->work.private, wait);
-   return 1;
-}
-
-int sync_fence_wait_async(struct sync_fence *fence,
- struct sync_fence_waiter *waiter)
-{
-   int err = atomic_read(&fence->status);
-   unsigned long flags;
-
-   if (err < 0)
-   return err;
-
-   if (!err)
-   return 1;
-
-   init_waitqueue_func_entry(&waiter->work, sync_fence_wake_up_wq);
-   waiter->work.private = fence;
-
-   spin_lock_irqsave(&fence->wq.lock, flags);
-   err = atomic_read(&fence->status);
-   if (err > 0)
-   __add_wait_queue_tail(&fence->wq, &waiter->work);
-   spin_unlock_irqrestore(&fence->wq.lock, flags);
-
-   if (err < 0)
-   return err;
-
-   return !err;
-}
-EXPORT_SYMBOL(sync_fence_wait_async);
-
-int sync_fence_cancel_async(struct sync_fence *fence,
-   struct sync_fence_waiter *waiter)
-{
-   unsigned long flags;
-   int ret = 0;
-
-   spin_lock_irqsave(&fence->wq.lock, flags);
-   if (!list_empty(&waiter->work.task_list))
-   list_del_init(&waiter->work.task_list);
-   else
-   ret = -ENOENT;
-   spin_unlock_irqrestore(&fence->wq.lock, flags);
-   return ret;
-}
-EXPORT_SYMBOL(sync_fence_cancel_async);
-
 int sync_fence_wait(struct sync_fence *fence, long timeout)
 {
long ret;
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 7a4d820..e0865b9 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -159,27 +159,6 @@ struct sync_fence {
struct sync_fence_cbcbs[];
 };
 
-struct sync_fence_waiter;
-typedef void (*sync_callback_t)(struct sync_fence *fence,
-   struct sync_fence_waiter *waiter);
-
-/**
- * struct sync_fence_waiter - metadata for asynchronous waiter on a fence
- * @work:  wait_queue for the fence waiter
- * @callback:  function pointer to call when fence signals
- */
-struct sync_fence_waiter {
-   wait_queue_t work;
-   sync_callback_t callback;
-};
-
-static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter,
- sync_callback_t callback)
-{
-   INIT_LIST_HEAD(&waiter->work.task_list);
-   waiter->callback = callback;
-}
-
 /*
  * API for sync_timeline implementers
  */
@@ -304,33 +283,6 @@ void sync_fence_put(struct sync_fence *fence);
 void sync_fence_install(struct sync_fence *fence, int fd);
 
 /**
- * sync_fence_wait_async() - registers and async wait on the fence
- * @fence: fence to wait on
- * @waiter:waiter callback struck
- *
- * Registers a callback to be called when @fence signals or has an error.
- * @waiter should be initialized with sync_fence_waiter_init().
- *
- * Returns 1 if @fence has already signaled, 0 if not or <0 if error.
- */
-int sync_fence_wait_async(struct sync_fence *fence,
- struct sync_fence_waiter *waiter);
-
-/**
- * sync_fence_cancel_async() - cancels an async wait
- * @fence: fence to wait on
- * @waiter:waiter callback struck
- *
- * Cancels a previously registered async wait.  Will fail gracefully if
- * @waiter was never registered or if @fence has already signaled @waiter.
- *
- * Returns 0 if waiter was removed from fence's async waiter list.
- * Returns -ENOENT if waiter was not found on fence's async waiter list.
- */
-int sync_fence_cancel_async(struct sync_fence *fence,
-   struct sync_fence_waiter *waiter);
-
-/**
  * sync_fence_wait() - wait on fence
  * @fence: fence to wait on
  * @tiemout:   timeout in ms
@@ -357,7 +309,5 @@ void sync_dump(void);
 # define sync_fence_debug_remove(fence)
 # define sync_dump()
 #endif
-int sync_fence_wake_up_wq(wait_queue_t *curr, unsigned mode,
-int wake_flags, void *key);
 
 #e

[PATCH 07/11] staging/android: rename 'sync_pt' to 'fence' in struct sync_fence_cb

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

'sync_pt' is actually declared as struct fence so to make the name means
its type we rename it to 'fence'.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c   | 20 ++--
 drivers/staging/android/sync.h   |  2 +-
 drivers/staging/android/sync_debug.c |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 8cccdf9..22b1d9b 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -197,7 +197,7 @@ struct sync_file *sync_file_create_dma(const char *name, 
struct fence *pt)
sync_file->num_fences = 1;
atomic_set(&sync_file->status, 1);
 
-   sync_file->cbs[0].sync_pt = pt;
+   sync_file->cbs[0].fence = pt;
sync_file->cbs[0].sync_file = sync_file;
if (fence_add_callback(pt, &sync_file->cbs[0].cb, fence_check_cb_func))
atomic_dec(&sync_file->status);
@@ -247,7 +247,7 @@ EXPORT_SYMBOL(sync_file_install);
 static void sync_file_add_pt(struct sync_file *sync_file, int *i,
 struct fence *pt)
 {
-   sync_file->cbs[*i].sync_pt = pt;
+   sync_file->cbs[*i].fence = pt;
sync_file->cbs[*i].sync_file = sync_file;
 
if (!fence_add_callback(pt, &sync_file->cbs[*i].cb,
@@ -279,8 +279,8 @@ struct sync_file *sync_file_merge(const char *name,
 * and sync_file_create, this is a reasonable assumption.
 */
for (i = i_a = i_b = 0; i_a < a->num_fences && i_b < b->num_fences; ) {
-   struct fence *pt_a = a->cbs[i_a].sync_pt;
-   struct fence *pt_b = b->cbs[i_b].sync_pt;
+   struct fence *pt_a = a->cbs[i_a].fence;
+   struct fence *pt_b = b->cbs[i_b].fence;
 
if (pt_a->context < pt_b->context) {
sync_file_add_pt(sync_file, &i, pt_a);
@@ -302,10 +302,10 @@ struct sync_file *sync_file_merge(const char *name,
}
 
for (; i_a < a->num_fences; i_a++)
-   sync_file_add_pt(sync_file, &i, a->cbs[i_a].sync_pt);
+   sync_file_add_pt(sync_file, &i, a->cbs[i_a].fence);
 
for (; i_b < b->num_fences; i_b++)
-   sync_file_add_pt(sync_file, &i, b->cbs[i_b].sync_pt);
+   sync_file_add_pt(sync_file, &i, b->cbs[i_b].fence);
 
if (num_fences > i)
atomic_sub(num_fences - i, &sync_file->status);
@@ -328,7 +328,7 @@ int sync_file_wait(struct sync_file *sync_file, long 
timeout)
 
trace_sync_wait(sync_file, 1);
for (i = 0; i < sync_file->num_fences; ++i)
-   trace_sync_pt(sync_file->cbs[i].sync_pt);
+   trace_sync_pt(sync_file->cbs[i].fence);
ret = wait_event_interruptible_timeout(sync_file->wq,
   atomic_read(&sync_file->status) 
<= 0,
   timeout);
@@ -468,9 +468,9 @@ static void sync_file_free(struct kref *kref)
int i;
 
for (i = 0; i < sync_file->num_fences; ++i) {
-   fence_remove_callback(sync_file->cbs[i].sync_pt,
+   fence_remove_callback(sync_file->cbs[i].fence,
  &sync_file->cbs[i].cb);
-   fence_put(sync_file->cbs[i].sync_pt);
+   fence_put(sync_file->cbs[i].fence);
}
 
kfree(sync_file);
@@ -624,7 +624,7 @@ static long sync_file_ioctl_fence_info(struct sync_file 
*sync_file,
len = sizeof(struct sync_file_info_data);
 
for (i = 0; i < sync_file->num_fences; ++i) {
-   struct fence *pt = sync_file->cbs[i].sync_pt;
+   struct fence *pt = sync_file->cbs[i].fence;
 
ret = sync_fill_pt_info(pt, (u8 *)data + len, size - len);
 
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index bec62c3..a18d1e3 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -110,7 +110,7 @@ static inline struct sync_timeline *sync_pt_parent(struct 
sync_pt *pt)
 
 struct sync_file_cb {
struct fence_cb cb;
-   struct fence *sync_pt;
+   struct fence *fence;
struct sync_file *sync_file;
 };
 
diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index 6887ba7..1889b5b 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -161,7 +161,7 @@ static void sync_print_sync_file(struct seq_file *s,
   sync_status_str(atomic_read(&sync_file->status)));
 
for (i = 0; i < sync_file->num_fences; ++i) {
-   sync_print_pt(s, sync_file->cbs[i].sync_pt, true);
+   sync_print_pt(s, sync_file->cbs[i].fence, true);
}
 }
 
-- 
2.5.0

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


[PATCH 05/11] staging/android: move SW_SYNC_USER to a debugfs file

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

This remove CONFIG_SW_SYNC_USER and instead compile the sw_sync file into
debugpfs under /sync/sw_sync.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/Kconfig  |   9 ---
 drivers/staging/android/sw_sync.c| 129 ---
 drivers/staging/android/sync_debug.c | 118 +++-
 3 files changed, 117 insertions(+), 139 deletions(-)

diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 42b1512..bd90d20 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -57,15 +57,6 @@ config SW_SYNC
  synchronization.  Useful when there is no hardware primitive backing
  the synchronization.
 
-config SW_SYNC_USER
-   bool "Userspace API for SW_SYNC"
-   default n
-   depends on SW_SYNC
-   ---help---
- Provides a user space API to the sw sync object.
- *WARNING* improper use of this can result in deadlocking kernel
- drivers from userspace.
-
 source "drivers/staging/android/ion/Kconfig"
 
 endif # if ANDROID
diff --git a/drivers/staging/android/sw_sync.c 
b/drivers/staging/android/sw_sync.c
index 566dcdc..f491dbc 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -102,132 +102,3 @@ void sw_sync_timeline_inc(struct sw_sync_timeline *obj, 
u32 inc)
sync_timeline_signal(&obj->obj);
 }
 EXPORT_SYMBOL(sw_sync_timeline_inc);
-
-#ifdef CONFIG_SW_SYNC_USER
-/* *WARNING*
- *
- * improper use of this can result in deadlocking kernel drivers from 
userspace.
- */
-
-/* opening sw_sync create a new sync obj */
-static int sw_sync_open(struct inode *inode, struct file *file)
-{
-   struct sw_sync_timeline *obj;
-   char task_comm[TASK_COMM_LEN];
-
-   get_task_comm(task_comm, current);
-
-   obj = sw_sync_timeline_create(task_comm);
-   if (!obj)
-   return -ENOMEM;
-
-   file->private_data = obj;
-
-   return 0;
-}
-
-static int sw_sync_release(struct inode *inode, struct file *file)
-{
-   struct sw_sync_timeline *obj = file->private_data;
-
-   sync_timeline_destroy(&obj->obj);
-   return 0;
-}
-
-static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj,
-  unsigned long arg)
-{
-   int fd = get_unused_fd_flags(O_CLOEXEC);
-   int err;
-   struct sync_pt *pt;
-   struct sync_fence *fence;
-   struct sw_sync_create_fence_data data;
-
-   if (fd < 0)
-   return fd;
-
-   if (copy_from_user(&data, (void __user *)arg, sizeof(data))) {
-   err = -EFAULT;
-   goto err;
-   }
-
-   pt = sw_sync_pt_create(obj, data.value);
-   if (!pt) {
-   err = -ENOMEM;
-   goto err;
-   }
-
-   data.name[sizeof(data.name) - 1] = '\0';
-   fence = sync_fence_create(data.name, pt);
-   if (!fence) {
-   sync_pt_free(pt);
-   err = -ENOMEM;
-   goto err;
-   }
-
-   data.fence = fd;
-   if (copy_to_user((void __user *)arg, &data, sizeof(data))) {
-   sync_fence_put(fence);
-   err = -EFAULT;
-   goto err;
-   }
-
-   sync_fence_install(fence, fd);
-
-   return 0;
-
-err:
-   put_unused_fd(fd);
-   return err;
-}
-
-static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg)
-{
-   u32 value;
-
-   if (copy_from_user(&value, (void __user *)arg, sizeof(value)))
-   return -EFAULT;
-
-   sw_sync_timeline_inc(obj, value);
-
-   return 0;
-}
-
-static long sw_sync_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
-   struct sw_sync_timeline *obj = file->private_data;
-
-   switch (cmd) {
-   case SW_SYNC_IOC_CREATE_FENCE:
-   return sw_sync_ioctl_create_fence(obj, arg);
-
-   case SW_SYNC_IOC_INC:
-   return sw_sync_ioctl_inc(obj, arg);
-
-   default:
-   return -ENOTTY;
-   }
-}
-
-static const struct file_operations sw_sync_fops = {
-   .owner = THIS_MODULE,
-   .open = sw_sync_open,
-   .release = sw_sync_release,
-   .unlocked_ioctl = sw_sync_ioctl,
-   .compat_ioctl = sw_sync_ioctl,
-};
-
-static struct miscdevice sw_sync_dev = {
-   .minor  = MISC_DYNAMIC_MINOR,
-   .name   = "sw_sync",
-   .fops   = &sw_sync_fops,
-};
-
-static int __init sw_sync_device_init(void)
-{
-   return misc_register(&sw_sync_dev);
-}
-device_initcall(sw_sync_device_init);
-
-#endif /* CONFIG_SW_SYNC_USER */
diff --git a/drivers/staging/android/sync_debug.c 
b/drivers/staging/android/sync_debug.c
index ca35f97..ae08fc1 100644
--- a/drivers/staging/android/sync_debug.c
+++ b/drivers/staging/android/sync_debug.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include "sync.h"
+#include "sw_sync.h"
 
 #ifdef CONFIG_DEBUG_FS
 
@@

[PATCH 01/11] staging/android: fix sync framework documentation

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

Updates comments about functions and structures.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.h | 45 --
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index afa0752..7a4d820 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -110,15 +110,9 @@ struct sync_timeline {
 
 /**
  * struct sync_pt - sync point
- * @fence: base fence class
+ * @base:  base fence class
  * @child_list:membership in sync_timeline.child_list_head
  * @active_list:   membership in sync_timeline.active_list_head
- * @signaled_list: membership in temporary signaled_list on stack
- * @fence: sync_fence to which the sync_pt belongs
- * @pt_list:   membership in sync_fence.pt_list_head
- * @status:1: signaled, 0:active, <0: error
- * @timestamp: time which sync_pt status transitioned from active to
- *   signaled or error.
  */
 struct sync_pt {
struct fence base;
@@ -144,12 +138,11 @@ struct sync_fence_cb {
  * @file:  file representing this fence
  * @kref:  reference count on fence.
  * @name:  name of sync_fence.  Useful for debugging
- * @pt_list_head:  list of sync_pts in the fence.  immutable once fence
- *   is created
- * @status:0: signaled, >0:active, <0: error
- *
- * @wq:wait queue for fence signaling
  * @sync_fence_list:   membership in global fence list
+ * @num_fences number of sync_pts in the fence
+ * @wq:wait queue for fence signaling
+ * @status:0: signaled, >0:active, <0: error
+ * @cbs:   sync_pts callback information
  */
 struct sync_fence {
struct file *file;
@@ -172,9 +165,8 @@ typedef void (*sync_callback_t)(struct sync_fence *fence,
 
 /**
  * struct sync_fence_waiter - metadata for asynchronous waiter on a fence
- * @waiter_list:   membership in sync_fence.waiter_list_head
+ * @work:  wait_queue for the fence waiter
  * @callback:  function pointer to call when fence signals
- * @callback_data: pointer to pass to @callback
  */
 struct sync_fence_waiter {
wait_queue_t work;
@@ -200,7 +192,8 @@ static inline void sync_fence_waiter_init(struct 
sync_fence_waiter *waiter,
  *
  * Creates a new sync_timeline which will use the implementation specified by
  * @ops.  @size bytes will be allocated allowing for implementation specific
- * data to be kept after the generic sync_timeline struct.
+ * data to be kept after the generic sync_timeline struct. Returns the
+ * sync_timeline object or NULL in case of error.
  */
 struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
   int size, const char *name);
@@ -231,7 +224,8 @@ void sync_timeline_signal(struct sync_timeline *obj);
  *
  * Creates a new sync_pt as a child of @parent.  @size bytes will be
  * allocated allowing for implementation specific data to be kept after
- * the generic sync_timeline struct.
+ * the generic sync_timeline struct. Returns the sync_pt object or
+ * NULL in case of error.
  */
 struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size);
 
@@ -275,7 +269,8 @@ struct sync_fence *sync_fence_create_dma(const char *name, 
struct fence *pt);
  * @b: fence b
  *
  * Creates a new fence which contains copies of all the sync_pts in both
- * @a and @b.  @a and @b remain valid, independent fences.
+ * @a and @b.  @a and @b remain valid, independent fences. Returns the
+ * new merged fence or NULL in case of error.
  */
 struct sync_fence *sync_fence_merge(const char *name,
struct sync_fence *a, struct sync_fence *b);
@@ -285,7 +280,7 @@ struct sync_fence *sync_fence_merge(const char *name,
  * @fd:fd referencing a fence
  *
  * Ensures @fd references a valid fence, increments the refcount of the backing
- * file, and returns the fence.
+ * file, and returns the fence. Returns the fence or NULL in case of error.
  */
 struct sync_fence *sync_fence_fdget(int fd);
 
@@ -313,10 +308,10 @@ void sync_fence_install(struct sync_fence *fence, int fd);
  * @fence: fence to wait on
  * @waiter:waiter callback struck
  *
- * Returns 1 if @fence has already signaled.
- *
  * Registers a callback to be called when @fence signals or has an error.
  * @waiter should be initialized with sync_fence_waiter_init().
+ *
+ * Returns 1 if @fence has already signaled, 0 if not or <0 if error.
  */
 int sync_fence_wait_async(struct sync_fence *fence,
  struct sync_fence_waiter *waiter);
@@ -326,11 +321,11 @@ int sync_fence_wait_async(struct sync_fence *fence,
  * @fence:  

[PATCH 00/11] sync framework de-staging: part 1 - clean up

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

Hi,

The following patches are some clean ups on the sync framework before
we start the actual de-staging. The main changes here are the move of
SW_SYNC_USER to debugfs. Removal of struct sync_pt in favor of direct
use of struct fence. And the rename of sync_fence to sync_file, a name
to better reflect what it is for, a struct that connects struct fence(s)
to a file.

Please review. Thanks.

Gustavo Padovan (11):
  staging/android: fix sync framework documentation
  staging/android: sync: remove interfaces that are not used
  staging/android: remove not used sync_timeline ops
  staging/android: create a 'sync' dir for debugfs information
  staging/android: move SW_SYNC_USER to a debugfs file
  staging/android: rename sync_fence to sync_file
  staging/android: rename 'sync_pt' to 'fence' in struct sync_fence_cb
  staging/android: remove struct sync_pt
  staging/android: remove unused var from sync_timeline_signal()
  staging/android: remove pointless sync_timeline_signal at destroy
phase
  staging/android: remove sync_fence_create_dma()

 drivers/staging/android/Kconfig  |   9 -
 drivers/staging/android/sw_sync.c| 181 ++--
 drivers/staging/android/sw_sync.h|   8 +-
 drivers/staging/android/sync.c   | 406 ++-
 drivers/staging/android/sync.h   | 237 ++--
 drivers/staging/android/sync_debug.c | 228 +++-
 drivers/staging/android/trace/sync.h |  24 +--
 drivers/staging/android/uapi/sync.h  |  14 +-
 include/linux/fence.h|   2 +
 9 files changed, 438 insertions(+), 671 deletions(-)

-- 
2.5.0

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


[PATCH 11/11] staging/android: remove sync_fence_create_dma()

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

With the removal of struct sync_pt sync_fence_create_dma() now takes
the same arguments as sync_fence_create() so let's keep only
sync_fence_create().

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c |  8 +---
 drivers/staging/android/sync.h | 10 --
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index b9f167f..5fa4779 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -174,7 +174,7 @@ static void fence_check_cb_func(struct fence *f, struct 
fence_cb *cb)
 }
 
 /* TODO: implement a create which takes more that one fence */
-struct sync_file *sync_file_create_dma(const char *name, struct fence *fence)
+struct sync_file *sync_file_create(const char *name, struct fence *fence)
 {
struct sync_file *sync_file;
 
@@ -196,12 +196,6 @@ struct sync_file *sync_file_create_dma(const char *name, 
struct fence *fence)
 
return sync_file;
 }
-EXPORT_SYMBOL(sync_file_create_dma);
-
-struct sync_file *sync_file_create(const char *name, struct fence *fence)
-{
-   return sync_file_create_dma(name, fence);
-}
 EXPORT_SYMBOL(sync_file_create);
 
 struct sync_file *sync_file_fdget(int fd)
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index 8cdac1a..8980b55 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -185,16 +185,6 @@ struct fence *sync_pt_create(struct sync_timeline *parent, 
int size);
  */
 struct sync_file *sync_file_create(const char *name, struct fence *fence);
 
-/**
- * sync_file_create_dma() - creates a sync file from dma-fence
- * @name:  name of file to create
- * @pt:dma-fence to add to the file
- *
- * Creates a sync_file containg @pt.  Once this is called, the fence takes
- * ownership of @pt.
- */
-struct sync_file *sync_file_create_dma(const char *name, struct fence *pt);
-
 /*
  * API for sync_file consumers
  */
-- 
2.5.0

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


[PATCH 03/11] staging/android: remove not used sync_timeline ops

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

.dup and .compare are not used by the sync framework, so remove them
from sw_sync.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sw_sync.c | 29 +
 drivers/staging/android/sync.c|  6 --
 drivers/staging/android/sync.h| 19 ---
 3 files changed, 1 insertion(+), 53 deletions(-)

diff --git a/drivers/staging/android/sw_sync.c 
b/drivers/staging/android/sw_sync.c
index c4ff167..566dcdc 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -25,14 +25,6 @@
 
 #include "sw_sync.h"
 
-static int sw_sync_cmp(u32 a, u32 b)
-{
-   if (a == b)
-   return 0;
-
-   return ((s32)a - (s32)b) < 0 ? -1 : 1;
-}
-
 struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
 {
struct sw_sync_pt *pt;
@@ -46,30 +38,13 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline 
*obj, u32 value)
 }
 EXPORT_SYMBOL(sw_sync_pt_create);
 
-static struct sync_pt *sw_sync_pt_dup(struct sync_pt *sync_pt)
-{
-   struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
-   struct sw_sync_timeline *obj =
-   (struct sw_sync_timeline *)sync_pt_parent(sync_pt);
-
-   return (struct sync_pt *)sw_sync_pt_create(obj, pt->value);
-}
-
 static int sw_sync_pt_has_signaled(struct sync_pt *sync_pt)
 {
struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
struct sw_sync_timeline *obj =
(struct sw_sync_timeline *)sync_pt_parent(sync_pt);
 
-   return sw_sync_cmp(obj->value, pt->value) >= 0;
-}
-
-static int sw_sync_pt_compare(struct sync_pt *a, struct sync_pt *b)
-{
-   struct sw_sync_pt *pt_a = (struct sw_sync_pt *)a;
-   struct sw_sync_pt *pt_b = (struct sw_sync_pt *)b;
-
-   return sw_sync_cmp(pt_a->value, pt_b->value);
+   return (pt->value > obj->value) ? 0 : 1;
 }
 
 static int sw_sync_fill_driver_data(struct sync_pt *sync_pt,
@@ -103,9 +78,7 @@ static void sw_sync_pt_value_str(struct sync_pt *sync_pt,
 
 static struct sync_timeline_ops sw_sync_timeline_ops = {
.driver_name = "sw_sync",
-   .dup = sw_sync_pt_dup,
.has_signaled = sw_sync_pt_has_signaled,
-   .compare = sw_sync_pt_compare,
.fill_driver_data = sw_sync_fill_driver_data,
.timeline_value_str = sw_sync_timeline_value_str,
.pt_value_str = sw_sync_pt_value_str,
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 7a84f88..f4d9bcd 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -68,9 +68,6 @@ static void sync_timeline_free(struct kref *kref)
 
sync_timeline_debug_remove(obj);
 
-   if (obj->ops->release_obj)
-   obj->ops->release_obj(obj);
-
kfree(obj);
 }
 
@@ -383,9 +380,6 @@ static void android_fence_release(struct fence *fence)
list_del(&pt->active_list);
spin_unlock_irqrestore(fence->lock, flags);
 
-   if (parent->ops->free_pt)
-   parent->ops->free_pt(pt);
-
sync_timeline_put(parent);
fence_free(&pt->base);
 }
diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h
index e0865b9..b47058f 100644
--- a/drivers/staging/android/sync.h
+++ b/drivers/staging/android/sync.h
@@ -30,17 +30,10 @@ struct sync_fence;
 /**
  * struct sync_timeline_ops - sync object implementation ops
  * @driver_name:   name of the implementation
- * @dup:   duplicate a sync_pt
  * @has_signaled:  returns:
  *   1 if pt has signaled
  *   0 if pt has not signaled
  *  <0 on error
- * @compare:   returns:
- *   1 if b will signal before a
- *   0 if a and b will signal at the same time
- *  -1 if a will signal before b
- * @free_pt:   called before sync_pt is freed
- * @release_obj:   called before sync_timeline is freed
  * @fill_driver_data:  write implementation specific driver data to data.
  *   should return an error if there is not enough room
  *   as specified by size.  This information is returned
@@ -52,20 +45,8 @@ struct sync_timeline_ops {
const char *driver_name;
 
/* required */
-   struct sync_pt * (*dup)(struct sync_pt *pt);
-
-   /* required */
int (*has_signaled)(struct sync_pt *pt);
 
-   /* required */
-   int (*compare)(struct sync_pt *a, struct sync_pt *b);
-
-   /* optional */
-   void (*free_pt)(struct sync_pt *sync_pt);
-
-   /* optional */
-   void (*release_obj)(struct sync_timeline *sync_timeline);
-
/* optional */
int (*fill_driver_data)(struct sync_pt *syncpt, void *data, int size);
 
-- 
2.5.0

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

[PATCH 06/11] staging/android: rename sync_fence to sync_file

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

sync_file has a more close meaning to what a sync_fence really, a struct
that represent a file that can be used by userspace to get information on
a fence, or wait for it to be signaled.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c   | 254 ++-
 drivers/staging/android/sync.h   |  98 +++---
 drivers/staging/android/sync_debug.c |  53 
 drivers/staging/android/trace/sync.h |  10 +-
 drivers/staging/android/uapi/sync.h  |  14 +-
 5 files changed, 218 insertions(+), 211 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index f4d9bcd..8cccdf9 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -32,7 +32,7 @@
 #include "trace/sync.h"
 
 static const struct fence_ops android_fence_ops;
-static const struct file_operations sync_fence_fops;
+static const struct file_operations sync_file_fops;
 
 struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops,
   int size, const char *name)
@@ -147,80 +147,81 @@ void sync_pt_free(struct sync_pt *pt)
 }
 EXPORT_SYMBOL(sync_pt_free);
 
-static struct sync_fence *sync_fence_alloc(int size, const char *name)
+static struct sync_file *sync_file_alloc(int size, const char *name)
 {
-   struct sync_fence *fence;
+   struct sync_file *sync_file;
 
-   fence = kzalloc(size, GFP_KERNEL);
-   if (!fence)
+   sync_file = kzalloc(size, GFP_KERNEL);
+   if (!sync_file)
return NULL;
 
-   fence->file = anon_inode_getfile("sync_fence", &sync_fence_fops,
-fence, 0);
-   if (IS_ERR(fence->file))
+   sync_file->file = anon_inode_getfile("sync_file", &sync_file_fops,
+sync_file, 0);
+   if (IS_ERR(sync_file->file))
goto err;
 
-   kref_init(&fence->kref);
-   strlcpy(fence->name, name, sizeof(fence->name));
+   kref_init(&sync_file->kref);
+   strlcpy(sync_file->name, name, sizeof(sync_file->name));
 
-   init_waitqueue_head(&fence->wq);
+   init_waitqueue_head(&sync_file->wq);
 
-   return fence;
+   return sync_file;
 
 err:
-   kfree(fence);
+   kfree(sync_file);
return NULL;
 }
 
 static void fence_check_cb_func(struct fence *f, struct fence_cb *cb)
 {
-   struct sync_fence_cb *check;
-   struct sync_fence *fence;
+   struct sync_file_cb *check;
+   struct sync_file *sync_file;
 
-   check = container_of(cb, struct sync_fence_cb, cb);
-   fence = check->fence;
+   check = container_of(cb, struct sync_file_cb, cb);
+   sync_file = check->sync_file;
 
-   if (atomic_dec_and_test(&fence->status))
-   wake_up_all(&fence->wq);
+   if (atomic_dec_and_test(&sync_file->status))
+   wake_up_all(&sync_file->wq);
 }
 
 /* TODO: implement a create which takes more that one sync_pt */
-struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt)
+struct sync_file *sync_file_create_dma(const char *name, struct fence *pt)
 {
-   struct sync_fence *fence;
+   struct sync_file *sync_file;
 
-   fence = sync_fence_alloc(offsetof(struct sync_fence, cbs[1]), name);
-   if (!fence)
+   sync_file = sync_file_alloc(offsetof(struct sync_file, cbs[1]),
+   name);
+   if (!sync_file)
return NULL;
 
-   fence->num_fences = 1;
-   atomic_set(&fence->status, 1);
+   sync_file->num_fences = 1;
+   atomic_set(&sync_file->status, 1);
 
-   fence->cbs[0].sync_pt = pt;
-   fence->cbs[0].fence = fence;
-   if (fence_add_callback(pt, &fence->cbs[0].cb, fence_check_cb_func))
-   atomic_dec(&fence->status);
+   sync_file->cbs[0].sync_pt = pt;
+   sync_file->cbs[0].sync_file = sync_file;
+   if (fence_add_callback(pt, &sync_file->cbs[0].cb, fence_check_cb_func))
+   atomic_dec(&sync_file->status);
 
-   sync_fence_debug_add(fence);
+   sync_file_debug_add(sync_file);
 
-   return fence;
+   return sync_file;
 }
-EXPORT_SYMBOL(sync_fence_create_dma);
+EXPORT_SYMBOL(sync_file_create_dma);
 
-struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt)
+struct sync_file *sync_file_create(const char *name, struct sync_pt *pt)
 {
-   return sync_fence_create_dma(name, &pt->base);
+   return sync_file_create_dma(name, &pt->base);
 }
-EXPORT_SYMBOL(sync_fence_create);
+EXPORT_SYMBOL(sync_file_create);
 
-struct sync_fence *sync_fence_fdget(int fd)
+struct sync_file *sync_file_fdget(int fd)
 {
struct file *file = fget(fd);
 
if (!file)
return NULL;
 
-   if (file->f_op != &sync_fence_fops)
+   if (file->f_op != &sync_file_fops)
goto err;
 
return file->private_data;
@@ -229,70 +230,71 @@ 

[PATCH 08/11] staging/android: remove struct sync_pt

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

struct sync_pt was just wrapping around struct fence and creating an
extra abstraction layer. The only two members of struct sync_pt, child_list
and active_list, were moved to struct fence in an earlier commit. After
removing those two members struct sync_pt is nothing more than struct
fence, so remove it all and use struct fence directly.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sw_sync.c|  23 
 drivers/staging/android/sw_sync.h|   8 +--
 drivers/staging/android/sync.c   | 101 +++
 drivers/staging/android/sync.h   |  63 +++---
 drivers/staging/android/sync_debug.c |  43 +++
 drivers/staging/android/trace/sync.h |  14 ++---
 include/linux/fence.h|   2 +
 7 files changed, 110 insertions(+), 144 deletions(-)

diff --git a/drivers/staging/android/sw_sync.c 
b/drivers/staging/android/sw_sync.c
index f491dbc..3bee959 100644
--- a/drivers/staging/android/sw_sync.c
+++ b/drivers/staging/android/sw_sync.c
@@ -25,7 +25,7 @@
 
 #include "sw_sync.h"
 
-struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
+struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value)
 {
struct sw_sync_pt *pt;
 
@@ -34,23 +34,23 @@ struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline 
*obj, u32 value)
 
pt->value = value;
 
-   return (struct sync_pt *)pt;
+   return (struct fence *)pt;
 }
 EXPORT_SYMBOL(sw_sync_pt_create);
 
-static int sw_sync_pt_has_signaled(struct sync_pt *sync_pt)
+static int sw_sync_fence_has_signaled(struct fence *fence)
 {
-   struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
+   struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
struct sw_sync_timeline *obj =
-   (struct sw_sync_timeline *)sync_pt_parent(sync_pt);
+   (struct sw_sync_timeline *)fence_parent(fence);
 
return (pt->value > obj->value) ? 0 : 1;
 }
 
-static int sw_sync_fill_driver_data(struct sync_pt *sync_pt,
+static int sw_sync_fill_driver_data(struct fence *fence,
void *data, int size)
 {
-   struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
+   struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
 
if (size < sizeof(pt->value))
return -ENOMEM;
@@ -68,20 +68,19 @@ static void sw_sync_timeline_value_str(struct sync_timeline 
*sync_timeline,
snprintf(str, size, "%d", timeline->value);
 }
 
-static void sw_sync_pt_value_str(struct sync_pt *sync_pt,
-char *str, int size)
+static void sw_sync_fence_value_str(struct fence *fence, char *str, int size)
 {
-   struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;
+   struct sw_sync_pt *pt = (struct sw_sync_pt *)fence;
 
snprintf(str, size, "%d", pt->value);
 }
 
 static struct sync_timeline_ops sw_sync_timeline_ops = {
.driver_name = "sw_sync",
-   .has_signaled = sw_sync_pt_has_signaled,
+   .has_signaled = sw_sync_fence_has_signaled,
.fill_driver_data = sw_sync_fill_driver_data,
.timeline_value_str = sw_sync_timeline_value_str,
-   .pt_value_str = sw_sync_pt_value_str,
+   .fence_value_str = sw_sync_fence_value_str,
 };
 
 struct sw_sync_timeline *sw_sync_timeline_create(const char *name)
diff --git a/drivers/staging/android/sw_sync.h 
b/drivers/staging/android/sw_sync.h
index c87ae9e..e18667b 100644
--- a/drivers/staging/android/sw_sync.h
+++ b/drivers/staging/android/sw_sync.h
@@ -29,7 +29,7 @@ struct sw_sync_timeline {
 };
 
 struct sw_sync_pt {
-   struct sync_pt  pt;
+   struct fencept;
 
u32 value;
 };
@@ -38,7 +38,7 @@ struct sw_sync_pt {
 struct sw_sync_timeline *sw_sync_timeline_create(const char *name);
 void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc);
 
-struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value);
+struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value);
 #else
 static inline struct sw_sync_timeline *sw_sync_timeline_create(const char 
*name)
 {
@@ -49,8 +49,8 @@ static inline void sw_sync_timeline_inc(struct 
sw_sync_timeline *obj, u32 inc)
 {
 }
 
-static inline struct sync_pt *sw_sync_pt_create(struct sw_sync_timeline *obj,
-   u32 value)
+static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj,
+ u32 value)
 {
return NULL;
 }
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 22b1d9b..3c2c8d0 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -102,51 +102,45 @@ void sync_timeline_signal(struct sync_timeline *obj)
 {
unsigned long flags;
LIST_HEAD(signaled_pts);
-   struct sync_pt *pt, *next;
+   struct fence *fence, *next;
 
trace_sync_time

[PATCH 10/11] staging/android: remove pointless sync_timeline_signal at destroy phase

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

All changes to timeline value come through the user via
sync_timeline_signal() calls. When sync_timeline_destroy() is called no
changes on timeline->value happens hence call sync_timeline_signal() with
no increment is pointless.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 9ec55ef..b9f167f 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -90,10 +90,6 @@ void sync_timeline_destroy(struct sync_timeline *obj)
 */
smp_wmb();
 
-   /*
-* signal any children that their parent is going away.
-*/
-   sync_timeline_signal(obj);
sync_timeline_put(obj);
 }
 EXPORT_SYMBOL(sync_timeline_destroy);
-- 
2.5.0

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


[PATCH 09/11] staging/android: remove unused var from sync_timeline_signal()

2016-01-21 Thread Gustavo Padovan
From: Gustavo Padovan 

signaled_pts is not used in this function.

Signed-off-by: Gustavo Padovan 
---
 drivers/staging/android/sync.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 3c2c8d0..9ec55ef 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -101,7 +101,6 @@ EXPORT_SYMBOL(sync_timeline_destroy);
 void sync_timeline_signal(struct sync_timeline *obj)
 {
unsigned long flags;
-   LIST_HEAD(signaled_pts);
struct fence *fence, *next;
 
trace_sync_timeline(obj);
-- 
2.5.0

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


Re: [PATCH 2/3] staging: comedi: ni_mio_comon: adds finite regeneration to AO output

2016-01-21 Thread Ian Abbott

On 12/01/16 08:17, Spencer E. Olson wrote:

This patch implements for analog output the reinterpretation of stop_arg
when stop_src == TRIG_NONE to allow the user to specify the length of the
buffer that should be repeated.  The intent is to allow a user to have a
specific buffer repeated as-is indefinitely.  The contents of the DMA
buffer can be left static or changed by the user via mmap access to the DMA
buffer.  If the contents are changed by the user, additional munging is not
performed by the driver and only a single call to
comedi_mark_buffer_written should be done.

This patch implements ni_ao_cmd much more closely organized like NI MHDDK
examples and DAQ-STC pseudo-code.  Adds comments with some more specific
references to the DAQ-STC.

ni_ao_reset similarly cleaned up and made to appear more comparable to
DAC-STC.

Signed-off-by: Spencer E. Olson 
---
  drivers/staging/comedi/drivers/ni_mio_common.c | 564 ++---
  1 file changed, 405 insertions(+), 159 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 6cc304a..8941351 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c


It would be nice if this patch could be split up, e.g. reorganization of 
ni_ao_cmd(), cleaning up of ni_ao_reset(), reinterpretation of stop_arg 
when stop_src == TRIG_NONE. It's a bit hard to keep track of all the 
changes in this patch.


[snip]

+static void ni_ao_cmd_set_counters(struct comedi_device *dev,
+  const struct comedi_cmd *cmd)
+{
+   struct ni_private *devpriv = dev->private;
+   /* Not supporting 'waveform staging' or 'local buffer with pauses' */
+
+   ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG);
+   /*
+* This relies on ao_mode1/(Trigger_Once | Continuous) being set in
+* set_trigger above.  It is unclear whether we really need to re-write
+* this register with these values.  The mhddk examples for e-series
+* show writing this in both places, but the examples for m-series show
+* a single write in the set_counters function (here).
+*/
ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
+
+   /* sync (upload number of buffer iterations -1) */
+   /* indicate that we want to use BC_Load_A_Register as the source */
devpriv->ao_mode2 &= ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC;
ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
-   if (cmd->stop_src == TRIG_NONE)
-   ni_stc_writel(dev, 0xff, NISTC_AO_BC_LOADA_REG);
-   else
-   ni_stc_writel(dev, 0, NISTC_AO_BC_LOADA_REG);
+
+   /*
+* if the BC_TC interrupt is still issued in spite of UC, BC, UI
+* ignoring BC_TC, then we will need to find a way to ignore that
+* interrupt in continuous mode.
+*/
+   ni_stc_writel(dev, 0, NISTC_AO_BC_LOADA_REG); /* iter once */
+
+   /* sync (issue command to load number of buffer iterations -1) */
ni_stc_writew(dev, NISTC_AO_CMD1_BC_LOAD, NISTC_AO_CMD1_REG);
+
+   /* sync (upload number of updates in buffer) */
+   /* indicate that we want to use UC_Load_A_Register as the source */
devpriv->ao_mode2 &= ~NISTC_AO_MODE2_UC_INIT_LOAD_SRC;
ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
-   switch (cmd->stop_src) {
-   case TRIG_COUNT:
+
+   /*
+* if a user specifies '0', this automatically assumes the entire 24bit
+* address space is available for the (multiple iterations of single
+* buffer) MISB.  Otherwise, stop_arg specifies the MISB length that
+* will be used, regardless of whether we are in continuous mode or not.
+* In continuous mode, the output will just iterate indefinitely over
+* the MISB.
+*/
+   {
+   unsigned int stop_arg = cmd->stop_arg > 0 ?
+   (cmd->stop_arg & 0xff) : 0xff;
+
if (devpriv->is_m_series) {
-   /*  this is how the NI example code does it for 
m-series boards, verified correct with 6259 */
-   ni_stc_writel(dev, cmd->stop_arg - 1,
- NISTC_AO_UC_LOADA_REG);
+   /*
+* this is how the NI example code does it for m-series
+* boards, verified correct with 6259
+*/
+   ni_stc_writel(dev, stop_arg - 1, NISTC_AO_UC_LOADA_REG);
+
+   /* sync (issue cmd to load number of updates in MISB) */
ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD,
  NISTC_AO_CMD1_REG);
} else {
-   ni_stc_writel(dev, cmd->stop_arg,
- NISTC_AO_UC_LOADA_REG)

Re: [PATCH 3/3] staging: comedi: ni_mio_comon: add finite regeneration to dio output

2016-01-21 Thread Ian Abbott

On 12/01/16 08:17, Spencer E. Olson wrote:

This patch continues the implementation of reinterpreting stop_arg when
stop_src == TRIG_NONE for national instruments cdio output on e/m-series
devices.  This is part of a series of patches that allow a user to have a
specific buffer repeated as-is indefinitely.  The contents of the DMA
buffer can be left static or changed by the user via mmap access to the DMA
buffer.  If the contents are changed by the user, additional munging is not
performed by the driver and only a single call to
comedi_mark_buffer_written should be done.  The original behavior is
preserved when stop_arg == 0, as would be the prior use case.

As opposed to analog output, this patch is relatively simple.  First, the
digital output capabilities are much more limited/simple as compared to the
analog output device on NI e/m-series hardware, and second, this patch
relies on changes made with the earlier patch to accomplish limiting the
DMA buffer transfer.

Signed-off-by: Spencer E. Olson 
---
  drivers/staging/comedi/drivers/ni_mio_common.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 8941351..2f79c14 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -3605,7 +3605,9 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
   cmd->chanlist_len);
-   err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
+   err |= comedi_check_trigger_arg_max(&cmd->stop_arg,
+   s->async->prealloc_bufsz /
+   comedi_bytes_per_scan(s));

if (err)
return 3;
@@ -3682,6 +3684,7 @@ static int ni_cdo_inttrig(struct comedi_device *dev,

  static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
  {
+   struct ni_private *devpriv = dev->private;
const struct comedi_cmd *cmd = &s->async->cmd;
unsigned cdo_mode_bits;
int retval;
@@ -3706,6 +3709,10 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
if (retval < 0)
return retval;

+   ni_cmd_set_mite_transfer(devpriv->cdo_mite_ring, s, cmd,
+s->async->prealloc_bufsz /
+comedi_bytes_per_scan(s));
+
s->async->inttrig = ni_cdo_inttrig;

return 0;



Looks good.

Reviewed-by: Ian Abbott 

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: android: ion: Set the length of the DMA sg entries in buffer

2016-01-21 Thread Laura Abbott

On 01/21/2016 03:57 AM, Jon Medhurst (Tixy) wrote:

From: Liviu Dudau 

ion_buffer_create() will allocate a buffer and then create a DMA
mapping for it, but it forgot to set the length of the page entries.

Signed-off-by: Liviu Dudau 
Signed-off-by: Jon Medhurst 
---
  drivers/staging/android/ion/ion.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e237e9f..df56021 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -251,8 +251,10 @@ static struct ion_buffer *ion_buffer_create(struct 
ion_heap *heap,
 * memory coming from the heaps is ready for dma, ie if it has a
 * cached mapping that mapping has been invalidated
 */
-   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
+   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) {
sg_dma_address(sg) = sg_phys(sg);
+   sg_dma_len(sg) = sg->length;
+   }
mutex_lock(&dev->buffer_lock);
ion_buffer_add(dev, buffer);
mutex_unlock(&dev->buffer_lock);



So Ion is really doing it wrong by setting the sg_dma_address manually as
the comment above notes. Ion has moved away from sg_dma_len though
(see 06e0dcaeb4fd72a010a1f5ad0c03abd8e0a58ef9). This isn't technically
a mapping as well. What's broken by not having sg_dma_len set?

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


Re: [PATCH] Staging: panel: Fix sparse warnings (line length, space after a cast) in panel.c

2016-01-21 Thread Arthur Marble
On Thu, Jan 21, 2016 at 12:27:59PM +0300, Dan Carpenter wrote:
> These are all checkpatch.pl warnings, not sparse warnings.
> 
> regards,
> dan carpenter
> 

Thanks for pointing this out. I will be more careful when choosing a subject in
the future.

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


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

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

Shouldn't errout3 now be errout2.. having a gap would seem odd.

> -errout2:
> -   clk_put(st->clk);
>  errout1:
> iounmap(st->adc_base_spear6xx);
> return ret;
> --
> 1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2016-01-21 Thread Dan Carpenter
On Thu, Jan 21, 2016 at 11:21:53AM -0800, Matt Ranostay wrote:
> > @@ -356,8 +356,6 @@ static int spear_adc_probe(struct platform_device *pdev)
> >
> >  errout3:
> > clk_disable_unprepare(st->clk);
> 
> Shouldn't errout3 now be errout2.. having a gap would seem odd.
> 
> > -errout2:
> > -   clk_put(st->clk);
> >  errout1:
> > iounmap(st->adc_base_spear6xx);

GW-BASIC style numbered gotos are nonsense.  Label names should be name
after what the label does.

err_unprepare:
err_put:
err_iounmap:

But that's something for a different patch, not related to this patch.

regards,
dan carpenter

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


Re: [PATCH] staging: android: ion: Set the length of the DMA sg entries in buffer

2016-01-21 Thread Jon Medhurst (Tixy)
On Thu, 2016-01-21 at 09:39 -0800, Laura Abbott wrote:
> On 01/21/2016 03:57 AM, Jon Medhurst (Tixy) wrote:
> > From: Liviu Dudau 
> >
> > ion_buffer_create() will allocate a buffer and then create a DMA
> > mapping for it, but it forgot to set the length of the page entries.
> >
> > Signed-off-by: Liviu Dudau 
> > Signed-off-by: Jon Medhurst 
> > ---
> >   drivers/staging/android/ion/ion.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/android/ion/ion.c 
> > b/drivers/staging/android/ion/ion.c
> > index e237e9f..df56021 100644
> > --- a/drivers/staging/android/ion/ion.c
> > +++ b/drivers/staging/android/ion/ion.c
> > @@ -251,8 +251,10 @@ static struct ion_buffer *ion_buffer_create(struct 
> > ion_heap *heap,
> >  * memory coming from the heaps is ready for dma, ie if it has a
> >  * cached mapping that mapping has been invalidated
> >  */
> > -   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
> > +   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) {
> > sg_dma_address(sg) = sg_phys(sg);
> > +   sg_dma_len(sg) = sg->length;
> > +   }
> > mutex_lock(&dev->buffer_lock);
> > ion_buffer_add(dev, buffer);
> > mutex_unlock(&dev->buffer_lock);
> >
> 
> So Ion is really doing it wrong by setting the sg_dma_address manually as
> the comment above notes. Ion has moved away from sg_dma_len though
> (see 06e0dcaeb4fd72a010a1f5ad0c03abd8e0a58ef9). This isn't technically
> a mapping as well. What's broken by not having sg_dma_len set?

I fear this could end up being embarrassing...

What's broken is that the out-of-tree kernel driver for ARM's Mali GPU
is getting passed a dma_buf corresponding to the ION buffer. It is then
calling dma_buf_map_attachment [1] on that and then parsing the
resultant scatter-gather list to get the physical pages so it can pass
them to the GPU hardware. In the process, it is using sg_dma_len() to
get the length, which is garbage for ION buffers if ion_buffer_create()
doesn't set it.

[1] 
http://git.linaro.org/landing-teams/working/arm/kernel-release.git/blob/9660bff61ab296be02aad111d0bc2b9919493de5:/drivers/gpu/arm/midgard/mali_kbase_jd.c#l333

Now, I just tried making the Mali driver use sg->length rather than 
sg_dma_len() and, unsurprisingly, that also fixes the problem. So, my
questions would be...

Is it acceptable for a driver getting a dma_buf to parse the
scatter-gather list for that by had?

If so, should it use ->length or sg_dma_len() to get the length of each
element?

If sg_dma_len() is correct or acceptable then it seems to me that the
ION code should set that length. Especially as the comment in the code
implies it's faking a call to map_sg and grepping the kernel tree for
real implementations of that functionality seems to show the dma_address
getting set.

As you can probably tell, I feel I may be on shaky ground. This is
because I don't fully understanding the code and suspecting both the ION
and GPU code is rather dodgy (and possibly the bits in between :-)

-- 
Tixy

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


Re: [PATCH] staging: android: ion: Set the length of the DMA sg entries in buffer

2016-01-21 Thread Laura Abbott

On 01/21/2016 12:19 PM, Jon Medhurst (Tixy) wrote:

On Thu, 2016-01-21 at 09:39 -0800, Laura Abbott wrote:

On 01/21/2016 03:57 AM, Jon Medhurst (Tixy) wrote:

From: Liviu Dudau 

ion_buffer_create() will allocate a buffer and then create a DMA
mapping for it, but it forgot to set the length of the page entries.

Signed-off-by: Liviu Dudau 
Signed-off-by: Jon Medhurst 
---
   drivers/staging/android/ion/ion.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index e237e9f..df56021 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -251,8 +251,10 @@ static struct ion_buffer *ion_buffer_create(struct 
ion_heap *heap,
 * memory coming from the heaps is ready for dma, ie if it has a
 * cached mapping that mapping has been invalidated
 */
-   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
+   for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) {
sg_dma_address(sg) = sg_phys(sg);
+   sg_dma_len(sg) = sg->length;
+   }
mutex_lock(&dev->buffer_lock);
ion_buffer_add(dev, buffer);
mutex_unlock(&dev->buffer_lock);



So Ion is really doing it wrong by setting the sg_dma_address manually as
the comment above notes. Ion has moved away from sg_dma_len though
(see 06e0dcaeb4fd72a010a1f5ad0c03abd8e0a58ef9). This isn't technically
a mapping as well. What's broken by not having sg_dma_len set?


I fear this could end up being embarrassing...

What's broken is that the out-of-tree kernel driver for ARM's Mali GPU
is getting passed a dma_buf corresponding to the ION buffer. It is then
calling dma_buf_map_attachment [1] on that and then parsing the
resultant scatter-gather list to get the physical pages so it can pass
them to the GPU hardware. In the process, it is using sg_dma_len() to
get the length, which is garbage for ION buffers if ion_buffer_create()
doesn't set it.

[1] 
http://git.linaro.org/landing-teams/working/arm/kernel-release.git/blob/9660bff61ab296be02aad111d0bc2b9919493de5:/drivers/gpu/arm/midgard/mali_kbase_jd.c#l333

Now, I just tried making the Mali driver use sg->length rather than
sg_dma_len() and, unsurprisingly, that also fixes the problem. So, my
questions would be...

Is it acceptable for a driver getting a dma_buf to parse the
scatter-gather list for that by had?

If so, should it use ->length or sg_dma_len() to get the length of each
element?

If sg_dma_len() is correct or acceptable then it seems to me that the
ION code should set that length. Especially as the comment in the code
implies it's faking a call to map_sg and grepping the kernel tree for
real implementations of that functionality seems to show the dma_address
getting set.

As you can probably tell, I feel I may be on shaky ground. This is
because I don't fully understanding the code and suspecting both the ION
and GPU code is rather dodgy (and possibly the bits in between :-)



I blame the Ion code completely. I remember hitting a similar problem
with other out of tree drivers. The solution then was to have drivers
switch to using sg->length instead of sg_dma_len given the state of that
tree. For the Mali driver, if it is ever going to be backed by an IOMMU
you will need to use sg_dma_len so I think at least that part of your
code is correct.

Thinking about it some, I'm okay with the patch going in. I thought
there was some reason why the out of tree code from before didn't just
do this hack but I can't remember it. It may have been an out of tree
use case. This does go well with Ion's behavior of pretending to do
DMA mapping. More out of tree users can plead their case if it breaks.

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


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

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


[PATCH 2/2] staging: wilc1000: pass vif to wilc_send_config_pkt

2016-01-21 Thread Glen Lee
This patch passes vif instead of wilc to wilc_send_config_pkt and it's related
functions as well, because we need vif which is currently being used and
vif has wilc as well.
Change custom print with netdev_xxx format if there are custom print inside
the functions we have changed.

Function parameter of following functions are modified to vif.
wilc_send_config_pkt
wilc_wlan_cfg_set
wilc_wlan_cfg_get
wilc_wlan_cfg_commit
wilc_wlan_txq_add_cfg_pkt
wilc_wlan_txq_add_to_head

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/host_interface.c | 88 +++
 drivers/staging/wilc1000/linux_wlan.c | 88 +++
 drivers/staging/wilc1000/wilc_wlan.c  | 57 +++-
 drivers/staging/wilc1000/wilc_wlan.h  |  7 +--
 4 files changed, 125 insertions(+), 115 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index dd2cd60..367495b 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -311,7 +311,7 @@ static s32 handle_set_channel(struct wilc_vif *vif,
 
PRINT_D(HOSTINF_DBG, "Setting channel\n");
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
if (result) {
@@ -333,7 +333,7 @@ static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
wid.val = (s8 *)hif_drv_handler;
wid.size = sizeof(*hif_drv_handler);
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
  hif_drv_handler->handler);
 
if (!hif_drv_handler->handler)
@@ -358,7 +358,7 @@ static s32 handle_set_operation_mode(struct wilc_vif *vif,
wid.val = (s8 *)&hif_op_mode->mode;
wid.size = sizeof(u32);
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
if ((hif_op_mode->mode) == IDLE_MODE)
@@ -396,7 +396,7 @@ static s32 handle_set_ip_address(struct wilc_vif *vif, u8 
*ip_addr, u8 idx)
wid.val = (u8 *)ip_addr;
wid.size = IP_ALEN;
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
host_int_get_ipaddress(vif, hif_drv, firmware_ip_addr, idx);
@@ -421,7 +421,7 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 
idx)
wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
wid.size = IP_ALEN;
 
-   result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
@@ -464,7 +464,7 @@ static s32 handle_set_mac_address(struct wilc_vif *vif,
wid.size = ETH_ALEN;
PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
if (result) {
PRINT_ER("Failed to set mac address\n");
@@ -486,7 +486,7 @@ static s32 handle_get_mac_address(struct wilc_vif *vif,
wid.val = get_mac_addr->mac_addr;
wid.size = ETH_ALEN;
 
-   result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
if (result) {
@@ -782,7 +782,7 @@ static s32 handle_cfg_param(struct wilc_vif *vif,
wid_cnt++;
}
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, wid_list,
+   result = wilc_send_config_pkt(vif, SET_CFG, wid_list,
  wid_cnt, wilc_get_vif_idx(vif));
 
if (result)
@@ -906,7 +906,7 @@ static s32 Handle_Scan(struct wilc_vif *vif,
else if (hif_drv->hif_state == HOST_IF_IDLE)
scan_while_connected = false;
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
+   result = wilc_send_config_pkt(vif, SET_CFG, strWIDList,
  u32WidsCount,
  wilc_get_vif_idx(vif));
 
@@ -952,7 +952,7 @@ static s32 Handle_ScanDone(struct wilc_vif *vif,
wid.val = (s8 *)&u8abort_running_scan;
wid.size = sizeof(char);
 
-   result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
+   result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1,
 wilc_get_vif_idx(vif));
 
if (result) {
@@ -1208,7 +1208,7 @@ static s32 Handle_Co

[PATCH 1/2] staging: wilc1000: move wilc_send_config_pkt to wilc_wlan.c

2016-01-21 Thread Glen Lee
This patch moves the function wilc_send_config_pkt to wilc_wlan.c which
handles transport since the purpose of the function is sending/getting of
config information. coreconfiguator.[ch] will be rename with frame.[ch] later.
The print codes of the function is removed also and they will be implemented
with netdev_xx print format later.
struct wid need to be moved to wilc_wlan_if.h which defines configure
informations.

Signed-off-by: Glen Lee 
---
 drivers/staging/wilc1000/coreconfigurator.c | 59 -
 drivers/staging/wilc1000/coreconfigurator.h |  9 -
 drivers/staging/wilc1000/wilc_wlan.c| 39 +++
 drivers/staging/wilc1000/wilc_wlan.h|  2 +
 drivers/staging/wilc1000/wilc_wlan_if.h |  7 
 5 files changed, 48 insertions(+), 68 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c 
b/drivers/staging/wilc1000/coreconfigurator.c
index 2d4d3f1..d101393 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -572,62 +572,3 @@ s32 wilc_dealloc_assoc_resp_info(tstrConnectRespInfo 
*pstrConnectRespInfo)
 
return s32Error;
 }
-
-/**
- *  @brief  sends certain Configuration Packet based on the input 
WIDs pstrWIDs
- *  using driver config layer
- *
- *  @details
- *  @param[in]  pstrWIDs WIDs to be sent in the configuration packet
- *  @param[in]  u32WIDsCount number of WIDs to be sent in the configuration 
packet
- *  @param[out] pu8RxResp The received Packet Response
- *  @param[out] ps32RxRespLen Length of the received Packet Response
- *  @return Error code indicating success/failure
- *  @note
- *  @authormabubakr
- *  @date  1 Mar 2012
- *  @version   1.0
- */
-s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
-u32 count, u32 drv)
-{
-   s32 counter = 0, ret = 0;
-
-   if (mode == GET_CFG) {
-   for (counter = 0; counter < count; counter++) {
-   PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet 
[%d][%d]\n", !counter,
-  (counter == count - 1));
-   if (!wilc_wlan_cfg_get(wilc, !counter,
-  wids[counter].id,
-  (counter == count - 1),
-  drv)) {
-   ret = -ETIMEDOUT;
-   printk("[Sendconfigpkt]Get Timed out\n");
-   break;
-   }
-   }
-   counter = 0;
-   for (counter = 0; counter < count; counter++) {
-   wids[counter].size = wilc_wlan_cfg_get_val(
-   wids[counter].id,
-   wids[counter].val,
-   wids[counter].size);
-   }
-   } else if (mode == SET_CFG) {
-   for (counter = 0; counter < count; counter++) {
-   PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET 
WID:%x\n", wids[counter].id);
-   if (!wilc_wlan_cfg_set(wilc, !counter,
-  wids[counter].id,
-  wids[counter].val,
-  wids[counter].size,
-  (counter == count - 1),
-  drv)) {
-   ret = -ETIMEDOUT;
-   printk("[Sendconfigpkt]Set Timed out\n");
-   break;
-   }
-   }
-   }
-
-   return ret;
-}
diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
b/drivers/staging/wilc1000/coreconfigurator.h
index fc43d04..ee107ac 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -70,13 +70,6 @@ typedef enum {
CONNECT_STS_FORCE_16_BIT = 0x
 } tenuConnectSts;
 
-struct wid {
-   u16 id;
-   enum wid_type type;
-   s32 size;
-   s8 *val;
-};
-
 typedef struct {
u8 u8Full;
u8 u8Index;
@@ -127,8 +120,6 @@ typedef struct {
size_t ie_len;
 } tstrDisconnectNotifInfo;
 
-s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
-u32 count, u32 drv);
 s32 wilc_parse_network_info(u8 *pu8MsgBuffer, tstrNetworkInfo 
**ppstrNetworkInfo);
 s32 wilc_dealloc_network_info(tstrNetworkInfo *pstrNetworkInfo);
 
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index a0819b9..077d1a4 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1439,6 +1439,45 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 
buffer_size)
return ret;

Re: [PATCH 04/26] staging: wilc1000: add sdio resume/suspend

2016-01-21 Thread Dan Carpenter
You should be running checkpatch.pl on your patches.

regards,
dan carpenter

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


Re: [PATCH 20/26] staging: wilc1000: remove define TCP_ACK_FILTER

2016-01-21 Thread Dan Carpenter
What does TCP_ACK_FILTER do?

regards,
dan carpenter

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