All of lore.kernel.org
 help / color / mirror / Atom feed
* How to create library module with callbacks?
@ 2011-10-14 13:21 Rafał Miłecki
  2011-10-14 14:42 ` Pavel Roskin
  2011-10-14 14:43 ` Arend van Spriel
  0 siblings, 2 replies; 3+ messages in thread
From: Rafał Miłecki @ 2011-10-14 13:21 UTC (permalink / raw)
  To: linux-wireless

I want to create module library, which will handle PHY operations on
Broadcom card. For most of the time, I'm going to call library
functions from b43.

However, there are places where I need to call some (b43) driver
function from library module.

How can I handle that? Should I pass some functions pointers to the
library? Is that going to work? Or is there a better approach?

P.S.
I'm asking at linux-wireless, it's not wireless related however. I
think question is quite simple for C hackers and there is no need to
hit LKML.

-- 
Rafał

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

* Re: How to create library module with callbacks?
  2011-10-14 13:21 How to create library module with callbacks? Rafał Miłecki
@ 2011-10-14 14:42 ` Pavel Roskin
  2011-10-14 14:43 ` Arend van Spriel
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Roskin @ 2011-10-14 14:42 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: linux-wireless

On Fri, 14 Oct 2011 15:21:16 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> I want to create module library, which will handle PHY operations on
> Broadcom card. For most of the time, I'm going to call library
> functions from b43.
> 
> However, there are places where I need to call some (b43) driver
> function from library module.
> 
> How can I handle that? Should I pass some functions pointers to the
> library? Is that going to work? Or is there a better approach?

Yes, that should work.  All modules and the kernel live in the same
address space.  But you should make sure that those pointers won't be
used if the calling module is unloaded.

In fact, b43 does it already with mac80211, ssb and bcma.  See
b43_hw_ops, b43_ssb_driver and b43_bcma_driver in the code.

-- 
Regards,
Pavel Roskin

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

* Re: How to create library module with callbacks?
  2011-10-14 13:21 How to create library module with callbacks? Rafał Miłecki
  2011-10-14 14:42 ` Pavel Roskin
@ 2011-10-14 14:43 ` Arend van Spriel
  1 sibling, 0 replies; 3+ messages in thread
From: Arend van Spriel @ 2011-10-14 14:43 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: linux-wireless

On 10/14/2011 03:21 PM, Rafał Miłecki wrote:
> I want to create module library, which will handle PHY operations on
> Broadcom card. For most of the time, I'm going to call library
> functions from b43.
> 
> However, there are places where I need to call some (b43) driver
> function from library module.
> 
> How can I handle that? Should I pass some functions pointers to the
> library? Is that going to work? Or is there a better approach?
> 
> P.S.
> I'm asking at linux-wireless, it's not wireless related however. I
> think question is quite simple for C hackers and there is no need to
> hit LKML.
> 

Hi Rafał,

It should be no different as normal drivers do. In your case I would say
b43 registers itself with phylib module and provides phylib_ops. It
could also provide the bcma_device for the 80211 core so the phylib can
use bcma directly. Whether or not phylib is still a library module when
doing so can be argued. As it does not provide a system function by
itself I tend to say it is.

I would suggest to look into mac80211 to see how it deals with the
callbacks it does into the device drivers.

Gr. AvS


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

end of thread, other threads:[~2011-10-14 14:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-14 13:21 How to create library module with callbacks? Rafał Miłecki
2011-10-14 14:42 ` Pavel Roskin
2011-10-14 14:43 ` Arend van Spriel

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.