diff options
-rw-r--r-- | drivers/dma/sh/shdma-base.c | 9 | ||||
-rw-r--r-- | drivers/dma/sh/shdma.c | 24 | ||||
-rw-r--r-- | drivers/dma/sh/shdma.h | 2 | ||||
-rw-r--r-- | include/linux/sh_dma.h | 2 | ||||
-rw-r--r-- | include/linux/shdma-base.h | 1 |
5 files changed, 18 insertions, 20 deletions
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index ff060d0da908..f75ebfa735c0 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c | |||
@@ -76,7 +76,7 @@ static dma_cookie_t shdma_tx_submit(struct dma_async_tx_descriptor *tx) | |||
76 | container_of(tx, struct shdma_desc, async_tx), | 76 | container_of(tx, struct shdma_desc, async_tx), |
77 | *last = desc; | 77 | *last = desc; |
78 | struct shdma_chan *schan = to_shdma_chan(tx->chan); | 78 | struct shdma_chan *schan = to_shdma_chan(tx->chan); |
79 | struct shdma_slave *slave = tx->chan->private; | 79 | struct shdma_slave *slave = schan->slave; |
80 | dma_async_tx_callback callback = tx->callback; | 80 | dma_async_tx_callback callback = tx->callback; |
81 | dma_cookie_t cookie; | 81 | dma_cookie_t cookie; |
82 | bool power_up; | 82 | bool power_up; |
@@ -208,6 +208,7 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan) | |||
208 | goto edescalloc; | 208 | goto edescalloc; |
209 | } | 209 | } |
210 | schan->desc_num = NR_DESCS_PER_CHANNEL; | 210 | schan->desc_num = NR_DESCS_PER_CHANNEL; |
211 | schan->slave = slave; | ||
211 | 212 | ||
212 | for (i = 0; i < NR_DESCS_PER_CHANNEL; i++) { | 213 | for (i = 0; i < NR_DESCS_PER_CHANNEL; i++) { |
213 | desc = ops->embedded_desc(schan->desc, i); | 214 | desc = ops->embedded_desc(schan->desc, i); |
@@ -365,9 +366,9 @@ static void shdma_free_chan_resources(struct dma_chan *chan) | |||
365 | if (!list_empty(&schan->ld_queue)) | 366 | if (!list_empty(&schan->ld_queue)) |
366 | shdma_chan_ld_cleanup(schan, true); | 367 | shdma_chan_ld_cleanup(schan, true); |
367 | 368 | ||
368 | if (chan->private) { | 369 | if (schan->slave) { |
369 | /* The caller is holding dma_list_mutex */ | 370 | /* The caller is holding dma_list_mutex */ |
370 | struct shdma_slave *slave = chan->private; | 371 | struct shdma_slave *slave = schan->slave; |
371 | clear_bit(slave->slave_id, shdma_slave_used); | 372 | clear_bit(slave->slave_id, shdma_slave_used); |
372 | chan->private = NULL; | 373 | chan->private = NULL; |
373 | } | 374 | } |
@@ -558,7 +559,7 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg( | |||
558 | struct shdma_chan *schan = to_shdma_chan(chan); | 559 | struct shdma_chan *schan = to_shdma_chan(chan); |
559 | struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); | 560 | struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); |
560 | const struct shdma_ops *ops = sdev->ops; | 561 | const struct shdma_ops *ops = sdev->ops; |
561 | struct shdma_slave *slave = chan->private; | 562 | struct shdma_slave *slave = schan->slave; |
562 | dma_addr_t slave_addr; | 563 | dma_addr_t slave_addr; |
563 | 564 | ||
564 | if (!chan) | 565 | if (!chan) |
diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c index f06906f281ac..9f0a2e507ac3 100644 --- a/drivers/dma/sh/shdma.c +++ b/drivers/dma/sh/shdma.c | |||
@@ -291,10 +291,8 @@ static void sh_dmae_setup_xfer(struct shdma_chan *schan, | |||
291 | shdma_chan); | 291 | shdma_chan); |
292 | 292 | ||
293 | if (sslave) { | 293 | if (sslave) { |
294 | struct sh_dmae_slave *slave = container_of(sslave, | ||
295 | struct sh_dmae_slave, shdma_slave); | ||
296 | const struct sh_dmae_slave_config *cfg = | 294 | const struct sh_dmae_slave_config *cfg = |
297 | slave->config; | 295 | sh_chan->config; |
298 | 296 | ||
299 | dmae_set_dmars(sh_chan, cfg->mid_rid); | 297 | dmae_set_dmars(sh_chan, cfg->mid_rid); |
300 | dmae_set_chcr(sh_chan, cfg->chcr); | 298 | dmae_set_chcr(sh_chan, cfg->chcr); |
@@ -326,13 +324,11 @@ static int sh_dmae_set_slave(struct shdma_chan *schan, | |||
326 | { | 324 | { |
327 | struct sh_dmae_chan *sh_chan = container_of(schan, struct sh_dmae_chan, | 325 | struct sh_dmae_chan *sh_chan = container_of(schan, struct sh_dmae_chan, |
328 | shdma_chan); | 326 | shdma_chan); |
329 | struct sh_dmae_slave *slave = container_of(sslave, struct sh_dmae_slave, | ||
330 | shdma_slave); | ||
331 | const struct sh_dmae_slave_config *cfg = dmae_find_slave(sh_chan, sslave->slave_id); | 327 | const struct sh_dmae_slave_config *cfg = dmae_find_slave(sh_chan, sslave->slave_id); |
332 | if (!cfg) | 328 | if (!cfg) |
333 | return -ENODEV; | 329 | return -ENODEV; |
334 | 330 | ||
335 | slave->config = cfg; | 331 | sh_chan->config = cfg; |
336 | 332 | ||
337 | return 0; | 333 | return 0; |
338 | } | 334 | } |
@@ -579,13 +575,12 @@ static int sh_dmae_resume(struct device *dev) | |||
579 | 575 | ||
580 | for (i = 0; i < shdev->pdata->channel_num; i++) { | 576 | for (i = 0; i < shdev->pdata->channel_num; i++) { |
581 | struct sh_dmae_chan *sh_chan = shdev->chan[i]; | 577 | struct sh_dmae_chan *sh_chan = shdev->chan[i]; |
582 | struct sh_dmae_slave *param = sh_chan->shdma_chan.dma_chan.private; | ||
583 | 578 | ||
584 | if (!sh_chan->shdma_chan.desc_num) | 579 | if (!sh_chan->shdma_chan.desc_num) |
585 | continue; | 580 | continue; |
586 | 581 | ||
587 | if (param) { | 582 | if (sh_chan->shdma_chan.slave) { |
588 | const struct sh_dmae_slave_config *cfg = param->config; | 583 | const struct sh_dmae_slave_config *cfg = sh_chan->config; |
589 | dmae_set_dmars(sh_chan, cfg->mid_rid); | 584 | dmae_set_dmars(sh_chan, cfg->mid_rid); |
590 | dmae_set_chcr(sh_chan, cfg->chcr); | 585 | dmae_set_chcr(sh_chan, cfg->chcr); |
591 | } else { | 586 | } else { |
@@ -609,14 +604,15 @@ const struct dev_pm_ops sh_dmae_pm = { | |||
609 | 604 | ||
610 | static dma_addr_t sh_dmae_slave_addr(struct shdma_chan *schan) | 605 | static dma_addr_t sh_dmae_slave_addr(struct shdma_chan *schan) |
611 | { | 606 | { |
612 | struct sh_dmae_slave *param = schan->dma_chan.private; | 607 | struct sh_dmae_chan *sh_chan = container_of(schan, |
608 | struct sh_dmae_chan, shdma_chan); | ||
613 | 609 | ||
614 | /* | 610 | /* |
615 | * Implicit BUG_ON(!param) | 611 | * Implicit BUG_ON(!sh_chan->config) |
616 | * if (param != NULL), this is a successfully requested slave channel, | 612 | * This is an exclusive slave DMA operation, may only be called after a |
617 | * therefore param->config != NULL too. | 613 | * successful slave configuration. |
618 | */ | 614 | */ |
619 | return param->config->addr; | 615 | return sh_chan->config->addr; |
620 | } | 616 | } |
621 | 617 | ||
622 | static struct shdma_desc *sh_dmae_embedded_desc(void *buf, int i) | 618 | static struct shdma_desc *sh_dmae_embedded_desc(void *buf, int i) |
diff --git a/drivers/dma/sh/shdma.h b/drivers/dma/sh/shdma.h index 840e47d1c86c..9314e93225db 100644 --- a/drivers/dma/sh/shdma.h +++ b/drivers/dma/sh/shdma.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifndef __DMA_SHDMA_H | 13 | #ifndef __DMA_SHDMA_H |
14 | #define __DMA_SHDMA_H | 14 | #define __DMA_SHDMA_H |
15 | 15 | ||
16 | #include <linux/sh_dma.h> | ||
16 | #include <linux/shdma-base.h> | 17 | #include <linux/shdma-base.h> |
17 | #include <linux/dmaengine.h> | 18 | #include <linux/dmaengine.h> |
18 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
@@ -25,6 +26,7 @@ struct device; | |||
25 | 26 | ||
26 | struct sh_dmae_chan { | 27 | struct sh_dmae_chan { |
27 | struct shdma_chan shdma_chan; | 28 | struct shdma_chan shdma_chan; |
29 | const struct sh_dmae_slave_config *config; /* Slave DMA configuration */ | ||
28 | int xmit_shift; /* log_2(bytes_per_xfer) */ | 30 | int xmit_shift; /* log_2(bytes_per_xfer) */ |
29 | u32 __iomem *base; | 31 | u32 __iomem *base; |
30 | char dev_id[16]; /* unique name per DMAC of channel */ | 32 | char dev_id[16]; /* unique name per DMAC of channel */ |
diff --git a/include/linux/sh_dma.h b/include/linux/sh_dma.h index 7c8ca41e60e6..a79f10a32243 100644 --- a/include/linux/sh_dma.h +++ b/include/linux/sh_dma.h | |||
@@ -20,8 +20,6 @@ struct device; | |||
20 | /* Used by slave DMA clients to request DMA to/from a specific peripheral */ | 20 | /* Used by slave DMA clients to request DMA to/from a specific peripheral */ |
21 | struct sh_dmae_slave { | 21 | struct sh_dmae_slave { |
22 | struct shdma_slave shdma_slave; /* Set by the platform */ | 22 | struct shdma_slave shdma_slave; /* Set by the platform */ |
23 | struct device *dma_dev; /* Set by the platform */ | ||
24 | const struct sh_dmae_slave_config *config; /* Set by the driver */ | ||
25 | }; | 23 | }; |
26 | 24 | ||
27 | /* | 25 | /* |
diff --git a/include/linux/shdma-base.h b/include/linux/shdma-base.h index 83efd1332b39..c3a19e9c20c4 100644 --- a/include/linux/shdma-base.h +++ b/include/linux/shdma-base.h | |||
@@ -66,6 +66,7 @@ struct shdma_chan { | |||
66 | size_t max_xfer_len; /* max transfer length */ | 66 | size_t max_xfer_len; /* max transfer length */ |
67 | int id; /* Raw id of this channel */ | 67 | int id; /* Raw id of this channel */ |
68 | int irq; /* Channel IRQ */ | 68 | int irq; /* Channel IRQ */ |
69 | struct shdma_slave *slave; /* Client data for slave DMA */ | ||
69 | enum shdma_pm_state pm_state; | 70 | enum shdma_pm_state pm_state; |
70 | }; | 71 | }; |
71 | 72 | ||