Skip to contentSkip to conversation

misc fixes

PATCH Applied Ahmad Fatoum 3 participants 9 messages Jan 3, 2022 – Jan 5, 2022

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover misc fixes

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(-)
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/5 pwm: atmel: point MMIO accesses at correct address

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.

---
 drivers/pwm/pwm-atmel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-atmel.c +1 -1
index 7819d321d387..648f75fb7292 100644
@@ -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];
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address

Hi Ahmad,

Quoted 5 lines · 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.

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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reviewed-by
#3 lore raw

Re: [PATCH master 1/5] pwm: atmel: point MMIO accesses at correct address

Quoted 14 lines · Sam Ravnborg

Hi Ahmad,

Quoted 5 lines · 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.

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.

Quoted 5 lines

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:

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

PATCH 2/5 clk: fixed: record parent name in clk_register_fixed_rate

In reply to Ahmad Fatoum

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

---
 drivers/clk/clk-fixed.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/clk-fixed.c +4 -0
index b961c382ec22..e813f31d76d9 100644
@@ -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;
 	}
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 3/5 imx-bbu-nand-fcb: suppress compiler warning about uninitialized use

In reply to 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.

---
 common/imx-bbu-nand-fcb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/imx-bbu-nand-fcb.c +1 -1
index 3b07d539ee6e..bde0b227f81c 100644
@@ -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) {
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 4/5 regulator: fix broken reference counting on disable

In reply to 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.

---
 drivers/regulator/core.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/regulator/core.c +5 -0
index d1d3a36dfc8d..ac4141c1cdbf 100644
@@ -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;
 
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 5/5 regulator: respect "regulator-always-on" property

In reply to Ahmad Fatoum

From: Enrico Jorns <[email protected]>

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.

---
 drivers/regulator/core.c | 3 ++-
 include/regulator.h      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -1
index ac4141c1cdbf..b2e5f8caa2ca 100644
@@ -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);
 
include/regulator.h +2 -1
index bbe8dd91d84b..dfdfbf033262 100644
@@ -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;
 };
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#8 lore raw
In reply to Ahmad Fatoum
Quoted 10 lines · Ahmad Fatoum

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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox