linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udev 092 with kernel 2.6.10?  (version neutral simple api)
@ 2007-03-02 17:34 Leisner, Martin
  2007-03-02 20:21 ` Greg KH
  2007-03-02 20:23 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Leisner, Martin @ 2007-03-02 17:34 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

After a number of gyrations, I got udev 092 working with 2.6.10 (and it
looks like its
working pretty good).

After running a number of udevs I found newer udevs have improved
logging/debugging 
facility over older udevs.  I found udevmonitor to be very useful.

Can someone explain why the API changed between various kernel versions?
(i.e. removed class_simple).

I wrapped the api changes into a header file and I ported some of the
ldd3 examples to udev...
I have a little tutorial on udev to pass around at work...

Writing device drivers to use udev seems very easy...but I had a great
deal of difficulty finding
a cookbook approach to "making udev work".

I found Dave Hawkins paper  at
http://www.ovro.caltech.edu/~dwh/correlator/pdf/LNX-723-Hawkins.pdf
very useful.

marty

[-- Attachment #2: class.pdf --]
[-- Type: application/octet-stream, Size: 109320 bytes --]

[-- Attachment #3: class.h --]
[-- Type: application/octet-stream, Size: 2116 bytes --]

#ifndef CLASS_H
#define CLASS_H




/* This is from Dave Hawkins dwh@ovro.caltech.edu
 * simple_driver.c
 *
 *
 *  2.6.9                       2.6.13
 *  class_simple_create         class_create
 *  class_simple_destroy        class_destroy
 *  class_simple_device_add     class_device_create
 *  class_simple_device_remove  class_device_destroy
 *
 * the only arguments that change are those to
 * class_device_destroy relative to class_simple_device_remove
 *
 * The APIs are not compatible, i.e., you have to use the
 * class_simple API in kernels earlier than 2.6.13.
 * You can test the compatibility in earlier kernels by
 * simply defining LINUX_VERSION_CODE to be KERNEL_VERSION(2,6,13)
 * and the driver will select the new API. The new API fails to
 * compile in the Centos 4.1 2.6.9-11 kernel.
 *
 * Kernel 2.6.14 added another argument to class_device_create.
 * ppdev.c sets it to NULL, so we can too.
 */


#include <linux/version.h>
#include <linux/module.h>
#include <linux/device.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)

typedef struct class_simple Device_class;

#define device_class_create(owner, name)	class_simple_create(owner, name);
#define device_class_add(class, devno, fmt, ...) class_simple_device_add(class, devno, NULL, fmt, ##__VA_ARGS__)

#define device_class_destroy(class)			class_simple_destroy(class)
// #define device_class_device_destroy(class, devno)	class_simple_device_remove(devno)

static inline void device_class_device_destroy(Device_class *class, int devno)
{
	class_simple_device_remove(devno);
}

#else
typedef struct class Device_class;

#define device_class_create(owner,name)		class_create(owner, name)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)

#define device_class_add(class, devno, fmt,...) class_device_create(class , devno, NULL, fmt, ##__VA_ARGS__)

#else
#define device_class_add(class, devno, fmt, ...) class_device_create(class, NULL, devno, NULL, fmt, ##__VA_ARGS__)
#endif

#define device_class_device_destroy(class, devno)	class_device_destroy(class, devno)
#define device_class_destroy(class)			class_destroy(class)

#endif


#endif



[-- Attachment #4: Type: text/plain, Size: 345 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #5: 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] 3+ messages in thread

* Re: udev 092 with kernel 2.6.10?  (version neutral simple api)
  2007-03-02 17:34 udev 092 with kernel 2.6.10? (version neutral simple api) Leisner, Martin
@ 2007-03-02 20:21 ` Greg KH
  2007-03-02 20:23 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2007-03-02 20:21 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Mar 02, 2007 at 12:34:21PM -0500, Leisner, Martin wrote:
> After a number of gyrations, I got udev 092 working with 2.6.10 (and it
> looks like its
> working pretty good).
> 
> After running a number of udevs I found newer udevs have improved
> logging/debugging 
> facility over older udevs.  I found udevmonitor to be very useful.
> 
> Can someone explain why the API changed between various kernel versions?
> (i.e. removed class_simple).

Internal kernel apis change all the time.  I changed this as the
"simple" stuff wasn't really necessary, in fact the whole class_device
stuff is being deprecated now, so I would not recommend using it
anymore.  Just use a struct device instead.

> I wrapped the api changes into a header file and I ported some of the
> ldd3 examples to udev...
> I have a little tutorial on udev to pass around at work...
> 
> Writing device drivers to use udev seems very easy...but I had a great
> deal of difficulty finding
> a cookbook approach to "making udev work".

There's two different things here, writing kernel code so that udev will
work properly, and getting udev to work in userspace.

If you are referring to the kernel code, just look at the
drivers/char/mem.c code for a very simple example of how to do this in
the chr_dev_init() function.

thanks,

greg k-h

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 3+ messages in thread

* Re: udev 092 with kernel 2.6.10?  (version neutral simple api)
  2007-03-02 17:34 udev 092 with kernel 2.6.10? (version neutral simple api) Leisner, Martin
  2007-03-02 20:21 ` Greg KH
@ 2007-03-02 20:23 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2007-03-02 20:23 UTC (permalink / raw)
  To: linux-hotplug

On Fri, Mar 02, 2007 at 12:34:21PM -0500, Leisner, Martin wrote:
> After a number of gyrations, I got udev 092 working with 2.6.10 (and it
> looks like its
> working pretty good).
> 
> After running a number of udevs I found newer udevs have improved
> logging/debugging 
> facility over older udevs.  I found udevmonitor to be very useful.
> 
> Can someone explain why the API changed between various kernel versions?
> (i.e. removed class_simple).
> 
> I wrapped the api changes into a header file and I ported some of the
> ldd3 examples to udev...
> I have a little tutorial on udev to pass around at work...

You are not allowing the parent pointer to be sent to the driver core,
which is one of the most important things to show for real devices.  You
want the topology information so that your code gets called properly for
suspend/resume, and so that userspace/udev can determine what specific
device your class device is associated with.

To just not allow this at all is missing a large portion of the
functionality of the driver core.

thanks,

greg k-h

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2007-03-02 20:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-02 17:34 udev 092 with kernel 2.6.10? (version neutral simple api) Leisner, Martin
2007-03-02 20:21 ` Greg KH
2007-03-02 20:23 ` Greg KH

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