Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver

Current code init regmap with &da9052_regmap_config for both da9052-spi and
da9052-i2c drivers. da9052-spi sets the read_flag_mask.
The same setting may be applied for da9052-i2c if da9052-spi driver is loaded
first because they actually use the same regmap_config setting.
Fix this issue by using a local variable for regmap_config in da9052-spi driver,
so the settings in spi driver won't impact the settings in i2c driver.
Also makes da9052_regmap_config const to avoid similar issue.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Axel Lin and committed by
Lee Jones
e9e9d397 c38715fe

+6 -5
+1 -1
drivers/mfd/da9052-core.c
··· 522 522 }, 523 523 }; 524 524 525 - struct regmap_config da9052_regmap_config = { 525 + const struct regmap_config da9052_regmap_config = { 526 526 .reg_bits = 8, 527 527 .val_bits = 8, 528 528
+4 -3
drivers/mfd/da9052-spi.c
··· 23 23 24 24 static int da9052_spi_probe(struct spi_device *spi) 25 25 { 26 + struct regmap_config config; 26 27 int ret; 27 28 const struct spi_device_id *id = spi_get_device_id(spi); 28 29 struct da9052 *da9052; ··· 41 40 42 41 spi_set_drvdata(spi, da9052); 43 42 44 - da9052_regmap_config.read_flag_mask = 1; 45 - da9052_regmap_config.write_flag_mask = 0; 43 + config = da9052_regmap_config; 44 + config.read_flag_mask = 1; 46 45 47 - da9052->regmap = devm_regmap_init_spi(spi, &da9052_regmap_config); 46 + da9052->regmap = devm_regmap_init_spi(spi, &config); 48 47 if (IS_ERR(da9052->regmap)) { 49 48 ret = PTR_ERR(da9052->regmap); 50 49 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
+1 -1
include/linux/mfd/da9052/da9052.h
··· 211 211 int da9052_device_init(struct da9052 *da9052, u8 chip_id); 212 212 void da9052_device_exit(struct da9052 *da9052); 213 213 214 - extern struct regmap_config da9052_regmap_config; 214 + extern const struct regmap_config da9052_regmap_config; 215 215 216 216 int da9052_irq_init(struct da9052 *da9052); 217 217 int da9052_irq_exit(struct da9052 *da9052);