diff mbox

[3/3] usb: gadget: s3c-hsudc: Replace 0 with NULL for pointers

Message ID 1346667500-22555-3-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat Sept. 3, 2012, 10:18 a.m. UTC
Silences the following type of sparse warnings:
warning: Using plain integer as NULL pointer

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/usb/gadget/s3c-hsudc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Comments

Kishon Vijay Abraham I Sept. 3, 2012, 11:07 a.m. UTC | #1
Hi,

On Mon, Sep 3, 2012 at 3:48 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> Silences the following type of sparse warnings:
> warning: Using plain integer as NULL pointer
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/usb/gadget/s3c-hsudc.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
> index 35cdc6a..d8e785d 100644
> --- a/drivers/usb/gadget/s3c-hsudc.c
> +++ b/drivers/usb/gadget/s3c-hsudc.c
> @@ -835,7 +835,7 @@ static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep,
>
>         hsreq = kzalloc(sizeof(*hsreq), gfp_flags);
>         if (!hsreq)
> -               return 0;
> +               return NULL;

shouldn't this be -ENOMEM?

Thanks
Kishon
Sachin Kamat Sept. 3, 2012, 11:30 a.m. UTC | #2
Hi

On 3 September 2012 16:37, ABRAHAM, KISHON VIJAY <kishon@ti.com> wrote:
> Hi,
>
> On Mon, Sep 3, 2012 at 3:48 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>> Silences the following type of sparse warnings:
>> warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/usb/gadget/s3c-hsudc.c |    8 ++++----
>>  1 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
>> index 35cdc6a..d8e785d 100644
>> --- a/drivers/usb/gadget/s3c-hsudc.c
>> +++ b/drivers/usb/gadget/s3c-hsudc.c
>> @@ -835,7 +835,7 @@ static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep,
>>
>>         hsreq = kzalloc(sizeof(*hsreq), gfp_flags);
>>         if (!hsreq)
>> -               return 0;
>> +               return NULL;
>
> shouldn't this be -ENOMEM?

That should have been the obvious return value. However, I thought
probably it was made so with some reasoning and did not change it as I
am not familiar with this driver.

>
> Thanks
> Kishon
Felipe Balbi Sept. 3, 2012, 2:07 p.m. UTC | #3
On Mon, Sep 03, 2012 at 05:00:44PM +0530, Sachin Kamat wrote:
> Hi
> 
> On 3 September 2012 16:37, ABRAHAM, KISHON VIJAY <kishon@ti.com> wrote:
> > Hi,
> >
> > On Mon, Sep 3, 2012 at 3:48 PM, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> >> Silences the following type of sparse warnings:
> >> warning: Using plain integer as NULL pointer
> >>
> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> >> ---
> >>  drivers/usb/gadget/s3c-hsudc.c |    8 ++++----
> >>  1 files changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
> >> index 35cdc6a..d8e785d 100644
> >> --- a/drivers/usb/gadget/s3c-hsudc.c
> >> +++ b/drivers/usb/gadget/s3c-hsudc.c
> >> @@ -835,7 +835,7 @@ static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep,
> >>
> >>         hsreq = kzalloc(sizeof(*hsreq), gfp_flags);
> >>         if (!hsreq)
> >> -               return 0;
> >> +               return NULL;
> >
> > shouldn't this be -ENOMEM?
> 
> That should have been the obvious return value. However, I thought
> probably it was made so with some reasoning and did not change it as I
> am not familiar with this driver.

it's just the way the API was designed. If we fail to allocate a
usb_request, we must return NULL so function/gadget drivers can check if
it was successful or not.

Of course it could be changed into ERR_PTR(-ENOMEM) or something, but
that's an API change... ;-)
diff mbox

Patch

diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 35cdc6a..d8e785d 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -835,7 +835,7 @@  static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep,
 
 	hsreq = kzalloc(sizeof(*hsreq), gfp_flags);
 	if (!hsreq)
-		return 0;
+		return NULL;
 
 	INIT_LIST_HEAD(&hsreq->queue);
 	return &hsreq->req;
@@ -904,16 +904,16 @@  static int s3c_hsudc_queue(struct usb_ep *_ep, struct usb_request *_req,
 			csr = readl((u32)hsudc->regs + offset);
 			if (!(csr & S3C_ESR_TX_SUCCESS) &&
 				(s3c_hsudc_write_fifo(hsep, hsreq) == 1))
-				hsreq = 0;
+				hsreq = NULL;
 		} else {
 			csr = readl((u32)hsudc->regs + offset);
 			if ((csr & S3C_ESR_RX_SUCCESS)
 				   && (s3c_hsudc_read_fifo(hsep, hsreq) == 1))
-				hsreq = 0;
+				hsreq = NULL;
 		}
 	}
 
-	if (hsreq != 0)
+	if (hsreq)
 		list_add_tail(&hsreq->queue, &hsep->queue);
 
 	spin_unlock_irqrestore(&hsudc->lock, flags);