diff options
author | Erik Andr?n <erik.andren@gmail.com> | 2008-12-27 10:28:00 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:44:35 -0400 |
commit | 051781b3a8ea31f1834fddb916607a3088a28f71 (patch) | |
tree | a8f7f4732467b73508257ef5090dec2292468986 /drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |
parent | ad567ec23501dfdf00dcc8915709a1fda556b6f4 (diff) |
V4L/DVB (11405): gspca - m5602: Simplify error handling
Simplfy error handling by replacing goto statements with return equivalents.
Signed-off-by: Erik Andr?n <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/m5602/m5602_s5k4aa.c')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k4aa.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c index 41ae7f0b959f..921d009e02c4 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |||
@@ -237,17 +237,17 @@ int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
237 | 237 | ||
238 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 238 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
239 | if (err < 0) | 239 | if (err < 0) |
240 | goto out; | 240 | return err; |
241 | 241 | ||
242 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); | 242 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); |
243 | if (err < 0) | 243 | if (err < 0) |
244 | goto out; | 244 | return err; |
245 | 245 | ||
246 | *val = data << 8; | 246 | *val = data << 8; |
247 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); | 247 | err = m5602_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); |
248 | *val |= data; | 248 | *val |= data; |
249 | PDEBUG(D_V4L2, "Read exposure %d", *val); | 249 | PDEBUG(D_V4L2, "Read exposure %d", *val); |
250 | out: | 250 | |
251 | return err; | 251 | return err; |
252 | } | 252 | } |
253 | 253 | ||
@@ -260,14 +260,14 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
260 | PDEBUG(D_V4L2, "Set exposure to %d", val); | 260 | PDEBUG(D_V4L2, "Set exposure to %d", val); |
261 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 261 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
262 | if (err < 0) | 262 | if (err < 0) |
263 | goto out; | 263 | return err; |
264 | data = (val >> 8) & 0xff; | 264 | data = (val >> 8) & 0xff; |
265 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); | 265 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_HI, &data, 1); |
266 | if (err < 0) | 266 | if (err < 0) |
267 | goto out; | 267 | return err; |
268 | data = val & 0xff; | 268 | data = val & 0xff; |
269 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); | 269 | err = m5602_write_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); |
270 | out: | 270 | |
271 | return err; | 271 | return err; |
272 | } | 272 | } |
273 | 273 | ||
@@ -279,13 +279,12 @@ int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
279 | 279 | ||
280 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 280 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
281 | if (err < 0) | 281 | if (err < 0) |
282 | goto out; | 282 | return err; |
283 | 283 | ||
284 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 284 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
285 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; | 285 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; |
286 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); | 286 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
287 | 287 | ||
288 | out: | ||
289 | return err; | 288 | return err; |
290 | } | 289 | } |
291 | 290 | ||
@@ -298,32 +297,32 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
298 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); | 297 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
299 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 298 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
300 | if (err < 0) | 299 | if (err < 0) |
301 | goto out; | 300 | return err; |
302 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 301 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
303 | if (err < 0) | 302 | if (err < 0) |
304 | goto out; | 303 | return err; |
305 | data = ((data & ~S5K4AA_RM_V_FLIP) | 304 | data = ((data & ~S5K4AA_RM_V_FLIP) |
306 | | ((val & 0x01) << 7)); | 305 | | ((val & 0x01) << 7)); |
307 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 306 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
308 | if (err < 0) | 307 | if (err < 0) |
309 | goto out; | 308 | return err; |
310 | 309 | ||
311 | if (val) { | 310 | if (val) { |
312 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 311 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
313 | if (err < 0) | 312 | if (err < 0) |
314 | goto out; | 313 | return err; |
315 | 314 | ||
316 | data++; | 315 | data++; |
317 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 316 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
318 | } else { | 317 | } else { |
319 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 318 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
320 | if (err < 0) | 319 | if (err < 0) |
321 | goto out; | 320 | return err; |
322 | 321 | ||
323 | data--; | 322 | data--; |
324 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 323 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
325 | } | 324 | } |
326 | out: | 325 | |
327 | return err; | 326 | return err; |
328 | } | 327 | } |
329 | 328 | ||
@@ -335,12 +334,12 @@ int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
335 | 334 | ||
336 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 335 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
337 | if (err < 0) | 336 | if (err < 0) |
338 | goto out; | 337 | return err; |
339 | 338 | ||
340 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 339 | err = m5602_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
341 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; | 340 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; |
342 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); | 341 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
343 | out: | 342 | |
344 | return err; | 343 | return err; |
345 | } | 344 | } |
346 | 345 | ||
@@ -354,32 +353,32 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
354 | val); | 353 | val); |
355 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 354 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
356 | if (err < 0) | 355 | if (err < 0) |
357 | goto out; | 356 | return err; |
358 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 357 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
359 | if (err < 0) | 358 | if (err < 0) |
360 | goto out; | 359 | return err; |
361 | 360 | ||
362 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); | 361 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); |
363 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 362 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
364 | if (err < 0) | 363 | if (err < 0) |
365 | goto out; | 364 | return err; |
366 | 365 | ||
367 | if (val) { | 366 | if (val) { |
368 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 367 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
369 | if (err < 0) | 368 | if (err < 0) |
370 | goto out; | 369 | return err; |
371 | data++; | 370 | data++; |
372 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 371 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
373 | if (err < 0) | 372 | if (err < 0) |
374 | goto out; | 373 | return err; |
375 | } else { | 374 | } else { |
376 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 375 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
377 | if (err < 0) | 376 | if (err < 0) |
378 | goto out; | 377 | return err; |
379 | data--; | 378 | data--; |
380 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 379 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
381 | } | 380 | } |
382 | out: | 381 | |
383 | return err; | 382 | return err; |
384 | } | 383 | } |
385 | 384 | ||
@@ -391,13 +390,12 @@ int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
391 | 390 | ||
392 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 391 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
393 | if (err < 0) | 392 | if (err < 0) |
394 | goto out; | 393 | return err; |
395 | 394 | ||
396 | err = m5602_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 395 | err = m5602_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); |
397 | *val = data; | 396 | *val = data; |
398 | PDEBUG(D_V4L2, "Read gain %d", *val); | 397 | PDEBUG(D_V4L2, "Read gain %d", *val); |
399 | 398 | ||
400 | out: | ||
401 | return err; | 399 | return err; |
402 | } | 400 | } |
403 | 401 | ||
@@ -410,12 +408,11 @@ int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
410 | PDEBUG(D_V4L2, "Set gain to %d", val); | 408 | PDEBUG(D_V4L2, "Set gain to %d", val); |
411 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 409 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
412 | if (err < 0) | 410 | if (err < 0) |
413 | goto out; | 411 | return err; |
414 | 412 | ||
415 | data = val & 0xff; | 413 | data = val & 0xff; |
416 | err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 414 | err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); |
417 | 415 | ||
418 | out: | ||
419 | return err; | 416 | return err; |
420 | } | 417 | } |
421 | 418 | ||