USB: gadget: Use ERR_PTR/IS_ERR
Use ERR_PTR and IS_ERR rather than mixing integers and pointers. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression *E; @@ * E < 0 // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
da307123c6
commit
ff3b968cee
1 changed files with 5 additions and 3 deletions
|
@ -252,12 +252,12 @@ static struct f_audio_buf *f_audio_buffer_alloc(int buf_size)
|
||||||
|
|
||||||
copy_buf = kzalloc(sizeof *copy_buf, GFP_ATOMIC);
|
copy_buf = kzalloc(sizeof *copy_buf, GFP_ATOMIC);
|
||||||
if (!copy_buf)
|
if (!copy_buf)
|
||||||
return (struct f_audio_buf *)-ENOMEM;
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
copy_buf->buf = kzalloc(buf_size, GFP_ATOMIC);
|
copy_buf->buf = kzalloc(buf_size, GFP_ATOMIC);
|
||||||
if (!copy_buf->buf) {
|
if (!copy_buf->buf) {
|
||||||
kfree(copy_buf);
|
kfree(copy_buf);
|
||||||
return (struct f_audio_buf *)-ENOMEM;
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy_buf;
|
return copy_buf;
|
||||||
|
@ -332,7 +332,7 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
list_add_tail(©_buf->list, &audio->play_queue);
|
list_add_tail(©_buf->list, &audio->play_queue);
|
||||||
schedule_work(&audio->playback_work);
|
schedule_work(&audio->playback_work);
|
||||||
copy_buf = f_audio_buffer_alloc(audio_buf_size);
|
copy_buf = f_audio_buffer_alloc(audio_buf_size);
|
||||||
if (copy_buf < 0)
|
if (IS_ERR(copy_buf))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,6 +576,8 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
|
||||||
usb_ep_enable(out_ep, audio->out_desc);
|
usb_ep_enable(out_ep, audio->out_desc);
|
||||||
out_ep->driver_data = audio;
|
out_ep->driver_data = audio;
|
||||||
audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
|
audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
|
||||||
|
if (IS_ERR(audio->copy_buf))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allocate a bunch of read buffers
|
* allocate a bunch of read buffers
|
||||||
|
|
Loading…
Add table
Reference in a new issue