linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] use mutex instead of semaphore in SPI core/init code
       [not found] <20070713192023.GD18159@traven>
@ 2007-07-13 19:23 ` Matthias Kaehlcke
  2007-07-13 19:59   ` David Brownell
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaehlcke @ 2007-07-13 19:23 UTC (permalink / raw)
  To: dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

The SPI core/init code uses a semaphore as mutex. Use the mutex
API instead of the (binary) semaphore.

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

--

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 4831edb..018884d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -23,6 +23,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/cache.h>
+#include <linux/mutex.h>
 #include <linux/spi/spi.h>
 
 
@@ -185,7 +186,7 @@ struct boardinfo {
 };
 
 static LIST_HEAD(board_list);
-static DECLARE_MUTEX(board_lock);
+static DEFINE_MUTEX(board_lock);
 
 
 /**
@@ -292,9 +293,9 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
 	bi->n_board_info = n;
 	memcpy(bi->board_info, info, n * sizeof *info);
 
-	down(&board_lock);
+	mutex_lock(&board_lock);
 	list_add_tail(&bi->list, &board_list);
-	up(&board_lock);
+	mutex_unlock(&board_lock);
 	return 0;
 }
 
@@ -308,7 +309,7 @@ scan_boardinfo(struct spi_master *master)
 	struct boardinfo	*bi;
 	struct device		*dev = master->cdev.dev;
 
-	down(&board_lock);
+	mutex_lock(&board_lock);
 	list_for_each_entry(bi, &board_list, list) {
 		struct spi_board_info	*chip = bi->board_info;
 		unsigned		n;
@@ -330,7 +331,7 @@ scan_boardinfo(struct spi_master *master)
 			(void) spi_new_device(master, chip);
 		}
 	}
-	up(&board_lock);
+	mutex_unlock(&board_lock);
 }
 
 /*-------------------------------------------------------------------------*/

-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona

    Ma patrie est où je suis, où personne ne me dérange, où personne
    ne me demande que je suis, d'où je viens et ce que je fais
                              (B. Traven)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/5] use mutex instead of semaphore in SPI core/init code
  2007-07-13 19:23 ` [PATCH 1/5] use mutex instead of semaphore in SPI core/init code Matthias Kaehlcke
@ 2007-07-13 19:59   ` David Brownell
  0 siblings, 0 replies; 2+ messages in thread
From: David Brownell @ 2007-07-13 19:59 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Friday 13 July 2007, Matthias Kaehlcke wrote:
> The SPI core/init code uses a semaphore as mutex. Use the mutex
> API instead of the (binary) semaphore.
> 
> Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

ACK ... and thanks!

> 
> --
> 
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 4831edb..018884d 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -23,6 +23,7 @@
>  #include <linux/device.h>
>  #include <linux/init.h>
>  #include <linux/cache.h>
> +#include <linux/mutex.h>
>  #include <linux/spi/spi.h>
>  
>  
> @@ -185,7 +186,7 @@ struct boardinfo {
>  };
>  
>  static LIST_HEAD(board_list);
> -static DECLARE_MUTEX(board_lock);
> +static DEFINE_MUTEX(board_lock);
>  
>  
>  /**
> @@ -292,9 +293,9 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
>  	bi->n_board_info = n;
>  	memcpy(bi->board_info, info, n * sizeof *info);
>  
> -	down(&board_lock);
> +	mutex_lock(&board_lock);
>  	list_add_tail(&bi->list, &board_list);
> -	up(&board_lock);
> +	mutex_unlock(&board_lock);
>  	return 0;
>  }
>  
> @@ -308,7 +309,7 @@ scan_boardinfo(struct spi_master *master)
>  	struct boardinfo	*bi;
>  	struct device		*dev = master->cdev.dev;
>  
> -	down(&board_lock);
> +	mutex_lock(&board_lock);
>  	list_for_each_entry(bi, &board_list, list) {
>  		struct spi_board_info	*chip = bi->board_info;
>  		unsigned		n;
> @@ -330,7 +331,7 @@ scan_boardinfo(struct spi_master *master)
>  			(void) spi_new_device(master, chip);
>  		}
>  	}
> -	up(&board_lock);
> +	mutex_unlock(&board_lock);
>  }
>  
>  /*-------------------------------------------------------------------------*/
> 
> -- 
> Matthias Kaehlcke
> Linux Application Developer
> Barcelona
> 
>     Ma patrie est où je suis, où personne ne me dérange, où personne
>     ne me demande que je suis, d'où je viens et ce que je fais
>                               (B. Traven)
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-13 19:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20070713192023.GD18159@traven>
2007-07-13 19:23 ` [PATCH 1/5] use mutex instead of semaphore in SPI core/init code Matthias Kaehlcke
2007-07-13 19:59   ` David Brownell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).