> Another possibility should be taken into account for source code variations.
>
> SmPL script example:
> @replacement@
> expression base, device1, device2, index, private;
> @@
> -private->res = platform_get_resource(device1, IORESOURCE_MEM, index);
>  base =
> -       devm_ioremap_resource
> +       devm_platform_get_and_ioremap_resource
>                              (device2,
> +                                     index, &
>                                               private->res
>                              );

Such a transformation approach can work to some degree.
Thus I would expect that it can be reused for a case distinction in the way
of a SmPL disjunction like the following.

Another SmPL script example:
@replacement@
expression base, device1, device2, index, private, resource;
@@
-resource = platform_get_resource(device1, IORESOURCE_MEM, index);
 base =
-       devm_ioremap_resource
+       devm_platform_get_and_ioremap_resource
                             (
(
-                             &
                               device1
-                                     ->dev
                              ,
+                             index, &
                                      resource
|
                              device2,
+                                      index, &
                                               private->res
)
                             );


Test command:
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch 
use_devm_platform_get_and_ioremap_resource10.cocci 
../Probe/i2c-rcar-excerpt-20200415.c


Now I wonder again why the known patch is not generated as expected so far.
How would you like to clarify this software situation?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to