1. 19 3月, 2014 1 次提交
    • P
      of: device_node kobject lifecycle fixes · 0829f6d1
      Pantelis Antoniou 提交于
      After the move to having device nodes be proper kobjects the lifecycle
      of the node needs to be controlled better.
      
      At first convert of_add_node() in the unflattened functions to
      of_init_node() which initializes the kobject so that of_node_get/put
      work correctly even before of_init is called.
      
      Afterwards introduce of_node_is_initialized & of_node_is_attached that
      query the underlying kobject about the state (attached means kobj
      is visible in sysfs)
      
      Using that make sure the lifecycle of the tree is correct at all
      times.
      Signed-off-by: NPantelis Antoniou <panto@antoniou-consulting.com>
      [grant.likely: moved of_node_init() calls, fixed up locking, and
                     dropped __of_populate() hunks]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      0829f6d1
  2. 12 3月, 2014 2 次提交
    • G
      of: remove /proc/device-tree · 8357041a
      Grant Likely 提交于
      The same data is now available in sysfs, so we can remove the code
      that exports it in /proc and replace it with a symlink to the sysfs
      version.
      
      Tested on versatile qemu model and mpc5200 eval board. More testing
      would be appreciated.
      
      v5: Fixed up conflicts with mainline changes
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
      Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
      8357041a
    • G
      of: Make device nodes kobjects so they show up in sysfs · 75b57ecf
      Grant Likely 提交于
      Device tree nodes are already treated as objects, and we already want to
      expose them to userspace which is done using the /proc filesystem today.
      Right now the kernel has to do a lot of work to keep the /proc view in
      sync with the in-kernel representation. If device_nodes are switched to
      be kobjects then the device tree code can be a whole lot simpler. It
      also turns out that switching to using /sysfs from /proc results in
      smaller code and data size, and the userspace ABI won't change if
      /proc/device-tree symlinks to /sys/firmware/devicetree/base.
      
      v7: Add missing sysfs_bin_attr_init()
      v6: Add __of_add_property() early init fixes from Pantelis
      v5: Rename firmware/ofw to firmware/devicetree
          Fix updating property values in sysfs
      v4: Fixed build error on Powerpc
          Fixed handling of dynamic nodes on powerpc
      v3: Fixed handling of duplicate attribute and child node names
      v2: switch to using sysfs bin_attributes which solve the problem of
          reporting incorrect property size.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Tested-by: NSascha Hauer <s.hauer@pengutronix.de>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
      Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
      75b57ecf
  3. 04 3月, 2014 1 次提交
  4. 20 2月, 2014 1 次提交
    • K
      of: reimplement the matching method for __of_match_node() · 215a14cf
      Kevin Hao 提交于
      In the current implementation of __of_match_node(), it will compare
      each given match entry against all the node's compatible strings
      with of_device_is_compatible().
      
      To achieve multiple compatible strings per node with ordering from
      specific to generic, this requires given matches to be ordered from
      specific to generic. For most of the drivers this is not true and
      also an alphabetical ordering is more sane there.
      
      Therefore, we define a following priority order for the match, and
      then scan all the entries to find the best match.
        1. specific compatible && type && name
        2. specific compatible && type
        3. specific compatible && name
        4. specific compatible
        5. general compatible && type && name
        6. general compatible && type
        7. general compatible && name
        8. general compatible
        9. type && name
        10. type
        11. name
      
      v5: Fix nested locking bug
      v4: Short-circuit failure cases instead of mucking with score, and
          remove extra __of_device_is_compatible() wrapper stub.
          Move scoring logic directly into __of_device_is_compatible()
      v3: Also need to bail out when there does have a compatible member in match
          entry, but it doesn't match with the device node's compatible.
      v2: Fix the bug such as we get the same score for the following two match
          entries with the empty node 'name2 { };'
      	struct of_device_id matches[] = {
      		{.name = "name2", },
      		{.name = "name2", .type = "type1", },
      		{}
      	};
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      [grant.likely: added v4 changes]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Tested-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Tested-by: NStephen Chivers <schivers@csc.com>
      Tested-by: NSachin Kamat <sachin.kamat@linaro.org>
      215a14cf
  5. 19 2月, 2014 1 次提交
  6. 16 2月, 2014 1 次提交
    • K
      of: search the best compatible match first in __of_match_node() · 06b29e76
      Kevin Hao 提交于
      Currently, of_match_node compares each given match against all node's
      compatible strings with of_device_is_compatible.
      
      To achieve multiple compatible strings per node with ordering from
      specific to generic, this requires given matches to be ordered from
      specific to generic. For most of the drivers this is not true and also
      an alphabetical ordering is more sane there.
      
      Therefore, this patch introduces a function to match each of the node's
      compatible strings against all given compatible matches without type and
      name first, before checking the next compatible string. This implies
      that node's compatibles are ordered from specific to generic while
      given matches can be in any order. If we fail to find such a match
      entry, then fall-back to the old method in order to keep compatibility.
      
      Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Tested-by: NStephen Chivers <schivers@csc.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      06b29e76
  7. 15 2月, 2014 1 次提交
    • K
      Revert "OF: base: match each node compatible against all given matches first" · 4e8ca6ee
      Kevin Hao 提交于
      This reverts commit 10535314.
      Stephen Chivers reported this is broken as we will get a match
      entry '.type = "serial"' instead of the '.compatible = "ns16550"'
      in the following scenario:
      	serial0: serial@4500 {
      		compatible = "fsl,ns16550", "ns16550";
      	}
      
      	struct of_device_id of_platform_serial_table[] = {
      		{ .compatible = "ns8250",   .data = (void *)PORT_8250, },
      		{ .compatible = "ns16450",  .data = (void *)PORT_16450, },
      		{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
      		{ .compatible = "ns16550",  .data = (void *)PORT_16550, },
      		{ .compatible = "ns16750",  .data = (void *)PORT_16750, },
      		{ .compatible = "ns16850",  .data = (void *)PORT_16850, },
      		...
      		{ .type = "serial",         .data = (void *)PORT_UNKNOWN, },
      		{ /* end of list */ },
      	};
      
      So just revert this patch, we will use another implementation to find
      the best compatible match in a follow-on patch.
      Reported-by: NStephen N Chivers <schivers@csc.com.au>
      Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      4e8ca6ee
  8. 05 2月, 2014 2 次提交
  9. 03 2月, 2014 1 次提交
  10. 17 1月, 2014 1 次提交
    • X
      of: Fix __of_device_is_available check · 42ccd781
      Xiubo Li 提交于
      From IEEE 1275, there defined a standard 'status' property indicating the
      operational status of one device. The 'status' property has four possible
      values: 'okay/ok', 'disabled', 'fail' and 'fail-xxx'.
      
      If it is absent, that means the status of the device is unknown or okay.
      
      The __of_device_is_available checks the state of the 'status' property of
      a device. If the property is absent or set to 'okay/ok', it returns 1.
      Otherwise it returns 0.
      
      While in __of_device_is_available:
       >	status = of_get_property(device, "status", &statlen);
       >	if (status == NULL)
       >		return 1;
      The status value returned from 'of_get_property()' will be NULL in two cases:
      Firstly: the 'device' value (device node) is NULL.
      Secondly: the 'status' property is actaully not exist.
      
      If the device node is NULL, the __of_device_is_available will return true,
      that will mean the absent state of the 'status' property.
      
      So this add the device node check before checking the 'status' property's
      state, and if the device node is not exist, 0 will be returned.
      Signed-off-by: NXiubo Li <Li.Xiubo@freescale.com>
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      42ccd781
  11. 05 12月, 2013 1 次提交
  12. 31 10月, 2013 1 次提交
  13. 24 10月, 2013 1 次提交
  14. 16 10月, 2013 2 次提交
    • G
      of: Fix iteration bug over CPU reg properties · f3cea45a
      Grant Likely 提交于
      The size of each hwid in a cpu nodes 'reg' property is defined by the
      parents #address-cells property in the normal way. The cpu parsing code
      has a bug where it will overrun the end of the property if
      address-cells is greater than one. This commit fixes the problem by
      adjusting the array size by the number of address cells. It also makes
      sure address-cells isn't zero for that would cause an infinite loop.
      
      v2: bail if #address-cells is zero instead of forcing to
          OF_ROOT_NODE_ADDR_CELLS_DEFAULT. Forcing it will cause the reg
          property to be parsed incorrectly.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      f3cea45a
    • D
      of: Make cpu node handling more portable. · d1cb9d1a
      David Miller 提交于
      Use for_each_node_by_type() to iterate all cpu nodes in the
      system.
      
      Provide and overridable function arch_find_n_match_cpu_physical_id,
      which sees if the given device node matches 'cpu' and if so sets
      '*thread' when non-NULL to the cpu thread number within the core.
      
      The default implementation behaves the same as the existing code.
      
      Add a sparc64 implementation.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Tested-by: NSudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      d1cb9d1a
  15. 14 10月, 2013 1 次提交
    • G
      of: fix unnecessary warning on missing /cpus node · 444c91e5
      Grant Likely 提交于
      Not all DT platforms have all the cpus collected under a /cpus node.
      That just happens to be a details of FDT, ePAPR and PowerPC platforms.
      Sparc does something different, but unfortunately the current code
      complains with a warning if /cpus isn't there. This became a problem
      with commit f86e4718, "driver/core cpu: initialize of_node in cpu's
      device structure", which caused the function to get called for all
      architectures.
      
      This commit is a temporary fix to fail silently if the cpus node isn't
      present. A proper fix will come later to allow arch code to provide a
      custom mechanism for decoding the CPU hwid if the 'reg' property isn't
      appropriate.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
      Cc: Rob Herring <rob.herring@calxeda.com>
      444c91e5
  16. 10 10月, 2013 1 次提交
  17. 30 8月, 2013 5 次提交
  18. 21 8月, 2013 1 次提交
    • S
      of: move of_get_cpu_node implementation to DT core library · 183912d3
      Sudeep KarkadaNagesha 提交于
      This patch moves the generalized implementation of of_get_cpu_node from
      PowerPC to DT core library, thereby adding support for retrieving cpu
      node for a given logical cpu index on any architecture.
      
      The CPU subsystem can now use this function to assign of_node in the
      cpu device while registering CPUs.
      
      It is recommended to use these helper function only in pre-SMP/early
      initialisation stages to retrieve CPU device node pointers in logical
      ordering. Once the cpu devices are registered, it can be retrieved easily
      from cpu device of_node which avoids unnecessary parsing and matching.
      
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Grant Likely <grant.likely@linaro.org>
      Acked-by: NRob Herring <rob.herring@calxeda.com>
      Signed-off-by: NSudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
      183912d3
  19. 13 8月, 2013 1 次提交
  20. 14 6月, 2013 1 次提交
  21. 12 6月, 2013 1 次提交
  22. 02 5月, 2013 1 次提交
  23. 17 4月, 2013 2 次提交
  24. 04 4月, 2013 2 次提交
  25. 13 2月, 2013 3 次提交
  26. 09 2月, 2013 1 次提交
  27. 06 2月, 2013 1 次提交
    • S
      of: Output devicetree alias names in uevent · ced4eec9
      Stepan Moskovchenko 提交于
      In some situations, userspace may want to resolve a
      device by function and logical number (ie, "serial0")
      rather than by the base address or full device path. Being
      able to resolve a device by alias frees userspace from the
      burden of otherwise having to maintain a mapping between
      device addresses and their logical assignments on each
      platform when multiple instances of the same hardware block
      are present in the system.
      
      Although the uevent device attribute contains devicetree
      compatible information and the full device path, the uevent
      does not list the alises that may have been defined for the
      device.
      Signed-off-by: NStepan Moskovchenko <stepanm@codeaurora.org>
      [grant.likely: Removed OF_ALIAS_N field; I don't think it's needed]
      [grant.likely: Added #ifndef _LINUX_OF_PRIVATE_H wrapper]
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      ced4eec9
  28. 28 1月, 2013 1 次提交
    • T
      OF: Fixup resursive locking code paths · 28d0e36b
      Thomas Gleixner 提交于
      There is no real reason to use a rwlock for devtree_lock. It even
      could be a mutex, but unfortunately it's locked from cpu hotplug
      paths which can't schedule :(
      
      So it needs to become a raw lock on rt as well.  The devtree_lock would
      be the only user of a raw_rw_lock, so we are better off cleaning up the
      recursive locking paths which allows us to convert devtree_lock to a
      read_lock.
      
      Here we do the standard thing of introducing __foo() as the "raw"
      version of foo(), so that we can take better control of the locking.
      The "raw" versions are not exported and are for internal use within
      the file itself.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NRob Herring <rob.herring@calxeda.com>
      28d0e36b
  29. 21 1月, 2013 1 次提交