patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / firmware / edd.c
index ac2246d..40257f7 100644 (file)
@@ -15,9 +15,8 @@
  * made in setup.S, copied to safe structures in setup.c,
  * and presents it in sysfs.
  *
- * Please see http://domsch.com/linux/edd30/results.html for
+ * Please see http://linux.dell.com/edd30/results.html for
  * the list of BIOSs which have been reported to implement EDD.
- * If you don't see yours listed, please send a report as described there.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License v2.0 as published by
  *
  */
 
-/*
- * Known issues:
- * - refcounting of struct device objects could be improved.
- *
- * TODO:
- * - Add IDE and USB disk device support
- * - move edd.[ch] to better locations if/when one is decided
- */
-
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/limits.h>
 #include <linux/device.h>
 #include <linux/pci.h>
-#include <linux/device.h>
 #include <linux/blkdev.h>
 #include <linux/edd.h>
-/* FIXME - this really belongs in include/scsi/scsi.h */
-#include <../drivers/scsi/scsi.h>
-#include <../drivers/scsi/hosts.h>
+
+#define EDD_VERSION "0.15"
+#define EDD_DATE    "2004-May-17"
 
 MODULE_AUTHOR("Matt Domsch <Matt_Domsch@Dell.com>");
 MODULE_DESCRIPTION("sysfs interface to BIOS EDD information");
 MODULE_LICENSE("GPL");
-
-#define EDD_VERSION "0.13 2004-Mar-09"
-#define EDD_DEVICE_NAME_SIZE 16
-#define REPORT_URL "http://linux.dell.com/edd/results.html"
+MODULE_VERSION(EDD_VERSION);
 
 #define left (PAGE_SIZE - (p - buf) - 1)
 
@@ -334,7 +320,7 @@ edd_show_info_flags(struct edd_device *edev, char *buf)
 }
 
 static ssize_t
-edd_show_legacy_cylinders(struct edd_device *edev, char *buf)
+edd_show_legacy_max_cylinder(struct edd_device *edev, char *buf)
 {
        struct edd_info *info;
        char *p = buf;
@@ -344,12 +330,12 @@ edd_show_legacy_cylinders(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += snprintf(p, left, "0x%x\n", info->legacy_cylinders);
+       p += snprintf(p, left, "%u\n", info->legacy_max_cylinder);
        return (p - buf);
 }
 
 static ssize_t
-edd_show_legacy_heads(struct edd_device *edev, char *buf)
+edd_show_legacy_max_head(struct edd_device *edev, char *buf)
 {
        struct edd_info *info;
        char *p = buf;
@@ -359,12 +345,12 @@ edd_show_legacy_heads(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += snprintf(p, left, "0x%x\n", info->legacy_heads);
+       p += snprintf(p, left, "%u\n", info->legacy_max_head);
        return (p - buf);
 }
 
 static ssize_t
-edd_show_legacy_sectors(struct edd_device *edev, char *buf)
+edd_show_legacy_sectors_per_track(struct edd_device *edev, char *buf)
 {
        struct edd_info *info;
        char *p = buf;
@@ -374,7 +360,7 @@ edd_show_legacy_sectors(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += snprintf(p, left, "0x%x\n", info->legacy_sectors);
+       p += snprintf(p, left, "%u\n", info->legacy_sectors_per_track);
        return (p - buf);
 }
 
@@ -389,7 +375,7 @@ edd_show_default_cylinders(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += scnprintf(p, left, "0x%x\n", info->params.num_default_cylinders);
+       p += scnprintf(p, left, "%u\n", info->params.num_default_cylinders);
        return (p - buf);
 }
 
@@ -404,7 +390,7 @@ edd_show_default_heads(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += scnprintf(p, left, "0x%x\n", info->params.num_default_heads);
+       p += scnprintf(p, left, "%u\n", info->params.num_default_heads);
        return (p - buf);
 }
 
@@ -419,7 +405,7 @@ edd_show_default_sectors_per_track(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += scnprintf(p, left, "0x%x\n", info->params.sectors_per_track);
+       p += scnprintf(p, left, "%u\n", info->params.sectors_per_track);
        return (p - buf);
 }
 
@@ -434,7 +420,7 @@ edd_show_sectors(struct edd_device *edev, char *buf)
        if (!info || !buf)
                return -EINVAL;
 
-       p += scnprintf(p, left, "0x%llx\n", info->params.number_of_sectors);
+       p += scnprintf(p, left, "%llu\n", info->params.number_of_sectors);
        return (p - buf);
 }
 
@@ -450,7 +436,7 @@ edd_show_sectors(struct edd_device *edev, char *buf)
  */
 
 static int
-edd_has_legacy_cylinders(struct edd_device *edev)
+edd_has_legacy_max_cylinder(struct edd_device *edev)
 {
        struct edd_info *info;
        if (!edev)
@@ -458,11 +444,11 @@ edd_has_legacy_cylinders(struct edd_device *edev)
        info = edd_dev_get_info(edev);
        if (!info)
                return -EINVAL;
-       return info->legacy_cylinders > 0;
+       return info->legacy_max_cylinder > 0;
 }
 
 static int
-edd_has_legacy_heads(struct edd_device *edev)
+edd_has_legacy_max_head(struct edd_device *edev)
 {
        struct edd_info *info;
        if (!edev)
@@ -470,11 +456,11 @@ edd_has_legacy_heads(struct edd_device *edev)
        info = edd_dev_get_info(edev);
        if (!info)
                return -EINVAL;
-       return info->legacy_heads > 0;
+       return info->legacy_max_head > 0;
 }
 
 static int
-edd_has_legacy_sectors(struct edd_device *edev)
+edd_has_legacy_sectors_per_track(struct edd_device *edev)
 {
        struct edd_info *info;
        if (!edev)
@@ -482,7 +468,7 @@ edd_has_legacy_sectors(struct edd_device *edev)
        info = edd_dev_get_info(edev);
        if (!info)
                return -EINVAL;
-       return info->legacy_sectors > 0;
+       return info->legacy_sectors_per_track > 0;
 }
 
 static int
@@ -569,12 +555,14 @@ static EDD_DEVICE_ATTR(version, 0444, edd_show_version, NULL);
 static EDD_DEVICE_ATTR(extensions, 0444, edd_show_extensions, NULL);
 static EDD_DEVICE_ATTR(info_flags, 0444, edd_show_info_flags, NULL);
 static EDD_DEVICE_ATTR(sectors, 0444, edd_show_sectors, NULL);
-static EDD_DEVICE_ATTR(legacy_cylinders, 0444, edd_show_legacy_cylinders,
-                      edd_has_legacy_cylinders);
-static EDD_DEVICE_ATTR(legacy_heads, 0444, edd_show_legacy_heads,
-                      edd_has_legacy_heads);
-static EDD_DEVICE_ATTR(legacy_sectors, 0444, edd_show_legacy_sectors,
-                      edd_has_legacy_sectors);
+static EDD_DEVICE_ATTR(legacy_max_cylinder, 0444,
+                       edd_show_legacy_max_cylinder,
+                      edd_has_legacy_max_cylinder);
+static EDD_DEVICE_ATTR(legacy_max_head, 0444, edd_show_legacy_max_head,
+                      edd_has_legacy_max_head);
+static EDD_DEVICE_ATTR(legacy_sectors_per_track, 0444,
+                       edd_show_legacy_sectors_per_track,
+                      edd_has_legacy_sectors_per_track);
 static EDD_DEVICE_ATTR(default_cylinders, 0444, edd_show_default_cylinders,
                       edd_has_default_cylinders);
 static EDD_DEVICE_ATTR(default_heads, 0444, edd_show_default_heads,
@@ -601,9 +589,9 @@ static struct attribute * def_attrs[] = {
 
 /* These attributes are conditional and only added for some devices. */
 static struct edd_attribute * edd_attrs[] = {
-       &edd_attr_legacy_cylinders,
-       &edd_attr_legacy_heads,
-       &edd_attr_legacy_sectors,
+       &edd_attr_legacy_max_cylinder,
+       &edd_attr_legacy_max_head,
+       &edd_attr_legacy_sectors_per_track,
        &edd_attr_default_cylinders,
        &edd_attr_default_heads,
        &edd_attr_default_sectors_per_track,
@@ -690,103 +678,6 @@ edd_create_symlink_to_pcidev(struct edd_device *edev)
        return sysfs_create_link(&edev->kobj,&pci_dev->dev.kobj,"pci_dev");
 }
 
-/*
- * FIXME - as of 15-Jan-2003, there are some non-"scsi_device"s on the
- * scsi_bus list.  The following functions could possibly mis-access
- * memory in that case.  This is actually a problem with the SCSI
- * layer, which is being addressed there.  Until then, don't use the
- * SCSI functions.
- */
-
-#undef CONFIG_SCSI
-#undef CONFIG_SCSI_MODULE
-#if defined(CONFIG_SCSI) || defined(CONFIG_SCSI_MODULE)
-
-struct edd_match_data {
-       struct edd_device       * edev;
-       struct scsi_device      * sd;
-};
-
-/**
- * edd_match_scsidev()
- * @edev - EDD device is a known SCSI device
- * @sd - scsi_device with host who's parent is a PCI controller
- *
- * returns 1 if a match is found, 0 if not.
- */
-static int edd_match_scsidev(struct device * dev, void * d)
-{
-       struct edd_match_data * data = (struct edd_match_data *)d;
-       struct edd_info *info = edd_dev_get_info(data->edev);
-       struct scsi_device * sd = to_scsi_device(dev);
-
-       if (info) {
-               if ((sd->channel == info->params.interface_path.pci.channel) &&
-                   (sd->id == info->params.device_path.scsi.id) &&
-                   (sd->lun == info->params.device_path.scsi.lun)) {
-                       data->sd = sd;
-                       return 1;
-               }
-       }
-       return 0;
-}
-
-/**
- * edd_find_matching_device()
- * @edev - edd_device to match
- *
- * Search the SCSI devices for a drive that matches the EDD
- * device descriptor we have. If we find a match, return it,
- * otherwise, return NULL.
- */
-
-static struct scsi_device *
-edd_find_matching_scsi_device(struct edd_device *edev)
-{
-       struct edd_match_data data;
-       struct bus_type * scsi_bus = find_bus("scsi");
-
-       if (!scsi_bus) {
-               return NULL;
-       }
-
-       data.edev = edev;
-
-       if (edd_dev_is_type(edev, "SCSI")) {
-               if (bus_for_each_dev(scsi_bus,NULL,&data,edd_match_scsidev))
-                       return data.sd;
-       }
-       return NULL;
-}
-
-static int
-edd_create_symlink_to_scsidev(struct edd_device *edev)
-{
-       struct pci_dev *pci_dev;
-       int rc = -EINVAL;
-
-       pci_dev = edd_get_pci_dev(edev);
-       if (pci_dev) {
-               struct scsi_device * sdev = edd_find_matching_scsi_device(edev);
-               if (sdev && get_device(&sdev->sdev_driverfs_dev)) {
-                       rc = sysfs_create_link(&edev->kobj,
-                                              &sdev->sdev_driverfs_dev.kobj,
-                                              "disc");
-                       put_device(&sdev->sdev_driverfs_dev);
-               }
-       }
-       return rc;
-}
-
-#else
-static int
-edd_create_symlink_to_scsidev(struct edd_device *edev)
-{
-       return -ENOSYS;
-}
-#endif
-
-
 static inline void
 edd_device_unregister(struct edd_device *edev)
 {
@@ -807,7 +698,6 @@ static void edd_populate_dir(struct edd_device * edev)
 
        if (!error) {
                edd_create_symlink_to_pcidev(edev);
-               edd_create_symlink_to_scsidev(edev);
        }
 }
 
@@ -820,8 +710,8 @@ edd_device_register(struct edd_device *edev, int i)
                return 1;
        memset(edev, 0, sizeof (*edev));
        edd_dev_set_info(edev, &edd[i]);
-       snprintf(edev->kobj.name, EDD_DEVICE_NAME_SIZE, "int13_dev%02x",
-                edd[i].device);
+       kobject_set_name(&edev->kobj, "int13_dev%02x",
+                        edd[i].device);
        kobj_set_kset_s(edev,edd_subsys);
        error = kobject_register(&edev->kobj);
        if (!error)
@@ -842,9 +732,8 @@ edd_init(void)
        int rc=0;
        struct edd_device *edev;
 
-       printk(KERN_INFO "BIOS EDD facility v%s, %d devices found\n",
-              EDD_VERSION, eddnr);
-       printk(KERN_INFO "Please report your BIOS at %s\n", REPORT_URL);
+       printk(KERN_INFO "BIOS EDD facility v%s %s, %d devices found\n",
+              EDD_VERSION, EDD_DATE, eddnr);
 
        if (!eddnr) {
                printk(KERN_INFO "EDD information not available.\n");