mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
dmaengine: stm32-dma3: introduce ddata2dev helper
The purpose of this helper is to 'standardize' device pointer retrieval, similar to the chan2dev() helper. ddata2dev() helper returns the device pointer from struct dma_device stored in stm32_dma3_ddata structure. Device pointer from struct dma_device has been initialized with &pdev->dev, so the ddata2dev helper returns &pdev->dev. Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Link: https://patch.msgid.link/20251121-dma3_improv-v2-4-76a207b13ea6@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
committed by
Vinod Koul
parent
dea737e31c
commit
8be4f3cbe2
@@ -333,6 +333,11 @@ static struct device *chan2dev(struct stm32_dma3_chan *chan)
|
||||
return &chan->vchan.chan.dev->device;
|
||||
}
|
||||
|
||||
static struct device *ddata2dev(struct stm32_dma3_ddata *ddata)
|
||||
{
|
||||
return ddata->dma_dev.dev;
|
||||
}
|
||||
|
||||
static void stm32_dma3_chan_dump_reg(struct stm32_dma3_chan *chan)
|
||||
{
|
||||
struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
|
||||
@@ -1110,7 +1115,7 @@ static int stm32_dma3_alloc_chan_resources(struct dma_chan *c)
|
||||
struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan);
|
||||
int ret;
|
||||
|
||||
ret = pm_runtime_resume_and_get(ddata->dma_dev.dev);
|
||||
ret = pm_runtime_resume_and_get(ddata2dev(ddata));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -1144,7 +1149,7 @@ err_pool_destroy:
|
||||
chan->lli_pool = NULL;
|
||||
|
||||
err_put_sync:
|
||||
pm_runtime_put_sync(ddata->dma_dev.dev);
|
||||
pm_runtime_put_sync(ddata2dev(ddata));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1170,7 +1175,7 @@ static void stm32_dma3_free_chan_resources(struct dma_chan *c)
|
||||
if (chan->semaphore_mode)
|
||||
stm32_dma3_put_chan_sem(chan);
|
||||
|
||||
pm_runtime_put_sync(ddata->dma_dev.dev);
|
||||
pm_runtime_put_sync(ddata2dev(ddata));
|
||||
|
||||
/* Reset configuration */
|
||||
memset(&chan->dt_config, 0, sizeof(chan->dt_config));
|
||||
@@ -1610,11 +1615,11 @@ static bool stm32_dma3_filter_fn(struct dma_chan *c, void *fn_param)
|
||||
if (!(mask & BIT(chan->id)))
|
||||
return false;
|
||||
|
||||
ret = pm_runtime_resume_and_get(ddata->dma_dev.dev);
|
||||
ret = pm_runtime_resume_and_get(ddata2dev(ddata));
|
||||
if (ret < 0)
|
||||
return false;
|
||||
semcr = readl_relaxed(ddata->base + STM32_DMA3_CSEMCR(chan->id));
|
||||
pm_runtime_put_sync(ddata->dma_dev.dev);
|
||||
pm_runtime_put_sync(ddata2dev(ddata));
|
||||
|
||||
/* Check if chan is free */
|
||||
if (semcr & CSEMCR_SEM_MUTEX)
|
||||
@@ -1636,7 +1641,7 @@ static struct dma_chan *stm32_dma3_of_xlate(struct of_phandle_args *dma_spec, st
|
||||
struct dma_chan *c;
|
||||
|
||||
if (dma_spec->args_count < 3) {
|
||||
dev_err(ddata->dma_dev.dev, "Invalid args count\n");
|
||||
dev_err(ddata2dev(ddata), "Invalid args count\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1645,14 +1650,14 @@ static struct dma_chan *stm32_dma3_of_xlate(struct of_phandle_args *dma_spec, st
|
||||
conf.tr_conf = dma_spec->args[2];
|
||||
|
||||
if (conf.req_line >= ddata->dma_requests) {
|
||||
dev_err(ddata->dma_dev.dev, "Invalid request line\n");
|
||||
dev_err(ddata2dev(ddata), "Invalid request line\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Request dma channel among the generic dma controller list */
|
||||
c = dma_request_channel(mask, stm32_dma3_filter_fn, &conf);
|
||||
if (!c) {
|
||||
dev_err(ddata->dma_dev.dev, "No suitable channel found\n");
|
||||
dev_err(ddata2dev(ddata), "No suitable channel found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1665,6 +1670,7 @@ static struct dma_chan *stm32_dma3_of_xlate(struct of_phandle_args *dma_spec, st
|
||||
|
||||
static u32 stm32_dma3_check_rif(struct stm32_dma3_ddata *ddata)
|
||||
{
|
||||
struct device *dev = ddata2dev(ddata);
|
||||
u32 chan_reserved, mask = 0, i, ccidcfgr, invalid_cid = 0;
|
||||
|
||||
/* Reserve Secure channels */
|
||||
@@ -1676,7 +1682,7 @@ static u32 stm32_dma3_check_rif(struct stm32_dma3_ddata *ddata)
|
||||
* In case CID filtering is not configured, dma-channel-mask property can be used to
|
||||
* specify available DMA channels to the kernel.
|
||||
*/
|
||||
of_property_read_u32(ddata->dma_dev.dev->of_node, "dma-channel-mask", &mask);
|
||||
of_property_read_u32(dev->of_node, "dma-channel-mask", &mask);
|
||||
|
||||
/* Reserve !CID-filtered not in dma-channel-mask, static CID != CID1, CID1 not allowed */
|
||||
for (i = 0; i < ddata->dma_channels; i++) {
|
||||
@@ -1696,7 +1702,7 @@ static u32 stm32_dma3_check_rif(struct stm32_dma3_ddata *ddata)
|
||||
ddata->chans[i].semaphore_mode = true;
|
||||
}
|
||||
}
|
||||
dev_dbg(ddata->dma_dev.dev, "chan%d: %s mode, %s\n", i,
|
||||
dev_dbg(dev, "chan%d: %s mode, %s\n", i,
|
||||
!(ccidcfgr & CCIDCFGR_CFEN) ? "!CID-filtered" :
|
||||
ddata->chans[i].semaphore_mode ? "Semaphore" : "Static CID",
|
||||
(chan_reserved & BIT(i)) ? "denied" :
|
||||
@@ -1704,7 +1710,7 @@ static u32 stm32_dma3_check_rif(struct stm32_dma3_ddata *ddata)
|
||||
}
|
||||
|
||||
if (invalid_cid)
|
||||
dev_warn(ddata->dma_dev.dev, "chan%*pbl have invalid CID configuration\n",
|
||||
dev_warn(dev, "chan%*pbl have invalid CID configuration\n",
|
||||
ddata->dma_channels, &invalid_cid);
|
||||
|
||||
return chan_reserved;
|
||||
|
||||
Reference in New Issue
Block a user