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

clk: si521xx: Fix regmap write accessor

Rework the write operation such that the Byte Count register is written with
a single raw i2c write outside of regmap using transfer which does specify
the number of bytes to be transfered, one in this case, and which makes the
expected subsequent write transfer look like address+register+data, and then
make use of this method. Without this change, the Byte Count register write
in probe() would succeed as it would provide the byte count as part of its
write payload, but any subsequent writes would fail due to this Byte Count
register programming. Such failing writes happens e.g. during resume, when
restoring the regmap content.

Fixes: edc12763a3a2 ("clk: si521xx: Clock driver for Skyworks Si521xx I2C PCIe clock generators")
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230831181656.154750-2-marex@denx.de
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Marek Vasut and committed by
Stephen Boyd
83df5bf0 f03a5624

+4 -3
+4 -3
drivers/clk/clk-si521xx.c
··· 96 96 unsigned int val) 97 97 { 98 98 struct i2c_client *i2c = context; 99 - const u8 data[3] = { reg, 1, val }; 99 + const u8 data[2] = { reg, val }; 100 100 const int count = ARRAY_SIZE(data); 101 101 int ret; 102 102 ··· 281 281 { 282 282 const u16 chip_info = (u16)(uintptr_t)device_get_match_data(&client->dev); 283 283 const struct clk_parent_data clk_parent_data = { .index = 0 }; 284 - struct si521xx *si; 284 + const u8 data[3] = { SI521XX_REG_BC, 1, 1 }; 285 285 unsigned char name[6] = "DIFF0"; 286 286 struct clk_init_data init = {}; 287 + struct si521xx *si; 287 288 int i, ret; 288 289 289 290 if (!chip_info) ··· 309 308 "Failed to allocate register map\n"); 310 309 311 310 /* Always read back 1 Byte via I2C */ 312 - ret = regmap_write(si->regmap, SI521XX_REG_BC, 1); 311 + ret = i2c_master_send(client, data, ARRAY_SIZE(data)); 313 312 if (ret < 0) 314 313 return ret; 315 314