diff options
author | Tejun Heo <tj@kernel.org> | 2009-04-22 22:05:20 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-04-28 01:37:36 -0400 |
commit | ec24751a6b57e1373a12361e581b2458bc9bb791 (patch) | |
tree | 098ce79b89e10437d7660f3d65935a48f31a611c | |
parent | f06d9a2b52e246a66b606130cea3f0d7b7be17a7 (diff) |
arm-omap: don't abuse rq->data
omap mailbox uses rq->data as the second opaque pointer to carry
mbox_msg_t and rq->special message argument which is needed only for
tx. Add and use omap_msg_tx_data struct for tx and use rq->special
for mbox_msg_t for rx such that only rq->special is used as opaque
pointer.
[ Impact: cleanup rq->data usage, extra kmalloc in msg_send ]
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Russell King <rmk@arm.linux.org.uk>
-rw-r--r-- | arch/arm/plat-omap/mailbox.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c index cf81bad8aec2..538ba7541d3f 100644 --- a/arch/arm/plat-omap/mailbox.c +++ b/arch/arm/plat-omap/mailbox.c | |||
@@ -147,24 +147,40 @@ static int __mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void *arg) | |||
147 | return ret; | 147 | return ret; |
148 | } | 148 | } |
149 | 149 | ||
150 | struct omap_msg_tx_data { | ||
151 | mbox_msg_t msg; | ||
152 | void *arg; | ||
153 | }; | ||
154 | |||
155 | static void omap_msg_tx_end_io(struct request *rq, int error) | ||
156 | { | ||
157 | kfree(rq->special); | ||
158 | __blk_put_request(rq->q, rq); | ||
159 | } | ||
160 | |||
150 | int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg) | 161 | int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg, void* arg) |
151 | { | 162 | { |
163 | struct omap_msg_tx_data *tx_data; | ||
152 | struct request *rq; | 164 | struct request *rq; |
153 | struct request_queue *q = mbox->txq->queue; | 165 | struct request_queue *q = mbox->txq->queue; |
154 | int ret = 0; | 166 | |
167 | tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); | ||
168 | if (unlikely(!tx_data)) | ||
169 | return -ENOMEM; | ||
155 | 170 | ||
156 | rq = blk_get_request(q, WRITE, GFP_ATOMIC); | 171 | rq = blk_get_request(q, WRITE, GFP_ATOMIC); |
157 | if (unlikely(!rq)) { | 172 | if (unlikely(!rq)) { |
158 | ret = -ENOMEM; | 173 | kfree(tx_data); |
159 | goto fail; | 174 | return -ENOMEM; |
160 | } | 175 | } |
161 | 176 | ||
162 | rq->data = (void *)msg; | 177 | tx_data->msg = msg; |
163 | blk_insert_request(q, rq, 0, arg); | 178 | tx_data->arg = arg; |
179 | rq->end_io = omap_msg_tx_end_io; | ||
180 | blk_insert_request(q, rq, 0, tx_data); | ||
164 | 181 | ||
165 | schedule_work(&mbox->txq->work); | 182 | schedule_work(&mbox->txq->work); |
166 | fail: | 183 | return 0; |
167 | return ret; | ||
168 | } | 184 | } |
169 | EXPORT_SYMBOL(omap_mbox_msg_send); | 185 | EXPORT_SYMBOL(omap_mbox_msg_send); |
170 | 186 | ||
@@ -178,6 +194,8 @@ static void mbox_tx_work(struct work_struct *work) | |||
178 | struct request_queue *q = mbox->txq->queue; | 194 | struct request_queue *q = mbox->txq->queue; |
179 | 195 | ||
180 | while (1) { | 196 | while (1) { |
197 | struct omap_msg_tx_data *tx_data; | ||
198 | |||
181 | spin_lock(q->queue_lock); | 199 | spin_lock(q->queue_lock); |
182 | rq = elv_next_request(q); | 200 | rq = elv_next_request(q); |
183 | spin_unlock(q->queue_lock); | 201 | spin_unlock(q->queue_lock); |
@@ -185,7 +203,9 @@ static void mbox_tx_work(struct work_struct *work) | |||
185 | if (!rq) | 203 | if (!rq) |
186 | break; | 204 | break; |
187 | 205 | ||
188 | ret = __mbox_msg_send(mbox, (mbox_msg_t) rq->data, rq->special); | 206 | tx_data = rq->special; |
207 | |||
208 | ret = __mbox_msg_send(mbox, tx_data->msg, tx_data->arg); | ||
189 | if (ret) { | 209 | if (ret) { |
190 | enable_mbox_irq(mbox, IRQ_TX); | 210 | enable_mbox_irq(mbox, IRQ_TX); |
191 | return; | 211 | return; |
@@ -222,7 +242,7 @@ static void mbox_rx_work(struct work_struct *work) | |||
222 | if (!rq) | 242 | if (!rq) |
223 | break; | 243 | break; |
224 | 244 | ||
225 | msg = (mbox_msg_t) rq->data; | 245 | msg = (mbox_msg_t)rq->special; |
226 | blk_end_request_all(rq, 0); | 246 | blk_end_request_all(rq, 0); |
227 | mbox->rxq->callback((void *)msg); | 247 | mbox->rxq->callback((void *)msg); |
228 | } | 248 | } |
@@ -260,7 +280,6 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) | |||
260 | goto nomem; | 280 | goto nomem; |
261 | 281 | ||
262 | msg = mbox_fifo_read(mbox); | 282 | msg = mbox_fifo_read(mbox); |
263 | rq->data = (void *)msg; | ||
264 | 283 | ||
265 | if (unlikely(mbox_seq_test(mbox, msg))) { | 284 | if (unlikely(mbox_seq_test(mbox, msg))) { |
266 | pr_info("mbox: Illegal seq bit!(%08x)\n", msg); | 285 | pr_info("mbox: Illegal seq bit!(%08x)\n", msg); |
@@ -268,7 +287,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox) | |||
268 | mbox->err_notify(); | 287 | mbox->err_notify(); |
269 | } | 288 | } |
270 | 289 | ||
271 | blk_insert_request(q, rq, 0, NULL); | 290 | blk_insert_request(q, rq, 0, (void *)msg); |
272 | if (mbox->ops->type == OMAP_MBOX_TYPE1) | 291 | if (mbox->ops->type == OMAP_MBOX_TYPE1) |
273 | break; | 292 | break; |
274 | } | 293 | } |
@@ -331,7 +350,7 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf) | |||
331 | if (!rq) | 350 | if (!rq) |
332 | break; | 351 | break; |
333 | 352 | ||
334 | *p = (mbox_msg_t) rq->data; | 353 | *p = (mbox_msg_t)rq->special; |
335 | 354 | ||
336 | blk_end_request_all(rq, 0); | 355 | blk_end_request_all(rq, 0); |
337 | 356 | ||