On Thu, 16 Apr 2020, Markus Elfring wrote:
> >> @replacement@
> >> expression* base, device, resource;
> >> @@
> >> -resource = platform_get_resource(device, IORESOURCE_MEM, 0);
> >> base =
> >> - devm_ioremap_resource(&device->dev, resource)
> >> + devm_platform_get_and_ioremap_resource(device, 0, &resource)
> >> ;
> …
> >> static int rcar_i2c_probe(struct platform_device *pdev)
> >> {
> >> struct rcar_i2c_priv *priv;
> …
> >> struct device *dev = &pdev->dev;
> …
> >> priv->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >>
> >> priv->io = devm_ioremap_resource(dev, priv->res);
> >> if (IS_ERR(priv->io))
> >> return PTR_ERR(priv->io);
> …
> >> }
> …
> > Probably Coccinelle is not able to determine that priv->res and priv->io
> > are pointers, if you have not given it enough encouragement to look for
> > header files to find the defintion of the type of the priv structure.
>
> Would you find the following test command encouraging enough?
>
> elfring@Sonne:~/Projekte/Linux/next-patched> spatch
> --include-headers-for-types
> ~/Projekte/Coccinelle/janitor/use_devm_platform_get_and_ioremap_resource3.cocci
> drivers/i2c/busses/i2c-rcar.c
No, include headers for types doesn't have any impact on how many header
files are included. You need options like --all-includes or
--recursive-includes. Include headers for types means only look at the
included files to collect type information, but ignore these files in the
matching and transformation process.
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci