public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
@ 2006-05-16 23:30 Alessandro Zummo
  2006-05-17 21:25 ` Randy.Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Alessandro Zummo @ 2006-05-16 23:30 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel



Appropriately use -ENOIOCTLCMD when
the ioctl is not implemented by a driver.

Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>

---
 drivers/rtc/rtc-dev.c    |    6 +++---
 drivers/rtc/rtc-sa1100.c |    2 +-
 drivers/rtc/rtc-test.c   |    2 +-
 drivers/rtc/rtc-vr41xx.c |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

--- linux-rtc.orig/drivers/rtc/rtc-test.c	2006-05-17 01:21:35.000000000 +0200
+++ linux-rtc/drivers/rtc/rtc-test.c	2006-05-17 01:22:39.000000000 +0200
@@ -71,7 +71,7 @@ static int test_rtc_ioctl(struct device 
 		return 0;
 
 	default:
-		return -EINVAL;
+		return -ENOIOCTLCMD;
 	}
 }
 
--- linux-rtc.orig/drivers/rtc/rtc-vr41xx.c	2006-05-17 01:21:59.000000000 +0200
+++ linux-rtc/drivers/rtc/rtc-vr41xx.c	2006-05-17 01:22:29.000000000 +0200
@@ -270,7 +270,7 @@ static int vr41xx_rtc_ioctl(struct devic
 		epoch = arg;
 		break;
 	default:
-		return -EINVAL;
+		return -ENOIOCTLCMD;
 	}
 
 	return 0;
--- linux-rtc.orig/drivers/rtc/rtc-sa1100.c	2006-05-17 01:18:19.000000000 +0200
+++ linux-rtc/drivers/rtc/rtc-sa1100.c	2006-05-17 01:23:26.000000000 +0200
@@ -247,7 +247,7 @@ static int sa1100_rtc_ioctl(struct devic
 		rtc_freq = arg;
 		return 0;
 	}
-	return -EINVAL;
+	return -ENOIOCTLCMD;
 }
 
 static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
--- linux-rtc.orig/drivers/rtc/rtc-dev.c	2006-05-17 01:18:19.000000000 +0200
+++ linux-rtc/drivers/rtc/rtc-dev.c	2006-05-17 01:26:01.000000000 +0200
@@ -141,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *i
 	/* try the driver's ioctl interface */
 	if (ops->ioctl) {
 		err = ops->ioctl(class_dev->dev, cmd, arg);
-		if (err != -EINVAL)
+		if (err != -ENOIOCTLCMD)
 			return err;
 	}
 
 	/* if the driver does not provide the ioctl interface
 	 * or if that particular ioctl was not implemented
-	 * (-EINVAL), we will try to emulate here.
+	 * (-ENOIOCTLCMD), we will try to emulate here.
 	 */
 
 	switch (cmd) {
@@ -233,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *i
 		break;
 
 	default:
-		err = -EINVAL;
+		err = -ENOIOCTLCMD;
 		break;
 	}
 

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

* Re: [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
  2006-05-16 23:30 [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate Alessandro Zummo
@ 2006-05-17 21:25 ` Randy.Dunlap
  2006-05-17 21:27   ` Alessandro Zummo
  0 siblings, 1 reply; 6+ messages in thread
From: Randy.Dunlap @ 2006-05-17 21:25 UTC (permalink / raw)
  To: Alessandro Zummo; +Cc: akpm, linux-kernel

On Wed, 17 May 2006 01:30:33 +0200 Alessandro Zummo wrote:

> 
> 
> Appropriately use -ENOIOCTLCMD when
> the ioctl is not implemented by a driver.

so this return value does not go back to userspace?
Comment in linux/errno.h says:
/* Should never be seen by user programs */

and ENOTTY is the return value for "Inappropriate ioctl for device":

http://marc.theaimsgroup.com/?l=linux-fsdevel&m=106739260707476&w=2
http://marc.theaimsgroup.com/?l=lustre-devel&m=106737825024915&w=2



> Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
> 
> ---
>  drivers/rtc/rtc-dev.c    |    6 +++---
>  drivers/rtc/rtc-sa1100.c |    2 +-
>  drivers/rtc/rtc-test.c   |    2 +-
>  drivers/rtc/rtc-vr41xx.c |    2 +-
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> --- linux-rtc.orig/drivers/rtc/rtc-test.c	2006-05-17 01:21:35.000000000 +0200
> +++ linux-rtc/drivers/rtc/rtc-test.c	2006-05-17 01:22:39.000000000 +0200
> @@ -71,7 +71,7 @@ static int test_rtc_ioctl(struct device 
>  		return 0;
>  
>  	default:
> -		return -EINVAL;
> +		return -ENOIOCTLCMD;
>  	}
>  }
>  
> --- linux-rtc.orig/drivers/rtc/rtc-vr41xx.c	2006-05-17 01:21:59.000000000 +0200
> +++ linux-rtc/drivers/rtc/rtc-vr41xx.c	2006-05-17 01:22:29.000000000 +0200
> @@ -270,7 +270,7 @@ static int vr41xx_rtc_ioctl(struct devic
>  		epoch = arg;
>  		break;
>  	default:
> -		return -EINVAL;
> +		return -ENOIOCTLCMD;
>  	}
>  
>  	return 0;
> --- linux-rtc.orig/drivers/rtc/rtc-sa1100.c	2006-05-17 01:18:19.000000000 +0200
> +++ linux-rtc/drivers/rtc/rtc-sa1100.c	2006-05-17 01:23:26.000000000 +0200
> @@ -247,7 +247,7 @@ static int sa1100_rtc_ioctl(struct devic
>  		rtc_freq = arg;
>  		return 0;
>  	}
> -	return -EINVAL;
> +	return -ENOIOCTLCMD;
>  }
>  
>  static int sa1100_rtc_read_time(struct device *dev, struct rtc_time *tm)
> --- linux-rtc.orig/drivers/rtc/rtc-dev.c	2006-05-17 01:18:19.000000000 +0200
> +++ linux-rtc/drivers/rtc/rtc-dev.c	2006-05-17 01:26:01.000000000 +0200
> @@ -141,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *i
>  	/* try the driver's ioctl interface */
>  	if (ops->ioctl) {
>  		err = ops->ioctl(class_dev->dev, cmd, arg);
> -		if (err != -EINVAL)
> +		if (err != -ENOIOCTLCMD)
>  			return err;
>  	}
>  
>  	/* if the driver does not provide the ioctl interface
>  	 * or if that particular ioctl was not implemented
> -	 * (-EINVAL), we will try to emulate here.
> +	 * (-ENOIOCTLCMD), we will try to emulate here.
>  	 */
>  
>  	switch (cmd) {
> @@ -233,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *i
>  		break;
>  
>  	default:
> -		err = -EINVAL;
> +		err = -ENOIOCTLCMD;
>  		break;
>  	}
>  
> -

---
~Randy

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

* Re: [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
  2006-05-17 21:25 ` Randy.Dunlap
@ 2006-05-17 21:27   ` Alessandro Zummo
  2006-05-18 20:30     ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: Alessandro Zummo @ 2006-05-17 21:27 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: akpm, linux-kernel

On Wed, 17 May 2006 14:25:10 -0700
"Randy.Dunlap" <rdunlap@xenotime.net> wrote:

> On Wed, 17 May 2006 01:30:33 +0200 Alessandro Zummo wrote:
> 
> > 
> > 
> > Appropriately use -ENOIOCTLCMD when
> > the ioctl is not implemented by a driver.
> 
> so this return value does not go back to userspace?
> Comment in linux/errno.h says:
> /* Should never be seen by user programs */
> 
> and ENOTTY is the return value for "Inappropriate ioctl for device":
>

 you're right. I'll go for ENOTTY. thanks.


-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Turin, Italy

  http://www.towertech.it


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

* Re: [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
  2006-05-17 21:27   ` Alessandro Zummo
@ 2006-05-18 20:30     ` H. Peter Anvin
  2006-05-18 22:32       ` Ingo Oeser
  0 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2006-05-18 20:30 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <20060517232742.2ac4ccaa@inspiron>
By author:    Alessandro Zummo <alessandro.zummo@towertech.it>
In newsgroup: linux.dev.kernel
> > 
> > and ENOTTY is the return value for "Inappropriate ioctl for device":
> >
> 
>  you're right. I'll go for ENOTTY. thanks.
> 

ENOIOCTLCMD is right here, *except* in the very last hunk, because
it's a request to the upper layers to emulate the operation:

> --- linux-rtc.orig/drivers/rtc/rtc-dev.c	2006-05-17 01:18:19.000000000 +0200
> +++ linux-rtc/drivers/rtc/rtc-dev.c	2006-05-17 01:26:01.000000000 +0200
> @@ -141,13 +141,13 @@ static int rtc_dev_ioctl(struct inode *i
>  	/* try the driver's ioctl interface */
>  	if (ops->ioctl) {
>  		err = ops->ioctl(class_dev->dev, cmd, arg);
> -		if (err != -EINVAL)
> +		if (err != -ENOIOCTLCMD)
>  			return err;
>  	}
>  
>  	/* if the driver does not provide the ioctl interface
>  	 * or if that particular ioctl was not implemented
> -	 * (-EINVAL), we will try to emulate here.
> +	 * (-ENOIOCTLCMD), we will try to emulate here.
>  	 */
>  
>  	switch (cmd) {
> @@ -233,7 +233,7 @@ static int rtc_dev_ioctl(struct inode *i
>  		break;
>  
>  	default:
> -		err = -EINVAL;
> +		err = -ENOIOCTLCMD;
>  		break;
>  	}
>  

The last hunk should be ENOTTY.

	-hpa


---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/




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

* Re: [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
  2006-05-18 20:30     ` H. Peter Anvin
@ 2006-05-18 22:32       ` Ingo Oeser
  2006-05-18 22:38         ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Oeser @ 2006-05-18 22:32 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel, Alessandro Zummo

Hi Hans Peter,

H. Peter Anvin wrote
> ENOIOCTLCMD is right here, *except* in the very last hunk, because
> it's a request to the upper layers to emulate the operation:

So would a patch like this be welcome and clear this up?

diff --git a/include/linux/errno.h b/include/linux/errno.h
index d90b80f..d33ae4b 100644
--- a/include/linux/errno.h
+++ b/include/linux/errno.h
@@ -9,7 +9,7 @@
 #define ERESTARTSYS	512
 #define ERESTARTNOINTR	513
 #define ERESTARTNOHAND	514	/* restart if no handler.. */
-#define ENOIOCTLCMD	515	/* No ioctl command */
+#define ENOIOCTLCMD	515	/* No ioctl command, upper layer please emulate or pass ENOTTY to user space */
 #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
 
 /* Defined for the NFSv3 protocol */


Regards

Ingo Oeser

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

* Re: [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate
  2006-05-18 22:32       ` Ingo Oeser
@ 2006-05-18 22:38         ` H. Peter Anvin
  0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2006-05-18 22:38 UTC (permalink / raw)
  To: Ingo Oeser; +Cc: linux-kernel, Alessandro Zummo

Ingo Oeser wrote:
> Hi Hans Peter,
> 
> H. Peter Anvin wrote
>> ENOIOCTLCMD is right here, *except* in the very last hunk, because
>> it's a request to the upper layers to emulate the operation:
> 
> So would a patch like this be welcome and clear this up?
> 
> diff --git a/include/linux/errno.h b/include/linux/errno.h
> index d90b80f..d33ae4b 100644
> --- a/include/linux/errno.h
> +++ b/include/linux/errno.h
> @@ -9,7 +9,7 @@
>  #define ERESTARTSYS	512
>  #define ERESTARTNOINTR	513
>  #define ERESTARTNOHAND	514	/* restart if no handler.. */
> -#define ENOIOCTLCMD	515	/* No ioctl command */
> +#define ENOIOCTLCMD	515	/* No ioctl command, upper layer please emulate or pass ENOTTY to user space */
>  #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
>  
>  /* Defined for the NFSv3 protocol */
> 

Sure, if people feel it's necessary.

	-hpa

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

end of thread, other threads:[~2006-05-18 22:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-16 23:30 [PATCH] rtc subsystem, use ENOIOCTLCMD where appropriate Alessandro Zummo
2006-05-17 21:25 ` Randy.Dunlap
2006-05-17 21:27   ` Alessandro Zummo
2006-05-18 20:30     ` H. Peter Anvin
2006-05-18 22:32       ` Ingo Oeser
2006-05-18 22:38         ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox