[02/10] ALSA: ml403-ac97cr: use resource_size
diff mbox series

Message ID 1577900990-8588-3-git-send-email-Julia.Lawall@inria.fr
State New
Headers show
Series
  • use resource_size
Related show

Commit Message

Julia Lawall Jan. 1, 2020, 5:49 p.m. UTC
Use resource_size rather than a verbose computation on
the end and start fields.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

<smpl>
@@ struct resource *ptr; @@
- ((ptr->end) - (ptr->start) + 1)
+ resource_size(ptr)
</smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 sound/drivers/ml403-ac97cr.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Takashi Iwai Jan. 1, 2020, 7:17 p.m. UTC | #1
On Wed, 01 Jan 2020 18:49:42 +0100,
Julia Lawall wrote:
> 
> Use resource_size rather than a verbose computation on
> the end and start fields.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> <smpl>
> @@ struct resource *ptr; @@
> - ((ptr->end) - (ptr->start) + 1)
> + resource_size(ptr)
> </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

Unfortunately this doesn't apply cleanly on my tree.  I guess you
worked on linux-next which contains a change outside the sound git
tree that converts ioremap_nocache() to ioremap().

We may apply it in sound git tree and let conflicts resolved at the
merge time.  OTOH, it's no urgent fix at all and can be postponed
after 5.6-rc1 merge, too -- then everything can be applied in a
cleaner way.

Let me know your preference.


thanks,

Takashi

> 
> ---
>  sound/drivers/ml403-ac97cr.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
> index 4e6042e652f0..9de5caaf6047 100644
> --- a/sound/drivers/ml403-ac97cr.c
> +++ b/sound/drivers/ml403-ac97cr.c
> @@ -1100,9 +1100,7 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
>  	PDEBUG(INIT_INFO, "Trying to reserve resources now ...\n");
>  	resource = platform_get_resource(pfdev, IORESOURCE_MEM, 0);
>  	/* get "port" */
> -	ml403_ac97cr->port = ioremap(resource->start,
> -					     (resource->end) -
> -					     (resource->start) + 1);
> +	ml403_ac97cr->port = ioremap(resource->start, resource_size(resource));
>  	if (ml403_ac97cr->port == NULL) {
>  		snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": "
>  			   "unable to remap memory region (%pR)\n",
>
Julia Lawall Jan. 1, 2020, 7:23 p.m. UTC | #2
On Wed, 1 Jan 2020, Takashi Iwai wrote:

> On Wed, 01 Jan 2020 18:49:42 +0100,
> Julia Lawall wrote:
> >
> > Use resource_size rather than a verbose computation on
> > the end and start fields.
> >
> > The semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > <smpl>
> > @@ struct resource *ptr; @@
> > - ((ptr->end) - (ptr->start) + 1)
> > + resource_size(ptr)
> > </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
>
> Unfortunately this doesn't apply cleanly on my tree.  I guess you
> worked on linux-next which contains a change outside the sound git
> tree that converts ioremap_nocache() to ioremap().
>
> We may apply it in sound git tree and let conflicts resolved at the
> merge time.  OTOH, it's no urgent fix at all and can be postponed
> after 5.6-rc1 merge, too -- then everything can be applied in a
> cleaner way.
>
> Let me know your preference.

It's from linux-next.  No hurry.  Postponing it is fine.

thanks,
julia
Takashi Iwai Jan. 2, 2020, 3:13 p.m. UTC | #3
On Wed, 01 Jan 2020 20:23:24 +0100,
Julia Lawall wrote:
> 
> On Wed, 1 Jan 2020, Takashi Iwai wrote:
> 
> > On Wed, 01 Jan 2020 18:49:42 +0100,
> > Julia Lawall wrote:
> > >
> > > Use resource_size rather than a verbose computation on
> > > the end and start fields.
> > >
> > > The semantic patch that makes this change is as follows:
> > > (http://coccinelle.lip6.fr/)
> > >
> > > <smpl>
> > > @@ struct resource *ptr; @@
> > > - ((ptr->end) - (ptr->start) + 1)
> > > + resource_size(ptr)
> > > </smpl>
> > >
> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
> >
> > Unfortunately this doesn't apply cleanly on my tree.  I guess you
> > worked on linux-next which contains a change outside the sound git
> > tree that converts ioremap_nocache() to ioremap().
> >
> > We may apply it in sound git tree and let conflicts resolved at the
> > merge time.  OTOH, it's no urgent fix at all and can be postponed
> > after 5.6-rc1 merge, too -- then everything can be applied in a
> > cleaner way.
> >
> > Let me know your preference.
> 
> It's from linux-next.  No hurry.  Postponing it is fine.

OK, let's postpone this.  Thanks.


Takashi

Patch
diff mbox series

diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index 4e6042e652f0..9de5caaf6047 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -1100,9 +1100,7 @@  snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev,
 	PDEBUG(INIT_INFO, "Trying to reserve resources now ...\n");
 	resource = platform_get_resource(pfdev, IORESOURCE_MEM, 0);
 	/* get "port" */
-	ml403_ac97cr->port = ioremap(resource->start,
-					     (resource->end) -
-					     (resource->start) + 1);
+	ml403_ac97cr->port = ioremap(resource->start, resource_size(resource));
 	if (ml403_ac97cr->port == NULL) {
 		snd_printk(KERN_ERR SND_ML403_AC97CR_DRIVER ": "
 			   "unable to remap memory region (%pR)\n",