mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 0/5] misc fixes
@ 2022-01-03 11:57 Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox

Collection of fixes for master.

Ahmad Fatoum (4):
  pwm: atmel: point MMIO accesses at correct address
  clk: fixed: record parent name in clk_register_fixed_rate
  imx-bbu-nand-fcb: suppress compiler warning about uninitialized use
  regulator: fix broken reference counting on disable

Enrico Jorns (1):
  regulator: respect "regulator-always-on" property

 common/imx-bbu-nand-fcb.c | 2 +-
 drivers/clk/clk-fixed.c   | 4 ++++
 drivers/pwm/pwm-atmel.c   | 2 +-
 drivers/regulator/core.c  | 8 +++++++-
 include/regulator.h       | 3 ++-
 5 files changed, 15 insertions(+), 4 deletions(-)

-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
@ 2022-01-03 11:57 ` Ahmad Fatoum
  2022-01-03 16:11   ` Sam Ravnborg
  2022-01-03 11:57 ` [PATCH master 2/5] clk: fixed: record parent name in clk_register_fixed_rate Ahmad Fatoum
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox; +Cc: Sam Ravnborg, Ahmad Fatoum

The base address for MMIO writes was the address of the resource struct,
not the start address pointed at by it.

Change untested, but it doesn't look like this driver could ever have
worked.

Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pwm/pwm-atmel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 7819d321d387..648f75fb7292 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -256,7 +256,7 @@ static int atmel_pwm_probe(struct device_d *dev)
 	if (IS_ERR(res))
 		return PTR_ERR(res);
 
-	atmel_pwm->base = IOMEM(res);
+	atmel_pwm->base = IOMEM(res->start);
 
 	for (i = 0; i < PWM_CHANNELS; i++) {
 		struct atmel_pwm_chip *chip = &atmel_pwm->atmel_pwm_chip[i];
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH master 2/5] clk: fixed: record parent name in clk_register_fixed_rate
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
@ 2022-01-03 11:57 ` Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 3/5] imx-bbu-nand-fcb: suppress compiler warning about uninitialized use Ahmad Fatoum
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

parent_names is allocated, but only populated with zeroes. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/clk/clk-fixed.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index b961c382ec22..e813f31d76d9 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -45,6 +45,10 @@ struct clk *clk_register_fixed_rate(const char *name,
 		if (!parent_names)
 			return ERR_PTR(-ENOMEM);
 
+		parent_names[0] = strdup(parent_name);
+		if (!parent_names[0])
+			return ERR_PTR(-ENOMEM);
+
 		fix->hw.clk.parent_names = parent_names;
 		fix->hw.clk.num_parents = 1;
 	}
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH master 3/5] imx-bbu-nand-fcb: suppress compiler warning about uninitialized use
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 2/5] clk: fixed: record parent name in clk_register_fixed_rate Ahmad Fatoum
@ 2022-01-03 11:57 ` Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 4/5] regulator: fix broken reference counting on disable Ahmad Fatoum
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

fw_orig_len is selectively initialized in read_firmware_all. In case
it's left uninitialized, fw_orig will keep it's initial value of NULL.
fw_orig is checked before fw_orig_len use, so there is no use of an
uninitialized variable in practice, but GCC 11.1.1 warns about it
anyway. Give it an initial value of 0 to silence the warning.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/imx-bbu-nand-fcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 3b07d539ee6e..bde0b227f81c 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -1155,7 +1155,7 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
 	enum filetype filetype;
 	unsigned num_blocks_fw, fw_size;
 	int used = 0;
-	int fw_orig_len;
+	int fw_orig_len = 0;
 	int used_refresh = 0, unused_refresh = 0;
 
 	if (data->image) {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH master 4/5] regulator: fix broken reference counting on disable
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2022-01-03 11:57 ` [PATCH master 3/5] imx-bbu-nand-fcb: suppress compiler warning about uninitialized use Ahmad Fatoum
@ 2022-01-03 11:57 ` Ahmad Fatoum
  2022-01-03 11:57 ` [PATCH master 5/5] regulator: respect "regulator-always-on" property Ahmad Fatoum
  2022-01-05  7:28 ` [PATCH master 0/5] misc fixes Sascha Hauer
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns, Ahmad Fatoum

Reference count is maintained correctly when enabling, but the very
first disable will ignore the reference count and disable the regulator
unconditionally. Make disable with an enable_count > 1 a no-op to fix
this.

Reported-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/regulator/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d1d3a36dfc8d..ac4141c1cdbf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -71,6 +71,11 @@ static int regulator_disable_internal(struct regulator_internal *ri)
 	if (!ri->enable_count)
 		return -EINVAL;
 
+	if (ri->enable_count > 1) {
+		ri->enable_count--;
+		return 0;
+	}
+
 	if (!ri->rdev->desc->ops->disable)
 		return -ENOSYS;
 
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH master 5/5] regulator: respect "regulator-always-on" property
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2022-01-03 11:57 ` [PATCH master 4/5] regulator: fix broken reference counting on disable Ahmad Fatoum
@ 2022-01-03 11:57 ` Ahmad Fatoum
  2022-01-05  7:28 ` [PATCH master 0/5] misc fixes Sascha Hauer
  5 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2022-01-03 11:57 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

From: Enrico Jorns <ejo@pengutronix.de>

As barebox ignored this property, a regulator could have been disabled
even if it should not have been.
By taking the same path as for 'regulator-boot-on', we ensure always
holding an enable count > 0 on the regulator.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/regulator/core.c | 3 ++-
 include/regulator.h      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ac4141c1cdbf..b2e5f8caa2ca 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -130,7 +130,7 @@ static struct regulator_internal * __regulator_register(struct regulator_dev *rd
 	if (name)
 		ri->name = xstrdup(name);
 
-	if (rd->boot_on) {
+	if (rd->boot_on && rd->always_on) {
 		ret = regulator_enable_internal(ri);
 		if (ret && ret != -ENOSYS)
 			goto err;
@@ -163,6 +163,7 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node)
 		return -EINVAL;
 
 	rd->boot_on = of_property_read_bool(node, "regulator-boot-on");
+	rd->always_on = of_property_read_bool(node, "regulator-always-on");
 
 	name = of_get_property(node, "regulator-name", NULL);
 
diff --git a/include/regulator.h b/include/regulator.h
index bbe8dd91d84b..dfdfbf033262 100644
--- a/include/regulator.h
+++ b/include/regulator.h
@@ -84,7 +84,8 @@ struct regulator_desc {
 struct regulator_dev {
 	const struct regulator_desc *desc;
 	struct regmap *regmap;
-	int boot_on;
+	bool boot_on;
+	bool always_on;
 	/* the device this regulator device belongs to */
 	struct device_d *dev;
 };
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address
  2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
@ 2022-01-03 16:11   ` Sam Ravnborg
  2022-01-03 16:18     ` Sam Ravnborg
  0 siblings, 1 reply; 9+ messages in thread
From: Sam Ravnborg @ 2022-01-03 16:11 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Hi Ahmad,

On Mon, Jan 03, 2022 at 12:57:14PM +0100, Ahmad Fatoum wrote:
> The base address for MMIO writes was the address of the resource struct,
> not the start address pointed at by it.
> 
> Change untested, but it doesn't look like this driver could ever have
> worked.

You are right that I never got around to see backlight dimming work.
I recall that backlight worked and then the pwm driver was added as part
of several other patches for barebox.
I should have dropped the patch until I had seen it actually work.

But nice catch!

I may try to dust of the skov board where this is used to test it.
But these days I play with an i.MX6 board which has a bit more power,
so no promises.

	Sam

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address
  2022-01-03 16:11   ` Sam Ravnborg
@ 2022-01-03 16:18     ` Sam Ravnborg
  0 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2022-01-03 16:18 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jan 03, 2022 at 05:11:53PM +0100, Sam Ravnborg wrote:
> Hi Ahmad,
> 
> On Mon, Jan 03, 2022 at 12:57:14PM +0100, Ahmad Fatoum wrote:
> > The base address for MMIO writes was the address of the resource struct,
> > not the start address pointed at by it.
> > 
> > Change untested, but it doesn't look like this driver could ever have
> > worked.
> 
> You are right that I never got around to see backlight dimming work.
> I recall that backlight worked and then the pwm driver was added as part
> of several other patches for barebox.
> I should have dropped the patch until I had seen it actually work.
> 
> But nice catch!
> 
> I may try to dust of the skov board where this is used to test it.
> But these days I play with an i.MX6 board which has a bit more power,
> so no promises.

For the patch btw:
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH master 0/5] misc fixes
  2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2022-01-03 11:57 ` [PATCH master 5/5] regulator: respect "regulator-always-on" property Ahmad Fatoum
@ 2022-01-05  7:28 ` Sascha Hauer
  5 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2022-01-05  7:28 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jan 03, 2022 at 12:57:13PM +0100, Ahmad Fatoum wrote:
> Collection of fixes for master.
> 
> Ahmad Fatoum (4):
>   pwm: atmel: point MMIO accesses at correct address
>   clk: fixed: record parent name in clk_register_fixed_rate
>   imx-bbu-nand-fcb: suppress compiler warning about uninitialized use
>   regulator: fix broken reference counting on disable
> 
> Enrico Jorns (1):
>   regulator: respect "regulator-always-on" property

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-05  7:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 11:57 [PATCH master 0/5] misc fixes Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address Ahmad Fatoum
2022-01-03 16:11   ` Sam Ravnborg
2022-01-03 16:18     ` Sam Ravnborg
2022-01-03 11:57 ` [PATCH master 2/5] clk: fixed: record parent name in clk_register_fixed_rate Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 3/5] imx-bbu-nand-fcb: suppress compiler warning about uninitialized use Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 4/5] regulator: fix broken reference counting on disable Ahmad Fatoum
2022-01-03 11:57 ` [PATCH master 5/5] regulator: respect "regulator-always-on" property Ahmad Fatoum
2022-01-05  7:28 ` [PATCH master 0/5] misc fixes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox