Merge branches 'clk-optional', 'clk-devm-clkdev-register', 'clk-allwinner', 'clk...
authorStephen Boyd <sboyd@kernel.org>
Fri, 8 Mar 2019 18:27:21 +0000 (10:27 -0800)
committerStephen Boyd <sboyd@kernel.org>
Fri, 8 Mar 2019 18:27:21 +0000 (10:27 -0800)
 - Add a {devm_}clk_get_optional() API
 - Add devm_clk_hw_register_clkdev() API to manage clkdev lookups

* clk-optional:
  clk: Add (devm_)clk_get_optional() functions
  clk: Add comment about __of_clk_get_by_name() error values

* clk-devm-clkdev-register:
  clk: clk-st: avoid clkdev lookup leak at remove
  clk: clk-max77686: Clean clkdev lookup leak and use devm
  clkdev: add managed clkdev lookup registration

* clk-allwinner:
  clk: sunxi-ng: sun8i-a23: Enable PLL-MIPI LDOs when ungating it

* clk-meson: (22 commits)
  clk: meson: meson8b: fix the naming of the APB clocks
  dt-bindings: clock: meson8b: add APB clock definition
  clk: meson: Add G12A AO Clock + Reset Controller
  dt-bindings: clk: add G12A AO Clock and Reset Bindings
  clk: meson: factorise meson64 peripheral clock controller drivers
  clk: meson: g12a: add peripheral clock controller
  dt-bindings: clk: meson: add g12a periph clock controller bindings
  clk: meson: pll: update driver for the g12a
  clk: meson: rework and clean drivers dependencies
  clk: meson: axg-audio does not require syscon
  clk: meson: use CONFIG_ARCH_MESON to enter meson clk directory
  clk: export some clk_hw function symbols for module drivers
  clk: meson: ao-clkc: claim clock controller input clocks from DT
  clk: meson: axg: claim clock controller input clock from DT
  clk: meson: gxbb: claim clock controller input clock from DT
  clk: meson: meson8b: add the GPU clock tree
  clk: meson: meson8b: use a separate clock table for Meson8
  clk: meson: axg-ao: add 32k generation subtree
  clk: meson: gxbb-ao: replace cec-32k with the dual divider
  clk: meson: add dual divider clock driver
  ...

* clk-renesas:
  clk: renesas: r8a774a1: Fix LAST_DT_CORE_CLK
  clk: renesas: r8a774c0: Fix LAST_DT_CORE_CLK
  clk: renesas: r8a774c0: Add TMU clock
  clk: renesas: r8a77980: Add RPC clocks
  clk: renesas: rcar-gen3: Add RPC clocks
  clk: renesas: rcar-gen3: Add spinlock
  clk: renesas: rcar-gen3: Factor out cpg_reg_modify()
  clk: renesas: r8a774c0: Correct parent clock of DU
  clk: renesas: r8a774a1: Add missing CANFD clock
  clk: renesas: r8a774c0: Add missing CANFD clock

1  2  3  4  5  6 
Documentation/driver-model/devres.txt
drivers/clk/Makefile
drivers/clk/clk.c
drivers/clk/clkdev.c

Simple merge
Simple merge
Simple merge
@@@@@@@ -456,18 -462,18 -464,75 -456,18 -456,18 -456,18 +470,75 @@@@@@@ int clk_hw_register_clkdev(struct clk_h
      {
        struct clk_lookup *cl;
      
-- ---  if (IS_ERR(hw))
-- ---          return PTR_ERR(hw);
++ +++  return do_clk_register_clkdev(hw, &cl, con_id, dev_id);
++ +++}
++ +++EXPORT_SYMBOL(clk_hw_register_clkdev);
      
-- ---  /*
-- ---   * Since dev_id can be NULL, and NULL is handled specially, we must
-- ---   * pass it as either a NULL format string, or with "%s".
-- ---   */
-- ---  if (dev_id)
-- ---          cl = __clk_register_clkdev(hw, con_id, "%s", dev_id);
-- ---  else
-- ---          cl = __clk_register_clkdev(hw, con_id, NULL);
++ +++static void devm_clkdev_release(struct device *dev, void *res)
++ +++{
++ +++  clkdev_drop(*(struct clk_lookup **)res);
++ +++}
+  +++
 -      return cl ? 0 : -ENOMEM;
++ +++static int devm_clk_match_clkdev(struct device *dev, void *res, void *data)
++ +++{
++ +++  struct clk_lookup **l = res;
 +    
-  ---  return cl ? 0 : -ENOMEM;
++ +++  return *l == data;
      }
-- ---EXPORT_SYMBOL(clk_hw_register_clkdev);
++ +++
++ +++/**
++ +++ * devm_clk_release_clkdev - Resource managed clkdev lookup release
++ +++ * @dev: device this lookup is bound
++ +++ * @con_id: connection ID string on device
++ +++ * @dev_id: format string describing device name
++ +++ *
++ +++ * Drop the clkdev lookup created with devm_clk_hw_register_clkdev.
++ +++ * Normally this function will not need to be called and the resource
++ +++ * management code will ensure that the resource is freed.
++ +++ */
++ +++void devm_clk_release_clkdev(struct device *dev, const char *con_id,
++ +++                       const char *dev_id)
++ +++{
++ +++  struct clk_lookup *cl;
++ +++  int rval;
++ +++
++ +++  cl = clk_find(dev_id, con_id);
++ +++  WARN_ON(!cl);
++ +++  rval = devres_release(dev, devm_clkdev_release,
++ +++                        devm_clk_match_clkdev, cl);
++ +++  WARN_ON(rval);
++ +++}
++ +++EXPORT_SYMBOL(devm_clk_release_clkdev);
++ +++
++ +++/**
++ +++ * devm_clk_hw_register_clkdev - managed clk lookup registration for clk_hw
++ +++ * @dev: device this lookup is bound
++ +++ * @hw: struct clk_hw to associate with all clk_lookups
++ +++ * @con_id: connection ID string on device
++ +++ * @dev_id: format string describing device name
++ +++ *
++ +++ * con_id or dev_id may be NULL as a wildcard, just as in the rest of
++ +++ * clkdev.
++ +++ *
++ +++ * To make things easier for mass registration, we detect error clk_hws
++ +++ * from a previous clk_hw_register_*() call, and return the error code for
++ +++ * those.  This is to permit this function to be called immediately
++ +++ * after clk_hw_register_*().
++ +++ */
++ +++int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw,
++ +++                          const char *con_id, const char *dev_id)
++ +++{
++ +++  int rval = -ENOMEM;
++ +++  struct clk_lookup **cl;
++ +++
++ +++  cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL);
++ +++  if (cl) {
++ +++          rval = do_clk_register_clkdev(hw, cl, con_id, dev_id);
++ +++          if (!rval)
++ +++                  devres_add(dev, cl);
++ +++          else
++ +++                  devres_free(cl);
++ +++  }
++ +++  return rval;
++ +++}
++ +++EXPORT_SYMBOL(devm_clk_hw_register_clkdev);