Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: shdma: prepare to stop using struct dma_chan::private

Using struct dma_chan::private is deprecated. To update the shdma driver to
stop using it we first have to eliminate internal runtime uses of it. After
that we will also be able to stop using it for channel configuration.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>

authored by

Guennadi Liakhovetski and committed by
Vinod Koul
ecf90fbb 1e7f07b5

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