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

Configure Feed

Select the types of activity you want to include in your feed.

leds: lp8860: Hold lock for all of EEPROM programming

The lock is taken while unlocking the EEPROM but then released, it should
instead be held for the whole EEPROM programming process. To do this
merge in the lp8860_unlock_eeprom() function to the only call site in
the lp8860_init() function. This way we hold the lock for all steps.
While here, rename this function to lp8860_program_eeprom() to better
represent what it really does.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://patch.msgid.link/20260305203706.841384-3-afd@ti.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andrew Davis and committed by
Lee Jones
67a4a344 665e0642

+17 -30
+17 -30
drivers/leds/leds-lp8860.c
··· 125 125 { LP8860_EEPROM_REG_24, 0x3E }, 126 126 }; 127 127 128 - static int lp8860_unlock_eeprom(struct lp8860_led *led) 129 - { 130 - int ret; 131 - 132 - guard(mutex)(&led->lock); 133 - 134 - ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_1); 135 - if (ret) { 136 - dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 137 - return ret; 138 - } 139 - 140 - ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_2); 141 - if (ret) { 142 - dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 143 - return ret; 144 - } 145 - ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_3); 146 - if (ret) { 147 - dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 148 - return ret; 149 - } 150 - 151 - return ret; 152 - } 153 - 154 128 static int lp8860_fault_check(struct lp8860_led *led) 155 129 { 156 130 int ret, fault; ··· 183 209 return 0; 184 210 } 185 211 186 - static int lp8860_init(struct lp8860_led *led) 212 + static int lp8860_program_eeprom(struct lp8860_led *led) 187 213 { 188 214 unsigned int read_buf; 189 215 int ret, reg_count; 216 + 217 + guard(mutex)(&led->lock); 190 218 191 219 ret = lp8860_fault_check(led); 192 220 if (ret) ··· 198 222 if (ret) 199 223 return ret; 200 224 201 - ret = lp8860_unlock_eeprom(led); 225 + ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_1); 202 226 if (ret) { 203 - dev_err(&led->client->dev, "Failed unlocking EEPROM\n"); 227 + dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 228 + return ret; 229 + } 230 + 231 + ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_2); 232 + if (ret) { 233 + dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 234 + return ret; 235 + } 236 + ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_3); 237 + if (ret) { 238 + dev_err(&led->client->dev, "EEPROM Unlock failed\n"); 204 239 return ret; 205 240 } 206 241 ··· 305 318 return ret; 306 319 } 307 320 308 - ret = lp8860_init(led); 321 + ret = lp8860_program_eeprom(led); 309 322 if (ret) 310 323 return ret; 311 324