Commit 36b8defc authored by Takashi Iwai's avatar Takashi Iwai

ALSA: us122l: Use alloc_pages_exact()

alloc_pages_exact() is more suitable choice for allocating the sound
buffers, as it doesn't need to align with power-of-two.  Along with
the conversion, we can drop __GFP_COMP as well.

The patch also replace the error messages to be more explicit.
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 734b5a0b
...@@ -155,9 +155,9 @@ void usb_stream_free(struct usb_stream_kernel *sk) ...@@ -155,9 +155,9 @@ void usb_stream_free(struct usb_stream_kernel *sk)
if (!s) if (!s)
return; return;
free_pages((unsigned long)sk->write_page, get_order(s->write_size)); free_pages_exact(sk->write_page, s->write_size);
sk->write_page = NULL; sk->write_page = NULL;
free_pages((unsigned long)s, get_order(s->read_size)); free_pages_exact(s, s->read_size);
sk->s = NULL; sk->s = NULL;
} }
...@@ -172,7 +172,6 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, ...@@ -172,7 +172,6 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
int read_size = sizeof(struct usb_stream); int read_size = sizeof(struct usb_stream);
int write_size; int write_size;
int usb_frames = dev->speed == USB_SPEED_HIGH ? 8000 : 1000; int usb_frames = dev->speed == USB_SPEED_HIGH ? 8000 : 1000;
int pg;
in_pipe = usb_rcvisocpipe(dev, in_endpoint); in_pipe = usb_rcvisocpipe(dev, in_endpoint);
out_pipe = usb_sndisocpipe(dev, out_endpoint); out_pipe = usb_sndisocpipe(dev, out_endpoint);
...@@ -202,11 +201,10 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, ...@@ -202,11 +201,10 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
goto out; goto out;
} }
pg = get_order(read_size); sk->s = alloc_pages_exact(read_size,
sk->s = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO| GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
__GFP_NOWARN, pg);
if (!sk->s) { if (!sk->s) {
snd_printk(KERN_WARNING "couldn't __get_free_pages()\n"); pr_warn("us122l: couldn't allocate read buffer\n");
goto out; goto out;
} }
sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION; sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION;
...@@ -221,13 +219,11 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk, ...@@ -221,13 +219,11 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
sk->s->period_size = frame_size * period_frames; sk->s->period_size = frame_size * period_frames;
sk->s->write_size = write_size; sk->s->write_size = write_size;
pg = get_order(write_size);
sk->write_page = sk->write_page = alloc_pages_exact(write_size,
(void *)__get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO| GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
__GFP_NOWARN, pg);
if (!sk->write_page) { if (!sk->write_page) {
snd_printk(KERN_WARNING "couldn't __get_free_pages()\n"); pr_warn("us122l: couldn't allocate write buffer\n");
usb_stream_free(sk); usb_stream_free(sk);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment