aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorEldad Zack <eldad@fogrefinery.com>2013-04-03 17:18:53 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-04 02:30:49 -0400
commitf6a8bc70f85fdc49c5a3eca687c6018ffee8f050 (patch)
treeae73558b4fde7bfa7b9cfe02a6c895de1a64cd1d /sound/usb
parent98ae472b574647e36b2c8306091dff6de4606222 (diff)
ALSA: usb-audio: use endianness macros
Replace the endianness conversions with the kernel-wide swabbing macros in get/set_sample_rate_v2. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/clock.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index e3ccf3d81075..013b346f045d 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -251,21 +251,21 @@ static int get_sample_rate_v2(struct snd_usb_audio *chip, int iface,
251 int altsetting, int clock) 251 int altsetting, int clock)
252{ 252{
253 struct usb_device *dev = chip->dev; 253 struct usb_device *dev = chip->dev;
254 unsigned char data[4]; 254 __le32 data;
255 int err; 255 int err;
256 256
257 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 257 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
258 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 258 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
259 UAC2_CS_CONTROL_SAM_FREQ << 8, 259 UAC2_CS_CONTROL_SAM_FREQ << 8,
260 snd_usb_ctrl_intf(chip) | (clock << 8), 260 snd_usb_ctrl_intf(chip) | (clock << 8),
261 data, sizeof(data)); 261 &data, sizeof(data));
262 if (err < 0) { 262 if (err < 0) {
263 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 263 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
264 dev->devnum, iface, altsetting); 264 dev->devnum, iface, altsetting);
265 return 0; 265 return 0;
266 } 266 }
267 267
268 return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); 268 return le32_to_cpu(data);
269} 269}
270 270
271static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, 271static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
@@ -273,7 +273,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
273 struct audioformat *fmt, int rate) 273 struct audioformat *fmt, int rate)
274{ 274{
275 struct usb_device *dev = chip->dev; 275 struct usb_device *dev = chip->dev;
276 unsigned char data[4]; 276 __le32 data;
277 int err, cur_rate, prev_rate; 277 int err, cur_rate, prev_rate;
278 int clock = snd_usb_clock_find_source(chip, fmt->clock); 278 int clock = snd_usb_clock_find_source(chip, fmt->clock);
279 279
@@ -289,15 +289,12 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
289 289
290 prev_rate = get_sample_rate_v2(chip, iface, fmt->altsetting, clock); 290 prev_rate = get_sample_rate_v2(chip, iface, fmt->altsetting, clock);
291 291
292 data[0] = rate; 292 data = cpu_to_le32(rate);
293 data[1] = rate >> 8;
294 data[2] = rate >> 16;
295 data[3] = rate >> 24;
296 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 293 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
297 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, 294 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
298 UAC2_CS_CONTROL_SAM_FREQ << 8, 295 UAC2_CS_CONTROL_SAM_FREQ << 8,
299 snd_usb_ctrl_intf(chip) | (clock << 8), 296 snd_usb_ctrl_intf(chip) | (clock << 8),
300 data, sizeof(data))) < 0) { 297 &data, sizeof(data))) < 0) {
301 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 298 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
302 dev->devnum, iface, fmt->altsetting, rate); 299 dev->devnum, iface, fmt->altsetting, rate);
303 return err; 300 return err;