diff mbox series

usb: musb: remove unused variable 'devctl'

Message ID 20201117082125.7619-1-min.guo@mediatek.com (mailing list archive)
State New
Headers show
Series usb: musb: remove unused variable 'devctl' | expand

Commit Message

Min Guo Nov. 17, 2020, 8:21 a.m. UTC
From: Min Guo <min.guo@mediatek.com>

Remove unused 'devctl' variable to fix compile warnings:

    drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
    drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
    but not used [-Wunused-but-set-variable]

Signed-off-by: Min Guo <min.guo@mediatek.com>
---
 drivers/usb/musb/musbhsdma.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Greg KH Nov. 18, 2020, 11:48 a.m. UTC | #1
On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> From: Min Guo <min.guo@mediatek.com>
> 
> Remove unused 'devctl' variable to fix compile warnings:
> 
>     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
>     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
>     but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Min Guo <min.guo@mediatek.com>
> ---
>  drivers/usb/musb/musbhsdma.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> index 0aacfc8be5a1..7acd1635850d 100644
> --- a/drivers/usb/musb/musbhsdma.c
> +++ b/drivers/usb/musb/musbhsdma.c
> @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
>  				musb_channel->channel.status =
>  					MUSB_DMA_STATUS_BUS_ABORT;
>  			} else {
> -				u8 devctl;
> -
>  				addr = musb_read_hsdma_addr(mbase,
>  						bchannel);
>  				channel->actual_len = addr
> @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
>  						< musb_channel->len) ?
>  					"=> reconfig 0" : "=> complete");
>  
> -				devctl = musb_readb(mbase, MUSB_DEVCTL);

Are you sure that the hardware does not require this read to complete
the command?  Lots of hardware is that way, so be very careful about
this.  Did you test it?

thanks,

greg k-h
Min Guo Nov. 20, 2020, 6:48 a.m. UTC | #2
Hi greg k-h:
On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > From: Min Guo <min.guo@mediatek.com>
> > 
> > Remove unused 'devctl' variable to fix compile warnings:
> > 
> >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> >     but not used [-Wunused-but-set-variable]
> > 
> > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > ---
> >  drivers/usb/musb/musbhsdma.c | 4 ----
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > index 0aacfc8be5a1..7acd1635850d 100644
> > --- a/drivers/usb/musb/musbhsdma.c
> > +++ b/drivers/usb/musb/musbhsdma.c
> > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> >  				musb_channel->channel.status =
> >  					MUSB_DMA_STATUS_BUS_ABORT;
> >  			} else {
> > -				u8 devctl;
> > -
> >  				addr = musb_read_hsdma_addr(mbase,
> >  						bchannel);
> >  				channel->actual_len = addr
> > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> >  						< musb_channel->len) ?
> >  					"=> reconfig 0" : "=> complete");
> >  
> > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> 
> Are you sure that the hardware does not require this read to complete
> the command?  Lots of hardware is that way, so be very careful about
> this.  Did you test it?

I have tested this patch on Mediatek's platform, and not sure if it
will affect other vendors' platforms.

Dear Bin:

Does this patch will affect other vendors' platforms?

Best Regards,
Min

> thanks,
> 
> greg k-h
Greg KH Nov. 20, 2020, 6:54 a.m. UTC | #3
On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> Hi greg k-h:
> On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > From: Min Guo <min.guo@mediatek.com>
> > > 
> > > Remove unused 'devctl' variable to fix compile warnings:
> > > 
> > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > >     but not used [-Wunused-but-set-variable]
> > > 
> > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > ---
> > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > >  1 file changed, 4 deletions(-)
> > > 
> > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > index 0aacfc8be5a1..7acd1635850d 100644
> > > --- a/drivers/usb/musb/musbhsdma.c
> > > +++ b/drivers/usb/musb/musbhsdma.c
> > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > >  				musb_channel->channel.status =
> > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > >  			} else {
> > > -				u8 devctl;
> > > -
> > >  				addr = musb_read_hsdma_addr(mbase,
> > >  						bchannel);
> > >  				channel->actual_len = addr
> > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > >  						< musb_channel->len) ?
> > >  					"=> reconfig 0" : "=> complete");
> > >  
> > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > 
> > Are you sure that the hardware does not require this read to complete
> > the command?  Lots of hardware is that way, so be very careful about
> > this.  Did you test it?
> 
> I have tested this patch on Mediatek's platform, and not sure if it
> will affect other vendors' platforms.
> 
> Dear Bin:
> 
> Does this patch will affect other vendors' platforms?

The hardware specs will answer this question, what do they say about
this read?

thanks,

greg k-h
Min Guo Nov. 20, 2020, 7:42 a.m. UTC | #4
On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > Hi greg k-h:
> > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > From: Min Guo <min.guo@mediatek.com>
> > > > 
> > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > 
> > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > >     but not used [-Wunused-but-set-variable]
> > > > 
> > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > ---
> > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > >  1 file changed, 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > >  				musb_channel->channel.status =
> > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > >  			} else {
> > > > -				u8 devctl;
> > > > -
> > > >  				addr = musb_read_hsdma_addr(mbase,
> > > >  						bchannel);
> > > >  				channel->actual_len = addr
> > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > >  						< musb_channel->len) ?
> > > >  					"=> reconfig 0" : "=> complete");
> > > >  
> > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > 
> > > Are you sure that the hardware does not require this read to complete
> > > the command?  Lots of hardware is that way, so be very careful about
> > > this.  Did you test it?
> > 
> > I have tested this patch on Mediatek's platform, and not sure if it
> > will affect other vendors' platforms.
> > 
> > Dear Bin:
> > 
> > Does this patch will affect other vendors' platforms?
> 
> The hardware specs will answer this question, what do they say about
> this read?

Sorry, I didn't seen the comment on the hardware specs indicate that
devctl register needs to read once to take effect.

> thanks,
> 
> greg k-h
Greg KH Nov. 20, 2020, 8:36 a.m. UTC | #5
On Fri, Nov 20, 2020 at 03:42:06PM +0800, Min Guo wrote:
> On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> > On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > > Hi greg k-h:
> > > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > > From: Min Guo <min.guo@mediatek.com>
> > > > > 
> > > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > > 
> > > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > >     but not used [-Wunused-but-set-variable]
> > > > > 
> > > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > > ---
> > > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > > >  1 file changed, 4 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > >  				musb_channel->channel.status =
> > > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > > >  			} else {
> > > > > -				u8 devctl;
> > > > > -
> > > > >  				addr = musb_read_hsdma_addr(mbase,
> > > > >  						bchannel);
> > > > >  				channel->actual_len = addr
> > > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > >  						< musb_channel->len) ?
> > > > >  					"=> reconfig 0" : "=> complete");
> > > > >  
> > > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > > 
> > > > Are you sure that the hardware does not require this read to complete
> > > > the command?  Lots of hardware is that way, so be very careful about
> > > > this.  Did you test it?
> > > 
> > > I have tested this patch on Mediatek's platform, and not sure if it
> > > will affect other vendors' platforms.
> > > 
> > > Dear Bin:
> > > 
> > > Does this patch will affect other vendors' platforms?
> > 
> > The hardware specs will answer this question, what do they say about
> > this read?
> 
> Sorry, I didn't seen the comment on the hardware specs indicate that
> devctl register needs to read once to take effect.

Perhaps you might want to add a comment here so that people will not
keep making this same mistake when they run auto-checkers on the
codebase?

thanks,

greg k-h
Min Guo Nov. 20, 2020, 9:02 a.m. UTC | #6
On Fri, 2020-11-20 at 09:36 +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 20, 2020 at 03:42:06PM +0800, Min Guo wrote:
> > On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> > > On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > > > Hi greg k-h:
> > > > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > > > From: Min Guo <min.guo@mediatek.com>
> > > > > > 
> > > > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > > > 
> > > > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > > >     but not used [-Wunused-but-set-variable]
> > > > > > 
> > > > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > > > ---
> > > > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > > > >  1 file changed, 4 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > >  				musb_channel->channel.status =
> > > > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > > > >  			} else {
> > > > > > -				u8 devctl;
> > > > > > -
> > > > > >  				addr = musb_read_hsdma_addr(mbase,
> > > > > >  						bchannel);
> > > > > >  				channel->actual_len = addr
> > > > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > >  						< musb_channel->len) ?
> > > > > >  					"=> reconfig 0" : "=> complete");
> > > > > >  
> > > > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > > > 
> > > > > Are you sure that the hardware does not require this read to complete
> > > > > the command?  Lots of hardware is that way, so be very careful about
> > > > > this.  Did you test it?
> > > > 
> > > > I have tested this patch on Mediatek's platform, and not sure if it
> > > > will affect other vendors' platforms.
> > > > 
> > > > Dear Bin:
> > > > 
> > > > Does this patch will affect other vendors' platforms?
> > > 
> > > The hardware specs will answer this question, what do they say about
> > > this read?
> > 
> > Sorry, I didn't seen the comment on the hardware specs indicate that
> > devctl register needs to read once to take effect.
> 
> Perhaps you might want to add a comment here so that people will not
> keep making this same mistake when they run auto-checkers on the
> codebase?

Sorry for confused you, I searched the hardware specs, but did not find
the special description of the register devctl indicating that it needs
to be read out before the hardware can work.

> thanks,
> 
> greg k-h
Greg KH Nov. 20, 2020, 9:20 a.m. UTC | #7
On Fri, Nov 20, 2020 at 05:02:15PM +0800, Min Guo wrote:
> On Fri, 2020-11-20 at 09:36 +0100, Greg Kroah-Hartman wrote:
> > On Fri, Nov 20, 2020 at 03:42:06PM +0800, Min Guo wrote:
> > > On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> > > > On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > > > > Hi greg k-h:
> > > > > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > > > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > > > > From: Min Guo <min.guo@mediatek.com>
> > > > > > > 
> > > > > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > > > > 
> > > > > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > > > >     but not used [-Wunused-but-set-variable]
> > > > > > > 
> > > > > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > > > > ---
> > > > > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > > > > >  1 file changed, 4 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > > >  				musb_channel->channel.status =
> > > > > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > > > > >  			} else {
> > > > > > > -				u8 devctl;
> > > > > > > -
> > > > > > >  				addr = musb_read_hsdma_addr(mbase,
> > > > > > >  						bchannel);
> > > > > > >  				channel->actual_len = addr
> > > > > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > > >  						< musb_channel->len) ?
> > > > > > >  					"=> reconfig 0" : "=> complete");
> > > > > > >  
> > > > > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > > > > 
> > > > > > Are you sure that the hardware does not require this read to complete
> > > > > > the command?  Lots of hardware is that way, so be very careful about
> > > > > > this.  Did you test it?
> > > > > 
> > > > > I have tested this patch on Mediatek's platform, and not sure if it
> > > > > will affect other vendors' platforms.
> > > > > 
> > > > > Dear Bin:
> > > > > 
> > > > > Does this patch will affect other vendors' platforms?
> > > > 
> > > > The hardware specs will answer this question, what do they say about
> > > > this read?
> > > 
> > > Sorry, I didn't seen the comment on the hardware specs indicate that
> > > devctl register needs to read once to take effect.
> > 
> > Perhaps you might want to add a comment here so that people will not
> > keep making this same mistake when they run auto-checkers on the
> > codebase?
> 
> Sorry for confused you, I searched the hardware specs, but did not find
> the special description of the register devctl indicating that it needs
> to be read out before the hardware can work.

If this is a PCI device, that is implied as that is how all PCI devices
work, right?

What is the problem that is fixed by removing this read?

thanks,

greg k-h
Alan Stern Nov. 20, 2020, 4:15 p.m. UTC | #8
On Fri, Nov 20, 2020 at 09:36:33AM +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 20, 2020 at 03:42:06PM +0800, Min Guo wrote:
> > On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> > > On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > > > Hi greg k-h:
> > > > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > > > From: Min Guo <min.guo@mediatek.com>
> > > > > > 
> > > > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > > > 
> > > > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > > >     but not used [-Wunused-but-set-variable]
> > > > > > 
> > > > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > > > ---
> > > > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > > > >  1 file changed, 4 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > >  				musb_channel->channel.status =
> > > > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > > > >  			} else {
> > > > > > -				u8 devctl;
> > > > > > -
> > > > > >  				addr = musb_read_hsdma_addr(mbase,
> > > > > >  						bchannel);
> > > > > >  				channel->actual_len = addr
> > > > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > >  						< musb_channel->len) ?
> > > > > >  					"=> reconfig 0" : "=> complete");
> > > > > >  
> > > > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > > > 
> > > > > Are you sure that the hardware does not require this read to complete
> > > > > the command?  Lots of hardware is that way, so be very careful about
> > > > > this.  Did you test it?
> > > > 
> > > > I have tested this patch on Mediatek's platform, and not sure if it
> > > > will affect other vendors' platforms.
> > > > 
> > > > Dear Bin:
> > > > 
> > > > Does this patch will affect other vendors' platforms?
> > > 
> > > The hardware specs will answer this question, what do they say about
> > > this read?
> > 
> > Sorry, I didn't seen the comment on the hardware specs indicate that
> > devctl register needs to read once to take effect.
> 
> Perhaps you might want to add a comment here so that people will not
> keep making this same mistake when they run auto-checkers on the
> codebase?

A better change would be

-			devctl = musb_readb(mbase, MUSB_DEVCTL);
+			(void) musb_readb(mbase, MUSB_DEVCTL);

and eliminate the unused variable.  Then there wouldn't be any compiler 
warning.

Alan Stern
Greg KH Nov. 20, 2020, 4:32 p.m. UTC | #9
On Fri, Nov 20, 2020 at 11:15:19AM -0500, Alan Stern wrote:
> On Fri, Nov 20, 2020 at 09:36:33AM +0100, Greg Kroah-Hartman wrote:
> > On Fri, Nov 20, 2020 at 03:42:06PM +0800, Min Guo wrote:
> > > On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> > > > On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > > > > Hi greg k-h:
> > > > > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > > > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min.guo@mediatek.com wrote:
> > > > > > > From: Min Guo <min.guo@mediatek.com>
> > > > > > > 
> > > > > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > > > > 
> > > > > > >     drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > > > >     drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > > > >     but not used [-Wunused-but-set-variable]
> > > > > > > 
> > > > > > > Signed-off-by: Min Guo <min.guo@mediatek.com>
> > > > > > > ---
> > > > > > >  drivers/usb/musb/musbhsdma.c | 4 ----
> > > > > > >  1 file changed, 4 deletions(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > > >  				musb_channel->channel.status =
> > > > > > >  					MUSB_DMA_STATUS_BUS_ABORT;
> > > > > > >  			} else {
> > > > > > > -				u8 devctl;
> > > > > > > -
> > > > > > >  				addr = musb_read_hsdma_addr(mbase,
> > > > > > >  						bchannel);
> > > > > > >  				channel->actual_len = addr
> > > > > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void *private_data)
> > > > > > >  						< musb_channel->len) ?
> > > > > > >  					"=> reconfig 0" : "=> complete");
> > > > > > >  
> > > > > > > -				devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > > > > 
> > > > > > Are you sure that the hardware does not require this read to complete
> > > > > > the command?  Lots of hardware is that way, so be very careful about
> > > > > > this.  Did you test it?
> > > > > 
> > > > > I have tested this patch on Mediatek's platform, and not sure if it
> > > > > will affect other vendors' platforms.
> > > > > 
> > > > > Dear Bin:
> > > > > 
> > > > > Does this patch will affect other vendors' platforms?
> > > > 
> > > > The hardware specs will answer this question, what do they say about
> > > > this read?
> > > 
> > > Sorry, I didn't seen the comment on the hardware specs indicate that
> > > devctl register needs to read once to take effect.
> > 
> > Perhaps you might want to add a comment here so that people will not
> > keep making this same mistake when they run auto-checkers on the
> > codebase?
> 
> A better change would be
> 
> -			devctl = musb_readb(mbase, MUSB_DEVCTL);
> +			(void) musb_readb(mbase, MUSB_DEVCTL);
> 
> and eliminate the unused variable.  Then there wouldn't be any compiler 
> warning.

No need for the (void), the compiler shouldn't warn about that, right?
Alan Stern Nov. 20, 2020, 4:37 p.m. UTC | #10
On Fri, Nov 20, 2020 at 05:32:44PM +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 20, 2020 at 11:15:19AM -0500, Alan Stern wrote:
> > > Perhaps you might want to add a comment here so that people will not
> > > keep making this same mistake when they run auto-checkers on the
> > > codebase?
> > 
> > A better change would be
> > 
> > -			devctl = musb_readb(mbase, MUSB_DEVCTL);
> > +			(void) musb_readb(mbase, MUSB_DEVCTL);
> > 
> > and eliminate the unused variable.  Then there wouldn't be any compiler 
> > warning.
> 
> No need for the (void), the compiler shouldn't warn about that, right?

True, but it clearly indicates to a human reader that the value was 
intended to be read and thrown away.  Alternatively, the (void) cast 
could be left out and a comment added.

Alan Stern
diff mbox series

Patch

diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 0aacfc8be5a1..7acd1635850d 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -321,8 +321,6 @@  irqreturn_t dma_controller_irq(int irq, void *private_data)
 				musb_channel->channel.status =
 					MUSB_DMA_STATUS_BUS_ABORT;
 			} else {
-				u8 devctl;
-
 				addr = musb_read_hsdma_addr(mbase,
 						bchannel);
 				channel->actual_len = addr
@@ -336,8 +334,6 @@  irqreturn_t dma_controller_irq(int irq, void *private_data)
 						< musb_channel->len) ?
 					"=> reconfig 0" : "=> complete");
 
-				devctl = musb_readb(mbase, MUSB_DEVCTL);
-
 				channel->status = MUSB_DMA_STATUS_FREE;
 
 				/* completed */