aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2005-12-12 12:03:44 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 19:18:09 -0500
commit263756ec228f1cdd49fc50b1f87001a4cebdfe12 (patch)
tree502925a94655348a768f25180e49126688100a8d /drivers/ide/ide.c
parentf743ca5e10f4145e0b3e6d11b9b46171e16af7ce (diff)
[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>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8af179b531c3..4b524f6b3ecd 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1904,9 +1904,69 @@ static int ide_bus_match(struct device *dev, struct device_driver *drv)
1904 return 1; 1904 return 1;
1905} 1905}
1906 1906
1907static char *media_string(ide_drive_t *drive)
1908{
1909 switch (drive->media) {
1910 case ide_disk:
1911 return "disk";
1912 case ide_cdrom:
1913 return "cdrom";
1914 case ide_tape:
1915 return "tape";
1916 case ide_floppy:
1917 return "floppy";
1918 default:
1919 return "UNKNOWN";
1920 }
1921}
1922
1923static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf)
1924{
1925 ide_drive_t *drive = to_ide_device(dev);
1926 return sprintf(buf, "%s\n", media_string(drive));
1927}
1928
1929static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf)
1930{
1931 ide_drive_t *drive = to_ide_device(dev);
1932 return sprintf(buf, "%s\n", drive->name);
1933}
1934
1935static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
1936{
1937 ide_drive_t *drive = to_ide_device(dev);
1938 return sprintf(buf, "ide:m-%s\n", media_string(drive));
1939}
1940
1941static struct device_attribute ide_dev_attrs[] = {
1942 __ATTR_RO(media),
1943 __ATTR_RO(drivename),
1944 __ATTR_RO(modalias),
1945 __ATTR_NULL
1946};
1947
1948static int ide_uevent(struct device *dev, char **envp, int num_envp,
1949 char *buffer, int buffer_size)
1950{
1951 ide_drive_t *drive = to_ide_device(dev);
1952 int i = 0;
1953 int length = 0;
1954
1955 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1956 "MEDIA=%s", media_string(drive));
1957 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1958 "DRIVENAME=%s", drive->name);
1959 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1960 "MODALIAS=ide:m-%s", media_string(drive));
1961 envp[i] = NULL;
1962 return 0;
1963}
1964
1907struct bus_type ide_bus_type = { 1965struct bus_type ide_bus_type = {
1908 .name = "ide", 1966 .name = "ide",
1909 .match = ide_bus_match, 1967 .match = ide_bus_match,
1968 .uevent = ide_uevent,
1969 .dev_attrs = ide_dev_attrs,
1910 .suspend = generic_ide_suspend, 1970 .suspend = generic_ide_suspend,
1911 .resume = generic_ide_resume, 1971 .resume = generic_ide_resume,
1912}; 1972};