Skip to contentSkip to conversation

passing function pointers through platform devices?

DISCUSSION NZG 5 participants 8 messages Mar 6, 2007 – Mar 8, 2007

lore
Share & tools
lore

NZG

author
#0 lore raw

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?

thank you,
NZG

#1 lore raw
Quoted 6 lines · NZG

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?

Once the generic GPIO framework migrates upstream from -mm you should just pass the GPIO token from board-specific code and gpio_get_value() it.

--Ben.

author
#2 lore raw
Quoted 1 line

Once the generic GPIO framework migrates upstream from -mm

Thank you, but I've reorganized my system to pass platform resources to a driver, which then registers simple gpio/pwm/quadencoder type devices as standard classes declared in a subdirectory. Specific methods are then simple exported by stackable drivers.
It's unlikely I will adopt the GPIO interface at this point unless they really bring something new to the table.

I googled extensively and requested information on any current work here before I began this project and got zip. (see forwarded email paste)

I also emailed Robert Schwebel directly and he told me to ask VGER as it was being developed by someone else.

I don't mean to sound rude, but I really tried to build on existing work and it wasn't made available, so I've gone my own way, I had not other choice.

P.S. Forgive my VGER newbness, but what is "-mm" ?

thx,
NZG

Quoted 23 lines

---------- Forwarded Message ----------

Subject: GPIO device class driver
Date: Tuesday 20 February 2007 10:40 am
From: NZG <[email protected]>
To: Linux kernel mailing list <[email protected]>

I am currently developing support for an ep9xx based SBC and want to export it's GPIO through sysfs in a simple and standard way,
without adding yet another platform specific gpio driver to the kernel.

As I understand it, a gpio class has already been begun by Robert Schwebel in but has not as of yet become part of the mainstream kernel.

Searching the archives for this yields no results since 2006.

Can anyone point me to a current patch?
I'd like to start from there.

thank you,
NZG

-------------------------------------------------

#3 lore raw
Quoted 11 lines · On Wed, 7 Mar 2007 10:37:00 -0600 NZG wrote:
Quoted 1 line

Once the generic GPIO framework migrates upstream from -mm

Thank you, but I've reorganized my system to pass platform resources to a driver, which then registers simple gpio/pwm/quadencoder type devices as standard classes declared in a subdirectory. Specific methods are then simple exported by stackable drivers.
It's unlikely I will adopt the GPIO interface at this point unless they really bring something new to the table.

I googled extensively and requested information on any current work here before I began this project and got zip. (see forwarded email paste)

Quoted 7 lines

I also emailed Robert Schwebel directly and he told me to ask VGER as it was being developed by someone else.

I don't mean to sound rude, but I really tried to build on existing work and it wasn't made available, so I've gone my own way, I had not other choice.

P.S. Forgive my VGER newbness, but what is "-mm" ?

See http://kernel.org/patchtypes/mm.html:

"""
The -mm patches to the Linux kernel
The -mm patches are a set of patches, released by Andrew Morton, against the official kernel series. They are frequently more experimental in nature than the official series. These patches are available in Andrew's kernel directory:

/pub/linux/kernel/people/akpm/
"""

Quoted 25 lines

thx,
NZG

Quoted 22 lines

---------- Forwarded Message ----------

Subject: GPIO device class driver
Date: Tuesday 20 February 2007 10:40 am
From: NZG <[email protected]>
To: Linux kernel mailing list <[email protected]>

I am currently developing support for an ep9xx based SBC and want to export it's GPIO through sysfs in a simple and standard way,
without adding yet another platform specific gpio driver to the kernel.

As I understand it, a gpio class has already been begun by Robert Schwebel in but has not as of yet become part of the mainstream kernel.

Searching the archives for this yields no results since 2006.

Can anyone point me to a current patch?
I'd like to start from there.

thank you,
NZG

Quoted 8 lines
Quoted 1 line

-------------------------------------------------

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

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

author
#4 lore raw
Quoted 4 lines

The -mm patches are a set of patches, released by Andrew Morton, against the official kernel series. They are frequently more experimental in nature than the official series. These patches are available in Andrew's kernel directory:

Thank you for pointing this out, I will use at as another source for background work before beginning future projects.

NZG

#5 lore raw
In reply to NZG
Quoted 1 line · NZG
Quoted 1 line

Once the generic GPIO framework migrates upstream from -mm

It already has:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4c20386c8d0719b42503efe65abe47ad3fb3d711

Quoted 2 lines

I googled extensively and requested information on any current work here before I began this project and got zip. (see forwarded email paste)

Your mail seems to be about a gpio userspace interface, which is something entirely different from an in-kernel API, although I suppose it should be possible to build a userspace interface on top of the generic in-kernel API.

If you're looking for a way to do GPIO from a driver, the new generic GPIO API should offer what you need, assuming it has actually been implemented on your platform.

Haavard

author
#6 lore raw
Quoted 3 lines

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=4c20386c8d0719b42503efe65abe47ad3fb3d711
Your mail seems to be about a gpio userspace interface, which is something entirely different from an in-kernel API,

Sort of, IMHO sysfs classes seems the logical final incarnation for user space access. But to get there it has to migrate down from the machine layer to something that declares it's mapping to the pins on a board. However, just like gpio.txt discusses I am using them to detect MMC insertion, so I needed standard way to declare the pin.
This provides that, thank you.

NZG

#7 lore raw
In reply to NZG

Hello NZG,

Quoted 8 lines · you

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.

Quoted 2 lines

thank you,
NZG

Signature · 2 lines
Best regards,
 Paul                            mailto:[email protected]