The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Make asm-generic/ioctl.h more generic using conditionals.
@ 2007-07-10 10:33 Robert P. J. Day
  2007-07-12 23:11 ` Andrew Morton
  2007-07-13  9:56 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-07-10 10:33 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton


Allow individual architectures to override a small set of macros
before including asm-generic/ioctl.h, in order to greatly simplify a
number of existing ioctl.h files.

The overrideable macros would be:

	_IOC_SIZEBITS
	_IOC_DIRBITS
	_IOC_NONE
	_IOC_WRITE
	_IOC_READ

---

  i've submitted this once before, and it didn't seem to garner a lot
of attention one way or the other.  this patch can be applied
standalone and shouldn't affect anything, but it would subsequently
allow at least a few ioctl.h files to be shortened considerably.

diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h
index cd02729..4fb087a 100644
--- a/include/asm-generic/ioctl.h
+++ b/include/asm-generic/ioctl.h
@@ -21,8 +21,19 @@
  */
 #define _IOC_NRBITS	8
 #define _IOC_TYPEBITS	8
-#define _IOC_SIZEBITS	14
-#define _IOC_DIRBITS	2
+
+/*
+ * Let any architecture override either of the following before
+ * including this file.
+ */
+
+#ifndef _IOC_SIZEBITS
+# define _IOC_SIZEBITS	14
+#endif
+
+#ifndef _IOC_DIRBITS
+# define _IOC_DIRBITS	2
+#endif

 #define _IOC_NRMASK	((1 << _IOC_NRBITS)-1)
 #define _IOC_TYPEMASK	((1 << _IOC_TYPEBITS)-1)
@@ -35,11 +46,21 @@
 #define _IOC_DIRSHIFT	(_IOC_SIZESHIFT+_IOC_SIZEBITS)

 /*
- * Direction bits.
+ * Direction bits, which any architecture can choose to override
+ * before including this file.
  */
-#define _IOC_NONE	0U
-#define _IOC_WRITE	1U
-#define _IOC_READ	2U
+
+#ifndef _IOC_NONE
+# define _IOC_NONE	0U
+#endif
+
+#ifndef _IOC_WRITE
+# define _IOC_WRITE	1U
+#endif
+
+#ifndef _IOC_READ
+# define _IOC_READ	2U
+#endif

 #define _IOC(dir,type,nr,size) \
 	(((dir)  << _IOC_DIRSHIFT) | \

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] Make asm-generic/ioctl.h more generic using conditionals.
  2007-07-10 10:33 [PATCH] Make asm-generic/ioctl.h more generic using conditionals Robert P. J. Day
@ 2007-07-12 23:11 ` Andrew Morton
  2007-07-13  0:51   ` Robert P. J. Day
  2007-07-13  9:56 ` Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2007-07-12 23:11 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List

On Tue, 10 Jul 2007 06:33:26 -0400 (EDT)
"Robert P. J. Day" <rpjday@mindspring.com> wrote:

> 
> Allow individual architectures to override a small set of macros
> before including asm-generic/ioctl.h, in order to greatly simplify a
> number of existing ioctl.h files.
> 
> The overrideable macros would be:
> 
> 	_IOC_SIZEBITS
> 	_IOC_DIRBITS
> 	_IOC_NONE
> 	_IOC_WRITE
> 	_IOC_READ
> 
> ---
> 
>   i've submitted this once before, and it didn't seem to garner a lot
> of attention one way or the other.  this patch can be applied
> standalone and shouldn't affect anything, but it would subsequently
> allow at least a few ioctl.h files to be shortened considerably.

It would be good if we could see one of these followon patches.  If such an
example patch (cc'ed to the arch maintainer, please) looks OK then we can
go ahead with this base patch.

 
> diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h
> index cd02729..4fb087a 100644
> --- a/include/asm-generic/ioctl.h
> +++ b/include/asm-generic/ioctl.h
> @@ -21,8 +21,19 @@
>   */
>  #define _IOC_NRBITS	8
>  #define _IOC_TYPEBITS	8
> -#define _IOC_SIZEBITS	14
> -#define _IOC_DIRBITS	2
> +
> +/*
> + * Let any architecture override either of the following before
> + * including this file.
> + */
> +
> +#ifndef _IOC_SIZEBITS
> +# define _IOC_SIZEBITS	14
> +#endif
> +
> +#ifndef _IOC_DIRBITS
> +# define _IOC_DIRBITS	2
> +#endif
> 
>  #define _IOC_NRMASK	((1 << _IOC_NRBITS)-1)
>  #define _IOC_TYPEMASK	((1 << _IOC_TYPEBITS)-1)
> @@ -35,11 +46,21 @@
>  #define _IOC_DIRSHIFT	(_IOC_SIZESHIFT+_IOC_SIZEBITS)
> 
>  /*
> - * Direction bits.
> + * Direction bits, which any architecture can choose to override
> + * before including this file.
>   */
> -#define _IOC_NONE	0U
> -#define _IOC_WRITE	1U
> -#define _IOC_READ	2U
> +
> +#ifndef _IOC_NONE
> +# define _IOC_NONE	0U
> +#endif
> +
> +#ifndef _IOC_WRITE
> +# define _IOC_WRITE	1U
> +#endif
> +
> +#ifndef _IOC_READ
> +# define _IOC_READ	2U
> +#endif
> 
>  #define _IOC(dir,type,nr,size) \
>  	(((dir)  << _IOC_DIRSHIFT) | \
> 
> -- 
> ========================================================================
> Robert P. J. Day
> Linux Consulting, Training and Annoying Kernel Pedantry
> Waterloo, Ontario, CANADA
> 
> http://fsdev.net/wiki/index.php?title=Main_Page
> ========================================================================

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

* Re: [PATCH] Make asm-generic/ioctl.h more generic using conditionals.
  2007-07-12 23:11 ` Andrew Morton
@ 2007-07-13  0:51   ` Robert P. J. Day
  0 siblings, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-07-13  0:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List, Ralf Baechle, matthew


On Thu, 12 Jul 2007, Andrew Morton wrote:

> On Tue, 10 Jul 2007 06:33:26 -0400 (EDT)
> "Robert P. J. Day" <rpjday@mindspring.com> wrote:
>
> >
> > Allow individual architectures to override a small set of macros
> > before including asm-generic/ioctl.h, in order to greatly simplify a
> > number of existing ioctl.h files.
> >
> > The overrideable macros would be:
> >
> > 	_IOC_SIZEBITS
> > 	_IOC_DIRBITS
> > 	_IOC_NONE
> > 	_IOC_WRITE
> > 	_IOC_READ
> >
> > ---
> >
> >   i've submitted this once before, and it didn't seem to garner a
> > lot of attention one way or the other.  this patch can be applied
> > standalone and shouldn't affect anything, but it would
> > subsequently allow at least a few ioctl.h files to be shortened
> > considerably.
>
> It would be good if we could see one of these followon patches.  If
> such an example patch (cc'ed to the arch maintainer, please) looks
> OK then we can go ahead with this base patch.

as a trivial example, i can demonstrate on include/asm-mips/ioctl.h.
once the generic ioctl.h file is enhanced, then the entire mips
ioctl.h file is reduced from 94 lines to:

===================================
#define _IOC_SIZEBITS	13
#define _IOC_DIRBITS	3

#define _IOC_NONE	1U
#define _IOC_READ	2U
#define _IOC_WRITE	4U

#include <asm-generic/ioctl.h>

/*
 * The following are included for compatibility
 */

#define _IOC_VOID	0x20000000
#define _IOC_OUT	0x40000000
#define _IOC_IN		0x80000000
#define _IOC_INOUT	(IOC_IN|IOC_OUT)
=================================

and the last part of that is purely MIPS-specific content.

  there are at least a couple other ioctl.h files that could be
reduced even further.  asm-parisc/ioctl.h would subsequently become
all of four lines:

=================================
#define _IOC_NONE	0U   (this line isn't even necessary)
#define _IOC_WRITE	2U
#define _IOC_READ	1U

#include <asm-generic/ioctl.h>
=================================

etc, etc.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

* Re: [PATCH] Make asm-generic/ioctl.h more generic using conditionals.
  2007-07-10 10:33 [PATCH] Make asm-generic/ioctl.h more generic using conditionals Robert P. J. Day
  2007-07-12 23:11 ` Andrew Morton
@ 2007-07-13  9:56 ` Christoph Hellwig
  2007-07-13  9:58   ` Robert P. J. Day
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2007-07-13  9:56 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Linux Kernel Mailing List, Andrew Morton

On Tue, Jul 10, 2007 at 06:33:26AM -0400, Robert P. J. Day wrote:
> + * Let any architecture override either of the following before
> + * including this file.
> + */
> +
> +#ifndef _IOC_SIZEBITS
> +# define _IOC_SIZEBITS	14
> +#endif
> +
> +#ifndef _IOC_DIRBITS
> +# define _IOC_DIRBITS	2
> +#endif

I don't think this is usefull.  It just makes it less obvious to find
this definition which must not change ever due to abi reasons anyway.


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

* Re: [PATCH] Make asm-generic/ioctl.h more generic using conditionals.
  2007-07-13  9:56 ` Christoph Hellwig
@ 2007-07-13  9:58   ` Robert P. J. Day
  0 siblings, 0 replies; 5+ messages in thread
From: Robert P. J. Day @ 2007-07-13  9:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Linux Kernel Mailing List, Andrew Morton

On Fri, 13 Jul 2007, Christoph Hellwig wrote:

> On Tue, Jul 10, 2007 at 06:33:26AM -0400, Robert P. J. Day wrote:
> > + * Let any architecture override either of the following before
> > + * including this file.
> > + */
> > +
> > +#ifndef _IOC_SIZEBITS
> > +# define _IOC_SIZEBITS	14
> > +#endif
> > +
> > +#ifndef _IOC_DIRBITS
> > +# define _IOC_DIRBITS	2
> > +#endif
>
> I don't think this is usefull.  It just makes it less obvious to
> find this definition which must not change ever due to abi reasons
> anyway.

huh?

alpha:

 #define _IOC_SIZEBITS  13
 #define _IOC_DIRBITS   3

mips:

 #define _IOC_SIZEBITS  13
 #define _IOC_DIRBITS   3

powerpc:

 #define _IOC_SIZEBITS  13
 #define _IOC_DIRBITS   3

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

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

end of thread, other threads:[~2007-07-13 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10 10:33 [PATCH] Make asm-generic/ioctl.h more generic using conditionals Robert P. J. Day
2007-07-12 23:11 ` Andrew Morton
2007-07-13  0:51   ` Robert P. J. Day
2007-07-13  9:56 ` Christoph Hellwig
2007-07-13  9:58   ` Robert P. J. Day

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