[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <612284348.20070307191127@gmail.com>
Date: Wed, 7 Mar 2007 19:11:27 +0200
From: Paul Sokolovsky <pmiscml@...il.com>
To: NZG <ngustavson@...cinc.com>
CC: linux-kernel@...r.kernel.org
Subject: Re: passing function pointers through platform devices?
Hello NZG,
Tuesday, March 6, 2007, 8:46:29 PM, you wrote:
> I'm developing an SPI- bus >MMC/SD block driver translation layer.
> As part of this layer the write protect and card detect lines need to be read.
> The method for determining the state of these lines will be board specific.
> Is it appropriate to pass a function pointer through a platform device
> (declared in the mach initialization) to implement card_available and
> write_protect function calls?
> Or is there a cleaner way to do it?
Apparently it must be appropriate, because that's pretty natural
and clean - if you can pass data, why wouldn't you be able to pass
methods?
I assume your usecase is to pass board-specific code, defined in
machine definition, down to a device driver. We (handhelds.org) go
even further and recently tried passing function pointers in opposite
direction - from device driver to client code which will use the
device, via device's platform_data.
That essentially implements virtual methods on devices, allowing
device clients to perform operations on them without bothering to know
how actually the operation is implemented, i.e. offers better
functionality separation and code reuse which OOP offers.
Either way, be assured that you're not the only one who puts Linux
Driver Model under full use.
> thank you,
> NZG
--
Best regards,
Paul mailto:pmiscml@...il.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists