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

[media] budget-core: fix sparse warnings

Fixes these sparse warnings.

drivers/media/pci/ttpci/budget-core.c:250:17: warning: context imbalance in 'ttpci_budget_debiread' - different lock contexts for basic block
drivers/media/pci/ttpci/budget-core.c:289:17: warning: context imbalance in 'ttpci_budget_debiwrite' - different lock contexts for basic block

To be honest, the new code does look better than the old.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
65adb86d e5b30145

+49 -40
+49 -40
drivers/media/pci/ttpci/budget-core.c
··· 231 231 } 232 232 233 233 234 - int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count, 235 - int uselocks, int nobusyloop) 234 + static int ttpci_budget_debiread_nolock(struct budget *budget, u32 config, 235 + int addr, int count, int nobusyloop) 236 236 { 237 237 struct saa7146_dev *saa = budget->dev; 238 - int result = 0; 239 - unsigned long flags = 0; 238 + int result; 240 239 241 - if (count > 4 || count <= 0) 242 - return 0; 243 - 244 - if (uselocks) 245 - spin_lock_irqsave(&budget->debilock, flags); 246 - 247 - if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { 248 - if (uselocks) 249 - spin_unlock_irqrestore(&budget->debilock, flags); 240 + result = saa7146_wait_for_debi_done(saa, nobusyloop); 241 + if (result < 0) 250 242 return result; 251 - } 252 243 253 244 saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff)); 254 245 saa7146_write(saa, DEBI_CONFIG, config); 255 246 saa7146_write(saa, DEBI_PAGE, 0); 256 247 saa7146_write(saa, MC2, (2 << 16) | 2); 257 248 258 - if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { 259 - if (uselocks) 260 - spin_unlock_irqrestore(&budget->debilock, flags); 249 + result = saa7146_wait_for_debi_done(saa, nobusyloop); 250 + if (result < 0) 261 251 return result; 262 - } 263 252 264 253 result = saa7146_read(saa, DEBI_AD); 265 254 result &= (0xffffffffUL >> ((4 - count) * 8)); 266 - 267 - if (uselocks) 268 - spin_unlock_irqrestore(&budget->debilock, flags); 269 - 270 255 return result; 271 256 } 272 257 273 - int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, 274 - int count, u32 value, int uselocks, int nobusyloop) 258 + int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count, 259 + int uselocks, int nobusyloop) 275 260 { 276 - struct saa7146_dev *saa = budget->dev; 277 - unsigned long flags = 0; 278 - int result; 279 - 280 261 if (count > 4 || count <= 0) 281 262 return 0; 282 263 283 - if (uselocks) 284 - spin_lock_irqsave(&budget->debilock, flags); 264 + if (uselocks) { 265 + unsigned long flags; 266 + int result; 285 267 286 - if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { 287 - if (uselocks) 288 - spin_unlock_irqrestore(&budget->debilock, flags); 268 + spin_lock_irqsave(&budget->debilock, flags); 269 + result = ttpci_budget_debiread_nolock(budget, config, addr, 270 + count, nobusyloop); 271 + spin_unlock_irqrestore(&budget->debilock, flags); 289 272 return result; 290 273 } 274 + return ttpci_budget_debiread_nolock(budget, config, addr, 275 + count, nobusyloop); 276 + } 277 + 278 + static int ttpci_budget_debiwrite_nolock(struct budget *budget, u32 config, 279 + int addr, int count, u32 value, int nobusyloop) 280 + { 281 + struct saa7146_dev *saa = budget->dev; 282 + int result; 283 + 284 + result = saa7146_wait_for_debi_done(saa, nobusyloop); 285 + if (result < 0) 286 + return result; 291 287 292 288 saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff)); 293 289 saa7146_write(saa, DEBI_CONFIG, config); ··· 291 295 saa7146_write(saa, DEBI_AD, value); 292 296 saa7146_write(saa, MC2, (2 << 16) | 2); 293 297 294 - if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { 295 - if (uselocks) 296 - spin_unlock_irqrestore(&budget->debilock, flags); 298 + result = saa7146_wait_for_debi_done(saa, nobusyloop); 299 + return result < 0 ? result : 0; 300 + } 301 + 302 + int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, 303 + int count, u32 value, int uselocks, int nobusyloop) 304 + { 305 + if (count > 4 || count <= 0) 306 + return 0; 307 + 308 + if (uselocks) { 309 + unsigned long flags; 310 + int result; 311 + 312 + spin_lock_irqsave(&budget->debilock, flags); 313 + result = ttpci_budget_debiwrite_nolock(budget, config, addr, 314 + count, value, nobusyloop); 315 + spin_unlock_irqrestore(&budget->debilock, flags); 297 316 return result; 298 317 } 299 - 300 - if (uselocks) 301 - spin_unlock_irqrestore(&budget->debilock, flags); 302 - return 0; 318 + return ttpci_budget_debiwrite_nolock(budget, config, addr, 319 + count, value, nobusyloop); 303 320 } 304 321 305 322