Staging: line6: minor coding style cleanups
This fixes up all of the remaining coding style issues that make any sense to make in the line6 driver. Cc: Markus Grabner <grabner@icg.tugraz.at> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
79be7254eb
commit
027360c564
14 changed files with 77 additions and 82 deletions
|
@ -37,7 +37,9 @@ int line6_init_audio(struct usb_line6 *line6)
|
||||||
strcpy(card->id, line6->properties->id);
|
strcpy(card->id, line6->properties->id);
|
||||||
strcpy(card->driver, DRIVER_NAME);
|
strcpy(card->driver, DRIVER_NAME);
|
||||||
strcpy(card->shortname, line6->properties->name);
|
strcpy(card->shortname, line6->properties->name);
|
||||||
sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, dev_name(line6->ifcdev)); /* 80 chars - see asound.h */
|
/* longname is 80 chars - see asound.h */
|
||||||
|
sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
|
||||||
|
dev_name(line6->ifcdev));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,15 +164,19 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize)
|
||||||
len * bytes_per_frame);
|
len * bytes_per_frame);
|
||||||
memcpy(runtime->dma_area, fbuf + len * bytes_per_frame,
|
memcpy(runtime->dma_area, fbuf + len * bytes_per_frame,
|
||||||
(frames - len) * bytes_per_frame);
|
(frames - len) * bytes_per_frame);
|
||||||
} else
|
} else {
|
||||||
dev_err(line6pcm->line6->ifcdev, "driver bug: len = %d\n", len); /* this is somewhat paranoid */
|
/* this is somewhat paranoid */
|
||||||
|
dev_err(line6pcm->line6->ifcdev,
|
||||||
|
"driver bug: len = %d\n", len);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* copy single chunk */
|
/* copy single chunk */
|
||||||
memcpy(runtime->dma_area +
|
memcpy(runtime->dma_area +
|
||||||
line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize);
|
line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((line6pcm->pos_in_done += frames) >= runtime->buffer_size)
|
line6pcm->pos_in_done += frames;
|
||||||
|
if (line6pcm->pos_in_done >= runtime->buffer_size)
|
||||||
line6pcm->pos_in_done -= runtime->buffer_size;
|
line6pcm->pos_in_done -= runtime->buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,15 +185,16 @@ void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length)
|
||||||
struct snd_pcm_substream *substream =
|
struct snd_pcm_substream *substream =
|
||||||
get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE);
|
get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE);
|
||||||
|
|
||||||
if ((line6pcm->bytes_in += length) >= line6pcm->period_in) {
|
line6pcm->bytes_in += length;
|
||||||
|
if (line6pcm->bytes_in >= line6pcm->period_in) {
|
||||||
line6pcm->bytes_in %= line6pcm->period_in;
|
line6pcm->bytes_in %= line6pcm->period_in;
|
||||||
snd_pcm_period_elapsed(substream);
|
snd_pcm_period_elapsed(substream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Callback for completed capture URB.
|
* Callback for completed capture URB.
|
||||||
*/
|
*/
|
||||||
static void audio_in_callback(struct urb *urb)
|
static void audio_in_callback(struct urb *urb)
|
||||||
{
|
{
|
||||||
int i, index, length = 0, shutdown = 0;
|
int i, index, length = 0, shutdown = 0;
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Development tools.
|
* Development tools.
|
||||||
*/
|
*/
|
||||||
#define DO_DEBUG_MESSAGES 0
|
#define DO_DEBUG_MESSAGES 0
|
||||||
#define DO_DUMP_URB_SEND DO_DEBUG_MESSAGES
|
#define DO_DUMP_URB_SEND DO_DEBUG_MESSAGES
|
||||||
#define DO_DUMP_URB_RECEIVE DO_DEBUG_MESSAGES
|
#define DO_DUMP_URB_RECEIVE DO_DEBUG_MESSAGES
|
||||||
|
|
|
@ -634,8 +634,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data,
|
||||||
"receiving status failed (error %d)\n", ret);
|
"receiving status failed (error %d)\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
} while (status == 0xff);
|
||||||
while (status == 0xff);
|
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
|
dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
|
||||||
|
@ -667,7 +666,7 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
|
||||||
/*
|
/*
|
||||||
No operation (i.e., unsupported).
|
No operation (i.e., unsupported).
|
||||||
*/
|
*/
|
||||||
ssize_t line6_nop_write(struct device * dev, struct device_attribute * attr,
|
ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
return count;
|
return count;
|
||||||
|
@ -677,7 +676,7 @@ ssize_t line6_nop_write(struct device * dev, struct device_attribute * attr,
|
||||||
"write" request on "raw" special file.
|
"write" request on "raw" special file.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_LINE6_USB_RAW
|
#ifdef CONFIG_LINE6_USB_RAW
|
||||||
ssize_t line6_set_raw(struct device * dev, struct device_attribute * attr,
|
ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct usb_interface *interface = to_usb_interface(dev);
|
struct usb_interface *interface = to_usb_interface(dev);
|
||||||
|
|
|
@ -71,9 +71,11 @@ do { \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_STARTUP_PROGRESS(x, n) \
|
#define CHECK_STARTUP_PROGRESS(x, n) \
|
||||||
if((x) >= (n)) \
|
do { \
|
||||||
|
if ((x) >= (n)) \
|
||||||
return; \
|
return; \
|
||||||
x = (n);
|
x = (n); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
extern const unsigned char line6_midi_id[3];
|
extern const unsigned char line6_midi_id[3];
|
||||||
extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
|
extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
|
||||||
|
|
|
@ -380,8 +380,10 @@ int line6_init_midi(struct usb_line6 *line6)
|
||||||
int err;
|
int err;
|
||||||
struct snd_line6_midi *line6midi;
|
struct snd_line6_midi *line6midi;
|
||||||
|
|
||||||
if (!(line6->properties->capabilities & LINE6_BIT_CONTROL))
|
if (!(line6->properties->capabilities & LINE6_BIT_CONTROL)) {
|
||||||
return 0; /* skip MIDI initialization and report success */
|
/* skip MIDI initialization and report success */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL);
|
line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL);
|
||||||
|
|
||||||
|
|
|
@ -361,9 +361,8 @@ static int snd_line6_pcm_free(struct snd_device *device)
|
||||||
*/
|
*/
|
||||||
static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
|
static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
|
||||||
{
|
{
|
||||||
if (substream->runtime && snd_pcm_running(substream)) {
|
if (substream->runtime && snd_pcm_running(substream))
|
||||||
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
|
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
/*
|
/*
|
||||||
Get substream from Line6 PCM data structure
|
Get substream from Line6 PCM data structure
|
||||||
*/
|
*/
|
||||||
#define get_substream(line6pcm, stream) (line6pcm->pcm->streams[stream].substream)
|
#define get_substream(line6pcm, stream) \
|
||||||
|
(line6pcm->pcm->streams[stream].substream)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PCM mode bits and masks.
|
PCM mode bits and masks.
|
||||||
|
@ -315,10 +316,10 @@ extern int line6_pcm_stop(struct snd_line6_pcm *line6pcm, int channels);
|
||||||
#define PRINT_FRAME_DIFF(op) { \
|
#define PRINT_FRAME_DIFF(op) { \
|
||||||
static int diff_prev = 1000; \
|
static int diff_prev = 1000; \
|
||||||
int diff = line6pcm->last_frame_out - line6pcm->last_frame_in; \
|
int diff = line6pcm->last_frame_out - line6pcm->last_frame_in; \
|
||||||
if((diff != diff_prev) && (abs(diff) < 100)) { \
|
if ((diff != diff_prev) && (abs(diff) < 100)) { \
|
||||||
printk("%s frame diff = %d\n", op, diff); \
|
printk(KERN_INFO "%s frame diff = %d\n", op, diff); \
|
||||||
diff_prev = diff; \
|
diff_prev = diff; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -165,9 +165,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
|
||||||
struct usb_iso_packet_descriptor *fout =
|
struct usb_iso_packet_descriptor *fout =
|
||||||
&urb_out->iso_frame_desc[i];
|
&urb_out->iso_frame_desc[i];
|
||||||
|
|
||||||
if (line6pcm->flags & MASK_CAPTURE) {
|
if (line6pcm->flags & MASK_CAPTURE)
|
||||||
fsize = line6pcm->prev_fsize;
|
fsize = line6pcm->prev_fsize;
|
||||||
}
|
|
||||||
|
|
||||||
if (fsize == 0) {
|
if (fsize == 0) {
|
||||||
int n;
|
int n;
|
||||||
|
@ -237,7 +236,8 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((line6pcm->pos_out += urb_frames) >= runtime->buffer_size)
|
line6pcm->pos_out += urb_frames;
|
||||||
|
if (line6pcm->pos_out >= runtime->buffer_size)
|
||||||
line6pcm->pos_out -= runtime->buffer_size;
|
line6pcm->pos_out -= runtime->buffer_size;
|
||||||
} else {
|
} else {
|
||||||
memset(urb_out->transfer_buffer, 0,
|
memset(urb_out->transfer_buffer, 0,
|
||||||
|
@ -418,8 +418,8 @@ static void audio_out_callback(struct urb *urb)
|
||||||
submit_audio_out_urb(line6pcm);
|
submit_audio_out_urb(line6pcm);
|
||||||
|
|
||||||
if (test_bit(BIT_PCM_ALSA_PLAYBACK, &line6pcm->flags)) {
|
if (test_bit(BIT_PCM_ALSA_PLAYBACK, &line6pcm->flags)) {
|
||||||
if ((line6pcm->bytes_out +=
|
line6pcm->bytes_out += length;
|
||||||
length) >= line6pcm->period_out) {
|
if (line6pcm->bytes_out >= line6pcm->period_out) {
|
||||||
line6pcm->bytes_out %= line6pcm->period_out;
|
line6pcm->bytes_out %= line6pcm->period_out;
|
||||||
snd_pcm_period_elapsed(substream);
|
snd_pcm_period_elapsed(substream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When the TonePort is used with jack in full duplex mode and the outputs are
|
* When the TonePort is used with jack in full duplex mode and the outputs are
|
||||||
not connected, the software monitor produces an ugly noise since everything
|
* not connected, the software monitor produces an ugly noise since everything
|
||||||
written to the output buffer (i.e., the input signal) will be repeated in the
|
* written to the output buffer (i.e., the input signal) will be repeated in
|
||||||
next period (sounds like a delay effect). As a workaround, the output buffer
|
* the next period (sounds like a delay effect). As a workaround, the output
|
||||||
is cleared after the data have been read, but there must be a better
|
* buffer is cleared after the data have been read, but there must be a better
|
||||||
solution. Until one is found, this workaround can be used to fix the problem.
|
* solution. Until one is found, this workaround can be used to fix the
|
||||||
*/
|
* problem.
|
||||||
|
*/
|
||||||
#define USE_CLEAR_BUFFER_WORKAROUND 1
|
#define USE_CLEAR_BUFFER_WORKAROUND 1
|
||||||
|
|
||||||
extern struct snd_pcm_ops snd_line6_playback_ops;
|
extern struct snd_pcm_ops snd_line6_playback_ops;
|
||||||
|
|
|
@ -1242,35 +1242,29 @@ static int pod_try_init(struct usb_interface *interface,
|
||||||
|
|
||||||
/* create sysfs entries: */
|
/* create sysfs entries: */
|
||||||
err = pod_create_files2(&interface->dev);
|
err = pod_create_files2(&interface->dev);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize audio system: */
|
/* initialize audio system: */
|
||||||
err = line6_init_audio(line6);
|
err = line6_init_audio(line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize MIDI subsystem: */
|
/* initialize MIDI subsystem: */
|
||||||
err = line6_init_midi(line6);
|
err = line6_init_midi(line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize PCM subsystem: */
|
/* initialize PCM subsystem: */
|
||||||
err = line6_init_pcm(line6, &pod_pcm_properties);
|
err = line6_init_pcm(line6, &pod_pcm_properties);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* register monitor control: */
|
/* register monitor control: */
|
||||||
err =
|
err = snd_ctl_add(line6->card,
|
||||||
snd_ctl_add(line6->card,
|
|
||||||
snd_ctl_new1(&pod_control_monitor, line6->line6pcm));
|
snd_ctl_new1(&pod_control_monitor, line6->line6pcm));
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
When the sound card is registered at this point, the PODxt Live
|
When the sound card is registered at this point, the PODxt Live
|
||||||
|
@ -1295,9 +1289,8 @@ int line6_pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
|
||||||
{
|
{
|
||||||
int err = pod_try_init(interface, pod);
|
int err = pod_try_init(interface, pod);
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
pod_destruct(interface);
|
pod_destruct(interface);
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1317,9 +1310,8 @@ void line6_pod_disconnect(struct usb_interface *interface)
|
||||||
struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
|
struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
|
||||||
struct device *dev = &interface->dev;
|
struct device *dev = &interface->dev;
|
||||||
|
|
||||||
if (line6pcm != NULL) {
|
if (line6pcm != NULL)
|
||||||
line6_pcm_disconnect(line6pcm);
|
line6_pcm_disconnect(line6pcm);
|
||||||
}
|
|
||||||
|
|
||||||
if (dev != NULL) {
|
if (dev != NULL) {
|
||||||
/* remove sysfs entries: */
|
/* remove sysfs entries: */
|
||||||
|
|
|
@ -349,24 +349,20 @@ static int toneport_try_init(struct usb_interface *interface,
|
||||||
|
|
||||||
/* initialize audio system: */
|
/* initialize audio system: */
|
||||||
err = line6_init_audio(line6);
|
err = line6_init_audio(line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize PCM subsystem: */
|
/* initialize PCM subsystem: */
|
||||||
err = line6_init_pcm(line6, &toneport_pcm_properties);
|
err = line6_init_pcm(line6, &toneport_pcm_properties);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* register monitor control: */
|
/* register monitor control: */
|
||||||
err =
|
err = snd_ctl_add(line6->card,
|
||||||
snd_ctl_add(line6->card,
|
|
||||||
snd_ctl_new1(&toneport_control_monitor,
|
snd_ctl_new1(&toneport_control_monitor,
|
||||||
line6->line6pcm));
|
line6->line6pcm));
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* register source select control: */
|
/* register source select control: */
|
||||||
switch (usbdev->descriptor.idProduct) {
|
switch (usbdev->descriptor.idProduct) {
|
||||||
|
@ -376,16 +372,14 @@ static int toneport_try_init(struct usb_interface *interface,
|
||||||
snd_ctl_add(line6->card,
|
snd_ctl_add(line6->card,
|
||||||
snd_ctl_new1(&toneport_control_source,
|
snd_ctl_new1(&toneport_control_source,
|
||||||
line6->line6pcm));
|
line6->line6pcm));
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* register audio system: */
|
/* register audio system: */
|
||||||
err = line6_register_audio(line6);
|
err = line6_register_audio(line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
line6_read_serial_number(line6, &toneport->serial_number);
|
line6_read_serial_number(line6, &toneport->serial_number);
|
||||||
line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
|
line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
|
||||||
|
@ -416,9 +410,8 @@ int line6_toneport_init(struct usb_interface *interface,
|
||||||
{
|
{
|
||||||
int err = toneport_try_init(interface, toneport);
|
int err = toneport_try_init(interface, toneport);
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
toneport_destruct(interface);
|
toneport_destruct(interface);
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,9 @@
|
||||||
/* device support hardware monitoring */
|
/* device support hardware monitoring */
|
||||||
#define LINE6_BIT_HWMON (1 << 2)
|
#define LINE6_BIT_HWMON (1 << 2)
|
||||||
|
|
||||||
#define LINE6_BIT_CONTROL_PCM_HWMON (LINE6_BIT_CONTROL | LINE6_BIT_PCM | LINE6_BIT_HWMON)
|
#define LINE6_BIT_CONTROL_PCM_HWMON (LINE6_BIT_CONTROL | \
|
||||||
|
LINE6_BIT_PCM | \
|
||||||
|
LINE6_BIT_HWMON)
|
||||||
|
|
||||||
#define LINE6_FALLBACK_INTERVAL 10
|
#define LINE6_FALLBACK_INTERVAL 10
|
||||||
#define LINE6_FALLBACK_MAXPACKETSIZE 16
|
#define LINE6_FALLBACK_MAXPACKETSIZE 16
|
||||||
|
|
|
@ -664,15 +664,13 @@ static int variax_try_init(struct usb_interface *interface,
|
||||||
|
|
||||||
/* initialize audio system: */
|
/* initialize audio system: */
|
||||||
err = line6_init_audio(&variax->line6);
|
err = line6_init_audio(&variax->line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize MIDI subsystem: */
|
/* initialize MIDI subsystem: */
|
||||||
err = line6_init_midi(&variax->line6);
|
err = line6_init_midi(&variax->line6);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/* initiate startup procedure: */
|
/* initiate startup procedure: */
|
||||||
variax_startup1(variax);
|
variax_startup1(variax);
|
||||||
|
@ -687,9 +685,8 @@ int line6_variax_init(struct usb_interface *interface,
|
||||||
{
|
{
|
||||||
int err = variax_try_init(interface, variax);
|
int err = variax_try_init(interface, variax);
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
variax_destruct(interface);
|
variax_destruct(interface);
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue