cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@inria.fr>,
	Coccinelle <cocci@systeme.lip6.fr>,
	Dejin Zheng <zhengdejin5@gmail.com>
Cc: Michal Marek <michal.lkml@markovi.net>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Cocci] [PATCH] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci”
Date: Mon, 7 Sep 2020 15:05:14 +0200	[thread overview]
Message-ID: <477abcea-e008-e509-d03f-f2753ebdfb20@web.de> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2009071357140.2476@hadrien>

>> +@display depends on context@
>> +expression base, device1, device2, index, private, resource;
>> +@@
>> +(
>> +*resource = platform_get_resource(device1, IORESOURCE_MEM, index);
>> + base =
>> +*       devm_ioremap_resource
>> +                             (&device1->dev, resource);
>
> Why do you require these statements to be next to each other?

I would appreciate indications for a general change acceptance
also according to such a simple transformation approach.
I imagine that it will become more challenging to tolerate extra
source code between these function calls (by the specification
of special SmPL filters).


>> +|
>> +*private->res = platform_get_resource(device1, IORESOURCE_MEM, index);
>> + base =
>> +*       devm_ioremap_resource
>> +                             (device2, private->res);
>
> Why do you have this special case?

The usage of the data structure member “res” triggers corresponding
software design consequences.
The expressions which are passed as the first function call parameters
can be different.


>> +@replacement depends on patch@
>> +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
>> +                              ,
>> +-                             resource
>> ++                             index, &resource
>> +                             );
>> +|
>> +-private->res = platform_get_resource(device1, IORESOURCE_MEM, index);
>> + base =
>> +-       devm_ioremap_resource
>> ++       devm_platform_get_and_ioremap_resource
>> +                             (device2,
>
> It is very suspicious that in one case you change the first argument of
> devm_platform_get_and_ioremap_resource and in one case you don't.

I noticed a few special cases during my source code analysis approach.


> If you don't know how to make the change in some cases, it would be better
> to do nothing at all.

How do you think about to take another look at any update candidates?

Examples:
* mvebu_sei_probe
  https://elixir.bootlin.com/linux/v5.9-rc4/source/drivers/irqchip/irq-mvebu-sei.c#L368
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-mvebu-sei.c?id=f4d51dffc6c01a9e94650d95ce0104964f8ae822#n368

* hi655x_pmic_probe
  https://elixir.bootlin.com/linux/v5.9-rc4/source/drivers/mfd/hi655x-pmic.c#L92
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mfd/hi655x-pmic.c?id=f4d51dffc6c01a9e94650d95ce0104964f8ae822#n92

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply	other threads:[~2020-09-07 13:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 15:21 [Cocci] Checking the replacement of two specific function calls Markus Elfring
2020-04-15 17:52 ` Julia Lawall
2020-04-15 18:22   ` Markus Elfring
2020-04-16  7:12   ` Markus Elfring
2020-04-16  8:53     ` Julia Lawall
2020-04-16  9:11       ` Markus Elfring
2020-04-16 12:45         ` Julia Lawall
2020-04-16 14:15           ` Markus Elfring
2020-04-16 14:28             ` Julia Lawall
2020-04-17  6:08               ` Markus Elfring
2020-04-17 14:51               ` Markus Elfring
2020-04-17 18:56                 ` Markus Elfring
2020-04-20  6:30                   ` Markus Elfring
2020-04-16 14:30           ` Markus Elfring
2020-06-17 18:20           ` Markus Elfring
2020-04-16 12:26   ` Markus Elfring
2020-09-07 11:43 ` [Cocci] [PATCH] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci” Markus Elfring
2020-09-07 12:00   ` Julia Lawall
2020-09-07 13:05     ` Markus Elfring [this message]
2020-09-07 13:11       ` Julia Lawall
     [not found]         ` <46d314d5-822e-3d73-2d70-015794556e56@web.de>
2020-09-07 13:46           ` Julia Lawall
     [not found]             ` <8aaa799f-0ec4-cfd0-854a-e1006d0d200a@web.de>
2020-09-07 14:18               ` Julia Lawall
2020-09-07 16:54   ` [Cocci] [PATCH v2] " Markus Elfring
2020-09-07 17:03     ` Julia Lawall
     [not found]       ` <8fb7782c-538b-b657-af13-da71124e6afa@web.de>
2020-09-07 17:31         ` Julia Lawall
     [not found]     ` <01ea8faa-6fca-a91e-2b5d-378262dcc671@web.de>
2023-01-06 13:04       ` [cocci] [PATCH v3] " Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=477abcea-e008-e509-d03f-f2753ebdfb20@web.de \
    --to=markus.elfring@web.de \
    --cc=Gilles.Muller@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    --cc=zhengdejin5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).