diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-07-03 19:01:54 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-07-10 07:55:54 -0400 |
commit | 76a5b8bb3525b63db137c714cf9ad5b3b99e75f0 (patch) | |
tree | 280f1db1fa249f73b01353cc4f9a926adf31ff3d /arch | |
parent | 0b7dbfbf13192a57591275d50b0993cb0acdb25c (diff) |
[POWERPC] powermac i2c: Use mutex
Convert the semaphores in low_i2c that are used as mutexes to real
mutexes.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/powermac/low_i2c.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c index 3f507ab9c5e5..efdf5eb81ecc 100644 --- a/arch/powerpc/platforms/powermac/low_i2c.c +++ b/arch/powerpc/platforms/powermac/low_i2c.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
43 | #include <linux/completion.h> | 43 | #include <linux/completion.h> |
44 | #include <linux/timer.h> | 44 | #include <linux/timer.h> |
45 | #include <linux/mutex.h> | ||
45 | #include <asm/keylargo.h> | 46 | #include <asm/keylargo.h> |
46 | #include <asm/uninorth.h> | 47 | #include <asm/uninorth.h> |
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
@@ -84,7 +85,7 @@ struct pmac_i2c_bus | |||
84 | void *hostdata; | 85 | void *hostdata; |
85 | int channel; /* some hosts have multiple */ | 86 | int channel; /* some hosts have multiple */ |
86 | int mode; /* current mode */ | 87 | int mode; /* current mode */ |
87 | struct semaphore sem; | 88 | struct mutex mutex; |
88 | int opened; | 89 | int opened; |
89 | int polled; /* open mode */ | 90 | int polled; /* open mode */ |
90 | struct platform_device *platform_dev; | 91 | struct platform_device *platform_dev; |
@@ -104,7 +105,7 @@ static LIST_HEAD(pmac_i2c_busses); | |||
104 | 105 | ||
105 | struct pmac_i2c_host_kw | 106 | struct pmac_i2c_host_kw |
106 | { | 107 | { |
107 | struct semaphore mutex; /* Access mutex for use by | 108 | struct mutex mutex; /* Access mutex for use by |
108 | * i2c-keywest */ | 109 | * i2c-keywest */ |
109 | void __iomem *base; /* register base address */ | 110 | void __iomem *base; /* register base address */ |
110 | int bsteps; /* register stepping */ | 111 | int bsteps; /* register stepping */ |
@@ -375,14 +376,14 @@ static void kw_i2c_timeout(unsigned long data) | |||
375 | static int kw_i2c_open(struct pmac_i2c_bus *bus) | 376 | static int kw_i2c_open(struct pmac_i2c_bus *bus) |
376 | { | 377 | { |
377 | struct pmac_i2c_host_kw *host = bus->hostdata; | 378 | struct pmac_i2c_host_kw *host = bus->hostdata; |
378 | down(&host->mutex); | 379 | mutex_lock(&host->mutex); |
379 | return 0; | 380 | return 0; |
380 | } | 381 | } |
381 | 382 | ||
382 | static void kw_i2c_close(struct pmac_i2c_bus *bus) | 383 | static void kw_i2c_close(struct pmac_i2c_bus *bus) |
383 | { | 384 | { |
384 | struct pmac_i2c_host_kw *host = bus->hostdata; | 385 | struct pmac_i2c_host_kw *host = bus->hostdata; |
385 | up(&host->mutex); | 386 | mutex_unlock(&host->mutex); |
386 | } | 387 | } |
387 | 388 | ||
388 | static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize, | 389 | 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 kw_i2c_host_init(struct device_node *np) | |||
498 | kfree(host); | 499 | kfree(host); |
499 | return NULL; | 500 | return NULL; |
500 | } | 501 | } |
501 | init_MUTEX(&host->mutex); | 502 | mutex_init(&host->mutex); |
502 | init_completion(&host->complete); | 503 | init_completion(&host->complete); |
503 | spin_lock_init(&host->lock); | 504 | spin_lock_init(&host->lock); |
504 | init_timer(&host->timeout_timer); | 505 | init_timer(&host->timeout_timer); |
@@ -571,7 +572,7 @@ static void __init kw_i2c_add(struct pmac_i2c_host_kw *host, | |||
571 | bus->open = kw_i2c_open; | 572 | bus->open = kw_i2c_open; |
572 | bus->close = kw_i2c_close; | 573 | bus->close = kw_i2c_close; |
573 | bus->xfer = kw_i2c_xfer; | 574 | bus->xfer = kw_i2c_xfer; |
574 | init_MUTEX(&bus->sem); | 575 | mutex_init(&bus->mutex); |
575 | if (controller == busnode) | 576 | if (controller == busnode) |
576 | bus->flags = pmac_i2c_multibus; | 577 | bus->flags = pmac_i2c_multibus; |
577 | list_add(&bus->link, &pmac_i2c_busses); | 578 | list_add(&bus->link, &pmac_i2c_busses); |
@@ -798,7 +799,7 @@ static void __init pmu_i2c_probe(void) | |||
798 | bus->mode = pmac_i2c_mode_std; | 799 | bus->mode = pmac_i2c_mode_std; |
799 | bus->hostdata = bus + 1; | 800 | bus->hostdata = bus + 1; |
800 | bus->xfer = pmu_i2c_xfer; | 801 | bus->xfer = pmu_i2c_xfer; |
801 | init_MUTEX(&bus->sem); | 802 | mutex_init(&bus->mutex); |
802 | bus->flags = pmac_i2c_multibus; | 803 | bus->flags = pmac_i2c_multibus; |
803 | list_add(&bus->link, &pmac_i2c_busses); | 804 | list_add(&bus->link, &pmac_i2c_busses); |
804 | 805 | ||
@@ -921,7 +922,7 @@ static void __init smu_i2c_probe(void) | |||
921 | bus->mode = pmac_i2c_mode_std; | 922 | bus->mode = pmac_i2c_mode_std; |
922 | bus->hostdata = bus + 1; | 923 | bus->hostdata = bus + 1; |
923 | bus->xfer = smu_i2c_xfer; | 924 | bus->xfer = smu_i2c_xfer; |
924 | init_MUTEX(&bus->sem); | 925 | mutex_init(&bus->mutex); |
925 | bus->flags = 0; | 926 | bus->flags = 0; |
926 | list_add(&bus->link, &pmac_i2c_busses); | 927 | list_add(&bus->link, &pmac_i2c_busses); |
927 | 928 | ||
@@ -1093,13 +1094,13 @@ int pmac_i2c_open(struct pmac_i2c_bus *bus, int polled) | |||
1093 | { | 1094 | { |
1094 | int rc; | 1095 | int rc; |
1095 | 1096 | ||
1096 | down(&bus->sem); | 1097 | mutex_lock(&bus->mutex); |
1097 | bus->polled = polled || pmac_i2c_force_poll; | 1098 | bus->polled = polled || pmac_i2c_force_poll; |
1098 | bus->opened = 1; | 1099 | bus->opened = 1; |
1099 | bus->mode = pmac_i2c_mode_std; | 1100 | bus->mode = pmac_i2c_mode_std; |
1100 | if (bus->open && (rc = bus->open(bus)) != 0) { | 1101 | if (bus->open && (rc = bus->open(bus)) != 0) { |
1101 | bus->opened = 0; | 1102 | bus->opened = 0; |
1102 | up(&bus->sem); | 1103 | mutex_unlock(&bus->mutex); |
1103 | return rc; | 1104 | return rc; |
1104 | } | 1105 | } |
1105 | return 0; | 1106 | return 0; |
@@ -1112,7 +1113,7 @@ void pmac_i2c_close(struct pmac_i2c_bus *bus) | |||
1112 | if (bus->close) | 1113 | if (bus->close) |
1113 | bus->close(bus); | 1114 | bus->close(bus); |
1114 | bus->opened = 0; | 1115 | bus->opened = 0; |
1115 | up(&bus->sem); | 1116 | mutex_unlock(&bus->mutex); |
1116 | } | 1117 | } |
1117 | EXPORT_SYMBOL_GPL(pmac_i2c_close); | 1118 | EXPORT_SYMBOL_GPL(pmac_i2c_close); |
1118 | 1119 | ||