diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-12-13 06:52:52 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-12-23 07:40:01 -0500 |
commit | 65adb86d6142f1233e84c81112907f4caa6afffd (patch) | |
tree | 87b57fce04ba7d930d9be5fd8a1d597ca7deb0cf | |
parent | e5b30145e56a20caeffed553d1239e401e4fb4e2 (diff) |
[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>
-rw-r--r-- | drivers/media/pci/ttpci/budget-core.c | 89 |
1 files changed, 49 insertions, 40 deletions
diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c index 37d02fe09137..23e05499b509 100644 --- a/drivers/media/pci/ttpci/budget-core.c +++ b/drivers/media/pci/ttpci/budget-core.c | |||
@@ -231,63 +231,59 @@ static void vpeirq(unsigned long data) | |||
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count, | 234 | static int ttpci_budget_debiread_nolock(struct budget *budget, u32 config, |
235 | int uselocks, int nobusyloop) | 235 | int addr, int count, int nobusyloop) |
236 | { | 236 | { |
237 | struct saa7146_dev *saa = budget->dev; | 237 | struct saa7146_dev *saa = budget->dev; |
238 | int result = 0; | 238 | int result; |
239 | unsigned long flags = 0; | ||
240 | |||
241 | if (count > 4 || count <= 0) | ||
242 | return 0; | ||
243 | |||
244 | if (uselocks) | ||
245 | spin_lock_irqsave(&budget->debilock, flags); | ||
246 | 239 | ||
247 | if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { | 240 | result = saa7146_wait_for_debi_done(saa, nobusyloop); |
248 | if (uselocks) | 241 | if (result < 0) |
249 | spin_unlock_irqrestore(&budget->debilock, flags); | ||
250 | return result; | 242 | return result; |
251 | } | ||
252 | 243 | ||
253 | saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff)); | 244 | saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff)); |
254 | saa7146_write(saa, DEBI_CONFIG, config); | 245 | saa7146_write(saa, DEBI_CONFIG, config); |
255 | saa7146_write(saa, DEBI_PAGE, 0); | 246 | saa7146_write(saa, DEBI_PAGE, 0); |
256 | saa7146_write(saa, MC2, (2 << 16) | 2); | 247 | saa7146_write(saa, MC2, (2 << 16) | 2); |
257 | 248 | ||
258 | if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { | 249 | result = saa7146_wait_for_debi_done(saa, nobusyloop); |
259 | if (uselocks) | 250 | if (result < 0) |
260 | spin_unlock_irqrestore(&budget->debilock, flags); | ||
261 | return result; | 251 | return result; |
262 | } | ||
263 | 252 | ||
264 | result = saa7146_read(saa, DEBI_AD); | 253 | result = saa7146_read(saa, DEBI_AD); |
265 | result &= (0xffffffffUL >> ((4 - count) * 8)); | 254 | result &= (0xffffffffUL >> ((4 - count) * 8)); |
266 | |||
267 | if (uselocks) | ||
268 | spin_unlock_irqrestore(&budget->debilock, flags); | ||
269 | |||
270 | return result; | 255 | return result; |
271 | } | 256 | } |
272 | 257 | ||
273 | int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, | 258 | int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count, |
274 | int count, u32 value, int uselocks, int nobusyloop) | 259 | int uselocks, int nobusyloop) |
275 | { | 260 | { |
276 | struct saa7146_dev *saa = budget->dev; | ||
277 | unsigned long flags = 0; | ||
278 | int result; | ||
279 | |||
280 | if (count > 4 || count <= 0) | 261 | if (count > 4 || count <= 0) |
281 | return 0; | 262 | return 0; |
282 | 263 | ||
283 | if (uselocks) | 264 | if (uselocks) { |
284 | spin_lock_irqsave(&budget->debilock, flags); | 265 | unsigned long flags; |
266 | int result; | ||
285 | 267 | ||
286 | if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { | 268 | spin_lock_irqsave(&budget->debilock, flags); |
287 | if (uselocks) | 269 | result = ttpci_budget_debiread_nolock(budget, config, addr, |
288 | spin_unlock_irqrestore(&budget->debilock, flags); | 270 | count, nobusyloop); |
271 | spin_unlock_irqrestore(&budget->debilock, flags); | ||
289 | return result; | 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 | saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff)); | 288 | saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff)); |
293 | saa7146_write(saa, DEBI_CONFIG, config); | 289 | saa7146_write(saa, DEBI_CONFIG, config); |
@@ -295,15 +291,28 @@ int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, | |||
295 | saa7146_write(saa, DEBI_AD, value); | 291 | saa7146_write(saa, DEBI_AD, value); |
296 | saa7146_write(saa, MC2, (2 << 16) | 2); | 292 | saa7146_write(saa, MC2, (2 << 16) | 2); |
297 | 293 | ||
298 | if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) { | 294 | result = saa7146_wait_for_debi_done(saa, nobusyloop); |
299 | if (uselocks) | 295 | return result < 0 ? result : 0; |
300 | spin_unlock_irqrestore(&budget->debilock, flags); | 296 | } |
301 | return result; | ||
302 | } | ||
303 | 297 | ||
304 | if (uselocks) | 298 | int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, |
299 | int count, u32 value, int uselocks, int nobusyloop) | ||
300 | { | ||
301 | if (count > 4 || count <= 0) | ||
302 | return 0; | ||
303 | |||
304 | if (uselocks) { | ||
305 | unsigned long flags; | ||
306 | int result; | ||
307 | |||
308 | spin_lock_irqsave(&budget->debilock, flags); | ||
309 | result = ttpci_budget_debiwrite_nolock(budget, config, addr, | ||
310 | count, value, nobusyloop); | ||
305 | spin_unlock_irqrestore(&budget->debilock, flags); | 311 | spin_unlock_irqrestore(&budget->debilock, flags); |
306 | return 0; | 312 | return result; |
313 | } | ||
314 | return ttpci_budget_debiwrite_nolock(budget, config, addr, | ||
315 | count, value, nobusyloop); | ||
307 | } | 316 | } |
308 | 317 | ||
309 | 318 | ||