1. 31 8月, 2018 2 次提交
  2. 29 8月, 2018 1 次提交
    • J
      of: add helper to lookup compatible child node · 36156f92
      Johan Hovold 提交于
      Add of_get_compatible_child() helper that can be used to lookup
      compatible child nodes.
      
      Several drivers currently use of_find_compatible_node() to lookup child
      nodes while failing to notice that the of_find_ functions search the
      entire tree depth-first (from a given start node) and therefore can
      match unrelated nodes. The fact that these functions also drop a
      reference to the node they start searching from (e.g. the parent node)
      is typically also overlooked, something which can lead to use-after-free
      bugs.
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      36156f92
  3. 04 3月, 2018 1 次提交
    • F
      of: change overlay apply input data from unflattened to FDT · 39a751a4
      Frank Rowand 提交于
      Move duplicating and unflattening of an overlay flattened devicetree
      (FDT) into the overlay application code.  To accomplish this,
      of_overlay_apply() is replaced by of_overlay_fdt_apply().
      
      The copy of the FDT (aka "duplicate FDT") now belongs to devicetree
      code, which is thus responsible for freeing the duplicate FDT.  The
      caller of of_overlay_fdt_apply() remains responsible for freeing the
      original FDT.
      
      The unflattened devicetree now belongs to devicetree code, which is
      thus responsible for freeing the unflattened devicetree.
      
      These ownership changes prevent early freeing of the duplicated FDT
      or the unflattened devicetree, which could result in use after free
      errors.
      
      of_overlay_fdt_apply() is a private function for the anticipated
      overlay loader.
      
      Update unittest.c to use of_overlay_fdt_apply() instead of
      of_overlay_apply().
      
      Move overlay fragments from artificial locations in
      drivers/of/unittest-data/tests-overlay.dtsi into one devicetree
      source file per overlay.  This led to changes in
      drivers/of/unitest-data/Makefile and drivers/of/unitest.c.
      
        - Add overlay directives to the overlay devicetree source files so
          that dtc will compile them as true overlays into one FDT data
          chunk per overlay.
      
        - Set CFLAGS for drivers/of/unittest-data/testcases.dts so that
          symbols will be generated for overlay resolution of overlays
          that are no longer artificially contained in testcases.dts
      
        - Unflatten and apply each unittest overlay FDT using
          of_overlay_fdt_apply().
      
        - Enable the of_resolve_phandles() check for whether the unflattened
          overlay is detached.  This check was previously disabled because the
          overlays from tests-overlay.dtsi were not unflattened into detached
          trees.
      
        - Other changes to unittest.c infrastructure to manage multiple test
          FDTs built into the kernel image (access by name instead of
          arbitrary number).
      
        - of_unittest_overlay_high_level(): previously unused code to add
          properties from the overlay_base devicetree to the live tree
          was triggered by the restructuring of tests-overlay.dtsi and thus
          testcases.dts.  This exposed two bugs: (1) the need to dup a
          property before adding it, and (2) property 'name' is
          auto-generated in the unflatten code and thus will be a duplicate
          in the __symbols__ node - do not treat this duplicate as an error.
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      39a751a4
  4. 12 2月, 2018 1 次提交
    • S
      of: Support parsing phandle argument lists through a nexus node · bd6f2fd5
      Stephen Boyd 提交于
      Platforms like 96boards have a standardized connector/expansion
      slot that exposes signals like GPIOs to expansion boards in an
      SoC agnostic way. We'd like the DT overlays for the expansion
      boards to be written once without knowledge of the SoC on the
      other side of the connector. This avoids the unscalable
      combinatorial explosion of a different DT overlay for each
      expansion board and SoC pair.
      
      We need a way to describe the GPIOs routed through the connector
      in an SoC agnostic way. Let's introduce nexus property parsing
      into the OF core to do this. This is largely based on the
      interrupt nexus support we already have. This allows us to remap
      a phandle list in a consumer node (e.g. reset-gpios) through a
      connector in a generic way (e.g. via gpio-map). Do this in a
      generic routine so that we can remap any sort of variable length
      phandle list.
      
      Taking GPIOs as an example, the connector would be a GPIO nexus,
      supporting the remapping of a GPIO specifier space to multiple
      GPIO providers on the SoC. DT would look as shown below, where
      'soc_gpio1' and 'soc_gpio2' are inside the SoC, 'connector' is an
      expansion port where boards can be plugged in, and
      'expansion_device' is a device on the expansion board.
      
      	soc {
      		soc_gpio1: gpio-controller1 {
      			#gpio-cells = <2>;
      		};
      
      		soc_gpio2: gpio-controller2 {
      			#gpio-cells = <2>;
      		};
      	};
      
      	connector: connector {
      		#gpio-cells = <2>;
      		gpio-map = <0 0 &soc_gpio1 1 0>,
      			   <1 0 &soc_gpio2 4 0>,
      			   <2 0 &soc_gpio1 3 0>,
      			   <3 0 &soc_gpio2 2 0>;
      		gpio-map-mask = <0xf 0x0>;
      		gpio-map-pass-thru = <0x0 0x1>
      	};
      
      	expansion_device {
      		reset-gpios = <&connector 2 GPIO_ACTIVE_LOW>;
      	};
      
      The GPIO core would use of_parse_phandle_with_args_map() instead
      of of_parse_phandle_with_args() and arrive at the same type of
      result, a phandle and argument list. The difference is that the
      phandle and arguments will be remapped through the nexus node to
      the underlying SoC GPIO controller node. In the example above,
      we would remap 'reset-gpios' from <&connector 2 GPIO_ACTIVE_LOW>
      to <&soc_gpio1 3 GPIO_ACTIVE_LOW>.
      
      Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Mark Brown <broonie@kernel.org>
      Signed-off-by: NStephen Boyd <stephen.boyd@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      bd6f2fd5
  5. 08 1月, 2018 1 次提交
  6. 03 1月, 2018 1 次提交
  7. 08 11月, 2017 1 次提交
    • A
      of: add of_property_read_variable_* dummy helpers · 96c623e5
      Arnd Bergmann 提交于
      Commit a67e9472 ("of: Add array read functions with min/max size
      limits") added a new interface for reading variable-length arrays from
      DT properties. One user was added in dsa recently and this causes a
      build error because that code can be built with CONFIG_OF disabled:
      
      net/dsa/dsa2.c: In function 'dsa_switch_parse_member_of':
      net/dsa/dsa2.c:678:7: error: implicit declaration of function 'of_property_read_variable_u32_array'; did you mean 'of_property_read_u32_array'? [-Werror=implicit-function-declaration]
      
      This adds a dummy functions for of_property_read_variable_u32_array()
      and a few others that had been missing here. I decided to move
      of_property_read_string() and of_property_read_string_helper() in the
      process to make it easier to compare the two sets of function prototypes
      to make sure they match.
      
      Fixes: 975e6e32 ("net: dsa: rework switch parsing")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NRob Herring <robh@kernel.org>
      Reviewed-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      96c623e5
  8. 18 10月, 2017 3 次提交
    • F
      of: overlay: avoid race condition between applying multiple overlays · f948d6d8
      Frank Rowand 提交于
      The process of applying an overlay consists of:
        - unflatten an overlay FDT (flattened device tree) into an
          EDT (expanded device tree)
        - fixup the phandle values in the overlay EDT to fit in a
          range above the phandle values in the live device tree
        - create the overlay changeset to reflect the contents of
          the overlay EDT
        - apply the overlay changeset, to modify the live device tree,
          potentially changing the maximum phandle value in the live
          device tree
      
      There is currently no protection against two overlay applies
      concurrently determining what range of phandle values are in use
      in the live device tree, and subsequently changing that range.
      Add a mutex to prevent multiple overlay applies from occurring
      simultaneously.
      
      Move of_resolve_phandles() into of_overlay_apply() so that it does not
      have to be duplicated by each caller of of_overlay_apply().
      
      The test in of_resolve_phandles() that the overlay tree is detached is
      temporarily disabled so that old style overlay unittests do not fail.
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      f948d6d8
    • F
      of: overlay: detect cases where device tree may become corrupt · 24789c5c
      Frank Rowand 提交于
      When an attempt to apply an overlay changeset fails, an effort
      is made to revert any partial application of the changeset.
      When an attempt to remove an overlay changeset fails, an effort
      is made to re-apply any partial reversion of the changeset.
      
      The existing code does not check for failure to recover a failed
      overlay changeset application or overlay changeset revert.
      
      Add the missing checks and flag the devicetree as corrupt if the
      state of the devicetree can not be determined.
      
      Improve and expand the returned errors to more fully reflect the
      result of the effort to undo the partial effects of a failed attempt
      to apply or remove an overlay changeset.
      
      If the device tree might be corrupt, do not allow further attempts
      to apply or remove an overlay changeset.
      
      When creating an overlay changeset from an overlay device tree,
      add some additional warnings if the state of the overlay device
      tree is not as expected.
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      24789c5c
    • F
      of: overlay: rename identifiers to more reflect what they do · 0290c4ca
      Frank Rowand 提交于
      This patch is aimed primarily at drivers/of/overlay.c, but those
      changes also have a small impact in a few other files.
      
      overlay.c is difficult to read and maintain.  Improve readability:
        - Rename functions, types and variables to better reflect what
          they do and to be consistent with names in other places,
          such as the device tree overlay FDT (flattened device tree),
          and make the algorithms more clear
        - Use the same names consistently throughout the file
        - Update comments for name changes
        - Fix incorrect comments
      
      This patch is intended to not introduce any functional change.
      Signed-off-by: NFrank Rowand <frank.rowand@sony.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      0290c4ca
  9. 17 10月, 2017 4 次提交
  10. 14 10月, 2017 1 次提交
  11. 22 7月, 2017 1 次提交
  12. 22 6月, 2017 1 次提交
  13. 15 6月, 2017 1 次提交
  14. 01 6月, 2017 2 次提交
  15. 03 4月, 2017 1 次提交
  16. 29 3月, 2017 1 次提交
  17. 17 1月, 2017 1 次提交
  18. 10 12月, 2016 1 次提交
  19. 18 11月, 2016 1 次提交
    • S
      of: base: add support to get machine model name · e5269794
      Sudeep Holla 提交于
      Currently platforms/drivers needing to get the machine model name are
      replicating the same snippet of code. In some case, the OF reference
      counting is either missing or incorrect.
      
      This patch adds support to read the machine model name either using
      the "model" or the "compatible" property in the device tree root node
      to the core OF/DT code.
      
      This can be used to remove all the duplicate code snippets doing exactly
      same thing later.
      
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      e5269794
  20. 11 11月, 2016 1 次提交
    • A
      of/overlay: add of overlay notifications · 39a842e2
      Alan Tull 提交于
      This patch add of overlay notifications.
      
      When DT overlays are being added, some drivers/subsystems
      need to see device tree overlays before the changes go into
      the live tree.
      
      This is distinct from reconfig notifiers that are
      post-apply or post-remove and which issue very granular
      notifications without providing access to the context
      of a whole overlay.
      
      The following 4 notificatons are issued:
        OF_OVERLAY_PRE_APPLY
        OF_OVERLAY_POST_APPLY
        OF_OVERLAY_PRE_REMOVE
        OF_OVERLAY_POST_REMOVE
      
      In the case of pre-apply notification, if the notifier
      returns error, the overlay will be rejected.
      
      This patch exports two functions for registering/unregistering
      notifications:
        of_overlay_notifier_register(struct notifier_block *nb)
        of_overlay_notifier_unregister(struct notifier_block *nb)
      
      The of_mutex is held during these notifications. The
      notification data includes pointers to the overlay target
      and the overlay:
      
      struct of_overlay_notify_data {
             struct device_node *overlay;
             struct device_node *target;
      };
      Signed-off-by: NAlan Tull <atull@opensource.altera.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Acked-by: NMoritz Fischer <moritz.fischer@ettus.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39a842e2
  21. 15 9月, 2016 1 次提交
    • R
      of: Add array read functions with min/max size limits · a67e9472
      Richard Fitzgerald 提交于
      Add a new set of array reading functions that take a minimum and
      maximum size limit and will fail if the property size is not within
      the size limits. This makes it more convenient for drivers that
      use variable-size DT arrays which must be bounded at both ends -
      data must be at least N entries but must not overflow the array
      it is being copied into. It is also more efficient than making this
      functionality out of existing public functions and avoids duplication.
      
      The existing array functions have been left in the API, since there
      are a very large number of clients of those functions and their
      existing functionality is still useful. This avoids turning a small
      API improvement into a major kernel rework.
      
      The old functions have been turned into mininmal static inlines calling
      the new functions. The old functions had no upper limit on the actual
      size of the dts entry, to preserve this functionality rather than keeping
      two near-identical implementations, if the new function is called with
      max=0 there is no limit on the size of the dts entry but only the min
      number of elements are read.
      Signed-off-by: NRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      a67e9472
  22. 20 7月, 2016 1 次提交
  23. 28 6月, 2016 1 次提交
    • D
      of: Add a new macro to declare_of for one parameter function returning a value · c35d9292
      Daniel Lezcano 提交于
      The macro OF_DECLARE_1 expect a void (*func)(struct device_node *) while the
      OF_DECLARE_2 expect a int (*func)(struct device_node *, struct device_node *).
      
      The second one allows to pass an init function returning a value, which make
      possible to call the functions in the table and check the return value in order
      to catch at a higher level the errors and handle them from there instead of
      doing a panic in each driver (well at least this is the case for the clkevt).
      
      Unfortunately the OF_DECLARE_1 does not allow that and that lead to some code
      duplication and crappyness in the drivers.
      
      The OF_DECLARE_1 is used by all the clk drivers and the clocksource/clockevent
      drivers. It is not possible to do the change in one shot as we have to change
      all the init functions.
      
      The OF_DECLARE_2 specifies an init function prototype with two parameters with
      the node and its parent. The latter won't be used, ever, in the timer drivers.
      
      Introduce a OF_DECLARE_1_RET macro to be used, and hopefully we can smoothly
      and iteratively change the users of OF_DECLARE_1 to use the new macro instead.
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Acked-by: NRob Herring <robh@kernel.org>
      c35d9292
  24. 26 6月, 2016 1 次提交
  25. 03 6月, 2016 1 次提交
  26. 28 4月, 2016 1 次提交
  27. 20 4月, 2016 4 次提交
  28. 16 4月, 2016 1 次提交
  29. 04 3月, 2016 1 次提交
  30. 25 1月, 2016 1 次提交