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

leds: regulator: Convert to devm_regulator_get_exclusive

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Axel Lin and committed by
Bryan Wu
29ce9feb 206c5f60

+5 -13
+5 -13
drivers/leds/leds-regulator.c
··· 153 153 return -ENODEV; 154 154 } 155 155 156 - vcc = regulator_get_exclusive(&pdev->dev, "vled"); 156 + vcc = devm_regulator_get_exclusive(&pdev->dev, "vled"); 157 157 if (IS_ERR(vcc)) { 158 158 dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); 159 159 return PTR_ERR(vcc); 160 160 } 161 161 162 162 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); 163 - if (led == NULL) { 164 - ret = -ENOMEM; 165 - goto err_vcc; 166 - } 163 + if (led == NULL) 164 + return -ENOMEM; 167 165 168 166 led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); 169 167 if (pdata->brightness > led->cdev.max_brightness) { 170 168 dev_err(&pdev->dev, "Invalid default brightness %d\n", 171 169 pdata->brightness); 172 - ret = -EINVAL; 173 - goto err_vcc; 170 + return -EINVAL; 174 171 } 175 172 led->value = pdata->brightness; 176 173 ··· 188 191 ret = led_classdev_register(&pdev->dev, &led->cdev); 189 192 if (ret < 0) { 190 193 cancel_work_sync(&led->work); 191 - goto err_vcc; 194 + return ret; 192 195 } 193 196 194 197 /* to expose the default value to userspace */ ··· 198 201 regulator_led_set_value(led); 199 202 200 203 return 0; 201 - 202 - err_vcc: 203 - regulator_put(vcc); 204 - return ret; 205 204 } 206 205 207 206 static int regulator_led_remove(struct platform_device *pdev) ··· 207 214 led_classdev_unregister(&led->cdev); 208 215 cancel_work_sync(&led->work); 209 216 regulator_led_disable(led); 210 - regulator_put(led->vcc); 211 217 return 0; 212 218 } 213 219