Commit 5bed9139 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: rawmidi: Tidy up coding styles

Just minor coding style fixes like removal of superfluous white space,
adding missing blank lines, etc.  No actual code changes at all.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent ed6b83d2
...@@ -88,6 +88,7 @@ static inline unsigned short snd_rawmidi_file_flags(struct file *file) ...@@ -88,6 +88,7 @@ static inline unsigned short snd_rawmidi_file_flags(struct file *file)
static inline int snd_rawmidi_ready(struct snd_rawmidi_substream *substream) static inline int snd_rawmidi_ready(struct snd_rawmidi_substream *substream)
{ {
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
return runtime->avail >= runtime->avail_min; return runtime->avail >= runtime->avail_min;
} }
...@@ -95,6 +96,7 @@ static inline int snd_rawmidi_ready_append(struct snd_rawmidi_substream *substre ...@@ -95,6 +96,7 @@ static inline int snd_rawmidi_ready_append(struct snd_rawmidi_substream *substre
size_t count) size_t count)
{ {
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
return runtime->avail >= runtime->avail_min && return runtime->avail >= runtime->avail_min &&
(!substream->append || runtime->avail >= count); (!substream->append || runtime->avail >= count);
} }
...@@ -103,6 +105,7 @@ static void snd_rawmidi_input_event_work(struct work_struct *work) ...@@ -103,6 +105,7 @@ static void snd_rawmidi_input_event_work(struct work_struct *work)
{ {
struct snd_rawmidi_runtime *runtime = struct snd_rawmidi_runtime *runtime =
container_of(work, struct snd_rawmidi_runtime, event_work); container_of(work, struct snd_rawmidi_runtime, event_work);
if (runtime->event) if (runtime->event)
runtime->event(runtime->substream); runtime->event(runtime->substream);
} }
...@@ -111,7 +114,8 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) ...@@ -111,7 +114,8 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
{ {
struct snd_rawmidi_runtime *runtime; struct snd_rawmidi_runtime *runtime;
if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
if (!runtime)
return -ENOMEM; return -ENOMEM;
runtime->substream = substream; runtime->substream = substream;
spin_lock_init(&runtime->lock); spin_lock_init(&runtime->lock);
...@@ -124,7 +128,8 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) ...@@ -124,7 +128,8 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
runtime->avail = 0; runtime->avail = 0;
else else
runtime->avail = runtime->buffer_size; runtime->avail = runtime->buffer_size;
if ((runtime->buffer = kmalloc(runtime->buffer_size, GFP_KERNEL)) == NULL) { runtime->buffer = kmalloc(runtime->buffer_size, GFP_KERNEL);
if (!runtime->buffer) {
kfree(runtime); kfree(runtime);
return -ENOMEM; return -ENOMEM;
} }
...@@ -143,7 +148,7 @@ static int snd_rawmidi_runtime_free(struct snd_rawmidi_substream *substream) ...@@ -143,7 +148,7 @@ static int snd_rawmidi_runtime_free(struct snd_rawmidi_substream *substream)
return 0; return 0;
} }
static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream,int up) static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream, int up)
{ {
if (!substream->opened) if (!substream->opened)
return; return;
...@@ -330,7 +335,7 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode, ...@@ -330,7 +335,7 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode,
/* called from sound/core/seq/seq_midi.c */ /* called from sound/core/seq/seq_midi.c */
int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice,
int mode, struct snd_rawmidi_file * rfile) int mode, struct snd_rawmidi_file *rfile)
{ {
struct snd_rawmidi *rmidi; struct snd_rawmidi *rmidi;
int err; int err;
...@@ -568,11 +573,13 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, ...@@ -568,11 +573,13 @@ static int snd_rawmidi_info(struct snd_rawmidi_substream *substream,
} }
static int snd_rawmidi_info_user(struct snd_rawmidi_substream *substream, static int snd_rawmidi_info_user(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_info __user * _info) struct snd_rawmidi_info __user *_info)
{ {
struct snd_rawmidi_info info; struct snd_rawmidi_info info;
int err; int err;
if ((err = snd_rawmidi_info(substream, &info)) < 0)
err = snd_rawmidi_info(substream, &info);
if (err < 0)
return err; return err;
if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info)))
return -EFAULT; return -EFAULT;
...@@ -619,13 +626,15 @@ static int snd_rawmidi_info_select_user(struct snd_card *card, ...@@ -619,13 +626,15 @@ static int snd_rawmidi_info_select_user(struct snd_card *card,
{ {
int err; int err;
struct snd_rawmidi_info info; struct snd_rawmidi_info info;
if (get_user(info.device, &_info->device)) if (get_user(info.device, &_info->device))
return -EFAULT; return -EFAULT;
if (get_user(info.stream, &_info->stream)) if (get_user(info.stream, &_info->stream))
return -EFAULT; return -EFAULT;
if (get_user(info.subdevice, &_info->subdevice)) if (get_user(info.subdevice, &_info->subdevice))
return -EFAULT; return -EFAULT;
if ((err = snd_rawmidi_info_select(card, &info)) < 0) err = snd_rawmidi_info_select(card, &info);
if (err < 0)
return err; return err;
if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info)))
return -EFAULT; return -EFAULT;
...@@ -633,7 +642,7 @@ static int snd_rawmidi_info_select_user(struct snd_card *card, ...@@ -633,7 +642,7 @@ static int snd_rawmidi_info_select_user(struct snd_card *card,
} }
int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_params * params) struct snd_rawmidi_params *params)
{ {
char *newbuf, *oldbuf; char *newbuf, *oldbuf;
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
...@@ -641,12 +650,10 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, ...@@ -641,12 +650,10 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
if (substream->append && substream->use_count > 1) if (substream->append && substream->use_count > 1)
return -EBUSY; return -EBUSY;
snd_rawmidi_drain_output(substream); snd_rawmidi_drain_output(substream);
if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L) { if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L)
return -EINVAL; return -EINVAL;
} if (params->avail_min < 1 || params->avail_min > params->buffer_size)
if (params->avail_min < 1 || params->avail_min > params->buffer_size) {
return -EINVAL; return -EINVAL;
}
if (params->buffer_size != runtime->buffer_size) { if (params->buffer_size != runtime->buffer_size) {
newbuf = kmalloc(params->buffer_size, GFP_KERNEL); newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
if (!newbuf) if (!newbuf)
...@@ -667,18 +674,16 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, ...@@ -667,18 +674,16 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
EXPORT_SYMBOL(snd_rawmidi_output_params); EXPORT_SYMBOL(snd_rawmidi_output_params);
int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_params * params) struct snd_rawmidi_params *params)
{ {
char *newbuf, *oldbuf; char *newbuf, *oldbuf;
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
snd_rawmidi_drain_input(substream); snd_rawmidi_drain_input(substream);
if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L) { if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L)
return -EINVAL; return -EINVAL;
} if (params->avail_min < 1 || params->avail_min > params->buffer_size)
if (params->avail_min < 1 || params->avail_min > params->buffer_size) {
return -EINVAL; return -EINVAL;
}
if (params->buffer_size != runtime->buffer_size) { if (params->buffer_size != runtime->buffer_size) {
newbuf = kmalloc(params->buffer_size, GFP_KERNEL); newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
if (!newbuf) if (!newbuf)
...@@ -697,7 +702,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, ...@@ -697,7 +702,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
EXPORT_SYMBOL(snd_rawmidi_input_params); EXPORT_SYMBOL(snd_rawmidi_input_params);
static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_status * status) struct snd_rawmidi_status *status)
{ {
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
...@@ -710,7 +715,7 @@ static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, ...@@ -710,7 +715,7 @@ static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream,
} }
static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream, static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream,
struct snd_rawmidi_status * status) struct snd_rawmidi_status *status)
{ {
struct snd_rawmidi_runtime *runtime = substream->runtime; struct snd_rawmidi_runtime *runtime = substream->runtime;
...@@ -739,6 +744,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -739,6 +744,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
{ {
int stream; int stream;
struct snd_rawmidi_info __user *info = argp; struct snd_rawmidi_info __user *info = argp;
if (get_user(stream, &info->stream)) if (get_user(stream, &info->stream))
return -EFAULT; return -EFAULT;
switch (stream) { switch (stream) {
...@@ -753,6 +759,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -753,6 +759,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
case SNDRV_RAWMIDI_IOCTL_PARAMS: case SNDRV_RAWMIDI_IOCTL_PARAMS:
{ {
struct snd_rawmidi_params params; struct snd_rawmidi_params params;
if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params))) if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params)))
return -EFAULT; return -EFAULT;
switch (params.stream) { switch (params.stream) {
...@@ -772,6 +779,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -772,6 +779,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
{ {
int err = 0; int err = 0;
struct snd_rawmidi_status status; struct snd_rawmidi_status status;
if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status))) if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status)))
return -EFAULT; return -EFAULT;
switch (status.stream) { switch (status.stream) {
...@@ -797,6 +805,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -797,6 +805,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
case SNDRV_RAWMIDI_IOCTL_DROP: case SNDRV_RAWMIDI_IOCTL_DROP:
{ {
int val; int val;
if (get_user(val, (int __user *) argp)) if (get_user(val, (int __user *) argp))
return -EFAULT; return -EFAULT;
switch (val) { switch (val) {
...@@ -811,6 +820,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long ...@@ -811,6 +820,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
case SNDRV_RAWMIDI_IOCTL_DRAIN: case SNDRV_RAWMIDI_IOCTL_DRAIN:
{ {
int val; int val;
if (get_user(val, (int __user *) argp)) if (get_user(val, (int __user *) argp))
return -EFAULT; return -EFAULT;
switch (val) { switch (val) {
...@@ -1020,6 +1030,7 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun ...@@ -1020,6 +1030,7 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
spin_lock_irq(&runtime->lock); spin_lock_irq(&runtime->lock);
while (!snd_rawmidi_ready(substream)) { while (!snd_rawmidi_ready(substream)) {
wait_queue_entry_t wait; wait_queue_entry_t wait;
if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) { if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
spin_unlock_irq(&runtime->lock); spin_unlock_irq(&runtime->lock);
return result > 0 ? result : -EAGAIN; return result > 0 ? result : -EAGAIN;
...@@ -1324,6 +1335,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, ...@@ -1324,6 +1335,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
spin_lock_irq(&runtime->lock); spin_lock_irq(&runtime->lock);
while (!snd_rawmidi_ready_append(substream, count)) { while (!snd_rawmidi_ready_append(substream, count)) {
wait_queue_entry_t wait; wait_queue_entry_t wait;
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
spin_unlock_irq(&runtime->lock); spin_unlock_irq(&runtime->lock);
return result > 0 ? result : -EAGAIN; return result > 0 ? result : -EAGAIN;
...@@ -1357,6 +1369,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, ...@@ -1357,6 +1369,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
while (runtime->avail != runtime->buffer_size) { while (runtime->avail != runtime->buffer_size) {
wait_queue_entry_t wait; wait_queue_entry_t wait;
unsigned int last_avail = runtime->avail; unsigned int last_avail = runtime->avail;
init_waitqueue_entry(&wait, current); init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait); add_wait_queue(&runtime->sleep, &wait);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -1374,7 +1387,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, ...@@ -1374,7 +1387,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
return result; return result;
} }
static __poll_t snd_rawmidi_poll(struct file *file, poll_table * wait) static __poll_t snd_rawmidi_poll(struct file *file, poll_table *wait)
{ {
struct snd_rawmidi_file *rfile; struct snd_rawmidi_file *rfile;
struct snd_rawmidi_runtime *runtime; struct snd_rawmidi_runtime *runtime;
...@@ -1411,7 +1424,6 @@ static __poll_t snd_rawmidi_poll(struct file *file, poll_table * wait) ...@@ -1411,7 +1424,6 @@ static __poll_t snd_rawmidi_poll(struct file *file, poll_table * wait)
#endif #endif
/* /*
*/ */
static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
...@@ -1479,8 +1491,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, ...@@ -1479,8 +1491,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
* Register functions * Register functions
*/ */
static const struct file_operations snd_rawmidi_f_ops = static const struct file_operations snd_rawmidi_f_ops = {
{
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = snd_rawmidi_read, .read = snd_rawmidi_read,
.write = snd_rawmidi_write, .write = snd_rawmidi_write,
...@@ -1535,7 +1546,7 @@ static void release_rawmidi_device(struct device *dev) ...@@ -1535,7 +1546,7 @@ static void release_rawmidi_device(struct device *dev)
*/ */
int snd_rawmidi_new(struct snd_card *card, char *id, int device, int snd_rawmidi_new(struct snd_card *card, char *id, int device,
int output_count, int input_count, int output_count, int input_count,
struct snd_rawmidi ** rrawmidi) struct snd_rawmidi **rrawmidi)
{ {
struct snd_rawmidi *rmidi; struct snd_rawmidi *rmidi;
int err; int err;
...@@ -1566,21 +1577,24 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, ...@@ -1566,21 +1577,24 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
rmidi->dev.release = release_rawmidi_device; rmidi->dev.release = release_rawmidi_device;
dev_set_name(&rmidi->dev, "midiC%iD%i", card->number, device); dev_set_name(&rmidi->dev, "midiC%iD%i", card->number, device);
if ((err = snd_rawmidi_alloc_substreams(rmidi, err = snd_rawmidi_alloc_substreams(rmidi,
&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT],
SNDRV_RAWMIDI_STREAM_INPUT, SNDRV_RAWMIDI_STREAM_INPUT,
input_count)) < 0) { input_count);
if (err < 0) {
snd_rawmidi_free(rmidi); snd_rawmidi_free(rmidi);
return err; return err;
} }
if ((err = snd_rawmidi_alloc_substreams(rmidi, err = snd_rawmidi_alloc_substreams(rmidi,
&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT],
SNDRV_RAWMIDI_STREAM_OUTPUT, SNDRV_RAWMIDI_STREAM_OUTPUT,
output_count)) < 0) { output_count);
if (err < 0) {
snd_rawmidi_free(rmidi); snd_rawmidi_free(rmidi);
return err; return err;
} }
if ((err = snd_device_new(card, SNDRV_DEV_RAWMIDI, rmidi, &ops)) < 0) { err = snd_device_new(card, SNDRV_DEV_RAWMIDI, rmidi, &ops);
if (err < 0) {
snd_rawmidi_free(rmidi); snd_rawmidi_free(rmidi);
return err; return err;
} }
...@@ -1624,6 +1638,7 @@ static int snd_rawmidi_free(struct snd_rawmidi *rmidi) ...@@ -1624,6 +1638,7 @@ static int snd_rawmidi_free(struct snd_rawmidi *rmidi)
static int snd_rawmidi_dev_free(struct snd_device *device) static int snd_rawmidi_dev_free(struct snd_device *device)
{ {
struct snd_rawmidi *rmidi = device->device_data; struct snd_rawmidi *rmidi = device->device_data;
return snd_rawmidi_free(rmidi); return snd_rawmidi_free(rmidi);
} }
...@@ -1631,6 +1646,7 @@ static int snd_rawmidi_dev_free(struct snd_device *device) ...@@ -1631,6 +1646,7 @@ static int snd_rawmidi_dev_free(struct snd_device *device)
static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device)
{ {
struct snd_rawmidi *rmidi = device->private_data; struct snd_rawmidi *rmidi = device->private_data;
rmidi->seq_dev = NULL; rmidi->seq_dev = NULL;
} }
#endif #endif
...@@ -1732,6 +1748,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device) ...@@ -1732,6 +1748,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
list_del_init(&rmidi->list); list_del_init(&rmidi->list);
for (dir = 0; dir < 2; dir++) { for (dir = 0; dir < 2; dir++) {
struct snd_rawmidi_substream *s; struct snd_rawmidi_substream *s;
list_for_each_entry(s, &rmidi->streams[dir].substreams, list) { list_for_each_entry(s, &rmidi->streams[dir].substreams, list) {
if (s->runtime) if (s->runtime)
wake_up(&s->runtime->sleep); wake_up(&s->runtime->sleep);
......
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