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

Merge series "regulator: unexport regulator_lock/unlock()" from Michał Mirosław <mirq-linux@rere.qmqm.pl>:

This removes regulator_lock/unlock() calls around
regulator_notifier_call_chain() as they are redundant - drivers
already have to guarantee regulator_dev's existence during the call.

This should make reasoing about the lock easier, as this was the only
use outside regulator core code.

The only client that needed recursive locking from the notifier chain
was drivers/usb/host/ohci-da8xx.c, which responds to over-current
notification by calling regulator_disable().

Michał Mirosław (3):
regulator: don't require mutex for regulator_notifier_call_chain()
regulator: remove locking around regulator_notifier_call_chain()
regulator: unexport regulator_lock/unlock()

drivers/regulator/core.c | 11 +++--------
drivers/regulator/da9055-regulator.c | 2 --
drivers/regulator/da9062-regulator.c | 2 --
drivers/regulator/da9063-regulator.c | 2 --
drivers/regulator/da9210-regulator.c | 4 ----
drivers/regulator/da9211-regulator.c | 4 ----
drivers/regulator/lp8755.c | 6 ------
drivers/regulator/ltc3589.c | 10 ++--------
drivers/regulator/ltc3676.c | 10 ++--------
drivers/regulator/pv88060-regulator.c | 10 ++--------
drivers/regulator/pv88080-regulator.c | 10 ++--------
drivers/regulator/pv88090-regulator.c | 10 ++--------
drivers/regulator/slg51000-regulator.c | 4 ----
drivers/regulator/stpmic1_regulator.c | 4 ----
drivers/regulator/wm831x-dcdc.c | 4 ----
drivers/regulator/wm831x-isink.c | 2 --
drivers/regulator/wm831x-ldo.c | 2 --
drivers/regulator/wm8350-regulator.c | 2 --
include/linux/regulator/driver.h | 3 ---
19 files changed, 13 insertions(+), 89 deletions(-)

--
2.20.1

+11 -82
+1 -4
drivers/regulator/core.c
··· 4725 4725 * @data: callback-specific data. 4726 4726 * 4727 4727 * Called by regulator drivers to notify clients a regulator event has 4728 - * occurred. We also notify regulator clients downstream. 4729 - * Note lock must be held by caller. 4728 + * occurred. 4730 4729 */ 4731 4730 int regulator_notifier_call_chain(struct regulator_dev *rdev, 4732 4731 unsigned long event, void *data) 4733 4732 { 4734 - lockdep_assert_held_once(&rdev->mutex.base); 4735 - 4736 4733 _notifier_call_chain(rdev, event, data); 4737 4734 return NOTIFY_DONE; 4738 4735
-2
drivers/regulator/da9055-regulator.c
··· 485 485 { 486 486 struct da9055_regulator *regulator = data; 487 487 488 - regulator_lock(regulator->rdev); 489 488 regulator_notifier_call_chain(regulator->rdev, 490 489 REGULATOR_EVENT_OVER_CURRENT, NULL); 491 - regulator_unlock(regulator->rdev); 492 490 493 491 return IRQ_HANDLED; 494 492 }
-2
drivers/regulator/da9062-regulator.c
··· 907 907 continue; 908 908 909 909 if (BIT(regl->info->oc_event.lsb) & bits) { 910 - regulator_lock(regl->rdev); 911 910 regulator_notifier_call_chain(regl->rdev, 912 911 REGULATOR_EVENT_OVER_CURRENT, NULL); 913 - regulator_unlock(regl->rdev); 914 912 handled = IRQ_HANDLED; 915 913 } 916 914 }
-2
drivers/regulator/da9063-regulator.c
··· 574 574 continue; 575 575 576 576 if (BIT(regl->info->oc_event.lsb) & bits) { 577 - regulator_lock(regl->rdev); 578 577 regulator_notifier_call_chain(regl->rdev, 579 578 REGULATOR_EVENT_OVER_CURRENT, NULL); 580 - regulator_unlock(regl->rdev); 581 579 } 582 580 } 583 581
-4
drivers/regulator/da9210-regulator.c
··· 77 77 if (error < 0) 78 78 goto error_i2c; 79 79 80 - regulator_lock(chip->rdev); 81 - 82 80 if (val & DA9210_E_OVCURR) { 83 81 regulator_notifier_call_chain(chip->rdev, 84 82 REGULATOR_EVENT_OVER_CURRENT, ··· 100 102 NULL); 101 103 handled |= DA9210_E_VMAX; 102 104 } 103 - 104 - regulator_unlock(chip->rdev); 105 105 106 106 if (handled) { 107 107 /* Clear handled events */
-4
drivers/regulator/da9211-regulator.c
··· 346 346 goto error_i2c; 347 347 348 348 if (reg_val & DA9211_E_OV_CURR_A) { 349 - regulator_lock(chip->rdev[0]); 350 349 regulator_notifier_call_chain(chip->rdev[0], 351 350 REGULATOR_EVENT_OVER_CURRENT, NULL); 352 - regulator_unlock(chip->rdev[0]); 353 351 354 352 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, 355 353 DA9211_E_OV_CURR_A); ··· 358 360 } 359 361 360 362 if (reg_val & DA9211_E_OV_CURR_B) { 361 - regulator_lock(chip->rdev[1]); 362 363 regulator_notifier_call_chain(chip->rdev[1], 363 364 REGULATOR_EVENT_OVER_CURRENT, NULL); 364 - regulator_unlock(chip->rdev[1]); 365 365 366 366 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, 367 367 DA9211_E_OV_CURR_B);
-6
drivers/regulator/lp8755.c
··· 329 329 if ((flag0 & (0x4 << icnt)) 330 330 && (pchip->irqmask & (0x04 << icnt)) 331 331 && (pchip->rdev[icnt] != NULL)) { 332 - regulator_lock(pchip->rdev[icnt]); 333 332 regulator_notifier_call_chain(pchip->rdev[icnt], 334 333 LP8755_EVENT_PWR_FAULT, 335 334 NULL); 336 - regulator_unlock(pchip->rdev[icnt]); 337 335 } 338 336 339 337 /* read flag1 register */ ··· 347 349 if ((flag1 & 0x01) && (pchip->irqmask & 0x01)) 348 350 for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) 349 351 if (pchip->rdev[icnt] != NULL) { 350 - regulator_lock(pchip->rdev[icnt]); 351 352 regulator_notifier_call_chain(pchip->rdev[icnt], 352 353 LP8755_EVENT_OCP, 353 354 NULL); 354 - regulator_unlock(pchip->rdev[icnt]); 355 355 } 356 356 357 357 /* send OVP event to all regulator devices */ 358 358 if ((flag1 & 0x02) && (pchip->irqmask & 0x02)) 359 359 for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) 360 360 if (pchip->rdev[icnt] != NULL) { 361 - regulator_lock(pchip->rdev[icnt]); 362 361 regulator_notifier_call_chain(pchip->rdev[icnt], 363 362 LP8755_EVENT_OVP, 364 363 NULL); 365 - regulator_unlock(pchip->rdev[icnt]); 366 364 } 367 365 return IRQ_HANDLED; 368 366
+2 -8
drivers/regulator/ltc3589.c
··· 357 357 358 358 if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) { 359 359 event = REGULATOR_EVENT_OVER_TEMP; 360 - for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { 361 - regulator_lock(ltc3589->regulators[i]); 360 + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) 362 361 regulator_notifier_call_chain(ltc3589->regulators[i], 363 362 event, NULL); 364 - regulator_unlock(ltc3589->regulators[i]); 365 - } 366 363 } 367 364 368 365 if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) { 369 366 event = REGULATOR_EVENT_UNDER_VOLTAGE; 370 - for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { 371 - regulator_lock(ltc3589->regulators[i]); 367 + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) 372 368 regulator_notifier_call_chain(ltc3589->regulators[i], 373 369 event, NULL); 374 - regulator_unlock(ltc3589->regulators[i]); 375 - } 376 370 } 377 371 378 372 /* Clear warning condition */
+2 -8
drivers/regulator/ltc3676.c
··· 276 276 if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) { 277 277 dev_warn(dev, "Over-temperature Warning\n"); 278 278 event = REGULATOR_EVENT_OVER_TEMP; 279 - for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { 280 - regulator_lock(ltc3676->regulators[i]); 279 + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) 281 280 regulator_notifier_call_chain(ltc3676->regulators[i], 282 281 event, NULL); 283 - regulator_unlock(ltc3676->regulators[i]); 284 - } 285 282 } 286 283 287 284 if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) { 288 285 dev_info(dev, "Undervoltage Warning\n"); 289 286 event = REGULATOR_EVENT_UNDER_VOLTAGE; 290 - for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { 291 - regulator_lock(ltc3676->regulators[i]); 287 + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) 292 288 regulator_notifier_call_chain(ltc3676->regulators[i], 293 289 event, NULL); 294 - regulator_unlock(ltc3676->regulators[i]); 295 - } 296 290 } 297 291 298 292 /* Clear warning condition */
+2 -8
drivers/regulator/pv88060-regulator.c
··· 233 233 234 234 if (reg_val & PV88060_E_VDD_FLT) { 235 235 for (i = 0; i < PV88060_MAX_REGULATORS; i++) { 236 - if (chip->rdev[i] != NULL) { 237 - regulator_lock(chip->rdev[i]); 236 + if (chip->rdev[i] != NULL) 238 237 regulator_notifier_call_chain(chip->rdev[i], 239 238 REGULATOR_EVENT_UNDER_VOLTAGE, 240 239 NULL); 241 - regulator_unlock(chip->rdev[i]); 242 - } 243 240 } 244 241 245 242 err = regmap_write(chip->regmap, PV88060_REG_EVENT_A, ··· 249 252 250 253 if (reg_val & PV88060_E_OVER_TEMP) { 251 254 for (i = 0; i < PV88060_MAX_REGULATORS; i++) { 252 - if (chip->rdev[i] != NULL) { 253 - regulator_lock(chip->rdev[i]); 255 + if (chip->rdev[i] != NULL) 254 256 regulator_notifier_call_chain(chip->rdev[i], 255 257 REGULATOR_EVENT_OVER_TEMP, 256 258 NULL); 257 - regulator_unlock(chip->rdev[i]); 258 - } 259 259 } 260 260 261 261 err = regmap_write(chip->regmap, PV88060_REG_EVENT_A,
+2 -8
drivers/regulator/pv88080-regulator.c
··· 334 334 335 335 if (reg_val & PV88080_E_VDD_FLT) { 336 336 for (i = 0; i < PV88080_MAX_REGULATORS; i++) { 337 - if (chip->rdev[i] != NULL) { 338 - regulator_lock(chip->rdev[i]); 337 + if (chip->rdev[i] != NULL) 339 338 regulator_notifier_call_chain(chip->rdev[i], 340 339 REGULATOR_EVENT_UNDER_VOLTAGE, 341 340 NULL); 342 - regulator_unlock(chip->rdev[i]); 343 - } 344 341 } 345 342 346 343 err = regmap_write(chip->regmap, PV88080_REG_EVENT_A, ··· 350 353 351 354 if (reg_val & PV88080_E_OVER_TEMP) { 352 355 for (i = 0; i < PV88080_MAX_REGULATORS; i++) { 353 - if (chip->rdev[i] != NULL) { 354 - regulator_lock(chip->rdev[i]); 356 + if (chip->rdev[i] != NULL) 355 357 regulator_notifier_call_chain(chip->rdev[i], 356 358 REGULATOR_EVENT_OVER_TEMP, 357 359 NULL); 358 - regulator_unlock(chip->rdev[i]); 359 - } 360 360 } 361 361 362 362 err = regmap_write(chip->regmap, PV88080_REG_EVENT_A,
+2 -8
drivers/regulator/pv88090-regulator.c
··· 226 226 227 227 if (reg_val & PV88090_E_VDD_FLT) { 228 228 for (i = 0; i < PV88090_MAX_REGULATORS; i++) { 229 - if (chip->rdev[i] != NULL) { 230 - regulator_lock(chip->rdev[i]); 229 + if (chip->rdev[i] != NULL) 231 230 regulator_notifier_call_chain(chip->rdev[i], 232 231 REGULATOR_EVENT_UNDER_VOLTAGE, 233 232 NULL); 234 - regulator_unlock(chip->rdev[i]); 235 - } 236 233 } 237 234 238 235 err = regmap_write(chip->regmap, PV88090_REG_EVENT_A, ··· 242 245 243 246 if (reg_val & PV88090_E_OVER_TEMP) { 244 247 for (i = 0; i < PV88090_MAX_REGULATORS; i++) { 245 - if (chip->rdev[i] != NULL) { 246 - regulator_lock(chip->rdev[i]); 248 + if (chip->rdev[i] != NULL) 247 249 regulator_notifier_call_chain(chip->rdev[i], 248 250 REGULATOR_EVENT_OVER_TEMP, 249 251 NULL); 250 - regulator_unlock(chip->rdev[i]); 251 - } 252 252 } 253 253 254 254 err = regmap_write(chip->regmap, PV88090_REG_EVENT_A,
-4
drivers/regulator/slg51000-regulator.c
··· 386 386 for (i = 0; i < SLG51000_MAX_REGULATORS; i++) { 387 387 if (!(evt[i][R2] & SLG51000_IRQ_ILIM_FLAG_MASK) && 388 388 (evt[i][R0] & SLG51000_EVT_ILIM_FLAG_MASK)) { 389 - regulator_lock(chip->rdev[i]); 390 389 regulator_notifier_call_chain(chip->rdev[i], 391 390 REGULATOR_EVENT_OVER_CURRENT, NULL); 392 - regulator_unlock(chip->rdev[i]); 393 391 394 392 if (evt[i][R1] & SLG51000_STA_ILIM_FLAG_MASK) 395 393 dev_warn(chip->dev, ··· 401 403 for (i = 0; i < SLG51000_MAX_REGULATORS; i++) { 402 404 if (!(evt[i][R1] & SLG51000_STA_ILIM_FLAG_MASK) && 403 405 (evt[i][R1] & SLG51000_STA_VOUT_OK_FLAG_MASK)) { 404 - regulator_lock(chip->rdev[i]); 405 406 regulator_notifier_call_chain(chip->rdev[i], 406 407 REGULATOR_EVENT_OVER_TEMP, NULL); 407 - regulator_unlock(chip->rdev[i]); 408 408 } 409 409 } 410 410 handled = IRQ_HANDLED;
-4
drivers/regulator/stpmic1_regulator.c
··· 505 505 { 506 506 struct regulator_dev *rdev = (struct regulator_dev *)data; 507 507 508 - regulator_lock(rdev); 509 - 510 508 /* Send an overcurrent notification */ 511 509 regulator_notifier_call_chain(rdev, 512 510 REGULATOR_EVENT_OVER_CURRENT, 513 511 NULL); 514 - 515 - regulator_unlock(rdev); 516 512 517 513 return IRQ_HANDLED; 518 514 }
-4
drivers/regulator/wm831x-dcdc.c
··· 178 178 { 179 179 struct wm831x_dcdc *dcdc = data; 180 180 181 - regulator_lock(dcdc->regulator); 182 181 regulator_notifier_call_chain(dcdc->regulator, 183 182 REGULATOR_EVENT_UNDER_VOLTAGE, 184 183 NULL); 185 - regulator_unlock(dcdc->regulator); 186 184 187 185 return IRQ_HANDLED; 188 186 } ··· 189 191 { 190 192 struct wm831x_dcdc *dcdc = data; 191 193 192 - regulator_lock(dcdc->regulator); 193 194 regulator_notifier_call_chain(dcdc->regulator, 194 195 REGULATOR_EVENT_OVER_CURRENT, 195 196 NULL); 196 - regulator_unlock(dcdc->regulator); 197 197 198 198 return IRQ_HANDLED; 199 199 }
-2
drivers/regulator/wm831x-isink.c
··· 99 99 { 100 100 struct wm831x_isink *isink = data; 101 101 102 - regulator_lock(isink->regulator); 103 102 regulator_notifier_call_chain(isink->regulator, 104 103 REGULATOR_EVENT_OVER_CURRENT, 105 104 NULL); 106 - regulator_unlock(isink->regulator); 107 105 108 106 return IRQ_HANDLED; 109 107 }
-2
drivers/regulator/wm831x-ldo.c
··· 46 46 { 47 47 struct wm831x_ldo *ldo = data; 48 48 49 - regulator_lock(ldo->regulator); 50 49 regulator_notifier_call_chain(ldo->regulator, 51 50 REGULATOR_EVENT_UNDER_VOLTAGE, 52 51 NULL); 53 - regulator_unlock(ldo->regulator); 54 52 55 53 return IRQ_HANDLED; 56 54 }
-2
drivers/regulator/wm8350-regulator.c
··· 1089 1089 { 1090 1090 struct regulator_dev *rdev = (struct regulator_dev *)data; 1091 1091 1092 - regulator_lock(rdev); 1093 1092 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2) 1094 1093 regulator_notifier_call_chain(rdev, 1095 1094 REGULATOR_EVENT_REGULATION_OUT, ··· 1097 1098 regulator_notifier_call_chain(rdev, 1098 1099 REGULATOR_EVENT_UNDER_VOLTAGE, 1099 1100 NULL); 1100 - regulator_unlock(rdev); 1101 1101 1102 1102 return IRQ_HANDLED; 1103 1103 }