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

pwm: twl-led: Drop driver local locking

The pwm core already serializes .apply(). twl6030's .request() and .free()
are also already serialized against .apply() because there is only a single
PWM. So the mutex doesn't add any additional protection and can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/c1c7f646190f7cb2fe43b10959aa8dade80cb79e.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
2c06a217 dce0df8a

+7 -42
+7 -42
drivers/pwm/pwm-twl-led.c
··· 61 61 #define TWL6040_LED_MODE_OFF 0x02 62 62 #define TWL6040_LED_MODE_MASK 0x03 63 63 64 - struct twl_pwmled_chip { 65 - struct mutex mutex; 66 - }; 67 - 68 64 static inline struct twl_pwmled_chip *to_twl(struct pwm_chip *chip) 69 65 { 70 66 return pwmchip_get_drvdata(chip); ··· 102 106 103 107 static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm) 104 108 { 105 - struct twl_pwmled_chip *twl = to_twl(chip); 106 109 int ret; 107 110 u8 val; 108 111 109 - mutex_lock(&twl->mutex); 110 112 ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG); 111 113 if (ret < 0) { 112 114 dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label); 113 - goto out; 115 + return ret; 114 116 } 115 117 116 118 val |= TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS); ··· 117 123 if (ret < 0) 118 124 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); 119 125 120 - out: 121 - mutex_unlock(&twl->mutex); 122 126 return ret; 123 127 } 124 128 125 129 static void twl4030_pwmled_disable(struct pwm_chip *chip, 126 130 struct pwm_device *pwm) 127 131 { 128 - struct twl_pwmled_chip *twl = to_twl(chip); 129 132 int ret; 130 133 u8 val; 131 134 132 - mutex_lock(&twl->mutex); 133 135 ret = twl_i2c_read_u8(TWL4030_MODULE_LED, &val, TWL4030_LEDEN_REG); 134 136 if (ret < 0) { 135 137 dev_err(pwmchip_parent(chip), "%s: Failed to read LEDEN\n", pwm->label); 136 - goto out; 138 + return; 137 139 } 138 140 139 141 val &= ~TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS); ··· 137 147 ret = twl_i2c_write_u8(TWL4030_MODULE_LED, val, TWL4030_LEDEN_REG); 138 148 if (ret < 0) 139 149 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); 140 - 141 - out: 142 - mutex_unlock(&twl->mutex); 143 150 } 144 151 145 152 static int twl4030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm, ··· 196 209 197 210 static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm) 198 211 { 199 - struct twl_pwmled_chip *twl = to_twl(chip); 200 212 int ret; 201 213 u8 val; 202 214 203 - mutex_lock(&twl->mutex); 204 215 ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2); 205 216 if (ret < 0) { 206 217 dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n", 207 218 pwm->label); 208 - goto out; 219 + return ret; 209 220 } 210 221 211 222 val &= ~TWL6040_LED_MODE_MASK; ··· 213 228 if (ret < 0) 214 229 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); 215 230 216 - out: 217 - mutex_unlock(&twl->mutex); 218 231 return ret; 219 232 } 220 233 221 234 static void twl6030_pwmled_disable(struct pwm_chip *chip, 222 235 struct pwm_device *pwm) 223 236 { 224 - struct twl_pwmled_chip *twl = to_twl(chip); 225 237 int ret; 226 238 u8 val; 227 239 228 - mutex_lock(&twl->mutex); 229 240 ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2); 230 241 if (ret < 0) { 231 242 dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n", 232 243 pwm->label); 233 - goto out; 244 + return; 234 245 } 235 246 236 247 val &= ~TWL6040_LED_MODE_MASK; ··· 235 254 ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2); 236 255 if (ret < 0) 237 256 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); 238 - 239 - out: 240 - mutex_unlock(&twl->mutex); 241 257 } 242 258 243 259 static int twl6030_pwmled_apply(struct pwm_chip *chip, struct pwm_device *pwm, ··· 265 287 266 288 static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm) 267 289 { 268 - struct twl_pwmled_chip *twl = to_twl(chip); 269 290 int ret; 270 291 u8 val; 271 292 272 - mutex_lock(&twl->mutex); 273 293 ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2); 274 294 if (ret < 0) { 275 295 dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n", 276 296 pwm->label); 277 - goto out; 297 + return ret; 278 298 } 279 299 280 300 val &= ~TWL6040_LED_MODE_MASK; ··· 282 306 if (ret < 0) 283 307 dev_err(pwmchip_parent(chip), "%s: Failed to request PWM\n", pwm->label); 284 308 285 - out: 286 - mutex_unlock(&twl->mutex); 287 309 return ret; 288 310 } 289 311 290 312 static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm) 291 313 { 292 - struct twl_pwmled_chip *twl = to_twl(chip); 293 314 int ret; 294 315 u8 val; 295 316 296 - mutex_lock(&twl->mutex); 297 317 ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, TWL6030_LED_PWM_CTRL2); 298 318 if (ret < 0) { 299 319 dev_err(pwmchip_parent(chip), "%s: Failed to read PWM_CTRL2\n", 300 320 pwm->label); 301 - goto out; 321 + return; 302 322 } 303 323 304 324 val &= ~TWL6040_LED_MODE_MASK; ··· 303 331 ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, TWL6030_LED_PWM_CTRL2); 304 332 if (ret < 0) 305 333 dev_err(pwmchip_parent(chip), "%s: Failed to free PWM\n", pwm->label); 306 - 307 - out: 308 - mutex_unlock(&twl->mutex); 309 334 } 310 335 311 336 static const struct pwm_ops twl6030_pwmled_ops = { ··· 314 345 static int twl_pwmled_probe(struct platform_device *pdev) 315 346 { 316 347 struct pwm_chip *chip; 317 - struct twl_pwmled_chip *twl; 318 348 unsigned int npwm; 319 349 const struct pwm_ops *ops; 320 350 ··· 325 357 npwm = 1; 326 358 } 327 359 328 - chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*twl)); 360 + chip = devm_pwmchip_alloc(&pdev->dev, npwm, 0); 329 361 if (IS_ERR(chip)) 330 362 return PTR_ERR(chip); 331 - twl = to_twl(chip); 332 363 333 364 chip->ops = ops; 334 - 335 - mutex_init(&twl->mutex); 336 365 337 366 return devm_pwmchip_add(&pdev->dev, chip); 338 367 }