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

ALSA: es18xx: Use guard() for spin locks

Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250829145300.5460-7-tiwai@suse.de

+22 -36
+22 -36
sound/isa/es18xx.c
··· 185 185 static int snd_es18xx_write(struct snd_es18xx *chip, 186 186 unsigned char reg, unsigned char data) 187 187 { 188 - unsigned long flags; 189 188 int ret; 190 189 191 - spin_lock_irqsave(&chip->reg_lock, flags); 190 + guard(spinlock_irqsave)(&chip->reg_lock); 192 191 ret = snd_es18xx_dsp_command(chip, reg); 193 192 if (ret < 0) 194 - goto end; 193 + return ret; 195 194 ret = snd_es18xx_dsp_command(chip, data); 196 - end: 197 - spin_unlock_irqrestore(&chip->reg_lock, flags); 198 195 #ifdef REG_DEBUG 199 196 dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, data); 200 197 #endif ··· 200 203 201 204 static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg) 202 205 { 203 - unsigned long flags; 204 206 int ret, data; 205 - spin_lock_irqsave(&chip->reg_lock, flags); 207 + 208 + guard(spinlock_irqsave)(&chip->reg_lock); 206 209 ret = snd_es18xx_dsp_command(chip, 0xC0); 207 210 if (ret < 0) 208 - goto end; 211 + return ret; 209 212 ret = snd_es18xx_dsp_command(chip, reg); 210 213 if (ret < 0) 211 - goto end; 214 + return ret; 212 215 data = snd_es18xx_dsp_get_byte(chip); 213 216 ret = data; 214 217 #ifdef REG_DEBUG 215 218 dev_dbg(chip->card->dev, "Reg %02x now is %02x (%d)\n", reg, data, ret); 216 219 #endif 217 - end: 218 - spin_unlock_irqrestore(&chip->reg_lock, flags); 219 220 return ret; 220 221 } 221 222 ··· 223 228 { 224 229 int ret; 225 230 unsigned char old, new, oval; 226 - unsigned long flags; 227 - spin_lock_irqsave(&chip->reg_lock, flags); 231 + 232 + guard(spinlock_irqsave)(&chip->reg_lock); 228 233 ret = snd_es18xx_dsp_command(chip, 0xC0); 229 234 if (ret < 0) 230 - goto end; 235 + return ret; 231 236 ret = snd_es18xx_dsp_command(chip, reg); 232 237 if (ret < 0) 233 - goto end; 238 + return ret; 234 239 ret = snd_es18xx_dsp_get_byte(chip); 235 - if (ret < 0) { 236 - goto end; 237 - } 240 + if (ret < 0) 241 + return ret; 238 242 old = ret; 239 243 oval = old & mask; 240 244 if (val != oval) { 241 245 ret = snd_es18xx_dsp_command(chip, reg); 242 246 if (ret < 0) 243 - goto end; 247 + return ret; 244 248 new = (old & ~mask) | (val & mask); 245 249 ret = snd_es18xx_dsp_command(chip, new); 246 250 if (ret < 0) 247 - goto end; 251 + return ret; 248 252 #ifdef REG_DEBUG 249 253 dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x (%d)\n", 250 254 reg, old, new, ret); 251 255 #endif 252 256 } 253 - ret = oval; 254 - end: 255 - spin_unlock_irqrestore(&chip->reg_lock, flags); 256 - return ret; 257 + return oval; 257 258 } 258 259 259 260 static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip, 260 261 unsigned char reg, unsigned char data) 261 262 { 262 - unsigned long flags; 263 - spin_lock_irqsave(&chip->mixer_lock, flags); 263 + guard(spinlock_irqsave)(&chip->mixer_lock); 264 264 outb(reg, chip->port + 0x04); 265 265 outb(data, chip->port + 0x05); 266 - spin_unlock_irqrestore(&chip->mixer_lock, flags); 267 266 #ifdef REG_DEBUG 268 267 dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, data); 269 268 #endif ··· 265 276 266 277 static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char reg) 267 278 { 268 - unsigned long flags; 269 279 int data; 270 - spin_lock_irqsave(&chip->mixer_lock, flags); 280 + 281 + guard(spinlock_irqsave)(&chip->mixer_lock); 271 282 outb(reg, chip->port + 0x04); 272 283 data = inb(chip->port + 0x05); 273 - spin_unlock_irqrestore(&chip->mixer_lock, flags); 274 284 #ifdef REG_DEBUG 275 285 dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data); 276 286 #endif ··· 281 293 unsigned char mask, unsigned char val) 282 294 { 283 295 unsigned char old, new, oval; 284 - unsigned long flags; 285 - spin_lock_irqsave(&chip->mixer_lock, flags); 296 + 297 + guard(spinlock_irqsave)(&chip->mixer_lock); 286 298 outb(reg, chip->port + 0x04); 287 299 old = inb(chip->port + 0x05); 288 300 oval = old & mask; ··· 294 306 reg, old, new); 295 307 #endif 296 308 } 297 - spin_unlock_irqrestore(&chip->mixer_lock, flags); 298 309 return oval; 299 310 } 300 311 ··· 301 314 unsigned char mask) 302 315 { 303 316 int old, expected, new; 304 - unsigned long flags; 305 - spin_lock_irqsave(&chip->mixer_lock, flags); 317 + 318 + guard(spinlock_irqsave)(&chip->mixer_lock); 306 319 outb(reg, chip->port + 0x04); 307 320 old = inb(chip->port + 0x05); 308 321 expected = old ^ mask; 309 322 outb(expected, chip->port + 0x05); 310 323 new = inb(chip->port + 0x05); 311 - spin_unlock_irqrestore(&chip->mixer_lock, flags); 312 324 #ifdef REG_DEBUG 313 325 dev_dbg(chip->card->dev, "Mixer reg %02x was %02x, set to %02x, now is %02x\n", 314 326 reg, old, expected, new);