1. 22 4月, 2016 3 次提交
    • J
      regulator: core: Move registration of regulator device · c438b9d0
      Jon Hunter 提交于
      The public functions to acquire a regulator, such as regulator_get(),
      internally look-up the regulator from the list of regulators that have
      been registered with the regulator device class. The registration of
      a new regulator with the regulator device class happens before the
      regulator has been completely setup. Therefore, it is possible that
      the regulator could be acquired before it has been setup successfully.
      To avoid this move the device registration of the regulator to the end
      of the regulator setup and update the error exit path accordingly.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c438b9d0
    • J
      regulator: core: Clear the supply pointer if enabling fails · 8e5356a7
      Jon Hunter 提交于
      During the resolution of a regulator's supply, we may attempt to enable
      the supply if the regulator itself is already enabled. If enabling the
      supply fails, then we will call _regulator_put() for the supply.
      However, the pointer to the supply has not been cleared for the
      regulator and this will cause a crash if we then unregister the
      regulator and attempt to call regulator_put() a second time for the
      supply. Fix this by clearing the supply pointer if enabling the supply
      after fails when resolving the supply for a regulator.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8e5356a7
    • J
      regulator: core: Don't terminate supply resolution early · 7ddede6a
      Jon Hunter 提交于
      The function regulator_register_resolve_supply() is called from the
      context of class_for_each_dev() (during the regulator registration) to
      resolve any supplies added. regulator_register_resolve_supply() will
      return an error if a regulator's supply cannot be resolved and this will
      terminate the loop in class_for_each_dev(). This means that we will not
      attempt to resolve any other supplies after one has failed. Hence, this
      may delay the resolution of other regulator supplies until the failing
      one itself can be resolved.
      
      Rather than terminating the loop early, don't return an error code and
      keep attempting to resolve any other supplies for regulators that have
      been registered.
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      7ddede6a
  2. 13 4月, 2016 1 次提交
  3. 12 4月, 2016 1 次提交
  4. 31 3月, 2016 1 次提交
    • J
      regulator: Fix deadlock during regulator registration · a2151374
      Jon Hunter 提交于
      Commit 5e3ca2b3 ("regulator: Try to resolve regulators supplies on
      registration") added a call to regulator_resolve_supply() within
      regulator_register() where the regulator_list_mutex is held. This causes
      a deadlock to occur on the Tegra114 Dalmore board when the palmas PMIC
      is registered because regulator_register_resolve_supply() calls
      regulator_dev_lookup() which may try to acquire the regulator_list_mutex
      again.
      
      Fix this by releasing the mutex before calling
      regulator_register_resolve_supply() and update the error exit path to
      ensure the mutex is released on an error.
      
      [Made commit message more legible -- broonie]
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      a2151374
  5. 28 3月, 2016 1 次提交
    • J
      regulator: Try to resolve regulators supplies on registration · 5e3ca2b3
      Javier Martinez Canillas 提交于
      Commit 6261b06d ("regulator: Defer lookup of supply to regulator_get")
      moved the regulator supplies lookup logic from the regulators registration
      to the regulators get time.
      
      Unfortunately, that changed the behavior of the regulator core since now a
      parent supply with a child regulator marked as always-on, won't be enabled
      unless a client driver attempts to get the child regulator during boot.
      
      This patch tries to resolve the parent supply for the already registered
      regulators each time that a new regulator is registered. So the regulators
      that have child regulators marked as always on will be enabled regardless
      if a driver gets the child regulator or not.
      
      That was the behavior before the mentioned commit, since parent supplies
      were looked up at regulator registration time instead of during child get.
      
      Since regulator_resolve_supply() checks for rdev->supply, most of the times
      it will be a no-op. Errors aren't checked to keep the possible out of order
      dependencies which was the motivation for the mentioned commit.
      
      Also, the supply being available will be enforced on regulator get anyways
      in case the resolve fails on regulators registration.
      
      Fixes: 6261b06d ("regulator: Defer lookup of supply to regulator_get")
      Suggested-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NJavier Martinez Canillas <javier@osg.samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: <stable@vger.kernel.org> # 4.1+
      5e3ca2b3
  6. 02 3月, 2016 2 次提交
  7. 25 2月, 2016 1 次提交
    • K
      regulator: core: fix crash in error path of regulator_register · 32165230
      Krzysztof Adamski 提交于
      This problem was introduced by:
      commit daad134d ("regulator: core: Request GPIO before creating
      sysfs entries")
      
      The error path was not updated correctly after moving GPIO registration
      code and in case regulator_ena_gpio_free failed, device_unregister() was
      called even though device_register() was not yet called.
      
      This problem breaks the boot at least on all Tegra 32-bit devices. It
      will also crash each device that specifices GPIO that is unavaiable at
      regulator_register call. Here's error log I've got when forced GPIO to
      be invalid:
      
      [    1.116612] usb-otg-vbus-reg: Failed to request enable GPIO10: -22
      [    1.122794] Unable to handle kernel NULL pointer dereference at
      virtual address 00000044
      [    1.130894] pgd = c0004000
      [    1.133598] [00000044] *pgd=00000000
      [    1.137205] Internal error: Oops: 5 [#1] SMP ARM
      
      and here's backtrace from KDB:
      
      Exception stack(0xef11fbd0 to 0xef11fc18)
      fbc0:                                     00000000 c0738a14 00000000 00000000
      fbe0: c0b2a0b0 00000000 00000000 c0738a14 c0b5fdf8 00000001 ef7f6074 ef11fc4c
      fc00: ef11fc50 ef11fc20 c02a8344 c02a7f1c 60000013 ffffffff
      [<c010cee0>] (__dabt_svc) from [<c02a7f1c>] (kernfs_find_ns+0x18/0xf8)
      [<c02a7f1c>] (kernfs_find_ns) from [<c02a8344>] (kernfs_find_and_get_ns+0x40/0x58)
      [<c02a8344>] (kernfs_find_and_get_ns) from [<c02ac4a4>] (sysfs_unmerge_group+0x28/0x68)
      [<c02ac4a4>] (sysfs_unmerge_group) from [<c044389c>] (dpm_sysfs_remove+0x30/0x5c)
      [<c044389c>] (dpm_sysfs_remove) from [<c0436ba8>] (device_del+0x48/0x1f4)
      [<c0436ba8>] (device_del) from [<c0436d84>] (device_unregister+0x30/0x6c)
      [<c0436d84>] (device_unregister) from [<c0403910>] (regulator_register+0x6d0/0xdac)
      [<c0403910>] (regulator_register) from [<c04052d4>] (devm_regulator_register+0x50/0x84)
      [<c04052d4>] (devm_regulator_register) from [<c0406298>] (reg_fixed_voltage_probe+0x25c/0x3c0)
      [<c0406298>] (reg_fixed_voltage_probe) from [<c043d21c>] (platform_drv_probe+0x60/0xb0)
      [<c043d21c>] (platform_drv_probe) from [<c043b078>] (driver_probe_device+0x24c/0x440)
      [<c043b078>] (driver_probe_device) from [<c043b5e8>] (__device_attach_driver+0xc0/0x120)
      [<c043b5e8>] (__device_attach_driver) from [<c043901c>] (bus_for_each_drv+0x6c/0x98)
      [<c043901c>] (bus_for_each_drv) from [<c043ad20>] (__device_attach+0xac/0x138)
      [<c043ad20>] (__device_attach) from [<c043b664>] (device_initial_probe+0x1c/0x20)
      [<c043b664>] (device_initial_probe) from [<c043a074>] (bus_probe_device+0x94/0x9c)
      [<c043a074>] (bus_probe_device) from [<c043a610>] (deferred_probe_work_func+0x80/0xcc)
      [<c043a610>] (deferred_probe_work_func) from [<c01381d0>] (process_one_work+0x158/0x454)
      [<c01381d0>] (process_one_work) from [<c013854c>] (worker_thread+0x38/0x510)
      [<c013854c>] (worker_thread) from [<c013e154>] (kthread+0xe8/0x104)
      [<c013e154>] (kthread) from [<c0108638>] (ret_from_fork+0x14/0x3c)
      Signed-off-by: NKrzysztof Adamski <krzysztof.adamski@tieto.com>
      Reported-by: NJon Hunter <jonathanh@nvidia.com>
      Acked-by: NJon Hunter <jonathanh@nvidia.com>
      Tested-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      32165230
  8. 22 2月, 2016 1 次提交
    • K
      regulator: core: Request GPIO before creating sysfs entries · daad134d
      Krzysztof Adamski 提交于
      regulator_attr_is_visible (which is a .is_visible callback of
      regulator_dev_group attribute_grpup) checks rdev->ena_pin to decide if
      "status" file should be present in sysfs. This field is set at the end
      of regulator_ena_gpio_request so it has to be called before
      device_register() otherwise this test will always fail, causing "status"
      file to not be visible.
      
      Since regulator_attr_is_visible also tests for is_enabled() op, this
      problem is only visible for regulators that does not define this
      callback, like regulator-fixed.c.
      Signed-off-by: NKrzysztof Adamski <krzysztof.adamski@tieto.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      daad134d
  9. 27 1月, 2016 1 次提交
  10. 07 1月, 2016 1 次提交
    • D
      regulator: core: remove some dead code · 70dc6daf
      Dan Carpenter 提交于
      Originally queue_delayed_work() used to negative error codes or 0 and 1
      on success depending if the work was queued or not.  It caused a lot of
      bugs where people treated all non-zero returns as failures so we changed
      it to return bool instead in d4283e93 ('workqueue: make queueing
      functions return bool').  Now it never returns failure.
      
      Checking for negative values causes a static checker warning since it is
      impossible based on the bool type.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      70dc6daf
  11. 05 1月, 2016 1 次提交
  12. 03 12月, 2015 2 次提交
    • T
      regulator: core: Fix nested locking of supplies · 70a7fb80
      Thierry Reding 提交于
      Commit fa731ac7 ("regulator: core: avoid unused variable warning")
      introduced a subtle change in how supplies are locked. Where previously
      code was always locking the regulator of the current iteration, the new
      implementation only locks the regulator if it has a supply. For any
      given power tree that means that the root will never get locked.
      
      On the other hand the regulator_unlock_supply() will still release all
      the locks, which in turn causes the lock debugging code to warn about a
      mutex being unlocked which wasn't locked.
      
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Fixes: Fixes: fa731ac7 ("regulator: core: avoid unused variable warning")
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      70a7fb80
    • M
      regulator: core: Ensure we lock all regulators · 49a6bb7a
      Mark Brown 提交于
      The latest workaround for the lockdep interface's not using the second
      argument of mutex_lock_nested() changed the loop missed locking the last
      regulator due to a thinko with the loop termination condition exiting
      one regulator too soon.
      Reported-by: NTyler Baker <tyler.baker@linaro.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      49a6bb7a
  13. 28 11月, 2015 1 次提交
    • A
      regulator: core: fix regulator_lock_supply regression · bb41897e
      Arnd Bergmann 提交于
      As noticed by Geert Uytterhoeven, my patch to avoid a harmless build warning
      in regulator_lock_supply() was total crap and introduced a real bug:
      
      > [ BUG: bad unlock balance detected! ]
      > kworker/u4:0/6 is trying to release lock (&rdev->mutex) at:
      > [<c0247b84>] regulator_set_voltage+0x38/0x50
      
      we still lock the regulator supplies, but not the actual regulators,
      so we are missing a lock, and the unlock is unbalanced.
      
      This rectifies it by first locking the regulator device itself before
      using the same loop as before to lock its supplies.
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 716fec9d1965 ("[SUBMITTED] regulator: core: avoid unused variable warning")
      Signed-off-by: NMark Brown <broonie@kernel.org>
      bb41897e
  14. 21 11月, 2015 1 次提交
    • A
      regulator: core: avoid unused variable warning · fa731ac7
      Arnd Bergmann 提交于
      The second argument of the mutex_lock_nested() helper is only
      evaluated if CONFIG_DEBUG_LOCK_ALLOC is set. Otherwise we
      get this build warning for the new regulator_lock_supply
      function:
      
      drivers/regulator/core.c: In function 'regulator_lock_supply':
      drivers/regulator/core.c:142:6: warning: unused variable 'i' [-Wunused-variable]
      
      To avoid the warning, this restructures the code to make it
      both simpler and to move the 'i++' outside of the mutex_lock_nested
      call, where it is now always used and the variable is not
      flagged as unused.
      
      We had some discussion about changing mutex_lock_nested to an
      inline function, which would make the code do the right thing here,
      but in the end decided against it, in order to guarantee that
      mutex_lock_nested() does not introduced overhead without
      CONFIG_DEBUG_LOCK_ALLOC.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 9f01cd4a ("regulator: core: introduce function to lock regulators and its supplies")
      Link: http://permalink.gmane.org/gmane.linux.kernel/2068900Signed-off-by: NMark Brown <broonie@kernel.org>
      fa731ac7
  15. 18 11月, 2015 1 次提交
  16. 04 11月, 2015 1 次提交
  17. 22 10月, 2015 1 次提交
    • S
      regulator: core: Propagate voltage changes to supply regulators · fc42112c
      Sascha Hauer 提交于
      Until now changing the voltage of a regulator only ever effected the
      regulator itself, but never its supplies. It's a common pattern though
      to put LDO regulators behind switching regulators. The switching
      regulators efficiently drop the input voltage but have a high ripple on
      their output. The output is then cleaned up by the LDOs. For higher
      energy efficiency the voltage drop at the LDOs should be minimized. For
      this scenario we need to propagate the voltage change to the supply
      regulators. Another scenario where voltage propagation is desired is
      a regulator which only consists of a switch and thus cannot regulate
      voltages itself. In this case we can pass setting voltages to the
      supply.
      
      This patch adds support for voltage propagation. We do voltage
      propagation when the current regulator has a minimum dropout voltage
      specified or if the current regulator lacks a get_voltage operation
      (indicating it's a switch and not a regulator).
      
      Changing the supply voltage must be done carefully. When we are
      increasing the current regulators output we must first increase the
      supply voltage and then the regulator itself. When we are decreasing the
      current regulators voltage we must decrease the supply voltage after
      changing the current regulators voltage.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      fc42112c
  18. 20 10月, 2015 1 次提交
  19. 17 10月, 2015 1 次提交
  20. 01 10月, 2015 3 次提交
  21. 22 9月, 2015 1 次提交
  22. 18 9月, 2015 1 次提交
  23. 17 9月, 2015 1 次提交
    • S
      regulator: core: Make error messages more informative · 7ebcf26c
      Stephen Boyd 提交于
      The same error print exists 4 times in the regulator core
      
      	<rdev>: operation not allowed
      
      Unfortunately, seeing this in the dmesg is not very informative.
      Add what type of operation is not allowed to the message so that
      these errors are unique, hopefully pointing developers in the
      right direction
      
      	<rdev>: drms operation not allowed
      	<rdev>: voltage operation not allowed
      	<rdev>: current operation not allowed
      	<rdev>: mode operation not allowed
      Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      7ebcf26c
  24. 02 9月, 2015 1 次提交
  25. 29 8月, 2015 1 次提交
  26. 18 8月, 2015 1 次提交
  27. 15 8月, 2015 1 次提交
  28. 13 8月, 2015 1 次提交
  29. 12 8月, 2015 3 次提交
  30. 07 8月, 2015 1 次提交
  31. 25 7月, 2015 1 次提交
  32. 17 7月, 2015 1 次提交