linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powermac i2c: use mutex
@ 2007-07-03 23:01 Johannes Berg
  2007-07-04 11:47 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2007-07-03 23:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, Paul Mackerras

Convert the semaphores in low_i2c that are used as mutexes to real
mutexes.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

---
 arch/powerpc/platforms/powermac/low_i2c.c |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

--- wireless-dev.orig/arch/powerpc/platforms/powermac/low_i2c.c	2007-07-04 00:42:08.267749881 +0200
+++ wireless-dev/arch/powerpc/platforms/powermac/low_i2c.c	2007-07-04 00:42:48.667749881 +0200
@@ -42,6 +42,7 @@
 #include <linux/interrupt.h>
 #include <linux/completion.h>
 #include <linux/timer.h>
+#include <linux/mutex.h>
 #include <asm/keylargo.h>
 #include <asm/uninorth.h>
 #include <asm/io.h>
@@ -84,7 +85,7 @@ struct pmac_i2c_bus
 	void			*hostdata;
 	int			channel;	/* some hosts have multiple */
 	int			mode;		/* current mode */
-	struct semaphore	sem;
+	struct mutex		mutex;
 	int			opened;
 	int			polled;		/* open mode */
 	struct platform_device	*platform_dev;
@@ -104,7 +105,7 @@ static LIST_HEAD(pmac_i2c_busses);
 
 struct pmac_i2c_host_kw
 {
-	struct semaphore	mutex;		/* Access mutex for use by
+	struct mutex		mutex;		/* Access mutex for use by
 						 * i2c-keywest */
 	void __iomem		*base;		/* register base address */
 	int			bsteps;		/* register stepping */
@@ -375,14 +376,14 @@ static void kw_i2c_timeout(unsigned long
 static int kw_i2c_open(struct pmac_i2c_bus *bus)
 {
 	struct pmac_i2c_host_kw *host = bus->hostdata;
-	down(&host->mutex);
+	mutex_lock(&host->mutex);
 	return 0;
 }
 
 static void kw_i2c_close(struct pmac_i2c_bus *bus)
 {
 	struct pmac_i2c_host_kw *host = bus->hostdata;
-	up(&host->mutex);
+	mutex_unlock(&host->mutex);
 }
 
 static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
@@ -498,7 +499,7 @@ static struct pmac_i2c_host_kw *__init k
 		kfree(host);
 		return NULL;
 	}
-	init_MUTEX(&host->mutex);
+	mutex_init(&host->mutex);
 	init_completion(&host->complete);
 	spin_lock_init(&host->lock);
 	init_timer(&host->timeout_timer);
@@ -571,7 +572,7 @@ static void __init kw_i2c_add(struct pma
 	bus->open = kw_i2c_open;
 	bus->close = kw_i2c_close;
 	bus->xfer = kw_i2c_xfer;
-	init_MUTEX(&bus->sem);
+	mutex_init(&bus->mutex);
 	if (controller == busnode)
 		bus->flags = pmac_i2c_multibus;
 	list_add(&bus->link, &pmac_i2c_busses);
@@ -798,7 +799,7 @@ static void __init pmu_i2c_probe(void)
 		bus->mode = pmac_i2c_mode_std;
 		bus->hostdata = bus + 1;
 		bus->xfer = pmu_i2c_xfer;
-		init_MUTEX(&bus->sem);
+		mutex_init(&bus->mutex);
 		bus->flags = pmac_i2c_multibus;
 		list_add(&bus->link, &pmac_i2c_busses);
 
@@ -921,7 +922,7 @@ static void __init smu_i2c_probe(void)
 		bus->mode = pmac_i2c_mode_std;
 		bus->hostdata = bus + 1;
 		bus->xfer = smu_i2c_xfer;
-		init_MUTEX(&bus->sem);
+		mutex_init(&bus->mutex);
 		bus->flags = 0;
 		list_add(&bus->link, &pmac_i2c_busses);
 
@@ -1093,13 +1094,13 @@ int pmac_i2c_open(struct pmac_i2c_bus *b
 {
 	int rc;
 
-	down(&bus->sem);
+	mutex_lock(&bus->mutex);
 	bus->polled = polled || pmac_i2c_force_poll;
 	bus->opened = 1;
 	bus->mode = pmac_i2c_mode_std;
 	if (bus->open && (rc = bus->open(bus)) != 0) {
 		bus->opened = 0;
-		up(&bus->sem);
+		mutex_unlock(&bus->mutex);
 		return rc;
 	}
 	return 0;
@@ -1112,7 +1113,7 @@ void pmac_i2c_close(struct pmac_i2c_bus 
 	if (bus->close)
 		bus->close(bus);
 	bus->opened = 0;
-	up(&bus->sem);
+	mutex_unlock(&bus->mutex);
 }
 EXPORT_SYMBOL_GPL(pmac_i2c_close);
 

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

* Re: [PATCH] powermac i2c: use mutex
  2007-07-03 23:01 [PATCH] powermac i2c: use mutex Johannes Berg
@ 2007-07-04 11:47 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-04 11:47 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev list, Paul Mackerras

On Wed, 2007-07-04 at 01:01 +0200, Johannes Berg wrote:
> Convert the semaphores in low_i2c that are used as mutexes to real
> mutexes.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>

Looks ok

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> ---
>  arch/powerpc/platforms/powermac/low_i2c.c |   23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> --- wireless-dev.orig/arch/powerpc/platforms/powermac/low_i2c.c	2007-07-04 00:42:08.267749881 +0200
> +++ wireless-dev/arch/powerpc/platforms/powermac/low_i2c.c	2007-07-04 00:42:48.667749881 +0200
> @@ -42,6 +42,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/completion.h>
>  #include <linux/timer.h>
> +#include <linux/mutex.h>
>  #include <asm/keylargo.h>
>  #include <asm/uninorth.h>
>  #include <asm/io.h>
> @@ -84,7 +85,7 @@ struct pmac_i2c_bus
>  	void			*hostdata;
>  	int			channel;	/* some hosts have multiple */
>  	int			mode;		/* current mode */
> -	struct semaphore	sem;
> +	struct mutex		mutex;
>  	int			opened;
>  	int			polled;		/* open mode */
>  	struct platform_device	*platform_dev;
> @@ -104,7 +105,7 @@ static LIST_HEAD(pmac_i2c_busses);
>  
>  struct pmac_i2c_host_kw
>  {
> -	struct semaphore	mutex;		/* Access mutex for use by
> +	struct mutex		mutex;		/* Access mutex for use by
>  						 * i2c-keywest */
>  	void __iomem		*base;		/* register base address */
>  	int			bsteps;		/* register stepping */
> @@ -375,14 +376,14 @@ static void kw_i2c_timeout(unsigned long
>  static int kw_i2c_open(struct pmac_i2c_bus *bus)
>  {
>  	struct pmac_i2c_host_kw *host = bus->hostdata;
> -	down(&host->mutex);
> +	mutex_lock(&host->mutex);
>  	return 0;
>  }
>  
>  static void kw_i2c_close(struct pmac_i2c_bus *bus)
>  {
>  	struct pmac_i2c_host_kw *host = bus->hostdata;
> -	up(&host->mutex);
> +	mutex_unlock(&host->mutex);
>  }
>  
>  static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
> @@ -498,7 +499,7 @@ static struct pmac_i2c_host_kw *__init k
>  		kfree(host);
>  		return NULL;
>  	}
> -	init_MUTEX(&host->mutex);
> +	mutex_init(&host->mutex);
>  	init_completion(&host->complete);
>  	spin_lock_init(&host->lock);
>  	init_timer(&host->timeout_timer);
> @@ -571,7 +572,7 @@ static void __init kw_i2c_add(struct pma
>  	bus->open = kw_i2c_open;
>  	bus->close = kw_i2c_close;
>  	bus->xfer = kw_i2c_xfer;
> -	init_MUTEX(&bus->sem);
> +	mutex_init(&bus->mutex);
>  	if (controller == busnode)
>  		bus->flags = pmac_i2c_multibus;
>  	list_add(&bus->link, &pmac_i2c_busses);
> @@ -798,7 +799,7 @@ static void __init pmu_i2c_probe(void)
>  		bus->mode = pmac_i2c_mode_std;
>  		bus->hostdata = bus + 1;
>  		bus->xfer = pmu_i2c_xfer;
> -		init_MUTEX(&bus->sem);
> +		mutex_init(&bus->mutex);
>  		bus->flags = pmac_i2c_multibus;
>  		list_add(&bus->link, &pmac_i2c_busses);
>  
> @@ -921,7 +922,7 @@ static void __init smu_i2c_probe(void)
>  		bus->mode = pmac_i2c_mode_std;
>  		bus->hostdata = bus + 1;
>  		bus->xfer = smu_i2c_xfer;
> -		init_MUTEX(&bus->sem);
> +		mutex_init(&bus->mutex);
>  		bus->flags = 0;
>  		list_add(&bus->link, &pmac_i2c_busses);
>  
> @@ -1093,13 +1094,13 @@ int pmac_i2c_open(struct pmac_i2c_bus *b
>  {
>  	int rc;
>  
> -	down(&bus->sem);
> +	mutex_lock(&bus->mutex);
>  	bus->polled = polled || pmac_i2c_force_poll;
>  	bus->opened = 1;
>  	bus->mode = pmac_i2c_mode_std;
>  	if (bus->open && (rc = bus->open(bus)) != 0) {
>  		bus->opened = 0;
> -		up(&bus->sem);
> +		mutex_unlock(&bus->mutex);
>  		return rc;
>  	}
>  	return 0;
> @@ -1112,7 +1113,7 @@ void pmac_i2c_close(struct pmac_i2c_bus 
>  	if (bus->close)
>  		bus->close(bus);
>  	bus->opened = 0;
> -	up(&bus->sem);
> +	mutex_unlock(&bus->mutex);
>  }
>  EXPORT_SYMBOL_GPL(pmac_i2c_close);
>  
> 

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

end of thread, other threads:[~2007-07-04 11:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-03 23:01 [PATCH] powermac i2c: use mutex Johannes Berg
2007-07-04 11:47 ` Benjamin Herrenschmidt

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).