[PATCH] regmap: Fix max_raw_read/write handling when bus is NULL

From: Marc Zyngier
Date: Mon Aug 31 2015 - 14:16:16 EST


Commit adaac459759d ("regmap: Introduce max_raw_read/write
for regmap_bulk_read/write") added new fields to regmap_bus
and started using them in __regmap_init, but failed to
consider the case where bus would be NULL, like in the
vexpress-syscgf case. The box (actually its qemu version)
ends up dying painfully.

Fix it by testing bus before doing anything else.

Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
drivers/base/regmap/regmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 650d3b1..0fdde9d 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -574,8 +574,8 @@ struct regmap *__regmap_init(struct device *dev,
map->use_single_read = config->use_single_rw || !bus || !bus->read;
map->use_single_write = config->use_single_rw || !bus || !bus->write;
map->can_multi_write = config->can_multi_write && bus && bus->write;
- map->max_raw_read = bus->max_raw_read;
- map->max_raw_write = bus->max_raw_write;
+ map->max_raw_read = bus ? bus->max_raw_read : 0;
+ map->max_raw_write = bus ? bus->max_raw_write : 0;
map->dev = dev;
map->bus = bus;
map->bus_context = bus_context;
--
2.1.4

I'd really like to understand why you observe failures with your
version of qemu, while I cannot reproduce them. What patches do you
have on top of qemu? Is your tree available somewhere?

Thanks,

M.
--
Without deviation from the norm, progress is not possible.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/