* [PATCH] 3w-xxxx: Add tw_sysfs_init() so udev will create /dev/twe* devices.
@ 2007-07-06 23:11 Joshua Daniel Franklin
2007-07-06 23:58 ` adam radford
0 siblings, 1 reply; 3+ messages in thread
From: Joshua Daniel Franklin @ 2007-07-06 23:11 UTC (permalink / raw)
To: linux-scsi; +Cc: linuxraid
[-- Attachment #1: Type: text/plain, Size: 484 bytes --]
Add tw_sysfs_init() to register 3w-xxxx driver with sysfs. This
also causes udev to create /dev/twe* devices with the correct
SELinux security context.
Signed-off-by: Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
---
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 174087252-3w-xxxx.patch --]
[-- Type: text/x-patch; name="3w-xxxx.patch", Size: 2536 bytes --]
--- 3w-xxxx.c.orig 2007-07-05 13:01:16.000000000 -0700
+++ 3w-xxxx.c 2007-07-06 15:32:08.000000000 -0700
@@ -194,6 +194,7 @@
1.26.02.002 - Free irq handler in __tw_shutdown().
Turn on RCD bit for caching mode page.
Serialize reset code.
+ 1.26.02.003 - Add tw_sysfs_init() so udev will create /dev/twe* devices.
*/
#include <linux/module.h>
@@ -217,11 +218,13 @@
#include "3w-xxxx.h"
/* Globals */
-#define TW_DRIVER_VERSION "1.26.02.002"
+#define TW_DRIVER_VERSION "1.26.02.003"
static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
static int tw_device_extension_count = 0;
static int twe_major = -1;
+static struct class *tw_sysfs_class;
+
/* Module parameters */
MODULE_AUTHOR("AMCC");
MODULE_DESCRIPTION("3ware Storage Controller Linux Driver");
@@ -1047,6 +1050,33 @@ static const struct file_operations tw_f
.release = NULL
};
+/* This function will create the twe* sysfs entries */
+static int tw_sysfs_init(void) {
+ int i;
+ struct class_device *tw_class_member;
+
+ twe_major = register_chrdev(0, "twe", &tw_fops);
+ if (twe_major < 0) {
+ printk(KERN_WARNING "3w-xxxx: Failed to register character device.\n");
+ return twe_major;
+ }
+ /* register twe* devices with sysfs */
+ tw_sysfs_class = class_create(THIS_MODULE, "twe");
+ if (IS_ERR(tw_sysfs_class)) {
+ printk(KERN_WARNING "3w-xxxx: Failed to create sysfs class.\n");
+ return PTR_ERR(tw_sysfs_class);
+ }
+
+ for(i = 0; i < TW_MAX_UNITS; i++) {
+ tw_class_member = class_device_create(tw_sysfs_class, NULL, MKDEV(twe_major,i), NULL, "twe%d",i);
+ if (IS_ERR(tw_class_member)) {
+ printk(KERN_WARNING "3w-xxxx: Unable to add sysfs class member twe%d\n", i);
+ return PTR_ERR(tw_class_member);
+ }
+ }
+ return 0;
+} /* End tw_sysfs_init() */
+
/* This function will free up device extension resources */
static void tw_free_device_extension(TW_Device_Extension *tw_dev)
{
@@ -2420,8 +2450,9 @@ static int __devinit tw_probe(struct pci
scsi_scan_host(host);
if (twe_major == -1) {
- if ((twe_major = register_chrdev (0, "twe", &tw_fops)) < 0)
- printk(KERN_WARNING "3w-xxxx: Failed to register character device.");
+ if (tw_sysfs_init() < 0) {
+ printk(KERN_WARNING "3w-xxxx: Failed to initialize sysfs for device.");
+ }
}
return 0;
@@ -2449,6 +2480,7 @@ static void tw_remove(struct pci_dev *pd
/* Unregister character device */
if (twe_major >= 0) {
unregister_chrdev(twe_major, "twe");
+ class_destroy(tw_sysfs_class);
twe_major = -1;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] 3w-xxxx: Add tw_sysfs_init() so udev will create /dev/twe* devices.
2007-07-06 23:11 [PATCH] 3w-xxxx: Add tw_sysfs_init() so udev will create /dev/twe* devices Joshua Daniel Franklin
@ 2007-07-06 23:58 ` adam radford
2007-07-07 1:58 ` Joshua Daniel Franklin
0 siblings, 1 reply; 3+ messages in thread
From: adam radford @ 2007-07-06 23:58 UTC (permalink / raw)
To: Joshua Daniel Franklin; +Cc: linux-scsi, linuxraid
On 7/6/07, Joshua Daniel Franklin <joshuadfranklin@yahoo.com> wrote:
> Add tw_sysfs_init() to register 3w-xxxx driver with sysfs. This
> also causes udev to create /dev/twe* devices with the correct
> SELinux security context.
>
> Signed-off-by: Joshua Daniel Franklin <joshuadfranklin@yahoo.com>
Thanks for the patch.
I have one problem with this patch:
You are calling "class_device_create()" from 0 to "TW_MAX_UNITS" which is 16...
shouldn't you be calling this only once per each controller instance
that is discovered
via twa_probe() ?
Also, no other scsi LLDD drivers are calling "class_device_create()",
so I wonder if
this is acceptable to scsi maintainers?
Right now we have our userspace tools creating the /dev/tweX devices.
-Adam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] 3w-xxxx: Add tw_sysfs_init() so udev will create /dev/twe* devices.
2007-07-06 23:58 ` adam radford
@ 2007-07-07 1:58 ` Joshua Daniel Franklin
0 siblings, 0 replies; 3+ messages in thread
From: Joshua Daniel Franklin @ 2007-07-07 1:58 UTC (permalink / raw)
To: linux-scsi, linuxraid
--- adam radford wrote:
> I have one problem with this patch:
>
> You are calling "class_device_create()" from 0 to "TW_MAX_UNITS"
> which is 16...
> shouldn't you be calling this only once per each controller instance
> that is discovered
> via twa_probe() ?
Well, I was just trying to emulate what the userspace tools do,
which is create all 16 devices whether or not they're physically
present. I actually tried with only twe0 (I have only one card in my
test system) and smartd seems to try to find twe1-15 anyway. I'm
not sure what it's doing, but I assume it's talking to the driver.
> Also, no other scsi LLDD drivers are calling "class_device_create()",
> so I wonder if
> this is acceptable to scsi maintainers?
I wondered the same thing. I think perhaps the only issue is with
SELinux mentioned below which is rare and so it's a low priority
to use sysfs. There may be other reasons I'm not aware of, though.
> Right now we have our userspace tools creating the /dev/tweX devices.
Yes, unfortunately that leaves the /dev/tweX devices with the
wrong SELinux security context and harald@redhat suggested this
approach:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232218
I'd be happy to hear alternative solutions, but it sounds like
they do not want to use a custom udev rule.
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-07 1:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-06 23:11 [PATCH] 3w-xxxx: Add tw_sysfs_init() so udev will create /dev/twe* devices Joshua Daniel Franklin
2007-07-06 23:58 ` adam radford
2007-07-07 1:58 ` Joshua Daniel Franklin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox