]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/base/power/trace.c
Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl
[mv-sheeva.git] / drivers / base / power / trace.c
index 2aa6e8fc4defff41ffaa63745baa3a54029ece80..9f4258df4cfdbace7c80d889154738f17c7d8461 100644 (file)
@@ -140,7 +140,7 @@ static unsigned int hash_string(unsigned int seed, const char *data, unsigned in
 
 void set_trace_device(struct device *dev)
 {
-       dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH);
+       dev_hash_value = hash_string(DEVSEED, dev_name(dev), DEVHASH);
 }
 EXPORT_SYMBOL(set_trace_device);
 
@@ -188,22 +188,56 @@ static int show_file_hash(unsigned int value)
 static int show_dev_hash(unsigned int value)
 {
        int match = 0;
-       struct list_head *entry = dpm_list.prev;
+       struct list_head *entry;
 
+       device_pm_lock();
+       entry = dpm_list.prev;
        while (entry != &dpm_list) {
                struct device * dev = to_device(entry);
-               unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH);
+               unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH);
                if (hash == value) {
                        dev_info(dev, "hash matches\n");
                        match++;
                }
                entry = entry->prev;
        }
+       device_pm_unlock();
        return match;
 }
 
 static unsigned int hash_value_early_read;
 
+int show_trace_dev_match(char *buf, size_t size)
+{
+       unsigned int value = hash_value_early_read / (USERHASH * FILEHASH);
+       int ret = 0;
+       struct list_head *entry;
+
+       /*
+        * It's possible that multiple devices will match the hash and we can't
+        * tell which is the culprit, so it's best to output them all.
+        */
+       device_pm_lock();
+       entry = dpm_list.prev;
+       while (size && entry != &dpm_list) {
+               struct device *dev = to_device(entry);
+               unsigned int hash = hash_string(DEVSEED, dev_name(dev),
+                                               DEVHASH);
+               if (hash == value) {
+                       int len = snprintf(buf, size, "%s\n",
+                                           dev_driver_string(dev));
+                       if (len > size)
+                               len = size;
+                       buf += len;
+                       ret += len;
+                       size -= len;
+               }
+               entry = entry->prev;
+       }
+       device_pm_unlock();
+       return ret;
+}
+
 static int early_resume_init(void)
 {
        hash_value_early_read = read_magic_time();