diff mbox

[1/2] ALSA: soundcore: coding style fixes

Message ID 1401970346-9043-1-git-send-email-zonque@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Mack June 5, 2014, 12:12 p.m. UTC
sound/sounc_core.c has a larger number of style issues. Fix them to make the
code more readable. No functional change.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/sound_core.c | 192 ++++++++++++++++++++++++-----------------------------
 1 file changed, 85 insertions(+), 107 deletions(-)

Comments

Takashi Sakamoto June 5, 2014, 1:37 p.m. UTC | #1
(Jun 5 2014 21:12), Daniel Mack wrote:
> sound/sounc_core.c has a larger number of style issues. Fix them to make the
> code more readable. No functional change.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
>  sound/sound_core.c | 192 ++++++++++++++++++++++++-----------------------------
>  1 file changed, 85 insertions(+), 107 deletions(-)

Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Takashi Iwai June 5, 2014, 1:53 p.m. UTC | #2
At Thu,  5 Jun 2014 14:12:25 +0200,
Daniel Mack wrote:
> 
> sound/sounc_core.c has a larger number of style issues. Fix them to make the
> code more readable. No functional change.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Thanks for the patches, but are you going to fix anything in these
codes along with them?  Such coding style fixes just stir git history,
which make often annoying for backporting or reviewing.  So, basically
I'd take such cleanup patches only if the real fixes will come
together.


Takashi

> ---
>  sound/sound_core.c | 192 ++++++++++++++++++++++++-----------------------------
>  1 file changed, 85 insertions(+), 107 deletions(-)
> 
> diff --git a/sound/sound_core.c b/sound/sound_core.c
> index 11e953a..bf9e41e 100644
> --- a/sound/sound_core.c
> +++ b/sound/sound_core.c
> @@ -68,21 +68,16 @@ module_exit(cleanup_soundcore);
>  #ifdef CONFIG_SOUND_OSS_CORE
>  /*
>   *	OSS sound core handling. Breaks out sound functions to submodules
> - *	
> - *	Author:		Alan Cox <alan@lxorguk.ukuu.org.uk>
> - *
> - *	Fixes:
>   *
> + *	Author:		Alan Cox <alan@lxorguk.ukuu.org.uk>
>   *
>   *	This program is free software; you can redistribute it and/or
>   *	modify it under the terms of the GNU General Public License
>   *	as published by the Free Software Foundation; either version
>   *	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 +106,7 @@ module_exit(cleanup_soundcore);
>  
>  #define SOUND_STEP 16
>  
> -struct sound_unit
> -{
> +struct sound_unit {
>  	int unit_minor;
>  	const struct file_operations *unit_fops;
>  	struct sound_unit *next;
> @@ -158,8 +152,7 @@ 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,71 +164,66 @@ static const struct file_operations soundcore_fops =
>   *	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_minor < n)
> +			list = &((*list)->next);
>  
> -		while (*list && (*list)->unit_minor<n)
> -			list=&((*list)->next);
> -
> -		while(n<top)
> -		{
> +		while (n < top) {
>  			/* Found a hole ? */
> -			if(*list==NULL || (*list)->unit_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);
> +		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;
> -	
> -	/*
> -	 *	Link it
> -	 */
> -	 
> -	s->next=*list;
> -	*list=s;
> -	
> -	
> +	}
> +
> +	/* Fill it in */
> +	s->unit_minor = n;
> +	s->unit_fops = fops;
> +
> +	/* Link it */
> +	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)
> +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;
>  }
> @@ -250,12 +238,15 @@ static DEFINE_SPINLOCK(sound_loader_lock);
>   *	Allocate the controlling structure and add it to the sound driver
>   *	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);
> +	struct sound_unit *s;
>  	int r;
>  
> +	s = kmalloc(sizeof(*s), GFP_KERNEL);
>  	if (!s)
>  		return -ENOMEM;
>  
> @@ -263,7 +254,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)
> @@ -292,7 +283,8 @@ retry:
>  	}
>  
>  	device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
> -		      NULL, "%s", s->name+6);
> +		      NULL, "%s", s->name + 6);
> +
>  	return s->unit_minor;
>  
>  fail:
> @@ -305,7 +297,6 @@ fail:
>   *	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 +348,6 @@ static struct sound_unit *chains[SOUND_STEP];
>   *	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 +357,66 @@ 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:
> -			sprintf(_name, "unknown%d", chain);
> -		    	if (unit >= SOUND_STEP)
> -		    		strcat(_name, "-");
> -		    	name = _name;
> -		}
> +	default:
> +__unknown:
> +		sprintf(_name, "unknown%d", chain);
> +		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);
>  
>  /**
> @@ -443,13 +430,11 @@ EXPORT_SYMBOL(register_sound_special);
>   *	Return: On success, the allocated number is returned. On failure,
>   *	a negative error code is returned.
>   */
> -
>  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 +454,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 +481,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 +497,6 @@ void unregister_sound_special(int unit)
>  {
>  	sound_remove_unit(&chains[unit % SOUND_STEP], unit);
>  }
> - 
>  EXPORT_SYMBOL(unregister_sound_special);
>  
>  /**
> @@ -529,7 +511,6 @@ void unregister_sound_mixer(int unit)
>  {
>  	sound_remove_unit(&chains[0], unit);
>  }
> -
>  EXPORT_SYMBOL(unregister_sound_mixer);
>  
>  /**
> @@ -544,7 +525,6 @@ void unregister_sound_midi(int unit)
>  {
>  	sound_remove_unit(&chains[2], unit);
>  }
> -
>  EXPORT_SYMBOL(unregister_sound_midi);
>  
>  /**
> @@ -561,21 +541,19 @@ 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 +564,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)
> @@ -608,8 +585,8 @@ static int soundcore_open(struct inode *inode, struct file *file)
>  		 *  ALSA toplevel modules for soundcards, thus we need
>  		 *  load them at first.	  [Jaroslav Kysela <perex@jcu.cz>]
>  		 */
> -		request_module("sound-slot-%i", unit>>4);
> -		request_module("sound-service-%i-%i", unit>>4, chain);
> +		request_module("sound-slot-%i", unit >> 4);
> +		request_module("sound-service-%i-%i", unit >> 4, chain);
>  
>  		/*
>  		 * sound-slot/service-* module aliases are scheduled
> @@ -636,10 +613,11 @@ 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;
>  	}
> +
>  	return -ENODEV;
>  }
>  
> -- 
> 1.9.3
>
Daniel Mack June 5, 2014, 1:59 p.m. UTC | #3
On 06/05/2014 03:53 PM, Takashi Iwai wrote:
> At Thu,  5 Jun 2014 14:12:25 +0200,
> Daniel Mack wrote:
>>
>> sound/sounc_core.c has a larger number of style issues. Fix them to make the
>> code more readable. No functional change.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
> 
> Thanks for the patches, but are you going to fix anything in these
> codes along with them?  Such coding style fixes just stir git history,
> which make often annoying for backporting or reviewing.  So, basically
> I'd take such cleanup patches only if the real fixes will come
> together.

Yeah, I know that code is legacy. I was just skimming over the sources
to trace a bug report on alsa-user, and stumbled over so many style
issues that made reading the code harder than necessary that I couldn't
resist fixing them :)

Hence, I don't know yet. Maybe there will be a fix as well at some late
point. Feel free to ignore the patches for now. I'll stash and resend
them along with real fixes in case there are any.


Thanks,
Daniel
Takashi Iwai June 5, 2014, 2:12 p.m. UTC | #4
At Thu, 05 Jun 2014 15:59:03 +0200,
Daniel Mack wrote:
> 
> On 06/05/2014 03:53 PM, Takashi Iwai wrote:
> > At Thu,  5 Jun 2014 14:12:25 +0200,
> > Daniel Mack wrote:
> >>
> >> sound/sounc_core.c has a larger number of style issues. Fix them to make the
> >> code more readable. No functional change.
> >>
> >> Signed-off-by: Daniel Mack <zonque@gmail.com>
> > 
> > Thanks for the patches, but are you going to fix anything in these
> > codes along with them?  Such coding style fixes just stir git history,
> > which make often annoying for backporting or reviewing.  So, basically
> > I'd take such cleanup patches only if the real fixes will come
> > together.
> 
> Yeah, I know that code is legacy. I was just skimming over the sources
> to trace a bug report on alsa-user, and stumbled over so many style
> issues that made reading the code harder than necessary that I couldn't
> resist fixing them :)

Ah, you're looking at usb disconnection issue?  I just saw the thread
now...

> Hence, I don't know yet. Maybe there will be a fix as well at some late
> point. Feel free to ignore the patches for now. I'll stash and resend
> them along with real fixes in case there are any.

OK, then let's postpone.


thanks,

Takashi
Daniel Mack June 5, 2014, 2:14 p.m. UTC | #5
On 06/05/2014 04:12 PM, Takashi Iwai wrote:
> At Thu, 05 Jun 2014 15:59:03 +0200,
> Daniel Mack wrote:
>>
>> On 06/05/2014 03:53 PM, Takashi Iwai wrote:
>>> At Thu,  5 Jun 2014 14:12:25 +0200,
>>> Daniel Mack wrote:
>>>>
>>>> sound/sounc_core.c has a larger number of style issues. Fix them to make the
>>>> code more readable. No functional change.
>>>>
>>>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>>>
>>> Thanks for the patches, but are you going to fix anything in these
>>> codes along with them?  Such coding style fixes just stir git history,
>>> which make often annoying for backporting or reviewing.  So, basically
>>> I'd take such cleanup patches only if the real fixes will come
>>> together.
>>
>> Yeah, I know that code is legacy. I was just skimming over the sources
>> to trace a bug report on alsa-user, and stumbled over so many style
>> issues that made reading the code harder than necessary that I couldn't
>> resist fixing them :)
> 
> Ah, you're looking at usb disconnection issue?  I just saw the thread
> now...

Jup. I was hoping that I could reproduce it here, but failed. The I had
a quick look at the code, but I didn't find anything yet ...


Daniel
diff mbox

Patch

diff --git a/sound/sound_core.c b/sound/sound_core.c
index 11e953a..bf9e41e 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -68,21 +68,16 @@  module_exit(cleanup_soundcore);
 #ifdef CONFIG_SOUND_OSS_CORE
 /*
  *	OSS sound core handling. Breaks out sound functions to submodules
- *	
- *	Author:		Alan Cox <alan@lxorguk.ukuu.org.uk>
- *
- *	Fixes:
  *
+ *	Author:		Alan Cox <alan@lxorguk.ukuu.org.uk>
  *
  *	This program is free software; you can redistribute it and/or
  *	modify it under the terms of the GNU General Public License
  *	as published by the Free Software Foundation; either version
  *	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 +106,7 @@  module_exit(cleanup_soundcore);
 
 #define SOUND_STEP 16
 
-struct sound_unit
-{
+struct sound_unit {
 	int unit_minor;
 	const struct file_operations *unit_fops;
 	struct sound_unit *next;
@@ -158,8 +152,7 @@  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,71 +164,66 @@  static const struct file_operations soundcore_fops =
  *	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_minor < n)
+			list = &((*list)->next);
 
-		while (*list && (*list)->unit_minor<n)
-			list=&((*list)->next);
-
-		while(n<top)
-		{
+		while (n < top) {
 			/* Found a hole ? */
-			if(*list==NULL || (*list)->unit_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);
+		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;
-	
-	/*
-	 *	Link it
-	 */
-	 
-	s->next=*list;
-	*list=s;
-	
-	
+	}
+
+	/* Fill it in */
+	s->unit_minor = n;
+	s->unit_fops = fops;
+
+	/* Link it */
+	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)
+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;
 }
@@ -250,12 +238,15 @@  static DEFINE_SPINLOCK(sound_loader_lock);
  *	Allocate the controlling structure and add it to the sound driver
  *	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);
+	struct sound_unit *s;
 	int r;
 
+	s = kmalloc(sizeof(*s), GFP_KERNEL);
 	if (!s)
 		return -ENOMEM;
 
@@ -263,7 +254,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)
@@ -292,7 +283,8 @@  retry:
 	}
 
 	device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
-		      NULL, "%s", s->name+6);
+		      NULL, "%s", s->name + 6);
+
 	return s->unit_minor;
 
 fail:
@@ -305,7 +297,6 @@  fail:
  *	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 +348,6 @@  static struct sound_unit *chains[SOUND_STEP];
  *	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 +357,66 @@  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:
-			sprintf(_name, "unknown%d", chain);
-		    	if (unit >= SOUND_STEP)
-		    		strcat(_name, "-");
-		    	name = _name;
-		}
+	default:
+__unknown:
+		sprintf(_name, "unknown%d", chain);
+		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);
 
 /**
@@ -443,13 +430,11 @@  EXPORT_SYMBOL(register_sound_special);
  *	Return: On success, the allocated number is returned. On failure,
  *	a negative error code is returned.
  */
-
 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 +454,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 +481,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 +497,6 @@  void unregister_sound_special(int unit)
 {
 	sound_remove_unit(&chains[unit % SOUND_STEP], unit);
 }
- 
 EXPORT_SYMBOL(unregister_sound_special);
 
 /**
@@ -529,7 +511,6 @@  void unregister_sound_mixer(int unit)
 {
 	sound_remove_unit(&chains[0], unit);
 }
-
 EXPORT_SYMBOL(unregister_sound_mixer);
 
 /**
@@ -544,7 +525,6 @@  void unregister_sound_midi(int unit)
 {
 	sound_remove_unit(&chains[2], unit);
 }
-
 EXPORT_SYMBOL(unregister_sound_midi);
 
 /**
@@ -561,21 +541,19 @@  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 +564,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)
@@ -608,8 +585,8 @@  static int soundcore_open(struct inode *inode, struct file *file)
 		 *  ALSA toplevel modules for soundcards, thus we need
 		 *  load them at first.	  [Jaroslav Kysela <perex@jcu.cz>]
 		 */
-		request_module("sound-slot-%i", unit>>4);
-		request_module("sound-service-%i-%i", unit>>4, chain);
+		request_module("sound-slot-%i", unit >> 4);
+		request_module("sound-service-%i-%i", unit >> 4, chain);
 
 		/*
 		 * sound-slot/service-* module aliases are scheduled
@@ -636,10 +613,11 @@  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;
 	}
+
 	return -ENODEV;
 }