From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E76E533F8C9 for ; Fri, 21 Nov 2025 09:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763717160; cv=none; b=RP7kRSLYK5O0xCScOHfIGQbMYJ0pvqtrEaLGRAgoDdtAQxS6Bs3h+tn696myRLprELPyNdU82wHWvAxs9PeiYCHpNEz6ZUjg43YP9zzxFCOaZUwijfHadoynVM47sbJ3Yq/GQD7YTXe/XTjK6sq0MfcpapjrbbB0gSrTRd4lqVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763717160; c=relaxed/simple; bh=iznXwiKM+BjhiSIg9K9OnWtD6qsiuHwK6Bo3UcexD38=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ac4nZXoLhnNv0MK8zI8uqN8zwq2GDKPwpu5Asihw3bS9JNxx38nTOZtL/bE1oDa1QxAaL19lxuTjVbP40tOVnitY1xblhpgwDAdB46TJO/XEv5o/ug2TWR3fGN+Op3P64Nbghh7PFAxfyieXvejEMnmBY5djp1cr2NEoKyuu4Bw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mLZ+LOeX; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mLZ+LOeX" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47790b080e4so9753955e9.3 for ; Fri, 21 Nov 2025 01:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763717156; x=1764321956; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=58wLSjoCtJmPW1lQLR4kpgVeNHbmr/e22y2z3O0EZnY=; b=mLZ+LOeXlL8veNAaGUD/xOaktZCGR/5YWiXeF0XSbNMrAnu5hKUvMYUuSOiSokqhXt HxKOxw70FbPO4USh8kGkaJwB+1wZyYJVLPTCH/QbFbciMwgKSi2hcfbm8fLwZEJB8zgd 2Fm58OEF1kOtprGsqLUbDQA8s2aaG4nw52exV+kwPe02g0tROQ+bK12E7RRw6M/XvOSn 0M45M7Beb9UicjVAdKiVY1DWkku6EqoMm5pdKo4V80N6jzKEx4cJA3wN+RZ3yF1/Aasw MjkggF8afoZse7BD0v5lE7cjjcJtIOkMtjwh0pHWZM1Z74FPeDbqg/93G2uzFZIJpnMQ VnkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763717156; x=1764321956; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=58wLSjoCtJmPW1lQLR4kpgVeNHbmr/e22y2z3O0EZnY=; b=xTlp4KtPs1vHLUQFf06ikArUz21LAOXoA0ZWt/riPReY0UnY7UZg729Qj87AEghHGS /mJ7xxzr2ZfOBVlKcfz0NdaHpAZtAL+CgH6mrdVBsVnBu9GmpFNZv5hXBa7RNghCp43e kQsJBstzJOSZ7xmraeN4lredY5pZ7MY9JMZorvcD8KZkFblSwx7cEH7v1mMKR6wexano nWmuv3DyU0zs21iTYUEQx2R5NvikAlGwwLMGt/1AfETY2GuEHU/xR5C7p1PdChcigHX0 oAsayeWufcno0I8hCGjv3W2z/J411Wgp8UDN5AW/wD8HJjrAngXiwS5RQTxTvwbFE57g MGqA== X-Forwarded-Encrypted: i=1; AJvYcCUhNy+v5EE8d9Y2NfjoQnryeNl0+H14tu8zODnRsqT5iNgK7B69MdlRSrwc0SiKtLFR54n8e6bcPKHJ78A=@vger.kernel.org X-Gm-Message-State: AOJu0YwL0lEoJ39leUfQzr3ZZWQmSTwN6JRuoq7y7TinmUQeQyXNWnSC IeI/1FNilmCTjKgNcaS+r8QFGSCuGfCxgxy4xnLeX6BRi+GmWgm9vWbrqAf+KJkW4mY= X-Gm-Gg: ASbGncuwj4KwnqmjwQ8obaNcYh1EfUH0YQp24SmiMhT3R/nOThFtQVhB6TLE86vJPI7 8kcfDa4Th0L2/jmEf61GEwQYhlqTm+9mDU9YNmX57KAMpZgUTx5/L/+x9BuabnOLD2tHc+Ahc9y x1WY312grkaqZBcfCXki7USZCd4bHHBhVZMZr4ENo5DSfxoh0SO7ecqUmtNnjjIB9kyjV7DToQG wdaqFz5OehHmzbeAtsAntcWDkg9j0aseMzfcLm8C7CM3iJ3Kkiji4lf+UNbOVWI6bWpShpIS6dE 9pZ0W4DqRuMXWS9VspL4jeA+Colp3VFZ4woUI+aPFvZ9RsyLuRMRkgBUwa7IlXfZs9R8JVkptx4 0BK58ojmdYi+Kncr+fMrApEJUZs88Qq4ufSEmklQoUpM5HX62H9s7NWFgC2Sv3XNwJGV4dguePg NfX9gqcKoAg//qRIsG3g== X-Google-Smtp-Source: AGHT+IEFUMDrJEcj1YdLI40b8qr8K1kgEr1NPgybegm0BhMiyY1WM8obZIXGtWivL6UxNUN6wVEB4g== X-Received: by 2002:a05:600c:5249:b0:477:5897:a0c4 with SMTP id 5b1f17b1804b1-477c10c858bmr13810195e9.4.1763717156078; Fri, 21 Nov 2025 01:25:56 -0800 (PST) Received: from [192.168.0.39] ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477bf3aef57sm31489005e9.11.2025.11.21.01.25.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Nov 2025 01:25:55 -0800 (PST) Message-ID: <85f08f72-7608-4076-a474-579eb4c7dc4c@linaro.org> Date: Fri, 21 Nov 2025 11:25:54 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] dmaengine: stm32-dma3: introduce ddata2dev helper To: Amelie Delaunay , Vinod Koul , Maxime Coquelin , Alexandre Torgue Cc: dmaengine@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251103-dma3_improv-v1-0-57f048bf2877@foss.st.com> <20251103-dma3_improv-v1-4-57f048bf2877@foss.st.com> Content-Language: en-US From: Eugen Hristev In-Reply-To: <20251103-dma3_improv-v1-4-57f048bf2877@foss.st.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/3/25 12:15, Amelie Delaunay wrote: > 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 > --- > drivers/dma/stm32/stm32-dma3.c | 29 ++++++++++++++++++----------- > 1 file changed, 18 insertions(+), 11 deletions(-) > > diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c > index 29ea510fa539..9f49ef8e2972 100644 > --- a/drivers/dma/stm32/stm32-dma3.c > +++ b/drivers/dma/stm32/stm32-dma3.c > @@ -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; > +} Not really sure how much this helper actually simplifies the code. To me it appears as if there is no improvement, but this is a personal preference.> + > static void stm32_dma3_chan_dump_reg(struct stm32_dma3_chan *chan) > { > struct stm32_dma3_ddata *ddata = to_stm32_dma3_ddata(chan); > @@ -392,6 +397,7 @@ static void stm32_dma3_chan_dump_hwdesc(struct stm32_dma3_chan *chan, > } else { > dev_dbg(chan2dev(chan), "X\n"); > } > + This newline here appears to be unintended > } > > static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_chan *chan, u32 count) > @@ -1110,7 +1116,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 +1150,7 @@ static int stm32_dma3_alloc_chan_resources(struct dma_chan *c) > 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 +1176,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 +1616,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 +1642,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 +1651,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 +1671,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 +1683,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 +1703,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 +1711,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; >