]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'driver-core/driver-core-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 9 Apr 2015 06:45:59 +0000 (16:45 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 9 Apr 2015 06:45:59 +0000 (16:45 +1000)
1  2 
drivers/base/core.c
drivers/base/dd.c
drivers/base/platform.c
drivers/base/property.c
include/linux/device.h

diff --combined drivers/base/core.c
index c7e2a9a708655bceeb8fa517106b5d904d332db8,cadf165651d8c5a507a32492fb78b7cff3e0b993..21d13038534e347f4fcccfc10f532659e2444928
@@@ -12,7 -12,6 +12,7 @@@
  
  #include <linux/device.h>
  #include <linux/err.h>
 +#include <linux/fwnode.h>
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/slab.h>
@@@ -806,8 -805,16 +806,16 @@@ static void cleanup_device_parent(struc
  
  static int device_add_class_symlinks(struct device *dev)
  {
+       struct device_node *of_node = dev_of_node(dev);
        int error;
  
+       if (of_node) {
+               error = sysfs_create_link(&dev->kobj, &of_node->kobj,"of_node");
+               if (error)
+                       dev_warn(dev, "Error %d creating of_node link\n",error);
+               /* An error here doesn't warrant bringing down the device */
+       }
        if (!dev->class)
                return 0;
  
                                  &dev->class->p->subsys.kobj,
                                  "subsystem");
        if (error)
-               goto out;
+               goto out_devnode;
  
        if (dev->parent && device_is_not_partition(dev)) {
                error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
@@@ -843,12 -850,16 +851,16 @@@ out_device
  
  out_subsys:
        sysfs_remove_link(&dev->kobj, "subsystem");
- out:
+ out_devnode:
+       sysfs_remove_link(&dev->kobj, "of_node");
        return error;
  }
  
  static void device_remove_class_symlinks(struct device *dev)
  {
+       if (dev_of_node(dev))
+               sysfs_remove_link(&dev->kobj, "of_node");
        if (!dev->class)
                return;
  
@@@ -1096,8 -1107,7 +1108,7 @@@ done
        kobject_del(&dev->kobj);
   Error:
        cleanup_device_parent(dev);
-       if (parent)
-               put_device(parent);
+       put_device(parent);
  name_error:
        kfree(dev->p);
        dev->p = NULL;
@@@ -2134,53 -2144,3 +2145,53 @@@ define_dev_printk_level(dev_notice, KER
  define_dev_printk_level(_dev_info, KERN_INFO);
  
  #endif
 +
 +static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
 +{
 +      return fwnode && !IS_ERR(fwnode->secondary);
 +}
 +
 +/**
 + * set_primary_fwnode - Change the primary firmware node of a given device.
 + * @dev: Device to handle.
 + * @fwnode: New primary firmware node of the device.
 + *
 + * Set the device's firmware node pointer to @fwnode, but if a secondary
 + * firmware node of the device is present, preserve it.
 + */
 +void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 +{
 +      if (fwnode) {
 +              struct fwnode_handle *fn = dev->fwnode;
 +
 +              if (fwnode_is_primary(fn))
 +                      fn = fn->secondary;
 +
 +              fwnode->secondary = fn;
 +              dev->fwnode = fwnode;
 +      } else {
 +              dev->fwnode = fwnode_is_primary(dev->fwnode) ?
 +                      dev->fwnode->secondary : NULL;
 +      }
 +}
 +EXPORT_SYMBOL_GPL(set_primary_fwnode);
 +
 +/**
 + * set_secondary_fwnode - Change the secondary firmware node of a given device.
 + * @dev: Device to handle.
 + * @fwnode: New secondary firmware node of the device.
 + *
 + * If a primary firmware node of the device is present, set its secondary
 + * pointer to @fwnode.  Otherwise, set the device's firmware node pointer to
 + * @fwnode.
 + */
 +void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 +{
 +      if (fwnode)
 +              fwnode->secondary = ERR_PTR(-ENODEV);
 +
 +      if (fwnode_is_primary(dev->fwnode))
 +              dev->fwnode->secondary = fwnode;
 +      else
 +              dev->fwnode = fwnode;
 +}
diff --combined drivers/base/dd.c
index aeb744891e44e290890c713cfa7cc9e33d699bc3,49a4a12fafef176506a46063b390a194b29e9db4..e843fdbe492514d83fd1f66cfc8678b10099e877
@@@ -298,12 -298,6 +298,12 @@@ static int really_probe(struct device *
                goto probe_failed;
        }
  
 +      if (dev->pm_domain && dev->pm_domain->activate) {
 +              ret = dev->pm_domain->activate(dev);
 +              if (ret)
 +                      goto probe_failed;
 +      }
 +
        if (dev->bus->probe) {
                ret = dev->bus->probe(dev);
                if (ret)
                        goto probe_failed;
        }
  
 +      if (dev->pm_domain && dev->pm_domain->sync)
 +              dev->pm_domain->sync(dev);
 +
        driver_bound(dev);
        ret = 1;
        pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
@@@ -328,24 -319,26 +328,28 @@@ probe_failed
        driver_sysfs_remove(dev);
        dev->driver = NULL;
        dev_set_drvdata(dev, NULL);
 +      if (dev->pm_domain && dev->pm_domain->dismiss)
 +              dev->pm_domain->dismiss(dev);
  
-       if (ret == -EPROBE_DEFER) {
+       switch (ret) {
+       case -EPROBE_DEFER:
                /* Driver requested deferred probing */
-               dev_info(dev, "Driver %s requests probe deferral\n", drv->name);
+               dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
                driver_deferred_probe_add(dev);
                /* Did a trigger occur while probing? Need to re-trigger if yes */
                if (local_trigger_count != atomic_read(&deferred_trigger_count))
                        driver_deferred_probe_trigger();
-       } else if (ret != -ENODEV && ret != -ENXIO) {
+               break;
+       case -ENODEV:
+       case -ENXIO:
+               pr_debug("%s: probe of %s rejects match %d\n",
+                        drv->name, dev_name(dev), ret);
+               break;
+       default:
                /* driver matched but the probe failed */
                printk(KERN_WARNING
                       "%s: probe of %s failed with error %d\n",
                       drv->name, dev_name(dev), ret);
-       } else {
-               pr_debug("%s: probe of %s rejects match %d\n",
-                      drv->name, dev_name(dev), ret);
        }
        /*
         * Ignore errors returned by ->probe so that the next driver can try
@@@ -536,9 -529,6 +540,9 @@@ static void __device_release_driver(str
                devres_release_all(dev);
                dev->driver = NULL;
                dev_set_drvdata(dev, NULL);
 +              if (dev->pm_domain && dev->pm_domain->dismiss)
 +                      dev->pm_domain->dismiss(dev);
 +
                klist_remove(&dev->p->knode_driver);
                if (dev->bus)
                        blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
diff --combined drivers/base/platform.c
index 17f0204fabefe10af56bbf6cf67722ed61a73dd1,e68ab79df28bbc9e84c3e2f6f17f92369144c96d..ebf034b97278592ab57cbd24ef0f53d3cfc56e0a
@@@ -101,6 -101,15 +101,15 @@@ int platform_get_irq(struct platform_de
        }
  
        r = platform_get_resource(dev, IORESOURCE_IRQ, num);
+       /*
+        * The resources may pass trigger flags to the irqs that need
+        * to be set up. It so happens that the trigger flags for
+        * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
+        * settings.
+        */
+       if (r && r->flags & IORESOURCE_BITS)
+               irqd_set_trigger_type(irq_get_irq_data(r->start),
+                                     r->flags & IORESOURCE_BITS);
  
        return r ? r->start : -ENXIO;
  #endif
@@@ -454,7 -463,7 +463,7 @@@ struct platform_device *platform_device
                goto err_alloc;
  
        pdev->dev.parent = pdevinfo->parent;
 -      ACPI_COMPANION_SET(&pdev->dev, pdevinfo->acpi_node.companion);
 +      pdev->dev.fwnode = pdevinfo->fwnode;
  
        if (pdevinfo->dma_mask) {
                /*
diff --combined drivers/base/property.c
index 6a3f7d8af341279428a5d11ad5d8f72e8420f420,423df593f262b1e0defaa087599781dad8ee4b8a..1d0b116cae959041682eaf6bb7ea91895b390e58
   * published by the Free Software Foundation.
   */
  
 -#include <linux/property.h>
 -#include <linux/export.h>
  #include <linux/acpi.h>
 +#include <linux/export.h>
 +#include <linux/kernel.h>
  #include <linux/of.h>
 +#include <linux/property.h>
 +
 +/**
 + * device_add_property_set - Add a collection of properties to a device object.
 + * @dev: Device to add properties to.
 + * @pset: Collection of properties to add.
 + *
 + * Associate a collection of device properties represented by @pset with @dev
 + * as its secondary firmware node.
 + */
 +void device_add_property_set(struct device *dev, struct property_set *pset)
 +{
 +      if (pset)
 +              pset->fwnode.type = FWNODE_PDATA;
 +
 +      set_secondary_fwnode(dev, &pset->fwnode);
 +}
 +EXPORT_SYMBOL_GPL(device_add_property_set);
 +
 +static inline bool is_pset(struct fwnode_handle *fwnode)
 +{
 +      return fwnode && fwnode->type == FWNODE_PDATA;
 +}
 +
 +static inline struct property_set *to_pset(struct fwnode_handle *fwnode)
 +{
 +      return is_pset(fwnode) ?
 +              container_of(fwnode, struct property_set, fwnode) : NULL;
 +}
 +
 +static struct property_entry *pset_prop_get(struct property_set *pset,
 +                                          const char *name)
 +{
 +      struct property_entry *prop;
 +
 +      if (!pset || !pset->properties)
 +              return NULL;
 +
 +      for (prop = pset->properties; prop->name; prop++)
 +              if (!strcmp(name, prop->name))
 +                      return prop;
 +
 +      return NULL;
 +}
 +
 +static int pset_prop_read_array(struct property_set *pset, const char *name,
 +                              enum dev_prop_type type, void *val, size_t nval)
 +{
 +      struct property_entry *prop;
 +      unsigned int item_size;
 +
 +      prop = pset_prop_get(pset, name);
 +      if (!prop)
 +              return -ENODATA;
 +
 +      if (prop->type != type)
 +              return -EPROTO;
 +
 +      if (!val)
 +              return prop->nval;
 +
 +      if (prop->nval < nval)
 +              return -EOVERFLOW;
 +
 +      switch (type) {
 +      case DEV_PROP_U8:
 +              item_size = sizeof(u8);
 +              break;
 +      case DEV_PROP_U16:
 +              item_size = sizeof(u16);
 +              break;
 +      case DEV_PROP_U32:
 +              item_size = sizeof(u32);
 +              break;
 +      case DEV_PROP_U64:
 +              item_size = sizeof(u64);
 +              break;
 +      case DEV_PROP_STRING:
 +              item_size = sizeof(const char *);
 +              break;
 +      default:
 +              return -EINVAL;
 +      }
 +      memcpy(val, prop->value.raw_data, nval * item_size);
 +      return 0;
 +}
 +
 +static inline struct fwnode_handle *dev_fwnode(struct device *dev)
 +{
 +      return IS_ENABLED(CONFIG_OF) && dev->of_node ?
 +              &dev->of_node->fwnode : dev->fwnode;
 +}
  
  /**
   * device_property_present - check if a property of a device is present
   */
  bool device_property_present(struct device *dev, const char *propname)
  {
 -      if (IS_ENABLED(CONFIG_OF) && dev->of_node)
 -              return of_property_read_bool(dev->of_node, propname);
 -
 -      return !acpi_dev_prop_get(ACPI_COMPANION(dev), propname, NULL);
 +      return fwnode_property_present(dev_fwnode(dev), propname);
  }
  EXPORT_SYMBOL_GPL(device_property_present);
  
@@@ -132,22 -43,32 +132,22 @@@ bool fwnode_property_present(struct fwn
        else if (is_acpi_node(fwnode))
                return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL);
  
 -      return false;
 +      return !!pset_prop_get(to_pset(fwnode), propname);
  }
  EXPORT_SYMBOL_GPL(fwnode_property_present);
  
 -#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
 -      (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
 -            : of_property_count_elems_of_size((node), (propname), sizeof(type))
 -
 -#define DEV_PROP_READ_ARRAY(_dev_, _propname_, _type_, _proptype_, _val_, _nval_) \
 -      IS_ENABLED(CONFIG_OF) && _dev_->of_node ? \
 -              (OF_DEV_PROP_READ_ARRAY(_dev_->of_node, _propname_, _type_, \
 -                                      _val_, _nval_)) : \
 -              acpi_dev_prop_read(ACPI_COMPANION(_dev_), _propname_, \
 -                                 _proptype_, _val_, _nval_)
 -
  /**
   * device_property_read_u8_array - return a u8 array property of a device
   * @dev: Device to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Function reads an array of u8 properties with @propname from the device
   * firmware description and stores them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
  int device_property_read_u8_array(struct device *dev, const char *propname,
                                  u8 *val, size_t nval)
  {
 -      return DEV_PROP_READ_ARRAY(dev, propname, u8, DEV_PROP_U8, val, nval);
 +      return fwnode_property_read_u8_array(dev_fwnode(dev), propname, val, nval);
  }
  EXPORT_SYMBOL_GPL(device_property_read_u8_array);
  
   * device_property_read_u16_array - return a u16 array property of a device
   * @dev: Device to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Function reads an array of u16 properties with @propname from the device
   * firmware description and stores them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
  int device_property_read_u16_array(struct device *dev, const char *propname,
                                   u16 *val, size_t nval)
  {
 -      return DEV_PROP_READ_ARRAY(dev, propname, u16, DEV_PROP_U16, val, nval);
 +      return fwnode_property_read_u16_array(dev_fwnode(dev), propname, val, nval);
  }
  EXPORT_SYMBOL_GPL(device_property_read_u16_array);
  
   * device_property_read_u32_array - return a u32 array property of a device
   * @dev: Device to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Function reads an array of u32 properties with @propname from the device
   * firmware description and stores them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
  int device_property_read_u32_array(struct device *dev, const char *propname,
                                   u32 *val, size_t nval)
  {
 -      return DEV_PROP_READ_ARRAY(dev, propname, u32, DEV_PROP_U32, val, nval);
 +      return fwnode_property_read_u32_array(dev_fwnode(dev), propname, val, nval);
  }
  EXPORT_SYMBOL_GPL(device_property_read_u32_array);
  
   * device_property_read_u64_array - return a u64 array property of a device
   * @dev: Device to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Function reads an array of u64 properties with @propname from the device
   * firmware description and stores them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
  int device_property_read_u64_array(struct device *dev, const char *propname,
                                   u64 *val, size_t nval)
  {
 -      return DEV_PROP_READ_ARRAY(dev, propname, u64, DEV_PROP_U64, val, nval);
 +      return fwnode_property_read_u64_array(dev_fwnode(dev), propname, val, nval);
  }
  EXPORT_SYMBOL_GPL(device_property_read_u64_array);
  
   * device_property_read_string_array - return a string array property of device
   * @dev: Device to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Function reads an array of string properties with @propname from the device
   * firmware description and stores them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO or %-EILSEQ if the property is not an array of strings,
  int device_property_read_string_array(struct device *dev, const char *propname,
                                      const char **val, size_t nval)
  {
 -      return IS_ENABLED(CONFIG_OF) && dev->of_node ?
 -              of_property_read_string_array(dev->of_node, propname, val, nval) :
 -              acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
 -                                 DEV_PROP_STRING, val, nval);
 +      return fwnode_property_read_string_array(dev_fwnode(dev), propname, val, nval);
  }
  EXPORT_SYMBOL_GPL(device_property_read_string_array);
  
  int device_property_read_string(struct device *dev, const char *propname,
                                const char **val)
  {
 -      return IS_ENABLED(CONFIG_OF) && dev->of_node ?
 -              of_property_read_string(dev->of_node, propname, val) :
 -              acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
 -                                 DEV_PROP_STRING, val, 1);
 +      return fwnode_property_read_string(dev_fwnode(dev), propname, val);
  }
  EXPORT_SYMBOL_GPL(device_property_read_string);
  
 +#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
 +      (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
 +            : of_property_count_elems_of_size((node), (propname), sizeof(type))
 +
  #define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \
  ({ \
        int _ret_; \
                _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \
                                           _proptype_, _val_, _nval_); \
        else \
 -              _ret_ = -ENXIO; \
 +              _ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \
 +                                           _proptype_, _val_, _nval_); \
        _ret_; \
  })
  
   * fwnode_property_read_u8_array - return a u8 array property of firmware node
   * @fwnode: Firmware node to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Read an array of u8 properties with @propname from @fwnode and stores them to
   * @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
@@@ -326,14 -243,13 +326,14 @@@ EXPORT_SYMBOL_GPL(fwnode_property_read_
   * fwnode_property_read_u16_array - return a u16 array property of firmware node
   * @fwnode: Firmware node to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Read an array of u16 properties with @propname from @fwnode and store them to
   * @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
@@@ -352,14 -268,13 +352,14 @@@ EXPORT_SYMBOL_GPL(fwnode_property_read_
   * fwnode_property_read_u32_array - return a u32 array property of firmware node
   * @fwnode: Firmware node to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Read an array of u32 properties with @propname from @fwnode store them to
   * @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
@@@ -378,14 -293,13 +378,14 @@@ EXPORT_SYMBOL_GPL(fwnode_property_read_
   * fwnode_property_read_u64_array - return a u64 array property firmware node
   * @fwnode: Firmware node to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Read an array of u64 properties with @propname from @fwnode and store them to
   * @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of numbers,
@@@ -404,14 -318,13 +404,14 @@@ EXPORT_SYMBOL_GPL(fwnode_property_read_
   * fwnode_property_read_string_array - return string array property of a node
   * @fwnode: Firmware node to get the property of
   * @propname: Name of the property
 - * @val: The values are stored here
 + * @val: The values are stored here or %NULL to return the number of values
   * @nval: Size of the @val array
   *
   * Read an string list property @propname from the given firmware node and store
   * them to @val if found.
   *
 - * Return: %0 if the property was found (success),
 + * Return: number of values if @val was %NULL,
 + *         %0 if the property was found (success),
   *       %-EINVAL if given arguments are not valid,
   *       %-ENODATA if the property does not have a value,
   *       %-EPROTO if the property is not an array of strings,
@@@ -423,16 -336,13 +423,16 @@@ int fwnode_property_read_string_array(s
                                      size_t nval)
  {
        if (is_of_node(fwnode))
 -              return of_property_read_string_array(of_node(fwnode), propname,
 -                                                   val, nval);
 +              return val ?
 +                      of_property_read_string_array(of_node(fwnode), propname,
 +                                                    val, nval) :
 +                      of_property_count_strings(of_node(fwnode), propname);
        else if (is_acpi_node(fwnode))
                return acpi_dev_prop_read(acpi_node(fwnode), propname,
                                          DEV_PROP_STRING, val, nval);
  
 -      return -ENXIO;
 +      return pset_prop_read_array(to_pset(fwnode), propname,
 +                                  DEV_PROP_STRING, val, nval);
  }
  EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
  
@@@ -455,7 -365,7 +455,7 @@@ int fwnode_property_read_string(struct 
                                const char *propname, const char **val)
  {
        if (is_of_node(fwnode))
-               return of_property_read_string(of_node(fwnode),propname, val);
+               return of_property_read_string(of_node(fwnode), propname, val);
        else if (is_acpi_node(fwnode))
                return acpi_dev_prop_read(acpi_node(fwnode), propname,
                                          DEV_PROP_STRING, val, 1);
diff --combined include/linux/device.h
index 324d02add7b4d4ea0794ef4fe4adb1826dd36532,f3f2c7e38060245e8e40df56d9d924168c795abd..6558af90c8fe3b9263441dc401b3689940d3453e
@@@ -38,7 -38,6 +38,7 @@@ struct class
  struct subsys_private;
  struct bus_type;
  struct device_node;
 +struct fwnode_handle;
  struct iommu_ops;
  struct iommu_group;
  
@@@ -651,6 -650,14 +651,6 @@@ struct device_dma_parameters 
        unsigned long segment_boundary_mask;
  };
  
 -struct acpi_device;
 -
 -struct acpi_dev_node {
 -#ifdef CONFIG_ACPI
 -      struct acpi_device *companion;
 -#endif
 -};
 -
  /**
   * struct device - The basic device structure
   * @parent:   The device's "parent" device, the device to which it is attached.
   * @cma_area: Contiguous memory area for dma allocations
   * @archdata: For arch-specific additions.
   * @of_node:  Associated device tree node.
 - * @acpi_node:        Associated ACPI device node.
 + * @fwnode:   Associated device node supplied by platform firmware.
   * @devt:     For creating the sysfs "dev".
   * @id:               device instance
   * @devres_lock: Spinlock to protect the resource of the device.
@@@ -772,7 -779,7 +772,7 @@@ struct device 
        struct dev_archdata     archdata;
  
        struct device_node      *of_node; /* associated device tree node */
 -      struct acpi_dev_node    acpi_node; /* associated ACPI device node */
 +      struct fwnode_handle    *fwnode; /* firmware device node */
  
        dev_t                   devt;   /* dev_t, creates the sysfs "dev" */
        u32                     id;     /* device instance */
@@@ -909,6 -916,13 +909,13 @@@ static inline void device_lock_assert(s
        lockdep_assert_held(&dev->mutex);
  }
  
+ static inline struct device_node *dev_of_node(struct device *dev)
+ {
+       if (!IS_ENABLED(CONFIG_OF))
+               return NULL;
+       return dev->of_node;
+ }
  void driver_init(void);
  
  /*
@@@ -940,9 -954,6 +947,9 @@@ extern void unlock_device_hotplug(void)
  extern int lock_device_hotplug_sysfs(void);
  extern int device_offline(struct device *dev);
  extern int device_online(struct device *dev);
 +extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 +extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 +
  /*
   * Root device objects for grouping under /sys/devices
   */