linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
@ 2019-11-20  0:10 Luc Van Oostenryck
  2019-11-20 15:59 ` Dragan Cvetic
  2019-11-21 15:39 ` Dragan Cvetic
  0 siblings, 2 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2019-11-20  0:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Luc Van Oostenryck, Derek Kiernan, Dragan Cvetic

xsdfec_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: Derek Kiernan <derek.kiernan@xilinx.com>
CC: Dragan Cvetic <dragan.cvetic@xilinx.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 drivers/misc/xilinx_sdfec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
index 11835969e982..48ba7e02bed7 100644
--- a/drivers/misc/xilinx_sdfec.c
+++ b/drivers/misc/xilinx_sdfec.c
@@ -1025,25 +1025,25 @@ static long xsdfec_dev_compat_ioctl(struct file *file, unsigned int cmd,
 }
 #endif
 
-static unsigned int xsdfec_poll(struct file *file, poll_table *wait)
+static __poll_t xsdfec_poll(struct file *file, poll_table *wait)
 {
-	unsigned int mask = 0;
+	__poll_t mask = 0;
 	struct xsdfec_dev *xsdfec;
 
 	xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev);
 
 	if (!xsdfec)
-		return POLLNVAL | POLLHUP;
+		return EPOLLNVAL | EPOLLHUP;
 
 	poll_wait(file, &xsdfec->waitq, wait);
 
 	/* XSDFEC ISR detected an error */
 	spin_lock_irqsave(&xsdfec->error_data_lock, xsdfec->flags);
 	if (xsdfec->state_updated)
-		mask |= POLLIN | POLLPRI;
+		mask |= EPOLLIN | EPOLLPRI;
 
 	if (xsdfec->stats_updated)
-		mask |= POLLIN | POLLRDNORM;
+		mask |= EPOLLIN | EPOLLRDNORM;
 	spin_unlock_irqrestore(&xsdfec->error_data_lock, xsdfec->flags);
 
 	return mask;
-- 
2.24.0


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

* RE: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
  2019-11-20  0:10 [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type Luc Van Oostenryck
@ 2019-11-20 15:59 ` Dragan Cvetic
  2019-11-20 18:02   ` Luc Van Oostenryck
  2019-11-21 15:39 ` Dragan Cvetic
  1 sibling, 1 reply; 5+ messages in thread
From: Dragan Cvetic @ 2019-11-20 15:59 UTC (permalink / raw)
  To: Luc Van Oostenryck, linux-kernel; +Cc: Derek Kiernan

Hi Luc,

For the sake of my understanding I'd like to ask you when the .pole method is defined 
Why I'm asking this? I have a fairly new book (published in 2017) which suggests what is implemented in SDFEC driver.

I'll test your suggestions and will come back to you soon.

Regards
Dragan


> -----Original Message-----
> From: Luc Van Oostenryck [mailto:luc.vanoostenryck@gmail.com]
> Sent: Wednesday 20 November 2019 00:11
> To: linux-kernel@vger.kernel.org
> Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>; Derek Kiernan <dkiernan@xilinx.com>; Dragan Cvetic
> <draganc@xilinx.com>
> Subject: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
> 
> xsdfec_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: Derek Kiernan <derek.kiernan@xilinx.com>
> CC: Dragan Cvetic <dragan.cvetic@xilinx.com>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  drivers/misc/xilinx_sdfec.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
> index 11835969e982..48ba7e02bed7 100644
> --- a/drivers/misc/xilinx_sdfec.c
> +++ b/drivers/misc/xilinx_sdfec.c
> @@ -1025,25 +1025,25 @@ static long xsdfec_dev_compat_ioctl(struct file *file, unsigned int cmd,
>  }
>  #endif
> 
> -static unsigned int xsdfec_poll(struct file *file, poll_table *wait)
> +static __poll_t xsdfec_poll(struct file *file, poll_table *wait)
>  {
> -	unsigned int mask = 0;
> +	__poll_t mask = 0;
>  	struct xsdfec_dev *xsdfec;
> 
>  	xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev);
> 
>  	if (!xsdfec)
> -		return POLLNVAL | POLLHUP;
> +		return EPOLLNVAL | EPOLLHUP;
> 
>  	poll_wait(file, &xsdfec->waitq, wait);
> 
>  	/* XSDFEC ISR detected an error */
>  	spin_lock_irqsave(&xsdfec->error_data_lock, xsdfec->flags);
>  	if (xsdfec->state_updated)
> -		mask |= POLLIN | POLLPRI;
> +		mask |= EPOLLIN | EPOLLPRI;
> 
>  	if (xsdfec->stats_updated)
> -		mask |= POLLIN | POLLRDNORM;
> +		mask |= EPOLLIN | EPOLLRDNORM;
>  	spin_unlock_irqrestore(&xsdfec->error_data_lock, xsdfec->flags);
> 
>  	return mask;
> --
> 2.24.0


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

* Re: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
  2019-11-20 15:59 ` Dragan Cvetic
@ 2019-11-20 18:02   ` Luc Van Oostenryck
  2019-11-20 19:08     ` Dragan Cvetic
  0 siblings, 1 reply; 5+ messages in thread
From: Luc Van Oostenryck @ 2019-11-20 18:02 UTC (permalink / raw)
  To: Dragan Cvetic; +Cc: linux-kernel, Derek Kiernan

On Wed, Nov 20, 2019 at 03:59:24PM +0000, Dragan Cvetic wrote:
> Hi Luc,
> 
> For the sake of my understanding I'd like to ask you when the .pole method is defined 
> Why I'm asking this? I have a fairly new book (published in 2017) which suggests what is implemented in SDFEC driver.
> 
> I'll test your suggestions and will come back to you soon.

Well, yes, it changed in July 2017.

The current definition can be found in include/linux/fs.h:
	struct file_operations {
		...
		__poll_t (*poll) (struct file *, struct poll_table_struct *);
		...

The main commit making the change is:
    a3f8683bf7d5 ("->poll() methods should return __poll_t")


The result can be verified by compiling the driver with the command
	make C=2 path/to/the/driver.o
which will use the static analyser 'sparse' to make additional checks
where the difference between 'unsigned int' and __poll_t will matter.
See Documentation/dev-tools/sparse.rst for more info about it.

Best regards,
-- Luc Van Oostenryck

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

* RE: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
  2019-11-20 18:02   ` Luc Van Oostenryck
@ 2019-11-20 19:08     ` Dragan Cvetic
  0 siblings, 0 replies; 5+ messages in thread
From: Dragan Cvetic @ 2019-11-20 19:08 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-kernel, Derek Kiernan

Hi Luc,

Thanks for the really useful answer.

I promise I'll test this soon.

Thanks
Dragan


> -----Original Message-----
> From: Luc Van Oostenryck [mailto:luc.vanoostenryck@gmail.com]
> Sent: Wednesday 20 November 2019 18:02
> To: Dragan Cvetic <draganc@xilinx.com>
> Cc: linux-kernel@vger.kernel.org; Derek Kiernan <dkiernan@xilinx.com>
> Subject: Re: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
> 
> On Wed, Nov 20, 2019 at 03:59:24PM +0000, Dragan Cvetic wrote:
> > Hi Luc,
> >
> > For the sake of my understanding I'd like to ask you when the .pole method is defined
> > Why I'm asking this? I have a fairly new book (published in 2017) which suggests what is implemented in SDFEC driver.
> >
> > I'll test your suggestions and will come back to you soon.
> 
> Well, yes, it changed in July 2017.
> 
> The current definition can be found in include/linux/fs.h:
> 	struct file_operations {
> 		...
> 		__poll_t (*poll) (struct file *, struct poll_table_struct *);
> 		...
> 
> The main commit making the change is:
>     a3f8683bf7d5 ("->poll() methods should return __poll_t")
> 
> 
> The result can be verified by compiling the driver with the command
> 	make C=2 path/to/the/driver.o
> which will use the static analyser 'sparse' to make additional checks
> where the difference between 'unsigned int' and __poll_t will matter.
> See Documentation/dev-tools/sparse.rst for more info about it.
> 
> Best regards,
> -- Luc Van Oostenryck

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

* RE: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
  2019-11-20  0:10 [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type Luc Van Oostenryck
  2019-11-20 15:59 ` Dragan Cvetic
@ 2019-11-21 15:39 ` Dragan Cvetic
  1 sibling, 0 replies; 5+ messages in thread
From: Dragan Cvetic @ 2019-11-21 15:39 UTC (permalink / raw)
  To: Luc Van Oostenryck, linux-kernel; +Cc: Derek Kiernan

Hi Luc,

please find my comments below.


> -----Original Message-----
> From: Luc Van Oostenryck [mailto:luc.vanoostenryck@gmail.com]
> Sent: Wednesday 20 November 2019 00:11
> To: linux-kernel@vger.kernel.org
> Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>; Derek Kiernan <dkiernan@xilinx.com>; Dragan Cvetic
> <draganc@xilinx.com>
> Subject: [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type
> 
> xsdfec_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: Derek Kiernan <derek.kiernan@xilinx.com>
> CC: Dragan Cvetic <dragan.cvetic@xilinx.com>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  drivers/misc/xilinx_sdfec.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
> index 11835969e982..48ba7e02bed7 100644
> --- a/drivers/misc/xilinx_sdfec.c
> +++ b/drivers/misc/xilinx_sdfec.c
> @@ -1025,25 +1025,25 @@ static long xsdfec_dev_compat_ioctl(struct file *file, unsigned int cmd,
>  }
>  #endif
> 
> -static unsigned int xsdfec_poll(struct file *file, poll_table *wait)
> +static __poll_t xsdfec_poll(struct file *file, poll_table *wait)
>  {
> -	unsigned int mask = 0;
> +	__poll_t mask = 0;
>  	struct xsdfec_dev *xsdfec;
> 
>  	xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev);
> 
>  	if (!xsdfec)
> -		return POLLNVAL | POLLHUP;
> +		return EPOLLNVAL | EPOLLHUP;
> 
>  	poll_wait(file, &xsdfec->waitq, wait);
> 
>  	/* XSDFEC ISR detected an error */
>  	spin_lock_irqsave(&xsdfec->error_data_lock, xsdfec->flags);
>  	if (xsdfec->state_updated)
> -		mask |= POLLIN | POLLPRI;
> +		mask |= EPOLLIN | EPOLLPRI;
> 
>  	if (xsdfec->stats_updated)
> -		mask |= POLLIN | POLLRDNORM;
> +		mask |= EPOLLIN | EPOLLRDNORM;
>  	spin_unlock_irqrestore(&xsdfec->error_data_lock, xsdfec->flags);
> 
>  	return mask;
> --
> 2.24.0

Acked-by: Dragan Cvetic <dragan.cvetic@xilinx.com>

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20  0:10 [PATCH] misc: xilinx_sdfec: fix xsdfec_poll()'s return type Luc Van Oostenryck
2019-11-20 15:59 ` Dragan Cvetic
2019-11-20 18:02   ` Luc Van Oostenryck
2019-11-20 19:08     ` Dragan Cvetic
2019-11-21 15:39 ` Dragan Cvetic

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