regulator: Don't return or expect -errno from of_map_mode()
authorDouglas Anderson <dianders@chromium.org>
Wed, 18 Apr 2018 15:54:18 +0000 (08:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:50:40 +0000 (07:50 +0200)
commitfb2b60e27a16c4bd5054bc518ec3d786036b7dce
tree67ca72528ad9bd36d701d2da11b47296678624e7
parent4886bf00337f4c70a2bffc0e2e5cdbf813342a95
regulator: Don't return or expect -errno from of_map_mode()

[ Upstream commit 02f3703934a42417021405ef336fe45add13c3d1 ]

In of_get_regulation_constraints() we were taking the result of
of_map_mode() (an unsigned int) and assigning it to an int.  We were
then checking whether this value was -EINVAL.  Some implementers of
of_map_mode() were returning -EINVAL (even though the return type of
their function needed to be unsigned int) because they needed to
signal an error back to of_get_regulation_constraints().

In general in the regulator framework the mode is always referred to
as an unsigned int.  While we could fix this to be a signed int (the
highest value we store in there right now is 0x8), it's actually
pretty clean to just define the regulator mode 0x0 (the lack of any
bits set) as an invalid mode.  Let's do that.

Fixes: 5e5e3a42c653 ("regulator: of: Add support for parsing initial and suspend modes")
Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/cpcap-regulator.c
drivers/regulator/of_regulator.c
drivers/regulator/twl-regulator.c
include/linux/regulator/consumer.h