diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-30 12:13:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-30 12:13:08 -0400 |
commit | 17d30ac077df253c12c7ba4db8d5cdacfceeb6d1 (patch) | |
tree | 991a18cd249d66c7e08faa1b93f014ad169f04f3 /drivers/mfd/pcf50633-adc.c | |
parent | e38c1e54ce51059a1aa8744c895762906cf43b32 (diff) | |
parent | 191211f50f35deb5b3b80bc7b620cfd4b0a4a2d9 (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (47 commits)
mfd: Rename twl5031 sih modules
mfd: Storage class for timberdale should be before const qualifier
mfd: Remove unneeded and dangerous clearing of clientdata
mfd: New AB8500 driver
gpio: Fix inverted rdc321x gpio data out registers
mfd: Change rdc321x resources flags to IORESOURCE_IO
mfd: Move pcf50633 irq related functions to its own file.
mfd: Use threaded irq for pcf50633
mfd: pcf50633-adc: Fix potential race in pcf50633_adc_sync_read
mfd: Fix pcf50633 bitfield logic in interrupt handler
gpio: rdc321x needs to select MFD_CORE
mfd: Use menuconfig for quicker config editing
ARM: AB3550 board configuration and irq for U300
mfd: AB3550 core driver
mfd: AB3100 register access change to abx500 API
mfd: Renamed ab3100.h to abx500.h
gpio: Add TC35892 GPIO driver
mfd: Add Toshiba's TC35892 MFD core
mfd: Delay to mask tsc irq in max8925
mfd: Remove incorrect wm8350 kfree
...
Diffstat (limited to 'drivers/mfd/pcf50633-adc.c')
-rw-r--r-- | drivers/mfd/pcf50633-adc.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c index fe8f922f6654..aed0d2a9b032 100644 --- a/drivers/mfd/pcf50633-adc.c +++ b/drivers/mfd/pcf50633-adc.c | |||
@@ -30,13 +30,13 @@ | |||
30 | struct pcf50633_adc_request { | 30 | struct pcf50633_adc_request { |
31 | int mux; | 31 | int mux; |
32 | int avg; | 32 | int avg; |
33 | int result; | ||
34 | void (*callback)(struct pcf50633 *, void *, int); | 33 | void (*callback)(struct pcf50633 *, void *, int); |
35 | void *callback_param; | 34 | void *callback_param; |
35 | }; | ||
36 | 36 | ||
37 | /* Used in case of sync requests */ | 37 | struct pcf50633_adc_sync_request { |
38 | int result; | ||
38 | struct completion completion; | 39 | struct completion completion; |
39 | |||
40 | }; | 40 | }; |
41 | 41 | ||
42 | #define PCF50633_MAX_ADC_FIFO_DEPTH 8 | 42 | #define PCF50633_MAX_ADC_FIFO_DEPTH 8 |
@@ -109,10 +109,10 @@ adc_enqueue_request(struct pcf50633 *pcf, struct pcf50633_adc_request *req) | |||
109 | return 0; | 109 | return 0; |
110 | } | 110 | } |
111 | 111 | ||
112 | static void | 112 | static void pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, |
113 | pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, int result) | 113 | int result) |
114 | { | 114 | { |
115 | struct pcf50633_adc_request *req = param; | 115 | struct pcf50633_adc_sync_request *req = param; |
116 | 116 | ||
117 | req->result = result; | 117 | req->result = result; |
118 | complete(&req->completion); | 118 | complete(&req->completion); |
@@ -120,28 +120,19 @@ pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, int result) | |||
120 | 120 | ||
121 | int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg) | 121 | int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg) |
122 | { | 122 | { |
123 | struct pcf50633_adc_request *req; | 123 | struct pcf50633_adc_sync_request req; |
124 | int err; | 124 | int ret; |
125 | 125 | ||
126 | /* req is freed when the result is ready, in interrupt handler */ | 126 | init_completion(&req.completion); |
127 | req = kzalloc(sizeof(*req), GFP_KERNEL); | ||
128 | if (!req) | ||
129 | return -ENOMEM; | ||
130 | |||
131 | req->mux = mux; | ||
132 | req->avg = avg; | ||
133 | req->callback = pcf50633_adc_sync_read_callback; | ||
134 | req->callback_param = req; | ||
135 | 127 | ||
136 | init_completion(&req->completion); | 128 | ret = pcf50633_adc_async_read(pcf, mux, avg, |
137 | err = adc_enqueue_request(pcf, req); | 129 | pcf50633_adc_sync_read_callback, &req); |
138 | if (err) | 130 | if (ret) |
139 | return err; | 131 | return ret; |
140 | 132 | ||
141 | wait_for_completion(&req->completion); | 133 | wait_for_completion(&req.completion); |
142 | 134 | ||
143 | /* FIXME by this time req might be already freed */ | 135 | return req.result; |
144 | return req->result; | ||
145 | } | 136 | } |
146 | EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read); | 137 | EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read); |
147 | 138 | ||