]> Git Repo - J-linux.git/commitdiff
Merge tag 'driver-core-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Tue, 5 Jun 2018 23:29:19 +0000 (16:29 -0700)
committerLinus Torvalds <[email protected]>
Tue, 5 Jun 2018 23:29:19 +0000 (16:29 -0700)
Pull driver core updates from Greg KH:
 "Here is the driver core patchset for 4.18-rc1.

  The large chunk of these are firmware core documentation and api
  updates. Nothing major there, just better descriptions for others to
  be able to understand the firmware code better. There's also a user
  for a new firmware api call.

  Other than that, there are some minor updates for debugfs, kernfs, and
  the driver core itself.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'driver-core-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (23 commits)
  driver core: hold dev's parent lock when needed
  driver-core: return EINVAL error instead of BUG_ON()
  driver core: add __printf verification to device_create_groups_vargs
  mm: memory_hotplug: use put_device() if device_register fail
  base: core: fix typo 'can by' to 'can be'
  debugfs: inode: debugfs_create_dir uses mode permission from parent
  debugfs: Re-use kstrtobool_from_user()
  Documentation: clarify firmware_class provenance and why we can't rename the module
  Documentation: remove stale firmware API reference
  Documentation: fix few typos and clarifications for the firmware loader
  ath10k: re-enable the firmware fallback mechanism for testmode
  ath10k: use firmware_request_nowarn() to load firmware
  firmware: add firmware_request_nowarn() - load firmware without warnings
  firmware_loader: make firmware_fallback_sysfs() print more useful
  firmware_loader: move kconfig FW_LOADER entries to its own file
  firmware_loader: replace ---help--- with help
  firmware_loader: enhance Kconfig documentation over FW_LOADER
  firmware_loader: document firmware_sysfs_fallback()
  firmware: rename fw_sysfs_fallback to firmware_fallback_sysfs()
  firmware: use () to terminate kernel-doc function names
  ...

1  2 
drivers/base/core.c
drivers/base/dd.c
include/linux/device.h

diff --combined drivers/base/core.c
index ad7b50897bcc703341ee7157baf743a225a3b4b5,35221144e0e67bd1e9210f224dfcfde28fcc630c..36622b52e419db9573c5cfb31f03bf740324e961
@@@ -144,26 -144,6 +144,26 @@@ static int device_reorder_to_tail(struc
        return 0;
  }
  
 +/**
 + * device_pm_move_to_tail - Move set of devices to the end of device lists
 + * @dev: Device to move
 + *
 + * This is a device_reorder_to_tail() wrapper taking the requisite locks.
 + *
 + * It moves the @dev along with all of its children and all of its consumers
 + * to the ends of the device_kset and dpm_list, recursively.
 + */
 +void device_pm_move_to_tail(struct device *dev)
 +{
 +      int idx;
 +
 +      idx = device_links_read_lock();
 +      device_pm_lock();
 +      device_reorder_to_tail(dev, NULL);
 +      device_pm_unlock();
 +      device_links_read_unlock(idx);
 +}
 +
  /**
   * device_link_add - Create a link between two devices.
   * @consumer: Consumer end of the link.
@@@ -1487,7 -1467,7 +1487,7 @@@ class_dir_create_and_add(struct class *
  
        dir = kzalloc(sizeof(*dir), GFP_KERNEL);
        if (!dir)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
  
        dir->class = class;
        kobject_init(&dir->kobj, &class_dir_ktype);
        retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name);
        if (retval < 0) {
                kobject_put(&dir->kobj);
-               return NULL;
+               return ERR_PTR(retval);
        }
        return &dir->kobj;
  }
@@@ -1804,6 -1784,10 +1804,10 @@@ int device_add(struct device *dev
  
        parent = get_device(dev->parent);
        kobj = get_device_parent(dev, parent);
+       if (IS_ERR(kobj)) {
+               error = PTR_ERR(kobj);
+               goto parent_error;
+       }
        if (kobj)
                dev->kobj.parent = kobj;
  
@@@ -1902,6 -1886,7 +1906,7 @@@ done
        kobject_del(&dev->kobj);
   Error:
        cleanup_glue_dir(dev, glue_dir);
+ parent_error:
        put_device(parent);
  name_error:
        kfree(dev->p);
@@@ -2426,7 -2411,7 +2431,7 @@@ static void device_create_release(struc
        kfree(dev);
  }
  
- static struct device *
+ static __printf(6, 0) struct device *
  device_create_groups_vargs(struct class *class, struct device *parent,
                           dev_t devt, void *drvdata,
                           const struct attribute_group **groups,
@@@ -2704,7 -2689,7 +2709,7 @@@ static int device_move_class_links(stru
  /**
   * device_move - moves a device to a new parent
   * @dev: the pointer to the struct device to be moved
-  * @new_parent: the new parent of the device (can by NULL)
+  * @new_parent: the new parent of the device (can be NULL)
   * @dpm_order: how to reorder the dpm_list
   */
  int device_move(struct device *dev, struct device *new_parent,
        device_pm_lock();
        new_parent = get_device(new_parent);
        new_parent_kobj = get_device_parent(dev, new_parent);
+       if (IS_ERR(new_parent_kobj)) {
+               error = PTR_ERR(new_parent_kobj);
+               put_device(new_parent);
+               goto out;
+       }
  
        pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev),
                 __func__, new_parent ? dev_name(new_parent) : "<NULL>");
diff --combined drivers/base/dd.c
index a41c91bfac0e9ca4a08a5df81d74dba74ffd876c,7c09f73b96f367059e469bb311394dd6fb59388a..fb4e2df68d95b9f16d6cf4f07dee1fa828decc05
@@@ -122,7 -122,9 +122,7 @@@ static void deferred_probe_work_func(st
                 * the list is a good order for suspend but deferred
                 * probe makes that very unsafe.
                 */
 -              device_pm_lock();
 -              device_pm_move_last(dev);
 -              device_pm_unlock();
 +              device_pm_move_to_tail(dev);
  
                dev_dbg(dev, "Retrying from deferred list\n");
                if (initcall_debug && !initcalls_done)
@@@ -580,7 -582,7 +580,7 @@@ int driver_probe_device(struct device_d
        pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
                 drv->bus->name, __func__, dev_name(dev), drv->name);
  
 -      pm_runtime_get_suppliers(dev);
 +      pm_runtime_resume_suppliers(dev);
        if (dev->parent)
                pm_runtime_get_sync(dev->parent);
  
        if (dev->parent)
                pm_runtime_put(dev->parent);
  
 -      pm_runtime_put_suppliers(dev);
        return ret;
  }
  
@@@ -814,13 -817,13 +814,13 @@@ static int __driver_attach(struct devic
                return ret;
        } /* ret > 0 means positive match */
  
-       if (dev->parent)        /* Needed for USB */
+       if (dev->parent && dev->bus->need_parent_lock)
                device_lock(dev->parent);
        device_lock(dev);
        if (!dev->driver)
                driver_probe_device(drv, dev);
        device_unlock(dev);
-       if (dev->parent)
+       if (dev->parent && dev->bus->need_parent_lock)
                device_unlock(dev->parent);
  
        return 0;
@@@ -916,7 -919,7 +916,7 @@@ void device_release_driver_internal(str
                                    struct device_driver *drv,
                                    struct device *parent)
  {
-       if (parent)
+       if (parent && dev->bus->need_parent_lock)
                device_lock(parent);
  
        device_lock(dev);
                __device_release_driver(dev, parent);
  
        device_unlock(dev);
-       if (parent)
+       if (parent && dev->bus->need_parent_lock)
                device_unlock(parent);
  }
  
diff --combined include/linux/device.h
index 00b6c3b424376c49f36f686c1258603eb254df43,beca424395dd36f83b6253993d8f3434b19e23a0..e9d4b43c4eadd3ae333e54757acfd774b9644d3d
@@@ -88,8 -88,6 +88,8 @@@ extern void bus_remove_file(struct bus_
   * @resume:   Called to bring a device on this bus out of sleep mode.
   * @num_vf:   Called to find out how many virtual functions a device on this
   *            bus supports.
 + * @dma_configure:    Called to setup DMA configuration on a device on
 +                      this bus.
   * @pm:               Power management operations of this bus, callback the specific
   *            device driver's pm-ops.
   * @iommu_ops:  IOMMU specific operations for this bus, used to attach IOMMU
   * @p:                The private data of the driver core, only the driver core can
   *            touch this.
   * @lock_key: Lock class key for use by the lock validator
 - * @force_dma:        Assume devices on this bus should be set up by dma_configure()
 - *            even if DMA capability is not explicitly described by firmware.
+  * @need_parent_lock: When probing or removing a device on this bus, the
+  *                    device core should lock the device's parent.
   *
   * A bus is a channel between the processor and one or more devices. For the
   * purposes of the device model, all devices are connected via a bus, even if
@@@ -130,14 -132,15 +132,16 @@@ struct bus_type 
  
        int (*num_vf)(struct device *dev);
  
 +      int (*dma_configure)(struct device *dev);
 +
        const struct dev_pm_ops *pm;
  
        const struct iommu_ops *iommu_ops;
  
        struct subsys_private *p;
        struct lock_class_key lock_key;
 -      bool force_dma;
+       bool need_parent_lock;
  };
  
  extern int __must_check bus_register(struct bus_type *bus);
@@@ -904,8 -907,6 +908,8 @@@ struct dev_links_info 
   * @offline:  Set after successful invocation of bus type's .offline().
   * @of_node_reused: Set if the device-tree node is shared with an ancestor
   *              device.
 + * @dma_32bit_limit: bridge limited to 32bit DMA even if the device itself
 + *            indicates support for a higher limit in the dma_mask field.
   *
   * At the lowest level, every device in a Linux system is represented by an
   * instance of struct device. The device structure contains the information
@@@ -994,7 -995,6 +998,7 @@@ struct device 
        bool                    offline_disabled:1;
        bool                    offline:1;
        bool                    of_node_reused:1;
 +      bool                    dma_32bit_limit:1;
  };
  
  static inline struct device *kobj_to_dev(struct kobject *kobj)
This page took 0.121349 seconds and 4 git commands to generate.