linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Pci driver and udev...
@ 2006-11-06 16:31 Kris van Rens
  2006-11-07  8:14 ` Greg KH
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Kris van Rens @ 2006-11-06 16:31 UTC (permalink / raw)
  To: linux-hotplug

Hi there,

I'm upgrading an 'old' pci-character-device-driver to use udev for
dynamic device file assignment. I was used to working with
'register_chrdev' but that function should not be used anymore because
it's old.

So I decided to go for the 'new-style' 'cdev' way.

I made a simple testdriver which uses 'pci_register_driver' and the
corresponding functions to register the driver; this works fine and
after a depmod the driver is automatically loaded at boot time
(triggered by the found vendor-/device-id combination of course).

Then I added the 'cdev' part and...well, actually nothing happened...
cdev_init() exits with returnvalue 0 and such but I actually expected
udev to be triggered and create a device file.

So I assume the cdev stuff is just for 'internal' registration of the
character device and something else should be used to tell udev a new
device is there? So I found the part about udev and 'class_simple_*'
in the ldd3 book but that was deleted from the kernel.

As I understand it was replaced by the better version of 'class' but I
kind of lost in all the functions in base/class.c...

Can someone enlighten me?

Thanks in advance,

-Kris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
@ 2006-11-07  8:14 ` Greg KH
  2006-11-07  8:38 ` Kris van Rens
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2006-11-07  8:14 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Nov 06, 2006 at 05:31:02PM +0100, Kris van Rens wrote:
> So I assume the cdev stuff is just for 'internal' registration of the
> character device and something else should be used to tell udev a new
> device is there?

Yes, that is true.

> So I found the part about udev and 'class_simple_*' in the ldd3 book
> but that was deleted from the kernel.
> 
> As I understand it was replaced by the better version of 'class' but I
> kind of lost in all the functions in base/class.c...
> 
> Can someone enlighten me?

class_device_create() is what you should look at.  Actually, I'd
recommend just using device_create() with a class instead, it's what I'm
converting the kernel to use in all places for class_device_create().

thanks,

greg k-h

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
  2006-11-07  8:14 ` Greg KH
@ 2006-11-07  8:38 ` Kris van Rens
  2006-11-08 11:14 ` Kris van Rens
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kris van Rens @ 2006-11-07  8:38 UTC (permalink / raw)
  To: linux-hotplug

Greg KH wrote:
> class_device_create() is what you should look at.  Actually, I'd
> recommend just using device_create() with a class instead, it's what I'm
> converting the kernel to use in all places for class_device_create().

Thank you very much!

And then the backwards compatibility; I guess it will work with kernel versions 2.6.13 (when you came with 'the massive set of driver core patches') and higher.

-Kris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
  2006-11-07  8:14 ` Greg KH
  2006-11-07  8:38 ` Kris van Rens
@ 2006-11-08 11:14 ` Kris van Rens
  2006-11-08 14:10 ` Kris van Rens
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kris van Rens @ 2006-11-08 11:14 UTC (permalink / raw)
  To: linux-hotplug

Hi,

On 11/7/06, Greg KH <greg@kroah.com> wrote:
> class_device_create() is what you should look at.  Actually, I'd
> recommend just using device_create() with a class instead, it's what I'm
> converting the kernel to use in all places for class_device_create().

Ok, I found 'device_create()' to be available as of kernel 2.6.18 but
because we cannot require our customers to be _that_ up-to-date with
Linux kernels, I decided to go for 'class_device_create()' for now.

Here's what I added to my pci-driver:

A global:
---
   static struct class *pcitest_class;
---

In the __init function:
---
   pcitest_class = class_create( THIS_MODULE, pcitest );
   if( IS_ERR( pcitest_class ) ) { ... }
---

In the __exit function:
---
   class_destroy( pcitest_class );
---

In the probe function:
---
   struct class_device *pclass;
   pclass = class_device_create( pcitest_class, NULL, MKDEV( major,
minor + index), NULL, "pcitest-%d", index );
   if( IS_ERR( pclass ) ) { ... }
---

In the remove function:
---
   class_device_destroy( pcitest_class, MKDEV( major, minor + index) );
---

But unfortunately I run into an error at the 'class_device_create()'
call. The pcitest class is created in /sys/class but
'class_device_create()' throws error 18 ( EXDEV i.e. Cross-device link
).

I searched throught the code of similar character device drivers using
'class_device_create()' but I cannot find what I do wrong. Maybe I'm
missing something here?

Thanks.

-Kris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
                   ` (2 preceding siblings ...)
  2006-11-08 11:14 ` Kris van Rens
@ 2006-11-08 14:10 ` Kris van Rens
  2006-11-08 17:32 ` Bryan Kadzban
  2006-11-08 18:22 ` Kris van Rens
  5 siblings, 0 replies; 7+ messages in thread
From: Kris van Rens @ 2006-11-08 14:10 UTC (permalink / raw)
  To: linux-hotplug

On 11/8/06, Kris van Rens <krisvanrens.list@gmail.com> wrote:
> But unfortunately I run into an error at the 'class_device_create()'
> call. The pcitest class is created in /sys/class but
> 'class_device_create()' throws error 18 ( EXDEV i.e. Cross-device link

Mmm...I know there's an error because I print the pointer in the if clause of:

---
  struct class_device *pclass;
  pclass = class_device_create( pcitest_class, NULL, MKDEV( major,
minor + index), NULL, "pcitest-%d", index );
  if( IS_ERR( pclass ) ) { ... }
---

The pointer value is 0xFFFFFFED; thus -0x00000012 = -18 decimal (=
-EXDEV according to errno-base.h).

A search on 'EXDEV' through the kernel sources left me with references
in 21 files, of which none seems to be affiliated with the creation of
a class_device...

Hmmm

-Kris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
                   ` (3 preceding siblings ...)
  2006-11-08 14:10 ` Kris van Rens
@ 2006-11-08 17:32 ` Bryan Kadzban
  2006-11-08 18:22 ` Kris van Rens
  5 siblings, 0 replies; 7+ messages in thread
From: Bryan Kadzban @ 2006-11-08 17:32 UTC (permalink / raw)
  To: linux-hotplug


[-- Attachment #1.1: Type: text/plain, Size: 469 bytes --]

On Wed, Nov 08, 2006 at 03:10:41PM +0100, Kris van Rens wrote:
> The pointer value is 0xFFFFFFED; thus -0x00000012 == -18 decimal (==
> -EXDEV according to errno-base.h).

Er, 0xFFFFFFED is not -0x12, it's -0x13.  (To translate between unsigned
and signed two's complement numbers: If the sign bit is set, bitwise-NOT
the value, *then add one*.  The result is negative this value.)

-0x13 is -19 decimal, which is -ENODEV.  Perhaps that will give better
insight.  :-)


[-- Attachment #1.2: Type: application/pgp-signature, Size: 191 bytes --]

[-- Attachment #2: Type: text/plain, Size: 373 bytes --]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

[-- Attachment #3: Type: text/plain, Size: 226 bytes --]

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Pci driver and udev...
  2006-11-06 16:31 Pci driver and udev Kris van Rens
                   ` (4 preceding siblings ...)
  2006-11-08 17:32 ` Bryan Kadzban
@ 2006-11-08 18:22 ` Kris van Rens
  5 siblings, 0 replies; 7+ messages in thread
From: Kris van Rens @ 2006-11-08 18:22 UTC (permalink / raw)
  To: linux-hotplug

Bryan Kadzban wrote:
> Er, 0xFFFFFFED is not -0x12, it's -0x13.  (To translate between unsigned
> and signed two's complement numbers: If the sign bit is set, bitwise-NOT
> the value, *then add one*.  The result is negative this value.)
> 
> -0x13 is -19 decimal, which is -ENODEV.  Perhaps that will give better
> insight.  :-)

Ah...yes, you're right...Why didn't I think of that? I was totally focused on decimal negation...bleh

Thanks for helping me out of this 'locked state'.

-Kris

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x120709&bid&3057&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2006-11-08 18:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-06 16:31 Pci driver and udev Kris van Rens
2006-11-07  8:14 ` Greg KH
2006-11-07  8:38 ` Kris van Rens
2006-11-08 11:14 ` Kris van Rens
2006-11-08 14:10 ` Kris van Rens
2006-11-08 17:32 ` Bryan Kadzban
2006-11-08 18:22 ` Kris van Rens

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).