All of lore.kernel.org
 help / color / mirror / Atom feed
* Adding new function to existing driver ops
@ 2011-07-08  9:25 Asha R
  2011-07-08 15:47 ` Dave Hylands
  0 siblings, 1 reply; 2+ messages in thread
From: Asha R @ 2011-07-08  9:25 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I would like to know how to add new function to a driver in Linux Framework?

For eg: In GPIO driver, there is gpio_chip structure defined.

static struct gpio_chip mygpio_chip = {
        .label                         = "mygpio",
        .owner                        = THIS_MODULE,
        .direction_input           = mygpio_direction_input,
        .get                            = mygpio_get,
        .direction_output         = mygpio_direction_output,
        .set                            = mygpio_set,
        .to_irq                        = mygpio_to_irq,
};
If i want to add *mygpio_pulldown* or *mygpio_altfunc* to support few more
gpio functionalities, how and where can i add these functions in the
structure?

Any suggestions on this will be appreciated.

Thanks in advance,
Asha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110708/40b51c94/attachment.html 

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

* Adding new function to existing driver ops
  2011-07-08  9:25 Adding new function to existing driver ops Asha R
@ 2011-07-08 15:47 ` Dave Hylands
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Hylands @ 2011-07-08 15:47 UTC (permalink / raw)
  To: kernelnewbies

Hi Asha,

On Fri, Jul 8, 2011 at 2:25 AM, Asha R <rd.asha22@gmail.com> wrote:
> Hi,
>
> I would like to know how to add new function to a driver in Linux Framework?
>
> For eg: In GPIO driver, there is gpio_chip structure defined.
>
> static struct gpio_chip mygpio_chip = {
> ??????? .label???????????????????????? = "mygpio",
> ??????? .owner????????????????????? ??= THIS_MODULE,
> ??????? .direction_input?????????? =?mygpio_direction_input,
> ??????? .get??????????????????????????? = mygpio_get,
> ??????? .direction_output???????? = mygpio_direction_output,
> ??????? .set??????????????????????????? = mygpio_set,
> ??????? .to_irq??????????????????????? = mygpio_to_irq,
> };
> If i want to add mygpio_pulldown or mygpio_altfunc to support few more gpio
> functionalities, how and where can i add these functions in the structure?

It depends on whether you're trying to do it by modifying the
gpio_chip structure, or want to "make an extension".

If you want to modify the structure itself, you would do so here:
http://lxr.linux.no/linux+v2.6.39/include/asm-generic/gpio.h#L90

If you want to make an extension, then you'd make your own structure
which includes the gpio_chip structure as its first member. I often
use this technique to add say an I/O address for the gpio bank, when
there are multiple banks of gpio registers on a chip.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

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

end of thread, other threads:[~2011-07-08 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-08  9:25 Adding new function to existing driver ops Asha R
2011-07-08 15:47 ` Dave Hylands

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.