summaryrefslogtreecommitdiff
path: root/drivers/regulator
AgeCommit message (Collapse)AuthorFilesLines
2019-07-26regulator: s2mps11: Fix buck7 and buck8 wrong voltagesKrzysztof Kozlowski1-2/+2
commit 16da0eb5ab6ef2dd1d33431199126e63db9997cc upstream. On S2MPS11 device, the buck7 and buck8 regulator voltages start at 750 mV, not 600 mV. Using wrong minimal value caused shifting of these regulator values by 150 mV (e.g. buck7 usually configured to v1.35 V was reported as 1.2 V). On most of the boards these regulators are left in default state so this was only affecting reported voltage. However if any driver wanted to change them, then effectively it would set voltage 150 mV higher than intended. Cc: <stable@vger.kernel.org> Fixes: cb74685ecb39 ("regulator: s2mps11: Add samsung s2mps11 regulator driver") Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-26regulator: s2mps11: Fix ERR_PTR dereference on GPIO lookup failureKrzysztof Kozlowski1-0/+1
commit 70ca117b02f3b1c8830fe95e4e3dea2937038e11 upstream. If devm_gpiod_get_from_of_node() call returns ERR_PTR, it is assigned into an array of GPIO descriptors and used later because such error is not treated as critical thus it is not propagated back to the probe function. All code later expects that such GPIO descriptor is either a NULL or proper value. This later might lead to dereference of ERR_PTR. Only devices with S2MPS14 flavor are affected (other do not control regulators with GPIOs). Fixes: 1c984942f0a4 ("regulator: s2mps11: Pass descriptor instead of GPIO number") Cc: <stable@vger.kernel.org> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-26gpio: Fix return value mismatch of function gpiod_get_from_of_node()Waibel Georg4-5/+12
[ Upstream commit 025bf37725f1929542361eef2245df30badf242e ] In case the requested gpio property is not found in the device tree, some callers of gpiod_get_from_of_node() expect a return value of NULL, others expect -ENOENT. In particular devm_fwnode_get_index_gpiod_from_child() expects -ENOENT. Currently it gets a NULL, which breaks the loop that tries all gpio_suffixes. The result is that a gpio property is not found, even though it is there. This patch changes gpiod_get_from_of_node() to return -ENOENT instead of NULL when the requested gpio property is not found in the device tree. Additionally it modifies all calling functions to properly evaluate the return value. Another approach would be to leave the return value of gpiod_get_from_of_node() as is and fix the bug in devm_fwnode_get_index_gpiod_from_child(). Other callers would still need to be reworked. The effort would be the same as with the chosen solution. Signed-off-by: Georg Waibel <georg.waibel@sensor-technik.de> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: da9055: Fix notifier mutex lock warningSteve Twiss1-0/+2
[ Upstream commit 5e6afb3832bedf420dd8e4c5b32ed85117c5087d ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: f6130be652d0 ("regulator: DA9055 regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: da9062: Fix notifier mutex lock warningSteve Twiss1-0/+2
[ Upstream commit 978995def0f6030aa6b3b494682f673aca13881b ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 4068e5182ada ("regulator: da9062: DA9062 regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: pv88090: Fix notifier mutex lock warningSteve Twiss1-0/+4
[ Upstream commit 275513b7695a61b75b2546406ecd0f8e3d9fc8be ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: c90456e36d9c ("regulator: pv88090: new regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: wm831x: Fix notifier mutex lock warningSteve Twiss1-0/+4
[ Upstream commit 119c4f5085c45b60cb23c5595e45d06135b89518 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: e4ee831f949a ("regulator: Add WM831x DC-DC buck convertor support") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: pv88080: Fix notifier mutex lock warningSteve Twiss1-0/+4
[ Upstream commit 1867af94cfdf37fc70fe67b3d522e78352800196 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 99cf3af5e2d5 ("regulator: pv88080: new regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: da9063: Fix notifier mutex lock warningSteve Twiss1-1/+4
[ Upstream commit 29d40b4a5776ec4727c9f0e00a884423dd5e3366 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 69ca3e58d178 ("regulator: da9063: Add Dialog DA9063 voltage regulators support.") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: da9211: Fix notifier mutex lock warningSteve Twiss1-0/+4
[ Upstream commit 65378de3359d30ebce44762d8b8027f372b5b1c4 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 1028a37daa14 ("regulator: da9211: new regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: lp8755: Fix notifier mutex lock warningSteve Twiss1-3/+12
[ Upstream commit 89b2758c192c35068b07766a6830433bfbdc1f44 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: b59320cc5a5e ("regulator: lp8755: new driver for LP8755") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: pv88060: Fix notifier mutex lock warningSteve Twiss1-0/+4
[ Upstream commit f58213637206e190453e3bd91f98f535566290a3 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: f307a7e9b7af ("regulator: pv88060: new regulator driver") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: ltc3589: Fix notifier mutex lock warningSteve Twiss1-2/+8
[ Upstream commit f132da2534ec6599c78c4adcef15340cff2e9dd9 ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 3eb2c7ecb7ea ("regulator: Add LTC3589 support") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: ltc3676: Fix notifier mutex lock warningSteve Twiss1-2/+8
[ Upstream commit 769fc8d4182c1d1875db7859852afeb436714c5c ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 37b918a034fe ("regulator: Add LTC3676 support") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: wm831x isink: Fix notifier mutex lock warningSteve Twiss1-0/+2
[ Upstream commit f7a621728a6a23bfd2c6ac4d3e42e1303aefde0f ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: d4d6b722e780 ("regulator: Add WM831x ISINK support") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: wm831x ldo: Fix notifier mutex lock warningSteve Twiss1-0/+2
[ Upstream commit 8be64b6d87bd47d81753b60ddafe70102ebfd76b ] The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: d1c6b4fe668b ("regulator: Add WM831x LDO support") Suggested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: core: Avoid potential deadlock on regulator_unregisterCharles Keepax1-1/+2
[ Upstream commit 063773011d33bb36588a90385aa9eb75d13c6d80 ] Lockdep reports the following issue on my setup: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((work_completion)(&(&rdev->disable_work)->work)); lock(regulator_list_mutex); lock((work_completion)(&(&rdev->disable_work)->work)); lock(regulator_list_mutex); The problem is that regulator_unregister takes the regulator_list_mutex and then calls flush_work on disable_work. But regulator_disable_work calls regulator_lock_dependent which will also take the regulator_list_mutex. Resulting in a deadlock if the flush_work call actually needs to flush the work. Fix this issue by moving the flush_work outside of the regulator_list_mutex. The list mutex is not used to guard the point at which the delayed work is queued, so its use adds no additional safety. Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-31regulator: core: Actually put the gpiod after useLinus Walleij1-0/+1
[ Upstream commit 78927aa40bc82f32de07323ddc1c9de07ac68180 ] I went to great lengths to hand over the management of the GPIO descriptors to the regulator core, and some stray rebased oneliner in the old patch must have been assuming the devices were still doing devres management of it. We handed the management over to the regulator core, so of course the regulator core shall issue gpiod_put() when done. Sorry for the descriptor leak. Fixes: 541d052d7215 ("regulator: core: Only support passing enable GPIO descriptors") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-25regulator: core: fix error path for regulator_set_voltage_unlockedSteve Twiss1-7/+4
commit 70b464918e5331e488058870fcc6821d54c4e541 upstream. During several error paths in the function regulator_set_voltage_unlocked() the value of 'ret' can take on negative error values. However, in calls that go through the 'goto out' statement, this return value is lost and return 0 is used instead, indicating a 'pass'. There are several cases where this function should legitimately return a fail instead of a pass: one such case includes constraints check during voltage selection in the call to regulator_check_voltage(), which can have -EINVAL for the case when an unsupported voltage is incorrectly requested. In that case, -22 is expected as the return value, not 0. Fixes: 9243a195be7a ("regulator: core: Change voltage setting path") Cc: stable <stable@vger.kernel.org> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-04regulator: mc13xxx: Constify regulator_ops variablesAxel Lin4-10/+10
These regulator_ops variables should never change, make them const. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: palmas: Constify palmas_smps_ramp_delay arrayAxel Lin1-1/+1
The palmas_smps_ramp_delay array should never modify, make it const. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: wm831x-dcdc: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-36/+6
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: pv88090: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-45/+8
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>; Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: pv88080: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-47/+8
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: pv88060: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-44/+7
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04Merge branch 'for-5.0' of ↵Mark Brown5-7/+8
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-5.1
2019-03-04regulator: max77650: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-49/+25
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: lp873x: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-39/+6
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: lp872x: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-60/+10
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: da9210: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-46/+7
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: da9055: Convert to use regulator_set/get_current_limit_regmapAxel Lin1-36/+9
Use regulator_set/get_current_limit_regmap helpers to save some code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-04regulator: core: Add set/get_current_limit helpers for regmap usersAxel Lin1-0/+86
By setting curr_table, n_current_limits, csel_reg and csel_mask, the regmap users can use regulator_set_current_limit_regmap and regulator_get_current_limit_regmap for set/get_current_limit callbacks. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-28regulator: stm32-vrefbuf: add power management supportFabrice Gasnier1-7/+114
Add support for suspend/resume and runtime PM to stm32-vrefbuf driver. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: 88pm8607: Remove unused fields from struct pm8607_regulator_infoAxel Lin1-14/+5
The *i2c and *i2c_8606 are no longer used since this driver was converted to use regmap helpers. The *chip and *regulator are not really required. So remove these unused fields. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: 88pm8607: Simplify pm8607_list_voltage implementationAxel Lin1-9/+10
Set volt_table filed then we can use regulator_list_voltage_table. Since we have volt_table setting, now we can remove vol_table from struct pm8607_regulator_info. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: cpcap: Constify omap4_regulators and xoom_regulatorsAxel Lin1-2/+2
They should never change, make them const. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: cpcap: Remove unused vsel_shift from struct cpcap_regulatorAxel Lin1-52/+50
This driver uses regulator_get/set_voltage_sel_regmap so it does not use vsel_shift. Actually, vsel_shift can be calculated by vsel_mask setting. Signed-off-by: Axel Lin <axel.lin@ingics.com> Tested-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: da9062: Use struct_size() in devm_kzalloc()Gustavo A. R. Silva1-4/+2
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; struct boo entry[]; }; size = sizeof(struct foo) + count * sizeof(struct boo); instance = alloc(size, GFP_KERNEL) Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = alloc(struct_size(instance, entry, count), GFP_KERNEL) Notice that, in this case, variable size is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: mcp16502: Remove module versionAxel Lin1-1/+0
The module version is unlikely to be updated, use kernel version should be enough. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: fan53555: Check pdata->slew_rate settingAxel Lin1-3/+5
Current code does not really avoid array access out of bounds, fix it by add checking for pdata->slew_rate. If pdata->slew_rate is too big, it's a bug in pdata that needs fix. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: arizona_ldo1: Simplify arizona_ldo1_hc_set/get_voltage_selAxel Lin1-13/+6
Setup .vsel_reg and .vsel_mask then we can use the standard set/get_voltage_sel_regmap helpers to simplify the code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-26regulator: wm831x-dcdc: Fix list of wm831x_dcdc_ilim from mA to uAAxel Lin1-2/+2
The wm831x_dcdc_ilim entries needs to be uA because it is used to compare with min_uA and max_uA. While at it also make the array const and change to use unsigned int. Fixes: e4ee831f949a ("regulator: Add WM831x DC-DC buck convertor support") Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-22regulator: da9063: Use struct_size() in devm_kzalloc()Gustavo A. R. Silva1-4/+2
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; struct boo entry[]; }; size = sizeof(struct foo) + count * sizeof(struct boo); instance = alloc(size, GFP_KERNEL) Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = alloc(struct_size(instance, entry, count), GFP_KERNEL) Notice that, in this case, variable size is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-22regulator: mt6311: Use linear instead of linear range for mt6311_buck_opsAxel Lin1-8/+2
Current code already set .min_uV and .uV_step fields and it actually can use regulator_list_voltage_linear. So remove buck_volt_range and use regulator_list_voltage_linear instead. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-22regulator: max77650: Fix set_current_limit implementationAxel Lin1-4/+2
Current code always return error, fix it. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-22regulator: tps65218: Add support for LS2Christian Hohnstaedt1-5/+13
Re-use the "tps65218_pmic_*_current_limit()" functions of LS3 and calculate the different required bit-shift by counting the trailing 0s in "struct regulator_desc.csel_mask" Signed-off-by: Christian Hohnstaedt <Christian.Hohnstaedt@wago.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-21regulator: s5m8767: Simplify s5m8767_set_voltage_time_sel implementationAxel Lin1-5/+1
Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-21regulator: s5m8767: Constify s5m8767_opmode_regAxel Lin1-1/+1
The s5m8767_opmode_reg should never change, make it const. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-21regulator: core: Log forbidden DRMS operationMarc Gonzalez1-1/+3
When REGULATOR_CHANGE_DRMS is not set, drms_uA_update is a no-op. It used to print a debug message, which was dropped in commit 8a34e979f684 ("regulator: refactor valid_ops_mask checking code") Let's bring the debug message back, because it helps find missing regulator-allow-set-load properties. Signed-off-by: Marc Gonzalez <marc.w.gonzalez@free.fr> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-21regulator: lp873x: Constify lp873x_buck_ramp_delay arrayAxel Lin1-1/+1
The lp873x_buck_ramp_delay should never change, make it const. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>