* How does the driver initialize corresponding with several same devices ?
[not found] ` <CAFNq8R4dF+QPvPcy5+SSOBketAdzyJfJ6WonX0Z8OHztcvsYvA@mail.gmail.com>
@ 2012-04-18 9:16 ` Li Haifeng
2012-04-18 10:48 ` Philipp Ittershagen
2012-04-18 10:59 ` Javier Martinez Canillas
0 siblings, 2 replies; 7+ messages in thread
From: Li Haifeng @ 2012-04-18 9:16 UTC (permalink / raw)
To: kernelnewbies
I make a driver module and built in the kernel.?There are three devices use
the same driver on the hardware platform.?To use each device, the probe
function of the driver module should be probed. So, the driver module is
registered in the kernel.
My question is, how times should the probe function of the driver be called
and create nodes in devfs to corresponding with the three devices?
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
2012-04-18 9:16 ` How does the driver initialize corresponding with several same devices ? Li Haifeng
@ 2012-04-18 10:48 ` Philipp Ittershagen
[not found] ` <CAK7N6vpEL21SUMWk05ODDY+JE4gMDz7A17zfZDnsfU-=Nw6hiA@mail.gmail.com>
2012-04-18 10:59 ` Javier Martinez Canillas
1 sibling, 1 reply; 7+ messages in thread
From: Philipp Ittershagen @ 2012-04-18 10:48 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote:
> I make a driver module and built in the kernel.?There are three devices use
> the same driver on the hardware platform.?To use each device, the probe
> function of the driver module should be probed. So, the driver module is
> registered in the kernel.
>
> My question is, how times should the probe function of the driver be called
> and create nodes in devfs to corresponding with the three devices?
It depends on what your architecture supports. If you have support for device
tree, your entry in the device tree will make the subsystem call your probe
function for each device it finds. You can then check the `compatible` entry
of the device node and your driver is then able to register itself to the
kernel subsystem.
Greetings,
Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
2012-04-18 9:16 ` How does the driver initialize corresponding with several same devices ? Li Haifeng
2012-04-18 10:48 ` Philipp Ittershagen
@ 2012-04-18 10:59 ` Javier Martinez Canillas
2012-04-18 11:01 ` Javier Martinez Canillas
1 sibling, 1 reply; 7+ messages in thread
From: Javier Martinez Canillas @ 2012-04-18 10:59 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 18, 2012 at 11:16 AM, Li Haifeng <omycle@gmail.com> wrote:
> I make a driver module and built in the kernel.?There are three devices use
> the same driver on the hardware platform.?To use each device, the probe
> function of the driver module should be probed. So, the driver module is
> registered in the kernel.
>
> My question is, how times should the probe function of the driver be called
> and create nodes in devfs to corresponding with the three devices?
>
Your driver probe function has to be called only once. You should have
in your driver a software representation of each device and register
each one with the corresponding subsystem and with the kernel kernel
device model to populate /dev with your device nodes.
How do you represent your devices internally is up to you, it can be
assigned on your module init function as a static array or you can do
it dynamically using a linked list.
Look at any driver inside drivers/char for reference.
Hope it helps,
--
Javier Mart?nez Canillas
(+34) 682 39 81 69
Barcelona, Spain
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
2012-04-18 10:59 ` Javier Martinez Canillas
@ 2012-04-18 11:01 ` Javier Martinez Canillas
0 siblings, 0 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2012-04-18 11:01 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 18, 2012 at 12:59 PM, Javier Martinez Canillas
<martinez.javier@gmail.com> wrote:
> On Wed, Apr 18, 2012 at 11:16 AM, Li Haifeng <omycle@gmail.com> wrote:
>> I make a driver module and built in the kernel.?There are three devices use
>> the same driver on the hardware platform.?To use each device, the probe
>> function of the driver module should be probed. So, the driver module is
>> registered in the kernel.
>>
>> My question is, how times should the probe function of the driver be called
>> and create nodes in devfs to corresponding with the three devices?
>>
>
> Your driver probe function has to be called only once. You should have
> in your driver a software representation of each device and register
> each one with the corresponding subsystem and with the kernel kernel
> device model to populate /dev with your device nodes.
>
> How do you represent your devices internally is up to you, it can be
> assigned on your module init function as a static array or you can do
> it dynamically using a linked list.
>
> Look at any driver inside drivers/char for reference.
>
Sorry, didn't understand your question. Forget about my answer and
sorry for the noise :)
Regards,
--
Javier Mart?nez Canillas
(+34) 682 39 81 69
Barcelona, Spain
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
[not found] ` <CAK7N6vpEL21SUMWk05ODDY+JE4gMDz7A17zfZDnsfU-=Nw6hiA@mail.gmail.com>
@ 2012-04-18 11:07 ` Philipp Ittershagen
2012-04-18 11:11 ` anish singh
0 siblings, 1 reply; 7+ messages in thread
From: Philipp Ittershagen @ 2012-04-18 11:07 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 18, 2012 at 04:32:12PM +0530, anish singh wrote:
> On Wed, Apr 18, 2012 at 4:18 PM, Philipp Ittershagen
> <p.ittershagen@googlemail.com> wrote:
> > On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote:
> >> I make a driver module and built in the kernel.?There are three devices use
> >> the same driver on the hardware platform.?To use each device, the probe
> >> function of the driver module should be probed. So, the driver module is
> >> registered in the kernel.
> >>
> >> My question is, how times should the probe function of the driver be called
> >> and create nodes in devfs to corresponding with the three devices?
> >
> > It depends on what your architecture supports. If you have support for device
> > tree, your entry in the device tree will make the subsystem call your probe
> > function for each device it finds. You can then check the `compatible` entry
> > of the device node and your driver is then able to register itself to the
> > kernel subsystem.
> Without device tree what would be your answer as i guess device
> tree has come recently in picture but not sure.
Let me rephrase your question and see if I understand it correctly. You have a
probe function which already gets called for each device in your platform and
you want to know how to make each device accessible in userspace (using i.e.
devfs nodes) ?
Greetings,
Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
2012-04-18 11:07 ` Philipp Ittershagen
@ 2012-04-18 11:11 ` anish singh
2012-04-18 13:38 ` Li Haifeng
0 siblings, 1 reply; 7+ messages in thread
From: anish singh @ 2012-04-18 11:11 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 18, 2012 at 4:37 PM, Philipp Ittershagen
<p.ittershagen@googlemail.com> wrote:
> On Wed, Apr 18, 2012 at 04:32:12PM +0530, anish singh wrote:
>> On Wed, Apr 18, 2012 at 4:18 PM, Philipp Ittershagen
>> <p.ittershagen@googlemail.com> wrote:
>> > On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote:
>> >> I make a driver module and built in the kernel.?There are three devices use
>> >> the same driver on the hardware platform.?To use each device, the probe
>> >> function of the driver module should be probed. So, the driver module is
>> >> registered in the kernel.
>> >>
>> >> My question is, how times should the probe function of the driver be called
>> >> and create nodes in devfs to corresponding with the three devices?
>> >
>> > It depends on what your architecture supports. If you have support for device
>> > tree, your entry in the device tree will make the subsystem call your probe
>> > function for each device it finds. You can then check the `compatible` entry
>> > of the device node and your driver is then able to register itself to the
>> > kernel subsystem.
>> Without device tree what would be your answer as i guess device
>> tree has come recently in picture but not sure.
>
> Let me rephrase your question and see if I understand it correctly. You have a
> probe function which already gets called for each device in your platform and
> you want to know how to make each device accessible in userspace (using i.e.
> devfs nodes) ?
I think he wants to know how will he differentiate different devices as probe of
the driver will be called three times for all the devices.Right?
>
> Greetings,
>
> ?Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* How does the driver initialize corresponding with several same devices ?
2012-04-18 11:11 ` anish singh
@ 2012-04-18 13:38 ` Li Haifeng
0 siblings, 0 replies; 7+ messages in thread
From: Li Haifeng @ 2012-04-18 13:38 UTC (permalink / raw)
To: kernelnewbies
Thanks all of you.
I got it.
To platform driver, when it is registered by platform_driver_register,
system will walk though the platform bus and match each device with
driver. If there are several same device, all of these device will be
probed.
On Wed, Apr 18, 2012 at 7:11 PM, anish singh
<anish198519851985@gmail.com> wrote:
> On Wed, Apr 18, 2012 at 4:37 PM, Philipp Ittershagen
> <p.ittershagen@googlemail.com> wrote:
>> On Wed, Apr 18, 2012 at 04:32:12PM +0530, anish singh wrote:
>>> On Wed, Apr 18, 2012 at 4:18 PM, Philipp Ittershagen
>>> <p.ittershagen@googlemail.com> wrote:
>>> > On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote:
>>> >> I make a driver module and built in the kernel.?There are three devices use
>>> >> the same driver on the hardware platform.?To use each device, the probe
>>> >> function of the driver module should be probed. So, the driver module is
>>> >> registered in the kernel.
>>> >>
>>> >> My question is, how times should the probe function of the driver be called
>>> >> and create nodes in devfs to corresponding with the three devices?
>>> >
>>> > It depends on what your architecture supports. If you have support for device
>>> > tree, your entry in the device tree will make the subsystem call your probe
>>> > function for each device it finds. You can then check the `compatible` entry
>>> > of the device node and your driver is then able to register itself to the
>>> > kernel subsystem.
>>> Without device tree what would be your answer as i guess device
>>> tree has come recently in picture but not sure.
>>
>> Let me rephrase your question and see if I understand it correctly. You have a
>> probe function which already gets called for each device in your platform and
>> you want to know how to make each device accessible in userspace (using i.e.
>> devfs nodes) ?
> I think he wants to know how will he differentiate different devices as probe of
> the driver will be called three times for all the devices.Right?
>>
>> Greetings,
>>
>> ?Philipp
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-18 13:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAFNq8R4U-1c4ONn8EDZ7-ZgO2BC0r1JvsBxKsD1MeBzRndJr-w@mail.gmail.com>
[not found] ` <CAFNq8R4dF+QPvPcy5+SSOBketAdzyJfJ6WonX0Z8OHztcvsYvA@mail.gmail.com>
2012-04-18 9:16 ` How does the driver initialize corresponding with several same devices ? Li Haifeng
2012-04-18 10:48 ` Philipp Ittershagen
[not found] ` <CAK7N6vpEL21SUMWk05ODDY+JE4gMDz7A17zfZDnsfU-=Nw6hiA@mail.gmail.com>
2012-04-18 11:07 ` Philipp Ittershagen
2012-04-18 11:11 ` anish singh
2012-04-18 13:38 ` Li Haifeng
2012-04-18 10:59 ` Javier Martinez Canillas
2012-04-18 11:01 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).