sched: Prevent balance_push() on remote runqueues
[linux-2.6-microblaze.git] / drivers / base / core.c
index 54ba506..6c0ef9d 100644 (file)
@@ -574,8 +574,10 @@ static void devlink_remove_symlinks(struct device *dev,
                return;
        }
 
-       snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
-       sysfs_remove_link(&con->kobj, buf);
+       if (device_is_registered(con)) {
+               snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
+               sysfs_remove_link(&con->kobj, buf);
+       }
        snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con));
        sysfs_remove_link(&sup->kobj, buf);
        kfree(buf);
@@ -2409,6 +2411,25 @@ static ssize_t online_store(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RW(online);
 
+static ssize_t removable_show(struct device *dev, struct device_attribute *attr,
+                             char *buf)
+{
+       const char *loc;
+
+       switch (dev->removable) {
+       case DEVICE_REMOVABLE:
+               loc = "removable";
+               break;
+       case DEVICE_FIXED:
+               loc = "fixed";
+               break;
+       default:
+               loc = "unknown";
+       }
+       return sysfs_emit(buf, "%s\n", loc);
+}
+static DEVICE_ATTR_RO(removable);
+
 int device_add_groups(struct device *dev, const struct attribute_group **groups)
 {
        return sysfs_create_groups(&dev->kobj, groups);
@@ -2586,8 +2607,16 @@ static int device_add_attrs(struct device *dev)
                        goto err_remove_dev_online;
        }
 
+       if (dev_removable_is_valid(dev)) {
+               error = device_create_file(dev, &dev_attr_removable);
+               if (error)
+                       goto err_remove_dev_waiting_for_supplier;
+       }
+
        return 0;
 
+ err_remove_dev_waiting_for_supplier:
+       device_remove_file(dev, &dev_attr_waiting_for_supplier);
  err_remove_dev_online:
        device_remove_file(dev, &dev_attr_online);
  err_remove_dev_groups:
@@ -2607,6 +2636,7 @@ static void device_remove_attrs(struct device *dev)
        struct class *class = dev->class;
        const struct device_type *type = dev->type;
 
+       device_remove_file(dev, &dev_attr_removable);
        device_remove_file(dev, &dev_attr_waiting_for_supplier);
        device_remove_file(dev, &dev_attr_online);
        device_remove_groups(dev, dev->groups);
@@ -2807,6 +2837,7 @@ void device_initialize(struct device *dev)
        device_pm_init(dev);
        set_dev_node(dev, -1);
 #ifdef CONFIG_GENERIC_MSI_IRQ
+       raw_spin_lock_init(&dev->msi_lock);
        INIT_LIST_HEAD(&dev->msi_list);
 #endif
        INIT_LIST_HEAD(&dev->links.consumers);
@@ -3442,7 +3473,7 @@ bool kill_device(struct device *dev)
         * to run while we are tearing out the bus/class/sysfs from
         * underneath the device.
         */
-       lockdep_assert_held(&dev->mutex);
+       device_lock_assert(dev);
 
        if (dev->p->dead)
                return false;
@@ -4727,6 +4758,13 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
 
+void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
+{
+       dev->fwnode = fwnode;
+       dev->of_node = to_of_node(fwnode);
+}
+EXPORT_SYMBOL_GPL(device_set_node);
+
 int device_match_name(struct device *dev, const void *name)
 {
        return sysfs_streq(dev_name(dev), name);