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

Merge tag 'regulator-fix-v4.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
"As well as some driver specific fixes there's several fixes here for
the core support for regulators supplying other regulators fixing both
an issue with ACPI support (which had never been tested before) and
some error handling and device removal issues that Javier noticed"

* tag 'regulator-fix-v4.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
regulator: core: Fix memory leak in regulator_resolve_supply()
regulator: core: Increase refcount for regulator supply's module
regulator: core: Handle full constraints systems when resolving supplies
regulator: 88pm800: fix LDO vsel_mask value
regulator: max8973: Fix up control flag option for bias control
regulator: s2mps11: Fix GPIO suspend enable shift wrapping bug

+27 -10
+1 -1
drivers/regulator/88pm800.c
··· 130 130 .owner = THIS_MODULE, \ 131 131 .n_voltages = ARRAY_SIZE(ldo_volt_table), \ 132 132 .vsel_reg = PM800_##vreg##_VOUT, \ 133 - .vsel_mask = 0x1f, \ 133 + .vsel_mask = 0xf, \ 134 134 .enable_reg = PM800_##ereg, \ 135 135 .enable_mask = 1 << (ebit), \ 136 136 .volt_table = ldo_volt_table, \
+15 -4
drivers/regulator/core.c
··· 109 109 static struct regulator *create_regulator(struct regulator_dev *rdev, 110 110 struct device *dev, 111 111 const char *supply_name); 112 + static void _regulator_put(struct regulator *regulator); 112 113 113 114 static const char *rdev_get_name(struct regulator_dev *rdev) 114 115 { ··· 1106 1105 1107 1106 rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); 1108 1107 1108 + if (!try_module_get(supply_rdev->owner)) 1109 + return -ENODEV; 1110 + 1109 1111 rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY"); 1110 1112 if (rdev->supply == NULL) { 1111 1113 err = -ENOMEM; ··· 1385 1381 } 1386 1382 1387 1383 if (!r) { 1388 - dev_err(dev, "Failed to resolve %s-supply for %s\n", 1389 - rdev->supply_name, rdev->desc->name); 1390 - return -EPROBE_DEFER; 1384 + if (have_full_constraints()) { 1385 + r = dummy_regulator_rdev; 1386 + } else { 1387 + dev_err(dev, "Failed to resolve %s-supply for %s\n", 1388 + rdev->supply_name, rdev->desc->name); 1389 + return -EPROBE_DEFER; 1390 + } 1391 1391 } 1392 1392 1393 1393 /* Recursively resolve the supply of the supply */ ··· 1406 1398 /* Cascade always-on state to supply */ 1407 1399 if (_regulator_is_enabled(rdev)) { 1408 1400 ret = regulator_enable(rdev->supply); 1409 - if (ret < 0) 1401 + if (ret < 0) { 1402 + if (rdev->supply) 1403 + _regulator_put(rdev->supply); 1410 1404 return ret; 1405 + } 1411 1406 } 1412 1407 1413 1408 return 0;
+1 -1
drivers/regulator/max8973-regulator.c
··· 450 450 pdata->control_flags |= MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE; 451 451 452 452 if (of_property_read_bool(np, "maxim,enable-bias-control")) 453 - pdata->control_flags |= MAX8973_BIAS_ENABLE; 453 + pdata->control_flags |= MAX8973_CONTROL_BIAS_ENABLE; 454 454 455 455 return pdata; 456 456 }
+10 -4
drivers/regulator/s2mps11.c
··· 34 34 #include <linux/mfd/samsung/s2mps14.h> 35 35 #include <linux/mfd/samsung/s2mpu02.h> 36 36 37 + /* The highest number of possible regulators for supported devices. */ 38 + #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX 37 39 struct s2mps11_info { 38 40 unsigned int rdev_num; 39 41 int ramp_delay2; ··· 51 49 * One bit for each S2MPS13/S2MPS14/S2MPU02 regulator whether 52 50 * the suspend mode was enabled. 53 51 */ 54 - unsigned long long s2mps14_suspend_state:50; 52 + DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX); 55 53 56 54 /* Array of size rdev_num with GPIO-s for external sleep control */ 57 55 int *ext_control_gpio; ··· 502 500 switch (s2mps11->dev_type) { 503 501 case S2MPS13X: 504 502 case S2MPS14X: 505 - if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 503 + if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) 506 504 val = S2MPS14_ENABLE_SUSPEND; 507 505 else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) 508 506 val = S2MPS14_ENABLE_EXT_CONTROL; ··· 510 508 val = rdev->desc->enable_mask; 511 509 break; 512 510 case S2MPU02: 513 - if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) 511 + if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) 514 512 val = S2MPU02_ENABLE_SUSPEND; 515 513 else 516 514 val = rdev->desc->enable_mask; ··· 564 562 if (ret < 0) 565 563 return ret; 566 564 567 - s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev)); 565 + set_bit(rdev_get_id(rdev), s2mps11->suspend_state); 568 566 /* 569 567 * Don't enable suspend mode if regulator is already disabled because 570 568 * this would effectively for a short time turn on the regulator after ··· 962 960 case S2MPS11X: 963 961 s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); 964 962 regulators = s2mps11_regulators; 963 + BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); 965 964 break; 966 965 case S2MPS13X: 967 966 s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); 968 967 regulators = s2mps13_regulators; 968 + BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); 969 969 break; 970 970 case S2MPS14X: 971 971 s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); 972 972 regulators = s2mps14_regulators; 973 + BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); 973 974 break; 974 975 case S2MPU02: 975 976 s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); 976 977 regulators = s2mpu02_regulators; 978 + BUILD_BUG_ON(S2MPS_REGULATOR_MAX < s2mps11->rdev_num); 977 979 break; 978 980 default: 979 981 dev_err(&pdev->dev, "Invalid device type: %u\n",