From patchwork Fri Aug 18 14:20:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donglin Peng X-Patchwork-Id: 9909195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 85122602C8 for ; Fri, 18 Aug 2017 14:21:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E6D928CCB for ; Fri, 18 Aug 2017 14:21:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ECC228CE0; Fri, 18 Aug 2017 14:21:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDC3E28CCB for ; Fri, 18 Aug 2017 14:21:10 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5E5B826781D; Fri, 18 Aug 2017 16:21:06 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0249426781E; Fri, 18 Aug 2017 16:21:05 +0200 (CEST) Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by alsa0.perex.cz (Postfix) with ESMTP id C1F73267819 for ; Fri, 18 Aug 2017 16:21:03 +0200 (CEST) Received: by mail-pg0-f65.google.com with SMTP id y129so15296849pgy.3 for ; Fri, 18 Aug 2017 07:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=vaZ+2YlEp3ZsrHA0sT0DJ0DC27NDVV79jUCkCKv52Kk=; b=sA4puRrdN/n2vnikJNVpLwD5pA2iBIElM8300hQuod1Nfl3yrA/6Jyuhp4yCO5YmWm zPaOhyvcjiCDwaLxY1zR+Lz2A8YtddjqEGF90y0Jfev/4btTA39cYP3RKejPpyN9jwPt 5C5/uNT2EykhZ9ZoHBNHGK6uDnQxm7q0vw8i6AwsrOuhxDL17k+RRABO+v4mb1CS1DQM XdPbKx5c1vt1Vf6PsiY4fWqoerdj01fHU46FQlM7jdy9rgo+qeqcKKJmUxPdhhYktoXb TlC3tGL3xTWw95ZkQhag8iAmL7pmtNhwxwlhTRVMi6xcU8BzpBDIb4RvMQsWI/tGkbn+ P+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vaZ+2YlEp3ZsrHA0sT0DJ0DC27NDVV79jUCkCKv52Kk=; b=X+1ZYXq7rT9vm97TlYLV2vGRCBdGlDmrHEM92fodBB+9/+Bg0Dq+kKcD00PvPlWkrk K3BGTsMO5QhXylQVkmzylD5fUCy3oeCA9g5fz/Z6EuibZdFE+WbnNa43COo71HAsAbIx fh+mJ0KMZwc9CuQn9+0JLrgBkZ/vvFIwArFBbLG0kXCjo9hpAZUQFPVNs+dqoXYX8g9N fhsH/dFdzSypJXiIWl4VeKa8n/D3Y+SeJVzwIBwn4b7RgVTfxcLVTbGHpyPk7tqcUm/6 7aIR6Kl8IHKH4lIDyLhGN0UewBcfrMDtpqOPuQ5+PH++J/3jxJmTzlCOfuHANuW417I/ p6KQ== X-Gm-Message-State: AHYfb5hy4h8TVpjCszCU078BvFoYAqGygzSU1ZUr/wvuUyhh10EpfaPU 1UWhW2sD37U6pvD8 X-Received: by 10.84.169.67 with SMTP id g61mr9753337plb.109.1503066062334; Fri, 18 Aug 2017 07:21:02 -0700 (PDT) Received: from localhost ([114.244.64.8]) by smtp.gmail.com with ESMTPSA id q3sm11469945pgf.69.2017.08.18.07.20.59 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 18 Aug 2017 07:21:01 -0700 (PDT) From: Peng Donglin To: perex@perex.cz, tiwai@suse.com Date: Fri, 18 Aug 2017 22:20:54 +0800 Message-Id: <1503066054-26512-1-git-send-email-dolinux.peng@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Peng Donglin Subject: [alsa-devel] [PATCH] sound: fix some checkpatch errors and warnings. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ERROR: trailing whitespace WARNING: please, no spaces at the start of a line ERROR: open brace '{' following struct go on the same line ERROR: do not initialise statics to 0 ERROR: "foo * bar" should be "foo *bar" ERROR: spaces required around that '=' ERROR: switch and case should be at the same indent WARNING: Statements should start on a tabstop WARNING: Block comments use * on subsequent lines Signed-off-by: Peng Donglin --- sound/last.c | 2 +- sound/sound_core.c | 163 ++++++++++++++++++++++++----------------------------- 2 files changed, 76 insertions(+), 89 deletions(-) diff --git a/sound/last.c b/sound/last.c index 43f2228..a47bbe0 100644 --- a/sound/last.c +++ b/sound/last.c @@ -25,7 +25,7 @@ static int __init alsa_sound_last_init(void) { int idx, ok = 0; - + printk(KERN_INFO "ALSA device list:\n"); for (idx = 0; idx < SNDRV_CARDS; idx++) if (snd_cards[idx] != NULL) { diff --git a/sound/sound_core.c b/sound/sound_core.c index 99b73c6..f99bb7a 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -68,7 +68,7 @@ static void __exit cleanup_soundcore(void) #ifdef CONFIG_SOUND_OSS_CORE /* * OSS sound core handling. Breaks out sound functions to submodules - * + * * Author: Alan Cox * * Fixes: @@ -80,9 +80,9 @@ static void __exit cleanup_soundcore(void) * 2 of the License, or (at your option) any later version. * * -------------------- - * + * * Top level handler for the sound subsystem. Various devices can - * plug into this. The fact they don't all go via OSS doesn't mean + * plug into this. The fact they don't all go via OSS doesn't mean * they don't have to implement the OSS API. There is a lot of logic * to keeping much of the OSS weight out of the code in a compatibility * module, but it's up to the driver to rember to load it... @@ -111,8 +111,7 @@ static void __exit cleanup_soundcore(void) #define SOUND_STEP 16 -struct sound_unit -{ +struct sound_unit { int unit_minor; const struct file_operations *unit_fops; struct sound_unit *next; @@ -151,15 +150,14 @@ struct sound_unit #ifdef CONFIG_SOUND_OSS_CORE_PRECLAIM static int preclaim_oss = 1; #else -static int preclaim_oss = 0; +static int preclaim_oss; #endif module_param(preclaim_oss, int, 0444); static int soundcore_open(struct inode *, struct file *); -static const struct file_operations soundcore_fops = -{ +static const struct file_operations soundcore_fops = { /* We must have an owner or the module locking fails */ .owner = THIS_MODULE, .open = soundcore_open, @@ -171,70 +169,68 @@ struct sound_unit * join into it. Called with the lock asserted */ -static int __sound_insert_unit(struct sound_unit * s, struct sound_unit **list, const struct file_operations *fops, int index, int low, int top) +static int __sound_insert_unit(struct sound_unit *s, struct sound_unit **list, + const struct file_operations *fops, int index, + int low, int top) { - int n=low; + int n = low; if (index < 0) { /* first free */ - while (*list && (*list)->unit_minornext); + while (*list && (*list)->unit_minor < n) + list = &((*list)->next); - while(nunit_minor>n) + if (*list == NULL || (*list)->unit_minor > n) break; - list=&((*list)->next); - n+=SOUND_STEP; + list = &((*list)->next); + n += SOUND_STEP; } - if(n>=top) + if (n >= top) return -ENOENT; } else { n = low+(index*16); while (*list) { - if ((*list)->unit_minor==n) + if ((*list)->unit_minor == n) return -EBUSY; - if ((*list)->unit_minor>n) + if ((*list)->unit_minor > n) break; - list=&((*list)->next); + list = &((*list)->next); } - } - + } + /* * Fill it in */ - - s->unit_minor=n; - s->unit_fops=fops; - + + s->unit_minor = n; + s->unit_fops = fops; + /* * Link it */ - - s->next=*list; - *list=s; - - + + s->next = *list; + *list = s; + return n; } /* * Remove a node from the chain. Called with the lock asserted */ - + static struct sound_unit *__sound_remove_unit(struct sound_unit **list, int unit) { - while(*list) - { - struct sound_unit *p=*list; - if(p->unit_minor==unit) - { - *list=p->next; + while (*list) { + struct sound_unit *p = *list; + if (p->unit_minor == unit) { + *list = p->next; return p; } - list=&(p->next); + list = &(p->next); } printk(KERN_ERR "Sound device %d went missing!\n", unit); return NULL; @@ -251,7 +247,9 @@ static struct sound_unit *__sound_remove_unit(struct sound_unit **list, int unit * list. Acquires locks as needed */ -static int sound_insert_unit(struct sound_unit **list, const struct file_operations *fops, int index, int low, int top, const char *name, umode_t mode, struct device *dev) +static int sound_insert_unit(struct sound_unit **list, const struct file_operations *fops, + int index, int low, int top, const char *name, + umode_t mode, struct device *dev) { struct sound_unit *s = kmalloc(sizeof(*s), GFP_KERNEL); int r; @@ -263,7 +261,7 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati retry: r = __sound_insert_unit(s, list, fops, index, low, top); spin_unlock(&sound_loader_lock); - + if (r < 0) goto fail; else if (r < SOUND_STEP) @@ -305,7 +303,7 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati * completed the removal before their file operations become * invalid. */ - + static void sound_remove_unit(struct sound_unit **list, int unit) { struct sound_unit *p; @@ -357,7 +355,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit) * Return: The allocated number is returned on success. On failure, * a negative error code is returned. */ - + int register_sound_special_device(const struct file_operations *fops, int unit, struct device *dev) { @@ -367,69 +365,67 @@ int register_sound_special_device(const struct file_operations *fops, int unit, char _name[16]; switch (chain) { - case 0: + case 0: name = "mixer"; break; - case 1: + case 1: name = "sequencer"; if (unit >= SOUND_STEP) goto __unknown; max_unit = unit + 1; break; - case 2: + case 2: name = "midi"; break; - case 3: + case 3: name = "dsp"; break; - case 4: + case 4: name = "audio"; break; - case 5: + case 5: name = "dspW"; break; - case 8: + case 8: name = "sequencer2"; if (unit >= SOUND_STEP) goto __unknown; max_unit = unit + 1; break; - case 9: + case 9: name = "dmmidi"; break; - case 10: + case 10: name = "dmfm"; break; - case 12: + case 12: name = "adsp"; break; - case 13: + case 13: name = "amidi"; break; - case 14: + case 14: name = "admmidi"; break; - default: - { - __unknown: + default: + { + __unknown: sprintf(_name, "unknown%d", chain); - if (unit >= SOUND_STEP) - strcat(_name, "-"); - name = _name; + if (unit >= SOUND_STEP) + strcat(_name, "-"); + name = _name; } break; } return sound_insert_unit(&chains[chain], fops, -1, unit, max_unit, name, S_IRUSR | S_IWUSR, dev); } - EXPORT_SYMBOL(register_sound_special_device); int register_sound_special(const struct file_operations *fops, int unit) { return register_sound_special_device(fops, unit, NULL); } - EXPORT_SYMBOL(register_sound_special); /** @@ -449,7 +445,6 @@ int register_sound_mixer(const struct file_operations *fops, int dev) return sound_insert_unit(&chains[0], fops, dev, 0, 128, "mixer", S_IRUSR | S_IWUSR, NULL); } - EXPORT_SYMBOL(register_sound_mixer); /** @@ -469,14 +464,13 @@ int register_sound_midi(const struct file_operations *fops, int dev) return sound_insert_unit(&chains[2], fops, dev, 2, 130, "midi", S_IRUSR | S_IWUSR, NULL); } - EXPORT_SYMBOL(register_sound_midi); /* * DSP's are registered as a triple. Register only one and cheat * in open - see below. */ - + /** * register_sound_dsp - register a DSP device * @fops: File operations for the driver @@ -497,7 +491,6 @@ int register_sound_dsp(const struct file_operations *fops, int dev) return sound_insert_unit(&chains[3], fops, dev, 3, 131, "dsp", S_IWUSR | S_IRUSR, NULL); } - EXPORT_SYMBOL(register_sound_dsp); /** @@ -514,7 +507,6 @@ void unregister_sound_special(int unit) { sound_remove_unit(&chains[unit % SOUND_STEP], unit); } - EXPORT_SYMBOL(unregister_sound_special); /** @@ -529,7 +521,6 @@ void unregister_sound_mixer(int unit) { sound_remove_unit(&chains[0], unit); } - EXPORT_SYMBOL(unregister_sound_mixer); /** @@ -544,7 +535,6 @@ void unregister_sound_midi(int unit) { sound_remove_unit(&chains[2], unit); } - EXPORT_SYMBOL(unregister_sound_midi); /** @@ -561,20 +551,17 @@ void unregister_sound_dsp(int unit) { sound_remove_unit(&chains[3], unit); } - - EXPORT_SYMBOL(unregister_sound_dsp); static struct sound_unit *__look_for_unit(int chain, int unit) { struct sound_unit *s; - - s=chains[chain]; - while(s && s->unit_minor <= unit) - { - if(s->unit_minor==unit) + + s = chains[chain]; + while (s && s->unit_minor <= unit) { + if (s->unit_minor == unit) return s; - s=s->next; + s = s->next; } return NULL; } @@ -586,14 +573,13 @@ static int soundcore_open(struct inode *inode, struct file *file) struct sound_unit *s; const struct file_operations *new_fops = NULL; - chain=unit&0x0F; - if(chain==4 || chain==5) /* dsp/audio/dsp16 */ - { - unit&=0xF0; - unit|=3; - chain=3; + chain = unit&0x0F; + if (chain == 4 || chain == 5) { /* dsp/audio/dsp16 */ + unit &= 0xF0; + unit |= 3; + chain = 3; } - + spin_lock(&sound_loader_lock); s = __look_for_unit(chain, unit); if (s) @@ -636,7 +622,7 @@ static int soundcore_open(struct inode *inode, struct file *file) replace_fops(file, new_fops); if (file->f_op->open) - err = file->f_op->open(inode,file); + err = file->f_op->open(inode, file); return err; } @@ -648,7 +634,8 @@ static int soundcore_open(struct inode *inode, struct file *file) static void cleanup_oss_soundcore(void) { /* We have nothing to really do here - we know the lists must be - empty */ + * empty + */ unregister_chrdev(SOUND_MAJOR, "sound"); }