[PATCH -mm2] CardServices compatibility layer

Russell King rmk+pcmcia at arm.linux.org.uk
Mon Dec 29 23:11:07 GMT 2003


On Mon, Dec 29, 2003 at 02:57:21PM -0800, Andrew Morton wrote:
> Russell King <rmk+pcmcia at arm.linux.org.uk> wrote:
> > On Mon, Dec 29, 2003 at 01:26:50PM -0800, Andrew Morton wrote:
> > > Well there's the third way, which is what Dominik did: implement a real
> > > CardServices() function which has a big switch statement, calls out to the
> > > new API.  Seems reasonable, doesn't it?
> > 
> > Isn't that exactly what we've just removed from cs.c, and was the
> > cause of the original problem which Arjan reported?
> > 
> > int CardServices(int func, void *a1, void *a2, void *a3)
> > {
> > ...
> >     switch (func) {
> >     case AccessConfigurationRegister:
> >         return pcmcia_access_configuration_register(a1, a2); break;
> >     case AdjustResourceInfo:
> >         return pcmcia_adjust_resource_info(a1, a2); break;
> > ...
> > 
> 
> yup, but this is a *compatibility* layer, for thus-far unconverted drivers.
>  Out-of-tree ones, presumably.

Sorry, I don't have the whole story on Dominik's idea, since it doesn't
seem to have been copied to this mailing list.

Arguments for the old switch() method:
- umm?

Arguments against the old method:
- we know it's buggy for certain architectures and compiler options
- it can never type-check it's arguments, or even verify the
  correct number of arguments

Arguments for #define method:
- gives us typechecking of arguments
- it doesn't generate buggy code

Arguments against #define method:
- ugly preprocessor stuff, though in a header file

IMO if we're going to have a compatibility layer, we might as well have
a correct compatibility layer rather than something buggy.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core



More information about the linux-pcmcia mailing list