1
Commit Graph

5065 Commits

Author SHA1 Message Date
Christophe JAILLET
4591a2271f
regulator: sm5703: Remove because it is unused and fails to build
This file does not compile because <linux/mfd/sm5703.h> is missing.
In KConfig, it depends on MFD_SM5703.

Both MFD_SM5703 and the missing include rely on another patch that never
got merged. The last iteration related to this patch is [1].

So remove this dead-code and undo commit e8858ba89c ("regulator:
sm5703-regulator: Add regulators support for SM5703 MFD")

[1]: https://lore.kernel.org/lkml/20220423085319.483524-5-markuss.broks@gmail.com/

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/0f5da91a05e7343d290c88e3c583b674cf6219ac.1725910247.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-13 19:08:14 +01:00
Chen-Yu Tsai
2a1de56789
regulator: Split up _regulator_get()
_regulator_get() contains a lot of common code doing checks prior to the
regulator lookup and housekeeping work after the lookup. Almost all the
code could be shared with a OF-specific variant of _regulator_get().

Split out the common parts so that they can be reused. The OF-specific
version of _regulator_get() will be added in a subsequent patch.
No functional changes were made.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240911072751.365361-4-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-13 17:39:48 +01:00
André Draszik
fb9ce84a01
regulator: update some comments ([gs]et_voltage_vsel vs [gs]et_voltage_sel)
Some comments here are referring to a non-existent
regulator_ops::get_voltage_vsel() where ::get_voltage_sel() is meant,
and similar for ::set_voltage_vsel() / ::set_voltage_sel().

Update the comments.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
Link: https://patch.msgid.link/20240913-regulator-typos-v1-1-92781c93f638@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-13 14:57:08 +01:00
Jinjie Ruan
ff97b9c0df
regulator: max8973: Use irq_get_trigger_type() helper
Use irq_get_trigger_type() to replace irq_get_irq_data() and then
irqd_get_trigger_type(), if the irq data is NULL it will return 0.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://patch.msgid.link/20240913013503.3754712-1-ruanjinjie@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-13 14:57:07 +01:00
Wei Fang
a1d12410d9
regulator: core: fix the broken behavior of regulator_dev_lookup()
The behavior of regulator_dev_lookup() for non-DT way has been broken
since the commit b8c3255457 ("regulator: Move OF-specific regulator
lookup code to of_regulator.c").

Before the commit, of_get_regulator() was used to get the regulator,
which returns NULL if the regulator is not found. So the regulator
will be looked up through regulator_lookup_by_name() if no matching
regulator is found in regulator_map_list.

However, currently, of_regulator_dev_lookup() is used to instead of
of_get_regulator(), but the variable 'r' is set to ERR_PTR(-ENODEV)
instead of NULL if the regulator is not found. In this case, if no
regulator is found in regulator_map_list, the variable 'r' is still
ERR_PTR(-ENODEV), So regulator_dev_lookup() returns the value of 'r'
directly instead of continuing to look up the regulator through
regulator_lookup_by_name().

Fixes: b8c3255457 ("regulator: Move OF-specific regulator lookup code to of_regulator.c")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20240911120338.526384-1-wei.fang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-11 15:39:01 +01:00
Mark Brown
5faf6daf65
regulator: Few constifications of static data
Merge series from Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>:

Few cleanups (safer code), built tested.  Last two patches should
probably be tested.
2024-09-11 11:20:37 +01:00
Krzysztof Kozlowski
c4d6a80471
regulator: max77650: Use container_of and constify static data
Switch from rdev_get_drvdata() to container_of(), so the static
'struct max77650_regulator_desc' holding 'struct regulator_desc' can
be made const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-17-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:18 +01:00
Krzysztof Kozlowski
7dd36b3287
regulator: hi6421v530: Use container_of and constify static data
Switch from rdev_get_drvdata() to container_of(), so the static
'struct hi6421v530_regulator_info' holding 'struct regulator_desc' can
be made const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-16-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:17 +01:00
Krzysztof Kozlowski
e9c7ff34c2
regulator: hi6421v530: Drop unused 'eco_microamp'
The hi6421v530_regulator_info.eco_microamp is assigned once and never
used again.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-15-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:16 +01:00
Krzysztof Kozlowski
7eb5d065ec
regulator: qcom-refgen: Constify static data
Driver does not modify static data with regulator description (struct
regulator_desc), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-14-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:15 +01:00
Krzysztof Kozlowski
6f4fd2b8a5
regulator: pfuze100: Constify static data
Driver does not modify static data with regulator description (struct
pfuze_regulator), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-13-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:14 +01:00
Krzysztof Kozlowski
7f1bfca46b
regulator: pcap: Constify static data
Driver does not modify static data with regulator description (struct
pcap_regulator), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-12-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:13 +01:00
Krzysztof Kozlowski
90b94a05b6
regulator: mtk-dvfsrc: Constify static data
Driver does not modify static data with regulator description (struct
regulator_desc), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-11-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:12 +01:00
Krzysztof Kozlowski
96d7ee7cb0
regulator: max77826: Constify static data
Driver does not modify static data with regulator description (struct
regulator_desc), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-10-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:11 +01:00
Krzysztof Kozlowski
653976707d
regulator: max77826: Drop unused 'rdesc' in 'struct max77826_regulator_info'
The max77826_regulator_info.rdesc is assigned once and never used again.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-9-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:10 +01:00
Krzysztof Kozlowski
7fb636dc26
regulator: tps65023: Constify static data
Driver does not modify static data with regulator description (struct
tps_driver_data), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-8-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:09 +01:00
Krzysztof Kozlowski
5ec424afc9
regulator: hi6421v600: Constify static data
Driver does not modify static data with regulator description (struct
hi6421_spmi_reg_info), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-7-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:08 +01:00
Krzysztof Kozlowski
b94afa51ca
regulator: hi6421: Constify static data
Driver does not modify static data with regulator description (struct
hi6421_regulator_info), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-6-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:07 +01:00
Krzysztof Kozlowski
b3f1e8e32e
regulator: da9121: Constify static data
Driver does not modify static data with regulator description (struct
da9121_range), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-4-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:06 +01:00
Krzysztof Kozlowski
0601c1e5c4
regulator: da9063: Constify static data
Driver does not modify static data with device variant description
(struct da9063_dev_model), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-3-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:05 +01:00
Krzysztof Kozlowski
dfa9e708c6
regulator: da9055: Constify static data
Driver does not modify static data with regulators description (struct
da9055_regulator_info), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-2-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:04 +01:00
Krzysztof Kozlowski
9653007e7d
regulator: da9052: Constify static data
Driver does not modify static data with regulators description (struct
da9052_regulator_info), so make it const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-1-8934704a5787@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:44:03 +01:00
Yu Jiaoliang
886fee3525
regulator: Fix typos in the comment
Fixed some confusing typographical errors:
comptabile->compatible,
asignment->assignment,
Verison->Version,
meansurement->measurement,
offets->offsets.

Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Link: https://patch.msgid.link/20240910064631.3223441-1-yujiaoliang@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-10 12:40:38 +01:00
Christophe JAILLET
63a68ee1c2
regulator: tps6287x: Constify struct regulator_desc
'struct regulator_desc' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   4974	    736	     16	   5726	   165e	drivers/regulator/tps6287x-regulator.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   5294	    416	     16	   5726	   165e	drivers/regulator/tps6287x-regulator.o

--
Compile tested only

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/7727e493490d37775a653905dfe0cc1d8478f8e0.1725908163.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-09 21:08:43 +01:00
Christophe JAILLET
48cc042bd6
regulator: wm8400: Constify struct regulator_desc
'struct regulator_desc' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   4419	   2512	      0	   6931	   1b13	drivers/regulator/wm8400-regulator.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   6307	    624	      0	   6931	   1b13	drivers/regulator/wm8400-regulator.o

--
Compile tested only

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/fde33ecfd9bbdbdc1da1620c9f3b1b7a72f9d805.1725906876.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-09 21:08:42 +01:00
Christophe JAILLET
0c0966b501
regulator: da9211: Constify struct regulator_desc
'struct regulator_desc' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  13982	   2118	     16	  16116	   3ef4	drivers/regulator/da9211-regulator.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  14622	   1478	     16	  16116	   3ef4	drivers/regulator/da9211-regulator.o

--
Compile tested only

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/54258bfe11112d70d2f1eb1deda2791eb9ef99c1.1725784852.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-09 18:27:02 +01:00
Christophe JAILLET
97e63bc35f
regulator: mp5416: Constify struct regulator_desc
'struct regulator_desc' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   3516	   5320	     32	   8868	   22a4	drivers/regulator/mp5416.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   8508	    320	     32	   8860	   229c	drivers/regulator/mp5416.o

--
Compile tested only

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/fd8d1307f211ec7754f46b6678c04309556003bc.1725807320.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-09 18:27:01 +01:00
Mark Brown
8651db0fcb
regulator: Add AXP717 boost support
Merge series from Andre Przywara <andre.przywara@arm.com>:

This is remainder of the AXP717 fix series, containing support for the
boost regulator. This is meant to increase the battery voltage to the 5
volts required to provide the USB VBUS power.
It's the usual trinity of DT bindings patch (1/3), the MFD part
describing the PMIC registers (2/3) and the final patch to model the
regulator (3/3).
Compared to v2, this drops the merged patches, and just retains the
boost related parts. It also changes the internal name of the register
to AXP717_MODULE_EN_CONTROL_2, since there is another control register
we will need later for battery support.
2024-09-07 01:44:08 +01:00
Andre Przywara
22dfe2ea1d
regulator: axp20x: AXP717: Add boost regulator
The AXP717 also contains an adjustable boost regulator, to provide the
5V USB VBUS rail when running on battery.

Add the regulator description that states the voltage range this
regulator can cover.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: John Watts <contact@jookia.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://patch.msgid.link/20240816001824.6028-4-andre.przywara@arm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-06 22:17:36 +01:00
Andy Shevchenko
401d078eaf
regulator: of: Refactor of_get_*regulator() to decrease indentation
Refactor of_get_*regulator() to decrease indentation and increase readability.
No functional changes intended.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240904190856.1221459-1-andy.shevchenko@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-05 19:15:52 +01:00
Chen-Yu Tsai
b8c3255457
regulator: Move OF-specific regulator lookup code to of_regulator.c
There's still a bit of OF-specific code in the regulator device lookup
function.

Move those bits of code over to of_regulator.c, and create a new
function of_regulator_dev_lookup() to encapsulate the code moved out of
regulator_dev_lookup().

Also mark of_find_regulator_by_node() as static, since there are no
other users in other compile units.

There are no functional changes. A line alignment was also fixed.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240904090016.2841572-4-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-09-04 13:15:21 +01:00
Chen-Yu Tsai
98ce82a528
regulator: Unify "negative error number" terminology in comments
Previous commits cleaning up kerneldoc used the term "negative error
number" to refer to error condition return values. Update remaining
instances of other terminology such as "error code" or "errno" as
well so the whole regulator subsystem is unified.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-11-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:30 +01:00
Chen-Yu Tsai
6eace77a60
regulator: of: Fix kerneldoc format for of_regulator_bulk_get_all()
of_regulator_bulk_get_all() has a comment section that pretty much
resembles a kerneldoc block, except that the block begins with "/*"
instead of "/**".

Fix that and also rework the "Return" section and the error code
terminology so that it is the same as the other kerneldoc blocks
in the same file.

Fixes: 27b9ecc7a9 ("regulator: Add of_regulator_bulk_get_all")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-10-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:30 +01:00
Chen-Yu Tsai
77904c8170
regulator: irq_helpers: Fix regulator_irq_map_event_simple() kerneldoc
kernel-doc complains about missing "Return" section for the function
regulator_irq_map_event_simple().

Add a "Return" section for it based on its behavior. The function
actually always returns 0, but fills in fields in its @rid parameter as
needed. Expand the description of the parameter to cover this.

While at it fix a typo found in the description of the same function.

Reported-by: Matti Vaittinen <mazziesaccount@gmail.com>
Closes: https://lore.kernel.org/all/e341240e-1c1f-49a2-91cd-440888fdbda0@gmail.com/
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-9-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:29 +01:00
Chen-Yu Tsai
4ddb16cf53
regulator: fixed-helper: Add missing "Return" kerneldoc section
kernel-doc complains about missing "Return" section for the function
regulator_register_always_on().

Add a "Return" section for it based on its behavior.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-8-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:28 +01:00
Chen-Yu Tsai
5f93c59e60
regulator: fixed: Fix incorrectly formatted kerneldoc "Return" section
kernel-doc complains about missing "Return" section for kerneldoc of
of_get_fixed_voltage_config(). The kerneldoc has a description
about the return values, just not in the format kernel-doc wants.

Convert it to use the proper "Return:" section header. The existing
description have been reworded and moved around to fit the grammar and
formatting.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-7-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:27 +01:00
Chen-Yu Tsai
dac41d59f2
regulator: of: Fix incorrectly formatted kerneldoc "Return" sections
kernel-doc complains about missing "Return" section for many documented
functions in the regulator OF-specific code. These all have descriptions
about the return values, just not in the format kernel-doc wants.

Convert these to use the proper "Return:" section header. The existing
descriptions have been reworded and moved around to fit the grammar and
formatting.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-6-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:26 +01:00
Chen-Yu Tsai
4ac204ff2d
regulator: core: Add missing kerneldoc "Return" sections
kernel-doc complains about missing "Return" section for many documented
functions in the regulator core. Some with free-form return value
descriptions have been fixed in the previous patch. The remaining are
completely missing any mention of return values.

Add "Return" sections to these kerneldoc blocks with basic descriptions.
In a few cases where the functions don't call even more functions and
the error numbers are known, those are documented in detail.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-5-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:25 +01:00
Chen-Yu Tsai
f746af13dd
regulator: core: Fix incorrectly formatted kerneldoc "Return" sections
kernel-doc complains about missing "Return" section for many documented
functions in the regulator core. Many of them actually have descriptions
about the return values, just not in the format kernel-doc wants.

Convert these to use the proper "Return:" section header. The existing
descriptions have been reworded and moved around to fit the grammar and
formatting.

In a few cases where the functions don't call even more functions
and the error numbers are known, those are documented in detail.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-4-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:24 +01:00
Chen-Yu Tsai
753b9d86ad
regulator: core: Fix regulator_is_supported_voltage() kerneldoc return value
The kerneldoc for regulator_is_supported_voltage() states that the
return value is a boolean. That is not correct, as it could return an
error number if the check failed.

Fix the description by expanding it to cover the valid return values and
error conditions. The description is also converted to a proper "Return"
section.

Fixes: c5f3939b8f ("regulator: core: Support fixed voltages in regulator_is_supported_voltage()")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-3-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:23 +01:00
Chen-Yu Tsai
caa08dd8cd
regulator: core: Fix short description for _regulator_check_status_enabled()
kernel-doc complains that _regulator_check_status_enabled() is missing a
short description.

Since the current description is already quite short, just trim it a bit
more and use it as the short description.

Fixes: f7d7ad42a9 ("regulator: Allow regulators to verify enabled during enable()")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20240829085131.1361701-2-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-29 14:20:22 +01:00
Rob Herring (Arm)
dd72a3b8a6
regulator: qcom_spmi: Use of_property_read_bool()
Use of_property_read_bool() to read boolean properties rather than
of_find_property(). This is part of a larger effort to remove callers
of of_find_property() and similar functions. of_find_property() leaks
the DT property pointer which is a problem for dynamically allocated
nodes which may be freed.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20240828130056.3481050-2-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-28 21:52:45 +01:00
Rob Herring (Arm)
7540bd3398
regulator: qcom_spmi: Drop unnecessary of_find_property() call
There's no need to check for presence of "qcom,saw-reg" before parsing
it. If the property doesn't exist, parsing it will return NULL.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20240828130056.3481050-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-28 21:52:44 +01:00
Mark Brown
bff5ca8379
regulator: Minor cleanups
Merge series from Chen-Yu Tsai <wenst@chromium.org>:

Here are some cleanups for some bits that I saw while reworking my I2C
device tree component prober to use of_regulator_bulk_get_all().
These are not directly related to that series, so I send them
separately here.
2024-08-22 21:58:11 +01:00
Krzysztof Kozlowski
b8195520e8
regulator: s2mps11: use scoped memory allocation to simplify probe
Allocate the memory with scoped/cleanup.h to reduce error handling (less
error paths) and make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240822161231.106744-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-22 17:52:31 +01:00
Chen-Yu Tsai
bfefa214d1
regulator: Fully clean up on error in of_regulator_bulk_get_all()
Currently in of_regulator_bulk_get_all(), if any regulator request
fails, the error path releases all regulators already requested,
but leaves the |struct regulator_bulk_data| memory to the caller
to free, and also leaves the regulator consumer pointers dangling.
The latter behavior is not documented, and may not be what the
caller is expecting.

Instead, explicitly clean up everything on error, and make it clear
that the result pointer is only update if the whole request succeeds.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240822072047.3097740-4-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-22 13:34:30 +01:00
Chen-Yu Tsai
395a41a1d3
regulator: Return actual error in of_regulator_bulk_get_all()
If regulator_get() in of_regulator_bulk_get_all() returns an error, that
error gets overridden and -EINVAL is always passed out. This masks probe
deferral requests and likely won't work properly in all cases.

Fix this by letting of_regulator_bulk_get_all() return the original
error code.

Fixes: 27b9ecc7a9 ("regulator: Add of_regulator_bulk_get_all")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240822072047.3097740-3-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-22 13:34:29 +01:00
Chen-Yu Tsai
ad9d7a8290
regulator: Clarify error message for "id == NULL" in _regulator_get()
The original error message simply said "get() with no identifier"
without any context as to what was requested or what device the
request was related to. The only thing the user or developer could
do was grep for the message in the full source tree.

Amend the error message to be more specific, and also use dev_*
to associate the error message with a device.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20240822072047.3097740-2-wenst@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-22 13:34:28 +01:00
Krzysztof Kozlowski
99cf5db9cd
regulator: scmi: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240814-cleanup-h-of-node-put-regulator-v1-7-87151088b883@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-14 18:21:48 +01:00
Krzysztof Kozlowski
d4cd75b8ef
regulator: qcom-smd: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240814-cleanup-h-of-node-put-regulator-v1-6-87151088b883@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2024-08-14 18:21:47 +01:00