linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] aspeed: fix snoop_file_poll()'s return type
@ 2019-11-20  0:06 Luc Van Oostenryck
  2019-11-20  5:44 ` Andrew Jeffery
  0 siblings, 1 reply; 4+ messages in thread
From: Luc Van Oostenryck @ 2019-11-20  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Luc Van Oostenryck, Joel Stanley, Andrew Jeffery, linux-aspeed,
	linux-arm-kernel

snoop_file_poll() is defined as returning 'unsigned int' but the
.poll method is declared as returning '__poll_t', a bitwise type.

Fix this by using the proper return type and using the EPOLL
constants instead of the POLL ones, as required for __poll_t.

CC: Joel Stanley <joel@jms.id.au>
CC: Andrew Jeffery <andrew@aj.id.au>
CC: linux-aspeed@lists.ozlabs.org
CC: linux-arm-kernel@lists.infradead.org
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c
index 48f7ac238861..f3d8d53ab84d 100644
--- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
+++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
@@ -97,13 +97,13 @@ static ssize_t snoop_file_read(struct file *file, char __user *buffer,
 	return ret ? ret : copied;
 }
 
-static unsigned int snoop_file_poll(struct file *file,
+static __poll_t snoop_file_poll(struct file *file,
 				    struct poll_table_struct *pt)
 {
 	struct aspeed_lpc_snoop_channel *chan = snoop_file_to_chan(file);
 
 	poll_wait(file, &chan->wq, pt);
-	return !kfifo_is_empty(&chan->fifo) ? POLLIN : 0;
+	return !kfifo_is_empty(&chan->fifo) ? EPOLLIN : 0;
 }
 
 static const struct file_operations snoop_fops = {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: fix snoop_file_poll()'s return type
  2019-11-20  0:06 [PATCH] aspeed: fix snoop_file_poll()'s return type Luc Van Oostenryck
@ 2019-11-20  5:44 ` Andrew Jeffery
  2019-11-21  2:52   ` Joel Stanley
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jeffery @ 2019-11-20  5:44 UTC (permalink / raw)
  To: Luc Van Oostenryck, linux-kernel, Robert Lippert, Patrick Venture
  Cc: Joel Stanley, linux-aspeed, linux-arm-kernel

On Wed, 20 Nov 2019, at 10:36, Luc Van Oostenryck wrote:
> snoop_file_poll() is defined as returning 'unsigned int' but the
> .poll method is declared as returning '__poll_t', a bitwise type.
> 
> Fix this by using the proper return type and using the EPOLL
> constants instead of the POLL ones, as required for __poll_t.
> 
> CC: Joel Stanley <joel@jms.id.au>
> CC: Andrew Jeffery <andrew@aj.id.au>
> CC: linux-aspeed@lists.ozlabs.org
> CC: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c 
> b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> index 48f7ac238861..f3d8d53ab84d 100644
> --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
> +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> @@ -97,13 +97,13 @@ static ssize_t snoop_file_read(struct file *file, 
> char __user *buffer,
>  	return ret ? ret : copied;
>  }
>  
> -static unsigned int snoop_file_poll(struct file *file,
> +static __poll_t snoop_file_poll(struct file *file,
>  				    struct poll_table_struct *pt)
>  {
>  	struct aspeed_lpc_snoop_channel *chan = snoop_file_to_chan(file);
>  
>  	poll_wait(file, &chan->wq, pt);
> -	return !kfifo_is_empty(&chan->fifo) ? POLLIN : 0;
> +	return !kfifo_is_empty(&chan->fifo) ? EPOLLIN : 0;

Looks fine to me as POLLIN and EPOLLIN evaluate to the same value despite
the type difference.

Patrick, Rob: can you take a look / test?

Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: fix snoop_file_poll()'s return type
  2019-11-20  5:44 ` Andrew Jeffery
@ 2019-11-21  2:52   ` Joel Stanley
  2019-11-21 10:08     ` Luc Van Oostenryck
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Stanley @ 2019-11-21  2:52 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Luc Van Oostenryck, Linux Kernel Mailing List, Robert Lippert,
	Patrick Venture, linux-aspeed, Linux ARM

On Wed, 20 Nov 2019 at 05:42, Andrew Jeffery <andrew@aj.id.au> wrote:
>
> On Wed, 20 Nov 2019, at 10:36, Luc Van Oostenryck wrote:
> > snoop_file_poll() is defined as returning 'unsigned int' but the
> > .poll method is declared as returning '__poll_t', a bitwise type.
> >
> > Fix this by using the proper return type and using the EPOLL
> > constants instead of the POLL ones, as required for __poll_t.
> >
> > CC: Joel Stanley <joel@jms.id.au>
> > CC: Andrew Jeffery <andrew@aj.id.au>
> > CC: linux-aspeed@lists.ozlabs.org
> > CC: linux-arm-kernel@lists.infradead.org
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> > ---
> >  drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c
> > b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> > index 48f7ac238861..f3d8d53ab84d 100644
> > --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
> > +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
> > @@ -97,13 +97,13 @@ static ssize_t snoop_file_read(struct file *file,
> > char __user *buffer,
> >       return ret ? ret : copied;
> >  }
> >
> > -static unsigned int snoop_file_poll(struct file *file,
> > +static __poll_t snoop_file_poll(struct file *file,
> >                                   struct poll_table_struct *pt)
> >  {
> >       struct aspeed_lpc_snoop_channel *chan = snoop_file_to_chan(file);
> >
> >       poll_wait(file, &chan->wq, pt);
> > -     return !kfifo_is_empty(&chan->fifo) ? POLLIN : 0;
> > +     return !kfifo_is_empty(&chan->fifo) ? EPOLLIN : 0;
>
> Looks fine to me as POLLIN and EPOLLIN evaluate to the same value despite
> the type difference.

I assume Luc was using sparse to check:

CHECK   ../drivers/soc/aspeed/aspeed-lpc-snoop.c
../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19: warning: incorrect
type in initializer (different base types)
../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19:    expected
restricted __poll_t ( *poll )( ... )
../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19:    got unsigned int (
* )( ... )

If you fix the return type:

  CHECK   ../drivers/soc/aspeed/aspeed-lpc-snoop.c
../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45: warning: incorrect
type in return expression (different base types)
../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45:    expected restricted __poll_t
../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45:    got int

Reviewed-by: Joel Stanley <joel@jms.id.au>

I will send this to the ARM SOC maintainer. Thanks Luc!

Cheers,

Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: fix snoop_file_poll()'s return type
  2019-11-21  2:52   ` Joel Stanley
@ 2019-11-21 10:08     ` Luc Van Oostenryck
  0 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2019-11-21 10:08 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Andrew Jeffery, Linux Kernel Mailing List, Robert Lippert,
	Patrick Venture, linux-aspeed, Linux ARM

On Thu, Nov 21, 2019 at 02:52:39AM +0000, Joel Stanley wrote:
> On Wed, 20 Nov 2019 at 05:42, Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> > Looks fine to me as POLLIN and EPOLLIN evaluate to the same value despite
> > the type difference.
> 
> I assume Luc was using sparse to check:
> 
> CHECK   ../drivers/soc/aspeed/aspeed-lpc-snoop.c
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19: warning: incorrect
> type in initializer (different base types)
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19:    expected
> restricted __poll_t ( *poll )( ... )
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:112:19:    got unsigned int (
> * )( ... )
> 
> If you fix the return type:
> 
>   CHECK   ../drivers/soc/aspeed/aspeed-lpc-snoop.c
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45: warning: incorrect
> type in return expression (different base types)
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45:    expected restricted __poll_t
> ../drivers/soc/aspeed/aspeed-lpc-snoop.c:106:45:    got int

Yes, but with the change s/POLLIN/EPOLLIN/ this last warning
is not issued.
 
Cheers,
-- Luc

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-21 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20  0:06 [PATCH] aspeed: fix snoop_file_poll()'s return type Luc Van Oostenryck
2019-11-20  5:44 ` Andrew Jeffery
2019-11-21  2:52   ` Joel Stanley
2019-11-21 10:08     ` Luc Van Oostenryck

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).