[PATCH] staging: vc04_services: rework ioctl code path

Michael Zoran mzoran at crowfest.net
Wed Nov 9 15:22:22 PST 2016


On Wed, 2016-11-09 at 15:00 -0800, Michael Zoran wrote:
> On Wed, 2016-11-09 at 23:51 +0100, Arnd Bergmann wrote:
> > On Wednesday, November 9, 2016 2:41:42 PM CET Michael Zoran wrote:
> > > > >     Arnd
> > > > 
> > > > That I have absolutely no problem changing.  I'll go ahead and
> > > > change
> > > > it and resubmit the patch.
> > > > > 
> > > 
> > > Actually, I'm looking at this a bit more and I'm noticing some
> > > interesting things.
> > > 
> > > If something like compat_ptr is used, why can the ioctl.h header
> > > be
> > > included twice with different #defines to generate both the 32
> > > bit
> > > and
> > > 64 bit cases.
> > 
> > I can't see how that would work, as you have to change the macro
> > names as well.
> > 
> 
> I think the C preprocessor allows macros to reference other
> macros.  So
> I can easily create a new set of macros that are conditionally
> defined
> to map to either compat_ptr in one case or foo __user * in the other
> case.
> 
> Perhaps I should look into this more.
> 

Perhaps it would make sense to even write "accessor" macros for the
various fields of the passed in structure and put some of the ioctl
handling code into a header.  then the code could be included twice. 
Once for the native case, and once for the compat case.

The only real complication is the silly compiler gives hard to diagnose
error messages when putting code in a header and it makes it extremely
hard to use traditional debuggers on the code.




More information about the linux-rpi-kernel mailing list