From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: kay.sievers@vrfy.org
Subject: [PATCH] ide: MODALIAS support for autoloading of ide-cd, ide-disk, ...
Date: Wed, 4 Jan 2006 16:49:30 -0800 [thread overview]
Message-ID: <11364221702858@kroah.com> (raw)
In-Reply-To: <11364221703787@kroah.com>
[PATCH] ide: MODALIAS support for autoloading of ide-cd, ide-disk, ...
IDE: MODALIAS support for autoloading of ide-cd, ide-disk, ...
Add MODULE_ALIAS to IDE midlayer modules: ide-disk, ide-cd, ide-floppy and
ide-tape, to autoload these modules depending on the probed media type of
the IDE device.
It is used by udev and replaces the former agent shell script of the hotplug
package, which was required to lookup the media type in the proc filesystem.
Using proc was racy, cause the media file is created after the hotplug event
is sent out.
The module autoloading does not take any effect, until something like the
following udev rule is configured:
SUBSYSTEM=="ide", ACTION=="add", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}"
The module ide-scsi will not be autoloaded, cause it requires manual
configuration. It can't be, and never was supported for automatic setup in
the hotplug package. Adding a MODULE_ALIAS to ide-scsi for all supported
media types, would just lead to a default blacklist entry anyway.
$ modinfo ide-disk
filename: /lib/modules/2.6.15-rc4-g1b0997f5/kernel/drivers/ide/ide-disk.ko
description: ATA DISK Driver
alias: ide:*m-disk*
license: GPL
...
$ modprobe -vn ide:m-disk
insmod /lib/modules/2.6.15-rc4-g1b0997f5/kernel/drivers/ide/ide-disk.ko
$ cat /sys/bus/ide/devices/0.0/modalias
ide:m-disk
It also adds attributes to the IDE device:
$ tree /sys/bus/ide/devices/0.0/
/sys/bus/ide/devices/0.0/
|-- bus -> ../../../../../../../bus/ide
|-- drivename
|-- media
|-- modalias
|-- power
| |-- state
| `-- wakeup
`-- uevent
$ cat /sys/bus/ide/devices/0.0/{modalias,drivename,media}
ide:m-disk
hda
disk
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
commit 263756ec228f1cdd49fc50b1f87001a4cebdfe12
tree 502925a94655348a768f25180e49126688100a8d
parent f743ca5e10f4145e0b3e6d11b9b46171e16af7ce
author Kay Sievers <kay.sievers@vrfy.org> Mon, 12 Dec 2005 18:03:44 +0100
committer Greg Kroah-Hartman <gregkh@suse.de> Wed, 04 Jan 2006 16:18:09 -0800
drivers/ide/ide-cd.c | 1 +
drivers/ide/ide-disk.c | 1 +
drivers/ide/ide-floppy.c | 1 +
drivers/ide/ide-tape.c | 1 +
drivers/ide/ide.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index b4d7a3e..70aeb3a 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3509,6 +3509,7 @@ static int __init ide_cdrom_init(void)
return driver_register(&ide_cdrom_driver.gen_driver);
}
+MODULE_ALIAS("ide:*m-cdrom*");
module_init(ide_cdrom_init);
module_exit(ide_cdrom_exit);
MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 449522f..4e57679 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1271,6 +1271,7 @@ static int __init idedisk_init(void)
return driver_register(&idedisk_driver.gen_driver);
}
+MODULE_ALIAS("ide:*m-disk*");
module_init(idedisk_init);
module_exit(idedisk_exit);
MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 9e293c8..fba3fff 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2197,6 +2197,7 @@ static int __init idefloppy_init(void)
return driver_register(&idefloppy_driver.gen_driver);
}
+MODULE_ALIAS("ide:*m-floppy*");
module_init(idefloppy_init);
module_exit(idefloppy_exit);
MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 7d7944e..fab9b2b 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4947,6 +4947,7 @@ out:
return error;
}
+MODULE_ALIAS("ide:*m-tape*");
module_init(idetape_init);
module_exit(idetape_exit);
MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8af179b..4b524f6 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1904,9 +1904,69 @@ static int ide_bus_match(struct device *
return 1;
}
+static char *media_string(ide_drive_t *drive)
+{
+ switch (drive->media) {
+ case ide_disk:
+ return "disk";
+ case ide_cdrom:
+ return "cdrom";
+ case ide_tape:
+ return "tape";
+ case ide_floppy:
+ return "floppy";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ ide_drive_t *drive = to_ide_device(dev);
+ return sprintf(buf, "%s\n", media_string(drive));
+}
+
+static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ ide_drive_t *drive = to_ide_device(dev);
+ return sprintf(buf, "%s\n", drive->name);
+}
+
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ ide_drive_t *drive = to_ide_device(dev);
+ return sprintf(buf, "ide:m-%s\n", media_string(drive));
+}
+
+static struct device_attribute ide_dev_attrs[] = {
+ __ATTR_RO(media),
+ __ATTR_RO(drivename),
+ __ATTR_RO(modalias),
+ __ATTR_NULL
+};
+
+static int ide_uevent(struct device *dev, char **envp, int num_envp,
+ char *buffer, int buffer_size)
+{
+ ide_drive_t *drive = to_ide_device(dev);
+ int i = 0;
+ int length = 0;
+
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "MEDIA=%s", media_string(drive));
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "DRIVENAME=%s", drive->name);
+ add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+ "MODALIAS=ide:m-%s", media_string(drive));
+ envp[i] = NULL;
+ return 0;
+}
+
struct bus_type ide_bus_type = {
.name = "ide",
.match = ide_bus_match,
+ .uevent = ide_uevent,
+ .dev_attrs = ide_dev_attrs,
.suspend = generic_ide_suspend,
.resume = generic_ide_resume,
};
next prev parent reply other threads:[~2006-01-05 0:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-05 0:48 [GIT PATCH] Driver Core patches for 2.6.15 Greg KH
2006-01-05 0:49 ` [PATCH] remove CONFIG_KOBJECT_UEVENT option Greg KH
2006-01-05 0:49 ` [PATCH] remove mount/umount uevents from superblock handling Greg KH
2006-01-05 0:49 ` [PATCH] keep pnpbios usermod_helper away from hotplug_path[] Greg KH
2006-01-05 0:49 ` [PATCH] add uevent_helper control in /sys/kernel/ Greg KH
2006-01-05 0:49 ` [PATCH] merge kobject_uevent and kobject_hotplug Greg KH
2006-01-05 0:49 ` [PATCH] driver core: replace "hotplug" by "uevent" Greg KH
2006-01-05 0:49 ` [PATCH] driver kill hotplug word from sn and others fix Greg KH
2006-01-05 0:49 ` [PATCH] HOTPLUG: always enable the .config option, unless EMBEDDED Greg KH
2006-01-05 0:49 ` [PATCH] Hold the device's parent's lock during probe and remove Greg KH
2006-01-05 0:49 ` [PATCH] Allow overlapping resources for platform devices Greg KH
2006-01-05 0:49 ` [PATCH] klist: Fix broken kref counting in find functions Greg KH
2006-01-05 0:49 ` [PATCH] kobject_uevent CONFIG_NET=n fix Greg KH
2006-01-05 0:49 ` [PATCH] Input: add modalias support Greg KH
2006-01-05 0:49 ` Greg KH [this message]
2006-01-05 0:49 ` [PATCH] Driver core: Make block devices create the proper symlink name Greg KH
2006-01-05 0:49 ` [PATCH] Driver core: only all userspace bind/unbind if CONFIG_HOTPLUG is enabled Greg KH
2006-01-05 0:49 ` [PATCH] Driver Core: Add platform_device_del() Greg KH
2006-01-05 0:49 ` [PATCH] Driver Core: Rearrange exports in platform.c Greg KH
2006-01-05 0:49 ` [PATCH] Input: fix add modalias support build error Greg KH
2006-01-05 0:49 ` [PATCH] sysfs: handle failures in sysfs_make_dirent Greg KH
2006-01-05 0:49 ` [PATCH] drivers/base/power/runtime.c: #if 0 dpm_set_power_state() Greg KH
2006-01-05 0:49 ` [PATCH] net: swich device attribute creation to default attrs Greg KH
2006-01-05 1:38 ` [GIT PATCH] Driver Core patches for 2.6.15 Linus Torvalds
2006-01-05 2:07 ` Greg KH
2006-01-05 2:40 ` Linus Torvalds
2006-01-05 3:31 ` Greg KH
2006-01-05 3:36 ` Linus Torvalds
2006-01-05 3:44 ` devfs going away, last chance to complain (was Re: [GIT PATCH] Driver Core patches for 2.6.15) Greg KH
2006-01-05 7:44 ` Steven Noonan
2006-01-05 9:17 ` Andrew Walrond
2006-01-05 9:18 ` Kyle Moffett
2006-01-05 14:04 ` [GIT PATCH] Driver Core patches for 2.6.15 John Stoffel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11364221702858@kroah.com \
--to=gregkh@suse.de \
--cc=greg@kroah.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox