2006-01-31 10:10:50

by Harald Welte

[permalink] [raw]
Subject: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

Hi!

Please apply this fix to the cm4000/4040 drivers, thanks!

[CM4000,CM4040] Add device class bits to enable udev device creation

Using this patch, Omnikey CardMan 4000 and 4040 devices automatically
get their device nodes created by udev.

Signed-off-by: Harald Welte <[email protected]>

---
commit 904a871a628c42031c3093c2b90bde526f0f35f0
tree fd05d26498ff86bf857331f270b7db13f4e077c0
parent 5b130c9da429fe28af1e59ce6589890f326cc182
author Harald Welte <[email protected]> Tue, 31 Jan 2006 11:08:33 +0100
committer Harald Welte <[email protected]> Tue, 31 Jan 2006 11:08:33 +0100

drivers/char/pcmcia/cm4000_cs.c | 14 +++++++++++++-
drivers/char/pcmcia/cm4040_cs.c | 13 ++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 649677b..d5cc5f3 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -56,7 +56,7 @@ module_param(pc_debug, int, 0600);
#else
#define DEBUGP(n, rdr, x, args...)
#endif
-static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
+static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";

#define T_1SEC (HZ)
#define T_10MSEC msecs_to_jiffies(10)
@@ -156,6 +156,7 @@ struct cm4000_dev {
/*queue*/ 4*sizeof(wait_queue_head_t))

static dev_link_t *dev_table[CM4000_MAX_DEV];
+static struct class *cmm_class;

/* This table doesn't use spaces after the comma between fields and thus
* violates CodingStyle. However, I don't really think wrapping it around will
@@ -1937,6 +1938,9 @@ static int cm4000_attach(struct pcmcia_d
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
cm4000_config(link, i);

+ class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
+ "cmm%d", i);
+
return 0;
}

@@ -1962,6 +1966,8 @@ static void cm4000_detach(struct pcmcia_
dev_table[devno] = NULL;
kfree(dev);

+ class_device_destroy(cmm_class, MKDEV(major, devno));
+
return;
}

@@ -1996,6 +2002,11 @@ static struct pcmcia_driver cm4000_drive
static int __init cmm_init(void)
{
printk(KERN_INFO "%s\n", version);
+
+ cmm_class = class_create(THIS_MODULE, "cmm");
+ if (!cmm_class)
+ return -1;
+
pcmcia_register_driver(&cm4000_driver);
major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
if (major < 0) {
@@ -2012,6 +2023,7 @@ static void __exit cmm_exit(void)
printk(KERN_INFO MODULE_NAME ": unloading\n");
pcmcia_unregister_driver(&cm4000_driver);
unregister_chrdev(major, DEVICE_NAME);
+ class_destroy(cmm_class);
};

module_init(cmm_init);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 46eb371..e907a7c 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -53,7 +53,7 @@ module_param(pc_debug, int, 0600);
#endif

static char *version =
-"OMNIKEY CardMan 4040 v1.1.0gm4 - All bugs added by Harald Welte";
+"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";

#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
@@ -67,6 +67,7 @@ static char *version =
static void reader_release(dev_link_t *link);

static int major;
+static struct class *cmx_class;

#define BS_READABLE 0x01
#define BS_WRITABLE 0x02
@@ -696,6 +697,9 @@ static int reader_attach(struct pcmcia_d
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
reader_config(link, i);

+ class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
+ "cmx%d", i);
+
return 0;
}

@@ -721,6 +725,8 @@ static void reader_detach(struct pcmcia_
dev_table[devno] = NULL;
kfree(dev);

+ class_device_destroy(cmx_class, MKDEV(major, devno));
+
return;
}

@@ -756,6 +762,10 @@ static struct pcmcia_driver reader_drive
static int __init cm4040_init(void)
{
printk(KERN_INFO "%s\n", version);
+ cmx_class = class_create(THIS_MODULE, "cmx");
+ if (!cmx_class)
+ return -1;
+
pcmcia_register_driver(&reader_driver);
major = register_chrdev(0, DEVICE_NAME, &reader_fops);
if (major < 0) {
@@ -771,6 +781,7 @@ static void __exit cm4040_exit(void)
printk(KERN_INFO MODULE_NAME ": unloading\n");
pcmcia_unregister_driver(&reader_driver);
unregister_chrdev(major, DEVICE_NAME);
+ class_destroy(cmx_class);
}

module_init(cm4040_init);
--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)


Attachments:
(No filename) (4.53 kB)
(No filename) (189.00 B)
Download all attachments

2006-02-01 02:10:12

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

Harald Welte <[email protected]> wrote:
>
> Please apply this fix to the cm4000/4040 drivers, thanks!
>
> [CM4000,CM4040] Add device class bits to enable udev device creation
>
> Using this patch, Omnikey CardMan 4000 and 4040 devices automatically
> get their device nodes created by udev.

Dominik has made quite widespread changes to these drivers - enough that
I'm not confident to fix the rejects, make it compile and hope that it
still works.

So can you please sort things out with Dominik? I guess a tested patch
against -mm4 would be ideal.

I note that these drivers forget to check for pcmcia_register_driver()
failure. That's a fairly good way of getting an oops in rmmod.

2006-02-01 09:17:51

by Harald Welte

[permalink] [raw]
Subject: Re: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

On Tue, Jan 31, 2006 at 10:59:32PM -0500, Dmitry Torokhov wrote:
> On Tuesday 31 January 2006 05:10, Harald Welte wrote:
> > @@ -756,6 +762,10 @@ static struct pcmcia_driver reader_drive
> > ?static int __init cm4040_init(void)
> > ?{
> > ????????printk(KERN_INFO "%s\n", version);
> > +???????cmx_class = class_create(THIS_MODULE, "cmx");
> > +???????if (!cmx_class)
> > +???????????????return -1;
> > +
> >
>
>
> Hi,
>
> What is "cmx" exactly? Can we have more descriptive name for a class,
> please?

'cmx' is the prefix of the device names, how the original vendor drivers
named their devices. 'cmm' in the cm4000 case is 'card man mobile'.
'cmx' is its successor, cm4040.

I'll rename the classes, thanks for your suggestion.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)


Attachments:
(No filename) (1.02 kB)
(No filename) (189.00 B)
Download all attachments

2006-02-14 08:05:46

by Harald Welte

[permalink] [raw]
Subject: Re: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

On Tue, Jan 31, 2006 at 06:09:27PM -0800, Andrew Morton wrote:
> Harald Welte <[email protected]> wrote:
> >
> > Please apply this fix to the cm4000/4040 drivers, thanks!
> >
> > [CM4000,CM4040] Add device class bits to enable udev device creation
> >
> > Using this patch, Omnikey CardMan 4000 and 4040 devices automatically
> > get their device nodes created by udev.
>
> Dominik has made quite widespread changes to these drivers - enough that
> I'm not confident to fix the rejects, make it compile and hope that it
> still works.

sorry for that. I honestly don't have the time to track two trees, and
I do all my development work against Linus' main tree, therefore my
patches are against that tree, too.

> So can you please sort things out with Dominik? I guess a tested patch
> against -mm4 would be ideal.

The question is: Why wouldn't my patch directly go mainline but rather
via -mm? It is a very special-purpose device, the number of users are
small, it clearly fixes the bug that no device nodes are created, and
the fix came from the original maintainer.

> I note that these drivers forget to check for pcmcia_register_driver()
> failure. That's a fairly good way of getting an oops in rmmod.

Thanks, I'll cook up a fix.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)


Attachments:
(No filename) (1.52 kB)
(No filename) (189.00 B)
Download all attachments

2006-02-14 08:17:30

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

Harald Welte <[email protected]> wrote:
>
> On Tue, Jan 31, 2006 at 06:09:27PM -0800, Andrew Morton wrote:
> > Harald Welte <[email protected]> wrote:
> > >
> > > Please apply this fix to the cm4000/4040 drivers, thanks!
> > >
> > > [CM4000,CM4040] Add device class bits to enable udev device creation
> > >
> > > Using this patch, Omnikey CardMan 4000 and 4040 devices automatically
> > > get their device nodes created by udev.
> >
> > Dominik has made quite widespread changes to these drivers - enough that
> > I'm not confident to fix the rejects, make it compile and hope that it
> > still works.
>
> sorry for that. I honestly don't have the time to track two trees, and
> I do all my development work against Linus' main tree, therefore my
> patches are against that tree, too.

Dominik maintains the pcmcia development tree, and these are
pcmcia drivers...

> > So can you please sort things out with Dominik? I guess a tested patch
> > against -mm4 would be ideal.
>
> The question is: Why wouldn't my patch directly go mainline but rather
> via -mm? It is a very special-purpose device, the number of users are
> small, it clearly fixes the bug that no device nodes are created, and
> the fix came from the original maintainer.

pcmcia patches should preferably go via the pcmcia development tree, and
get integrated and reviewed by the maintainer and all that good stuff.

So it wouldn't go via -mm at all - pcmcia only goes into -mm for testing.


The more specific point is that your patch conflicted with Dominik's
current development tree in a big way. That needs to get sorted out.

2006-02-14 08:30:22

by Harald Welte

[permalink] [raw]
Subject: Re: [PATCH] [CM4000,CM4040] Add device class bits to enable udev device creation

Thanks for helping me out, Andrew.

> Dominik maintains the pcmcia development tree, and these are
> pcmcia drivers...

ok, thanks for clarification. I'll locate his tree and prepare patches
against that tree.

--
- Harald Welte <[email protected]> http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)


Attachments:
(No filename) (517.00 B)
(No filename) (189.00 B)
Download all attachments