* Driver framework: binding a driver to two devices?
@ 2011-08-13 20:44 Geert Uytterhoeven
2011-08-14 17:38 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2011-08-13 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Linux/m68k
As Amiga Zorro expansion boards have only one BAR (unlike PCI, which has
multiple BARs), several Amiga graphics cards show up as two Zorro devices:
one for the graphics memory and one for the graphics controller's registers.
Traditionally, a driver for such a device used
dev1 = zorro_find_device(id1, ...)
dev2 = zorro_find_device(id2, ...)
to find the two devices and match them.
With the "new" driver framework, the matching with device id1 is now
done using a
struct zorro_driver with a table of IDs, while the matching with device id2 is
still done by calling zorro_find_device(id2, ...).
Recently (with cirrusfb) it turned out that the call to
zorro_find_device(id2, ...)
may fail to find the second device. I suspect this happens due to the second
device haven't been probed for at the time the zorro_driver for the
first device is
initialized.
I expect this can be fixed by delaying all calls to device_register() in
amiga_zorro_probe() until all devices have been detected and added to the array
used by zorro_find_device(). But I was wondering whether there's a more generic
way in the driver framework to bind a driver to two devices?
Are there any PCI devices that show similar behavior?
I know some PCI drivers look up data in DMI tables, but that's not
really the same.
Thanks in advance!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Driver framework: binding a driver to two devices?
2011-08-13 20:44 Driver framework: binding a driver to two devices? Geert Uytterhoeven
@ 2011-08-14 17:38 ` Greg KH
2011-08-14 19:32 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2011-08-14 17:38 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-kernel, Linux/m68k
On Sat, Aug 13, 2011 at 10:44:42PM +0200, Geert Uytterhoeven wrote:
> As Amiga Zorro expansion boards have only one BAR (unlike PCI, which has
> multiple BARs), several Amiga graphics cards show up as two Zorro devices:
> one for the graphics memory and one for the graphics controller's registers.
>
> Traditionally, a driver for such a device used
>
> dev1 = zorro_find_device(id1, ...)
> dev2 = zorro_find_device(id2, ...)
>
> to find the two devices and match them.
>
> With the "new" driver framework, the matching with device id1 is now
> done using a
> struct zorro_driver with a table of IDs, while the matching with device id2 is
> still done by calling zorro_find_device(id2, ...).
>
> Recently (with cirrusfb) it turned out that the call to
> zorro_find_device(id2, ...)
> may fail to find the second device. I suspect this happens due to the second
> device haven't been probed for at the time the zorro_driver for the
> first device is
> initialized.
>
> I expect this can be fixed by delaying all calls to device_register() in
> amiga_zorro_probe() until all devices have been detected and added to the array
> used by zorro_find_device(). But I was wondering whether there's a more generic
> way in the driver framework to bind a driver to two devices?
What you really want is the same "driver instance" bound to two devices,
right? That way the device would operate "knowing" about both physical
devices so as to properly control the thing.
Right now, no, there's not a simple way to do this with the driver
model. USB does this on its own for some devices that need to have
multiple "interfaces" (the USB equalivant for a "device") controlled at
the same time, so you might want to look at how that happens (in the
indivdual drivers, not in the USB core.)
Sorry,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Driver framework: binding a driver to two devices?
2011-08-14 17:38 ` Greg KH
@ 2011-08-14 19:32 ` Geert Uytterhoeven
2011-08-15 2:20 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2011-08-14 19:32 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, Linux/m68k
On Sun, Aug 14, 2011 at 19:38, Greg KH <greg@kroah.com> wrote:
> On Sat, Aug 13, 2011 at 10:44:42PM +0200, Geert Uytterhoeven wrote:
>> As Amiga Zorro expansion boards have only one BAR (unlike PCI, which has
>> multiple BARs), several Amiga graphics cards show up as two Zorro devices:
>> one for the graphics memory and one for the graphics controller's registers.
>>
>> Traditionally, a driver for such a device used
>>
>> dev1 = zorro_find_device(id1, ...)
>> dev2 = zorro_find_device(id2, ...)
>>
>> to find the two devices and match them.
>>
>> With the "new" driver framework, the matching with device id1 is now
>> done using a
>> struct zorro_driver with a table of IDs, while the matching with device id2 is
>> still done by calling zorro_find_device(id2, ...).
>>
>> Recently (with cirrusfb) it turned out that the call to
>> zorro_find_device(id2, ...)
>> may fail to find the second device. I suspect this happens due to the second
>> device haven't been probed for at the time the zorro_driver for the
>> first device is
>> initialized.
>>
>> I expect this can be fixed by delaying all calls to device_register() in
>> amiga_zorro_probe() until all devices have been detected and added to the array
>> used by zorro_find_device(). But I was wondering whether there's a more generic
>> way in the driver framework to bind a driver to two devices?
>
> What you really want is the same "driver instance" bound to two devices,
> right? That way the device would operate "knowing" about both physical
> devices so as to properly control the thing.
Yes, that's what I want.
> Right now, no, there's not a simple way to do this with the driver
> model. USB does this on its own for some devices that need to have
> multiple "interfaces" (the USB equalivant for a "device") controlled at
> the same time, so you might want to look at how that happens (in the
> indivdual drivers, not in the USB core.)
Thanks, I'll have a look at the USB drivers.
Do you know which examples to look at?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Driver framework: binding a driver to two devices?
2011-08-14 19:32 ` Geert Uytterhoeven
@ 2011-08-15 2:20 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-08-15 2:20 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-kernel, Linux/m68k
On Sun, Aug 14, 2011 at 09:32:01PM +0200, Geert Uytterhoeven wrote:
> On Sun, Aug 14, 2011 at 19:38, Greg KH <greg@kroah.com> wrote:
> > On Sat, Aug 13, 2011 at 10:44:42PM +0200, Geert Uytterhoeven wrote:
> >> As Amiga Zorro expansion boards have only one BAR (unlike PCI, which has
> >> multiple BARs), several Amiga graphics cards show up as two Zorro devices:
> >> one for the graphics memory and one for the graphics controller's registers.
> >>
> >> Traditionally, a driver for such a device used
> >>
> >> dev1 = zorro_find_device(id1, ...)
> >> dev2 = zorro_find_device(id2, ...)
> >>
> >> to find the two devices and match them.
> >>
> >> With the "new" driver framework, the matching with device id1 is now
> >> done using a
> >> struct zorro_driver with a table of IDs, while the matching with device id2 is
> >> still done by calling zorro_find_device(id2, ...).
> >>
> >> Recently (with cirrusfb) it turned out that the call to
> >> zorro_find_device(id2, ...)
> >> may fail to find the second device. I suspect this happens due to the second
> >> device haven't been probed for at the time the zorro_driver for the
> >> first device is
> >> initialized.
> >>
> >> I expect this can be fixed by delaying all calls to device_register() in
> >> amiga_zorro_probe() until all devices have been detected and added to the array
> >> used by zorro_find_device(). But I was wondering whether there's a more generic
> >> way in the driver framework to bind a driver to two devices?
> >
> > What you really want is the same "driver instance" bound to two devices,
> > right? That way the device would operate "knowing" about both physical
> > devices so as to properly control the thing.
>
> Yes, that's what I want.
>
> > Right now, no, there's not a simple way to do this with the driver
> > model. USB does this on its own for some devices that need to have
> > multiple "interfaces" (the USB equalivant for a "device") controlled at
> > the same time, so you might want to look at how that happens (in the
> > indivdual drivers, not in the USB core.)
>
> Thanks, I'll have a look at the USB drivers.
> Do you know which examples to look at?
The drivers/usb/class/cdc-acm.c driver, in the acm_probe() function,
grabs the "control" and "data" interfaces. The logic is messy, due to
the wide variety of broken devices out there, but you should get the
general idea.
What's needed is for your bus to be able to provide you a pointer to any
device you want to find. PCI provides this, so you should be fine, and
should not have any problems.
Hope this helps,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-15 2:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-13 20:44 Driver framework: binding a driver to two devices? Geert Uytterhoeven
2011-08-14 17:38 ` Greg KH
2011-08-14 19:32 ` Geert Uytterhoeven
2011-08-15 2:20 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox