hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/sound/usb/usx2y/usb_stream.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms of the GNU General Public License as published by the
6
- * Free Software Foundation; either version 2 of the License, or (at your
7
- * option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
- * for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software Foundation,
16
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
174 */
185
196 #include <linux/usb.h>
....@@ -104,7 +91,12 @@
10491
10592 for (u = 0; u < USB_STREAM_NURBS; ++u) {
10693 sk->inurb[u] = usb_alloc_urb(sk->n_o_ps, GFP_KERNEL);
94
+ if (!sk->inurb[u])
95
+ return -ENOMEM;
96
+
10797 sk->outurb[u] = usb_alloc_urb(sk->n_o_ps, GFP_KERNEL);
98
+ if (!sk->outurb[u])
99
+ return -ENOMEM;
108100 }
109101
110102 if (init_pipe_urbs(sk, use_packsize, sk->inurb, indata, dev, in_pipe) ||
....@@ -150,9 +142,12 @@
150142 if (!s)
151143 return;
152144
153
- free_pages((unsigned long)sk->write_page, get_order(s->write_size));
154
- sk->write_page = NULL;
155
- free_pages((unsigned long)s, get_order(s->read_size));
145
+ if (sk->write_page) {
146
+ free_pages_exact(sk->write_page, s->write_size);
147
+ sk->write_page = NULL;
148
+ }
149
+
150
+ free_pages_exact(s, s->read_size);
156151 sk->s = NULL;
157152 }
158153
....@@ -167,7 +162,6 @@
167162 int read_size = sizeof(struct usb_stream);
168163 int write_size;
169164 int usb_frames = dev->speed == USB_SPEED_HIGH ? 8000 : 1000;
170
- int pg;
171165
172166 in_pipe = usb_rcvisocpipe(dev, in_endpoint);
173167 out_pipe = usb_sndisocpipe(dev, out_endpoint);
....@@ -197,11 +191,10 @@
197191 goto out;
198192 }
199193
200
- pg = get_order(read_size);
201
- sk->s = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO|
202
- __GFP_NOWARN, pg);
194
+ sk->s = alloc_pages_exact(read_size,
195
+ GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
203196 if (!sk->s) {
204
- snd_printk(KERN_WARNING "couldn't __get_free_pages()\n");
197
+ pr_warn("us122l: couldn't allocate read buffer\n");
205198 goto out;
206199 }
207200 sk->s->cfg.version = USB_STREAM_INTERFACE_VERSION;
....@@ -216,13 +209,11 @@
216209 sk->s->period_size = frame_size * period_frames;
217210
218211 sk->s->write_size = write_size;
219
- pg = get_order(write_size);
220212
221
- sk->write_page =
222
- (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO|
223
- __GFP_NOWARN, pg);
213
+ sk->write_page = alloc_pages_exact(write_size,
214
+ GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN);
224215 if (!sk->write_page) {
225
- snd_printk(KERN_WARNING "couldn't __get_free_pages()\n");
216
+ pr_warn("us122l: couldn't allocate write buffer\n");
226217 usb_stream_free(sk);
227218 return NULL;
228219 }