From nobody Fri Dec 19 07:19:51 2025 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8333118030 for ; Wed, 28 Aug 2024 14:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724854001; cv=none; b=AnZGiocpQDD/ArChpZnoaWLgMlzAdovbrUPiCCfub5GOGPj8+uNEh6JuF5kYeMDzH2eAjZlhlAopXK9WL7XtBW/5BoVrFQa4qJxTURu/Xv8+9WkO4Ym7auhJU8LZk+cAlpoTCpllg0uufjfGaoFu8oyfpmC+5ymhn6S4R888jjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724854001; c=relaxed/simple; bh=otedDKXWRlErpy6D3v6S5UyI+6IgGWr+5u1rG34vxcQ=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=ZAYb2WvlmP66lmb5dVMQkh/HscY8UVfekPnEp3Ynw3LD6KQSQl7BaMFaLP8V7aXhtzokx9ZsJ19rwVTbPzrxGYzAwc0VU93kXqzreEkeKg9YIEihY2JwzIIcDD7w4r/p7QDPMOxBoXcOfbn+lAtlLKTq+M8/g/vaizK5Dc9TdyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=Rh/pjDuJ; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="Rh/pjDuJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1724853991; x=1725113191; bh=vPvncXPECDixTc76akVoXBodonoMLQRoRoMAD+A7dKQ=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Rh/pjDuJ9ib44eTecS/a14DMJLhWFnHamHzpPhlUQJKGwvoFITe+B+vXrlaGeNnYl ziLpJTLshwFo1sH8m59lH4Dfz5VrVi/ySpmZ65Z40Ra2zgcTO9JcmI70zZSy1w/qJ5 ruXkq80VTQI7DLo7izkHqP4IS4C+vBEzpNZ8R3Lux3F3a0ZZrn4M86OFErm1SMiq3L jIsHB75tEQ9OigsZ2ZnH92cTLI/hpdd7g7fj9X6uhtoXPaUh42w/wzQsv8KK21H7Ja hhJxAHndPdjKvUNWGK7SmUGHJqvdTBwoQnoQKhzzNkneVFdHeIFivR892G7PAHkfV2 dG7nKmHL4gYWQ== Date: Wed, 28 Aug 2024 14:06:25 +0000 To: perex@perex.cz, tiwai@suse.com From: =?utf-8?Q?Dominik_Karol_Pi=C4=85tkowski?= Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?Q?Dominik_Karol_Pi=C4=85tkowski?= Subject: [PATCH] sound: core: Fix issues detected by checkpatch Message-ID: <20240828140555.68565-1-dominik.karol.piatkowski@protonmail.com> Feedback-ID: 117888567:user:proton X-Pm-Message-ID: 11801dcb88d86c23edff23e64d7df05fecee8e70 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Running checkpatch.pl on sound_core.c resulted in: total: 75 errors, 37 warnings, 617 lines checked This patch fixes most of them, leaving two warnings: WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err= (dev, ... then pr_err(... to printk(KERN_ERR ... + printk(KERN_ERR "Sound device %d went missing!\n", unit); WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err= (dev, ... then pr_err(... to printk(KERN_ERR ... + printk(KERN_ERR "soundcore: sound device already in use.\n"); Signed-off-by: Dominik Karol Pi=C4=85tkowski --- sound/sound_core.c | 157 +++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 85 deletions(-) diff --git a/sound/sound_core.c b/sound/sound_core.c index d81fed1c1226..875ab0257904 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -70,15 +70,15 @@ module_exit(cleanup_soundcore); #ifdef CONFIG_SOUND_OSS_CORE /* * OSS sound core handling. Breaks out sound functions to submodules - *=09 + * * Author: Alan Cox * * Fixes: * * -------------------- - *=20 + * * 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=20 + * 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... @@ -107,8 +107,7 @@ module_exit(cleanup_soundcore); =20 #define SOUND_STEP 16 =20 -struct sound_unit -{ +struct sound_unit { int unit_minor; const struct file_operations *unit_fops; struct sound_unit *next; @@ -143,8 +142,7 @@ module_param(preclaim_oss, int, 0444); =20 static int soundcore_open(struct inode *, struct file *); =20 -static const struct file_operations soundcore_fops =3D -{ +static const struct file_operations soundcore_fops =3D { /* We must have an owner or the module locking fails */ .owner =3D THIS_MODULE, .open =3D soundcore_open, @@ -156,70 +154,68 @@ static const struct file_operations soundcore_fops = =3D * join into it. Called with the lock asserted */ =20 -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 **l= ist, const struct file_operations *fops, int index, int low, int top) { - int n=3Dlow; + int n =3D low; =20 if (index < 0) { /* first free */ =20 - while (*list && (*list)->unit_minornext); + while (*list && (*list)->unit_minor < n) + list =3D &((*list)->next); =20 - while(nunit_minor>n) + if (*list =3D=3D NULL || (*list)->unit_minor > n) break; - list=3D&((*list)->next); - n+=3DSOUND_STEP; + list =3D &((*list)->next); + n +=3D SOUND_STEP; } =20 - if(n>=3Dtop) + if (n >=3D top) return -ENOENT; } else { n =3D low+(index*16); while (*list) { - if ((*list)->unit_minor=3D=3Dn) + if ((*list)->unit_minor =3D=3D n) return -EBUSY; - if ((*list)->unit_minor>n) + if ((*list)->unit_minor > n) break; - list=3D&((*list)->next); + list =3D &((*list)->next); } - }=09 - =09 + } + /* * Fill it in */ - =20 - s->unit_minor=3Dn; - s->unit_fops=3Dfops; -=09 + + s->unit_minor =3D n; + s->unit_fops =3D fops; + /* * Link it */ - =20 - s->next=3D*list; - *list=3Ds; -=09 -=09 + + s->next =3D *list; + *list =3D s; + + return n; } =20 /* * Remove a node from the chain. Called with the lock asserted */ -=20 + static struct sound_unit *__sound_remove_unit(struct sound_unit **list, in= t unit) { - while(*list) - { - struct sound_unit *p=3D*list; - if(p->unit_minor=3D=3Dunit) - { - *list=3Dp->next; + while (*list) { + struct sound_unit *p =3D *list; + + if (p->unit_minor =3D=3D unit) { + *list =3D p->next; return p; } - list=3D&(p->next); + list =3D &(p->next); } printk(KERN_ERR "Sound device %d went missing!\n", unit); return NULL; @@ -248,7 +244,7 @@ static int sound_insert_unit(struct sound_unit **list, = const struct file_operati retry: r =3D __sound_insert_unit(s, list, fops, index, low, top); spin_unlock(&sound_loader_lock); -=09 + if (r < 0) goto fail; else if (r < SOUND_STEP) @@ -291,7 +287,7 @@ static int sound_insert_unit(struct sound_unit **list, = const struct file_operati * completed the removal before their file operations become * invalid. */ - =09 + static void sound_remove_unit(struct sound_unit **list, int unit) { struct sound_unit *p; @@ -335,7 +331,7 @@ static struct sound_unit *chains[SOUND_STEP]; * register_sound_special_device - register a special sound node * @fops: File operations for the driver * @unit: Unit number to allocate - * @dev: device pointer + * @dev: device pointer * * Allocate a special sound device by minor number from the sound * subsystem. @@ -343,7 +339,7 @@ static struct sound_unit *chains[SOUND_STEP]; * Return: The allocated number is returned on success. On failure, * a negative error code is returned. */ -=20 + int register_sound_special_device(const struct file_operations *fops, int = unit, struct device *dev) { @@ -353,69 +349,66 @@ int register_sound_special_device(const struct file_o= perations *fops, int unit, char _name[16]; =20 switch (chain) { - case 0: + case 0: name =3D "mixer"; break; - case 1: + case 1: name =3D "sequencer"; if (unit >=3D SOUND_STEP) goto __unknown; max_unit =3D unit + 1; break; - case 2: + case 2: name =3D "midi"; break; - case 3: + case 3: name =3D "dsp"; break; - case 4: + case 4: name =3D "audio"; break; - case 5: + case 5: name =3D "dspW"; break; - case 8: + case 8: name =3D "sequencer2"; if (unit >=3D SOUND_STEP) goto __unknown; max_unit =3D unit + 1; break; - case 9: + case 9: name =3D "dmmidi"; break; - case 10: + case 10: name =3D "dmfm"; break; - case 12: + case 12: name =3D "adsp"; break; - case 13: + case 13: name =3D "amidi"; break; - case 14: + case 14: name =3D "admmidi"; break; - default: - { - __unknown: + default: { +__unknown: sprintf(_name, "unknown%d", chain); - if (unit >=3D SOUND_STEP) - strcat(_name, "-"); - name =3D _name; + if (unit >=3D SOUND_STEP) + strcat(_name, "-"); + name =3D _name; } break; } return sound_insert_unit(&chains[chain], fops, -1, unit, max_unit, name, 0600, dev); } -=20 EXPORT_SYMBOL(register_sound_special_device); =20 int register_sound_special(const struct file_operations *fops, int unit) { return register_sound_special_device(fops, unit, NULL); } - EXPORT_SYMBOL(register_sound_special); =20 /** @@ -435,14 +428,13 @@ int register_sound_mixer(const struct file_operations= *fops, int dev) return sound_insert_unit(&chains[0], fops, dev, 0, 128, "mixer", 0600, NULL); } - EXPORT_SYMBOL(register_sound_mixer); =20 /* * DSP's are registered as a triple. Register only one and cheat * in open - see below. */ -=20 + /** * register_sound_dsp - register a DSP device * @fops: File operations for the driver @@ -463,7 +455,6 @@ int register_sound_dsp(const struct file_operations *fo= ps, int dev) return sound_insert_unit(&chains[3], fops, dev, 3, 131, "dsp", 0600, NULL); } - EXPORT_SYMBOL(register_sound_dsp); =20 /** @@ -480,7 +471,6 @@ void unregister_sound_special(int unit) { sound_remove_unit(&chains[unit % SOUND_STEP], unit); } -=20 EXPORT_SYMBOL(unregister_sound_special); =20 /** @@ -495,7 +485,6 @@ void unregister_sound_mixer(int unit) { sound_remove_unit(&chains[0], unit); } - EXPORT_SYMBOL(unregister_sound_mixer); =20 /** @@ -512,20 +501,17 @@ void unregister_sound_dsp(int unit) { sound_remove_unit(&chains[3], unit); } - - EXPORT_SYMBOL(unregister_sound_dsp); =20 static struct sound_unit *__look_for_unit(int chain, int unit) { struct sound_unit *s; -=09 - s=3Dchains[chain]; - while(s && s->unit_minor <=3D unit) - { - if(s->unit_minor=3D=3Dunit) + + s =3D chains[chain]; + while (s && s->unit_minor <=3D unit) { + if (s->unit_minor =3D=3D unit) return s; - s=3Ds->next; + s =3D s->next; } return NULL; } @@ -537,14 +523,13 @@ static int soundcore_open(struct inode *inode, struct= file *file) struct sound_unit *s; const struct file_operations *new_fops =3D NULL; =20 - chain=3Dunit&0x0F; - if(chain=3D=3D4 || chain=3D=3D5) /* dsp/audio/dsp16 */ - { - unit&=3D0xF0; - unit|=3D3; - chain=3D3; + chain =3D unit&0x0F; + if (chain =3D=3D 4 || chain =3D=3D 5) { /* dsp/audio/dsp16 */ + unit &=3D 0xF0; + unit |=3D 3; + chain =3D 3; } -=09 + spin_lock(&sound_loader_lock); s =3D __look_for_unit(chain, unit); if (s) @@ -598,8 +583,10 @@ MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR); =20 static void cleanup_oss_soundcore(void) { - /* We have nothing to really do here - we know the lists must be - empty */ + /* + * We have nothing to really do here - we know the lists must be + * empty + */ unregister_chrdev(SOUND_MAJOR, "sound"); } =20 --=20 2.34.1