lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <83c922b8-9cf0-4c4f-9a10-ee7c26bd85c4@foss.st.com>
Date: Wed, 29 Jan 2025 10:01:53 +0100
From: Raphael Gallais-Pou <raphael.gallais-pou@...s.st.com>
To: Anusha Srivatsa <asrivats@...hat.com>, Joel Stanley <joel@....id.au>,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard
	<mripard@...nel.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        David Airlie
	<airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
        Andrew Jeffery
	<andrew@...econstruct.com.au>,
        Stefan Agner <stefan@...er.ch>, Alison Wang
	<alison.wang@....com>,
        Xinliang Liu <xinliang.liu@...aro.org>,
        Tian Tao
	<tiantao6@...ilicon.com>,
        Xinwei Kong <kong.kongxinwei@...ilicon.com>,
        Sumit
 Semwal <sumit.semwal@...aro.org>,
        Yongqin Liu <yongqin.liu@...aro.org>,
        John
 Stultz <jstultz@...gle.com>,
        Chun-Kuang Hu <chunkuang.hu@...nel.org>,
        Philipp
 Zabel <p.zabel@...gutronix.de>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
        Neil
 Armstrong <neil.armstrong@...aro.org>,
        Kevin Hilman <khilman@...libre.com>,
        Jerome Brunet <jbrunet@...libre.com>,
        Martin Blumenstingl
	<martin.blumenstingl@...glemail.com>,
        Marek Vasut <marex@...x.de>, Shawn Guo
	<shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Pengutronix
 Kernel Team <kernel@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>, Sandy Huang <hjc@...k-chips.com>,
        Heiko Stübner
	<heiko@...ech.de>,
        Andy Yan <andy.yan@...k-chips.com>, Orson Zhai
	<orsonzhai@...il.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        Chunyan
 Zhang <zhang.lyra@...il.com>,
        Alain Volmat <alain.volmat@...s.st.com>,
        Raphael Gallais-Pou <rgallaispou@...il.com>,
        Yannick Fertre
	<yannick.fertre@...s.st.com>,
        Philippe Cornu <philippe.cornu@...s.st.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue
	<alexandre.torgue@...s.st.com>,
        Thierry Reding <thierry.reding@...il.com>,
        Mikko Perttunen <mperttunen@...dia.com>,
        Jonathan Hunter
	<jonathanh@...dia.com>,
        Alexey Brodkin <abrodkin@...opsys.com>,
        Dave
 Stevenson <dave.stevenson@...pberrypi.com>,
        Maíra Canal
	<mcanal@...lia.com>,
        Raspberry Pi Kernel Maintenance
	<kernel-list@...pberrypi.com>,
        Jonathan Corbet <corbet@....net>
CC: <linux-aspeed@...ts.ozlabs.org>, <dri-devel@...ts.freedesktop.org>,
        <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-amlogic@...ts.infradead.org>, <imx@...ts.linux.dev>,
        <linux-rockchip@...ts.infradead.org>,
        <linux-stm32@...md-mailman.stormreply.com>,
        <linux-tegra@...r.kernel.org>, <linux-doc@...r.kernel.org>
Subject: Re: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource()
 usage


On 1/28/25 23:29, Anusha Srivatsa wrote:
> Replace platform_get_resource/_byname + devm_ioremap
> with just devm_platform_ioremap_resource()
>
> Used Coccinelle to do this change. SmPl patch:
>
> @rule@
> identifier res;
> expression ioremap;
> identifier pdev;
> constant mem;
> expression name;
> @@
> -struct resource *res;
> ...
> -res = platform_get_resource_byname(pdev,mem,name);
> <...
> -if (!res) {
> -...
> -}
> ...>
> -ioremap = devm_ioremap(...);
> +ioremap = devm_platform_ioremap_resource_byname(pdev,name);
>
> and
> @rule_2@
> identifier res;
> expression ioremap;
> identifier pdev;
> @@
> -struct resource *res;
> ...
> -res = platform_get_resource(pdev,...);
> <...
> -if (!res) {
> -...
> -}
> ...>
> -ioremap = devm_ioremap(...);
> +ioremap = devm_platform_ioremap_resource(pdev,0);
>
> Cc: Alain Volmat <alain.volmat@...s.st.com>
> Signed-off-by: Anusha Srivatsa <asrivats@...hat.com>


Hi Anusha,


Thanks again for your work,

> ---
>  drivers/gpu/drm/sti/sti_compositor.c | 10 +---------
>  drivers/gpu/drm/sti/sti_dvo.c        | 10 +---------
>  drivers/gpu/drm/sti/sti_hda.c        | 10 +---------
>  drivers/gpu/drm/sti/sti_hdmi.c       | 11 +----------
>  drivers/gpu/drm/sti/sti_hqvdp.c      | 10 +---------
>  drivers/gpu/drm/sti/sti_tvout.c      | 10 +---------
>  drivers/gpu/drm/sti/sti_vtg.c        | 10 +---------
>  7 files changed, 7 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_compositor.c b/drivers/gpu/drm/sti/sti_compositor.c
> index 063f82d23d80c4ba83624a0066a18416a2b37351..7aefce6706ba2cd7d97a33228c9b9812edecf06f 100644
> --- a/drivers/gpu/drm/sti/sti_compositor.c
> +++ b/drivers/gpu/drm/sti/sti_compositor.c
> @@ -177,7 +177,6 @@ static int sti_compositor_probe(struct platform_device *pdev)
>  	struct device_node *np = dev->of_node;
>  	struct device_node *vtg_np;
>  	struct sti_compositor *compo;
> -	struct resource *res;
>  	unsigned int i;
>  
>  	compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL);
> @@ -194,14 +193,7 @@ static int sti_compositor_probe(struct platform_device *pdev)
>  
>  	memcpy(&compo->data, of_match_node(compositor_of_match, np)->data,
>  	       sizeof(struct sti_compositor_data));
> -
> -	/* Get Memory ressources */
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (res == NULL) {
> -		DRM_ERROR("Get memory resource failed\n");
> -		return -ENXIO;
> -	}
> -	compo->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	compo->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (compo->regs == NULL) {
>  		DRM_ERROR("Register mapping failed\n");
>  		return -ENXIO;
> diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
> index c6c2abaa1891cd3ea025805b50d275ec314512c3..660588f01f90950a9b2c180ab230188c19901f26 100644
> --- a/drivers/gpu/drm/sti/sti_dvo.c
> +++ b/drivers/gpu/drm/sti/sti_dvo.c
> @@ -511,7 +511,6 @@ static int sti_dvo_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct sti_dvo *dvo;
> -	struct resource *res;
>  	struct device_node *np = dev->of_node;
>  
>  	DRM_INFO("%s\n", __func__);
> @@ -523,14 +522,7 @@ static int sti_dvo_probe(struct platform_device *pdev)
>  	}
>  
>  	dvo->dev = pdev->dev;
> -
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dvo-reg");
> -	if (!res) {
> -		DRM_ERROR("Invalid dvo resource\n");
> -		return -ENOMEM;
> -	}
> -	dvo->regs = devm_ioremap(dev, res->start,
> -			resource_size(res));
> +	dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
>  	if (!dvo->regs)
>  		return -ENOMEM;
>  
> diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
> index b12863bea95559c4f874eb94cea8938609d435d4..28fde4c568d0069ecf2f2f69f5be0e87c1d5f4f3 100644
> --- a/drivers/gpu/drm/sti/sti_hda.c
> +++ b/drivers/gpu/drm/sti/sti_hda.c
> @@ -741,7 +741,6 @@ static int sti_hda_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct sti_hda *hda;
> -	struct resource *res;

There is a compile error, using an ARM toolchain on this patch and several others.

struct ressource *res is used on other places, which does not allow to remove
the instanciation here.


/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c: In function
‘sti_hda_probe’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9: error:
‘res’ undeclared (first use in this function)
  756 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
      |         ^~~
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9: note:
each undeclared identifier is reported only once for each function it appears in
  CC [M]  drivers/gpu/drm/nouveau/nvkm/core/event.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/sti/sti_hda.o] Error 1
make[8]: *** Waiting for unfinished jobs....


This can be applied:


* regarding [PATCH 07/14] rockchip driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:
In function ‘vop_bind’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
error: ‘res’ undeclared (first use in this function); did you mean ‘ret’?
 2212 |         vop->len = resource_size(res);
      |                                  ^~~
      |                                  ret
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
note: each undeclared identifier is reported only once for each function it
appears in
  CC [M]  drivers/gpu/drm/nouveau/nvif/fifo.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/rockchip/rockchip_drm_vop.o] Error 1
make[8]: *** Waiting for unfinished jobs....


* regarding  [PATCH 13/14] vc4 driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c: In function
‘vc5_hdmi_init_resources’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: error:
‘res’ undeclared (first use in this function); did you mean ‘ret’?
 2961 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hd");
      |         ^~~
      |         ret
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: note:
each undeclared identifier is reported only once for each function it appears in
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/vc4/vc4_hdmi.o] Error 1
make[8]: *** Waiting for unfinished jobs....


Regards,
Raphaël

>  
>  	DRM_INFO("%s\n", __func__);
>  
> @@ -750,14 +749,7 @@ static int sti_hda_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	hda->dev = pdev->dev;
> -
> -	/* Get resources */
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hda-reg");
> -	if (!res) {
> -		DRM_ERROR("Invalid hda resource\n");
> -		return -ENOMEM;
> -	}
> -	hda->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
>  	if (!hda->regs)
>  		return -ENOMEM;
>  
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index ca2fe17de4a5d1e0199e59a97e6c7601e139ed9e..666143c48b0d0f2c20cd26323ddbc8e69d966622 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -1380,7 +1380,6 @@ static int sti_hdmi_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct sti_hdmi *hdmi;
>  	struct device_node *np = dev->of_node;
> -	struct resource *res;
>  	struct device_node *ddc;
>  	int ret;
>  
> @@ -1399,15 +1398,7 @@ static int sti_hdmi_probe(struct platform_device *pdev)
>  	}
>  
>  	hdmi->dev = pdev->dev;
> -
> -	/* Get resources */
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg");
> -	if (!res) {
> -		DRM_ERROR("Invalid hdmi resource\n");
> -		ret = -ENOMEM;
> -		goto release_adapter;
> -	}
> -	hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	hdmi->regs = devm_platform_ioremap_resource_byname(pdev, "hdmi-reg");
>  	if (!hdmi->regs) {
>  		ret = -ENOMEM;
>  		goto release_adapter;
> diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> index 0f658709c9d0d398c4eed65202443db9d0b41f8c..420395598d119a403d531211022e6005d6a2bd59 100644
> --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> @@ -1356,7 +1356,6 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct device_node *vtg_np;
>  	struct sti_hqvdp *hqvdp;
> -	struct resource *res;
>  
>  	DRM_DEBUG_DRIVER("\n");
>  
> @@ -1367,14 +1366,7 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
>  	}
>  
>  	hqvdp->dev = dev;
> -
> -	/* Get Memory resources */
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		DRM_ERROR("Get memory resource failed\n");
> -		return -ENXIO;
> -	}
> -	hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (!hqvdp->regs) {
>  		DRM_ERROR("Register mapping failed\n");
>  		return -ENXIO;
> diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
> index af6c06f448c4819def8cc0d0836e30f991529690..0bebe815f5e7567f84388af93723a6fa7d2cc7a2 100644
> --- a/drivers/gpu/drm/sti/sti_tvout.c
> +++ b/drivers/gpu/drm/sti/sti_tvout.c
> @@ -838,7 +838,6 @@ static int sti_tvout_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct device_node *node = dev->of_node;
>  	struct sti_tvout *tvout;
> -	struct resource *res;
>  
>  	DRM_INFO("%s\n", __func__);
>  
> @@ -850,14 +849,7 @@ static int sti_tvout_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	tvout->dev = dev;
> -
> -	/* get memory resources */
> -	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tvout-reg");
> -	if (!res) {
> -		DRM_ERROR("Invalid glue resource\n");
> -		return -ENOMEM;
> -	}
> -	tvout->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	tvout->regs = devm_platform_ioremap_resource_byname(pdev, "tvout-reg");
>  	if (!tvout->regs)
>  		return -ENOMEM;
>  
> diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
> index 5ba469b711b5318e9e9e6d8df127fb8933d1fac1..b5353fe774d72fd629ecd3ef75a5d2817ca8617f 100644
> --- a/drivers/gpu/drm/sti/sti_vtg.c
> +++ b/drivers/gpu/drm/sti/sti_vtg.c
> @@ -380,20 +380,12 @@ static int vtg_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct sti_vtg *vtg;
> -	struct resource *res;
>  	int ret;
>  
>  	vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL);
>  	if (!vtg)
>  		return -ENOMEM;
> -
> -	/* Get Memory ressources */
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		DRM_ERROR("Get memory resource failed\n");
> -		return -ENOMEM;
> -	}
> -	vtg->regs = devm_ioremap(dev, res->start, resource_size(res));
> +	vtg->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (!vtg->regs) {
>  		DRM_ERROR("failed to remap I/O memory\n");
>  		return -ENOMEM;
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ