diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2008-08-14 11:03:49 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:50 -0400 |
commit | 506c629a8eb95a3232a0aafa3b80903224ccc461 (patch) | |
tree | e732ace80f384faa54b12ce63b1c4079271e9e40 /drivers/media/video | |
parent | 112116410aaab5310a9a279c71fb76605236e448 (diff) |
V4L/DVB (8686): mt9m111: style cleanup
Fix a typo in Kconfig, simplify error checking, further minor cleanup.
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Guennadi Liakhovetski <g.iakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/video/mt9m111.c | 86 |
2 files changed, 43 insertions, 45 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 6ebe9f1aca04..37123ff20fc5 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -810,7 +810,7 @@ config MT9M001_PCA9536_SWITCH | |||
810 | extender to switch between 8 and 10 bit datawidth modes | 810 | extender to switch between 8 and 10 bit datawidth modes |
811 | 811 | ||
812 | config SOC_CAMERA_MT9M111 | 812 | config SOC_CAMERA_MT9M111 |
813 | tristate "mt9m001 support" | 813 | tristate "mt9m111 support" |
814 | depends on SOC_CAMERA && I2C | 814 | depends on SOC_CAMERA && I2C |
815 | help | 815 | help |
816 | This driver supports MT9M111 cameras from Micron | 816 | This driver supports MT9M111 cameras from Micron |
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index 0c88e5d6dc44..d99932631050 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -173,7 +173,7 @@ static int reg_page_map_set(struct i2c_client *client, const u16 reg) | |||
173 | return -EINVAL; | 173 | return -EINVAL; |
174 | 174 | ||
175 | ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page)); | 175 | ret = i2c_smbus_write_word_data(client, MT9M111_PAGE_MAP, swab16(page)); |
176 | if (ret >= 0) | 176 | if (!ret) |
177 | lastpage = page; | 177 | lastpage = page; |
178 | return ret; | 178 | return ret; |
179 | } | 179 | } |
@@ -200,7 +200,7 @@ static int mt9m111_reg_write(struct soc_camera_device *icd, const u16 reg, | |||
200 | int ret; | 200 | int ret; |
201 | 201 | ||
202 | ret = reg_page_map_set(client, reg); | 202 | ret = reg_page_map_set(client, reg); |
203 | if (ret >= 0) | 203 | if (!ret) |
204 | ret = i2c_smbus_write_word_data(mt9m111->client, (reg & 0xff), | 204 | ret = i2c_smbus_write_word_data(mt9m111->client, (reg & 0xff), |
205 | swab16(data)); | 205 | swab16(data)); |
206 | dev_dbg(&icd->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); | 206 | dev_dbg(&icd->dev, "write reg.%03x = %04x -> %d\n", reg, data, ret); |
@@ -246,7 +246,7 @@ static int mt9m111_set_context(struct soc_camera_device *icd, | |||
246 | static int mt9m111_setup_rect(struct soc_camera_device *icd) | 246 | static int mt9m111_setup_rect(struct soc_camera_device *icd) |
247 | { | 247 | { |
248 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 248 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
249 | int ret = 0, is_raw_format; | 249 | int ret, is_raw_format; |
250 | int width = mt9m111->width; | 250 | int width = mt9m111->width; |
251 | int height = mt9m111->height; | 251 | int height = mt9m111->height; |
252 | 252 | ||
@@ -256,32 +256,31 @@ static int mt9m111_setup_rect(struct soc_camera_device *icd) | |||
256 | else | 256 | else |
257 | is_raw_format = 0; | 257 | is_raw_format = 0; |
258 | 258 | ||
259 | if (ret >= 0) | 259 | ret = reg_write(COLUMN_START, mt9m111->left); |
260 | ret = reg_write(COLUMN_START, mt9m111->left); | 260 | if (!ret) |
261 | if (ret >= 0) | ||
262 | ret = reg_write(ROW_START, mt9m111->top); | 261 | ret = reg_write(ROW_START, mt9m111->top); |
263 | 262 | ||
264 | if (is_raw_format) { | 263 | if (is_raw_format) { |
265 | if (ret >= 0) | 264 | if (!ret) |
266 | ret = reg_write(WINDOW_WIDTH, width); | 265 | ret = reg_write(WINDOW_WIDTH, width); |
267 | if (ret >= 0) | 266 | if (!ret) |
268 | ret = reg_write(WINDOW_HEIGHT, height); | 267 | ret = reg_write(WINDOW_HEIGHT, height); |
269 | } else { | 268 | } else { |
270 | if (ret >= 0) | 269 | if (!ret) |
271 | ret = reg_write(REDUCER_XZOOM_B, MT9M111_MAX_WIDTH); | 270 | ret = reg_write(REDUCER_XZOOM_B, MT9M111_MAX_WIDTH); |
272 | if (ret >= 0) | 271 | if (!ret) |
273 | ret = reg_write(REDUCER_YZOOM_B, MT9M111_MAX_HEIGHT); | 272 | ret = reg_write(REDUCER_YZOOM_B, MT9M111_MAX_HEIGHT); |
274 | if (ret >= 0) | 273 | if (!ret) |
275 | ret = reg_write(REDUCER_XSIZE_B, width); | 274 | ret = reg_write(REDUCER_XSIZE_B, width); |
276 | if (ret >= 0) | 275 | if (!ret) |
277 | ret = reg_write(REDUCER_YSIZE_B, height); | 276 | ret = reg_write(REDUCER_YSIZE_B, height); |
278 | if (ret >= 0) | 277 | if (!ret) |
279 | ret = reg_write(REDUCER_XZOOM_A, MT9M111_MAX_WIDTH); | 278 | ret = reg_write(REDUCER_XZOOM_A, MT9M111_MAX_WIDTH); |
280 | if (ret >= 0) | 279 | if (!ret) |
281 | ret = reg_write(REDUCER_YZOOM_A, MT9M111_MAX_HEIGHT); | 280 | ret = reg_write(REDUCER_YZOOM_A, MT9M111_MAX_HEIGHT); |
282 | if (ret >= 0) | 281 | if (!ret) |
283 | ret = reg_write(REDUCER_XSIZE_A, width); | 282 | ret = reg_write(REDUCER_XSIZE_A, width); |
284 | if (ret >= 0) | 283 | if (!ret) |
285 | ret = reg_write(REDUCER_YSIZE_A, height); | 284 | ret = reg_write(REDUCER_YSIZE_A, height); |
286 | } | 285 | } |
287 | 286 | ||
@@ -293,7 +292,7 @@ static int mt9m111_setup_pixfmt(struct soc_camera_device *icd, u16 outfmt) | |||
293 | int ret; | 292 | int ret; |
294 | 293 | ||
295 | ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); | 294 | ret = reg_write(OUTPUT_FORMAT_CTRL2_A, outfmt); |
296 | if (ret >= 0) | 295 | if (!ret) |
297 | ret = reg_write(OUTPUT_FORMAT_CTRL2_B, outfmt); | 296 | ret = reg_write(OUTPUT_FORMAT_CTRL2_B, outfmt); |
298 | return ret; | 297 | return ret; |
299 | } | 298 | } |
@@ -305,7 +304,6 @@ static int mt9m111_setfmt_bayer8(struct soc_camera_device *icd) | |||
305 | 304 | ||
306 | static int mt9m111_setfmt_bayer10(struct soc_camera_device *icd) | 305 | static int mt9m111_setfmt_bayer10(struct soc_camera_device *icd) |
307 | { | 306 | { |
308 | |||
309 | return mt9m111_setup_pixfmt(icd, MT9M111_OUTFMT_BYPASS_IFP); | 307 | return mt9m111_setup_pixfmt(icd, MT9M111_OUTFMT_BYPASS_IFP); |
310 | } | 308 | } |
311 | 309 | ||
@@ -356,7 +354,7 @@ static int mt9m111_enable(struct soc_camera_device *icd) | |||
356 | int ret; | 354 | int ret; |
357 | 355 | ||
358 | ret = reg_set(RESET, MT9M111_RESET_CHIP_ENABLE); | 356 | ret = reg_set(RESET, MT9M111_RESET_CHIP_ENABLE); |
359 | if (ret >= 0) | 357 | if (!ret) |
360 | mt9m111->powered = 1; | 358 | mt9m111->powered = 1; |
361 | return ret; | 359 | return ret; |
362 | } | 360 | } |
@@ -367,7 +365,7 @@ static int mt9m111_disable(struct soc_camera_device *icd) | |||
367 | int ret; | 365 | int ret; |
368 | 366 | ||
369 | ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE); | 367 | ret = reg_clear(RESET, MT9M111_RESET_CHIP_ENABLE); |
370 | if (ret >= 0) | 368 | if (!ret) |
371 | mt9m111->powered = 0; | 369 | mt9m111->powered = 0; |
372 | return ret; | 370 | return ret; |
373 | } | 371 | } |
@@ -377,9 +375,9 @@ static int mt9m111_reset(struct soc_camera_device *icd) | |||
377 | int ret; | 375 | int ret; |
378 | 376 | ||
379 | ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); | 377 | ret = reg_set(RESET, MT9M111_RESET_RESET_MODE); |
380 | if (ret >= 0) | 378 | if (!ret) |
381 | ret = reg_set(RESET, MT9M111_RESET_RESET_SOC); | 379 | ret = reg_set(RESET, MT9M111_RESET_RESET_SOC); |
382 | if (ret >= 0) | 380 | if (!ret) |
383 | ret = reg_clear(RESET, MT9M111_RESET_RESET_MODE | 381 | ret = reg_clear(RESET, MT9M111_RESET_RESET_MODE |
384 | | MT9M111_RESET_RESET_SOC); | 382 | | MT9M111_RESET_RESET_SOC); |
385 | return ret; | 383 | return ret; |
@@ -410,7 +408,7 @@ static int mt9m111_set_bus_param(struct soc_camera_device *icd, unsigned long f) | |||
410 | static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) | 408 | static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) |
411 | { | 409 | { |
412 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 410 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
413 | int ret = 0; | 411 | int ret; |
414 | 412 | ||
415 | switch (pixfmt) { | 413 | switch (pixfmt) { |
416 | case V4L2_PIX_FMT_SBGGR8: | 414 | case V4L2_PIX_FMT_SBGGR8: |
@@ -433,7 +431,7 @@ static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) | |||
433 | ret = -EINVAL; | 431 | ret = -EINVAL; |
434 | } | 432 | } |
435 | 433 | ||
436 | if (ret >= 0) | 434 | if (!ret) |
437 | mt9m111->pixfmt = pixfmt; | 435 | mt9m111->pixfmt = pixfmt; |
438 | 436 | ||
439 | return ret; | 437 | return ret; |
@@ -443,7 +441,7 @@ static int mt9m111_set_fmt_cap(struct soc_camera_device *icd, | |||
443 | __u32 pixfmt, struct v4l2_rect *rect) | 441 | __u32 pixfmt, struct v4l2_rect *rect) |
444 | { | 442 | { |
445 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 443 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
446 | int ret = 0; | 444 | int ret; |
447 | 445 | ||
448 | mt9m111->left = rect->left; | 446 | mt9m111->left = rect->left; |
449 | mt9m111->top = rect->top; | 447 | mt9m111->top = rect->top; |
@@ -455,9 +453,9 @@ static int mt9m111_set_fmt_cap(struct soc_camera_device *icd, | |||
455 | mt9m111->height); | 453 | mt9m111->height); |
456 | 454 | ||
457 | ret = mt9m111_setup_rect(icd); | 455 | ret = mt9m111_setup_rect(icd); |
458 | if (ret >= 0) | 456 | if (!ret) |
459 | ret = mt9m111_set_pixfmt(icd, pixfmt); | 457 | ret = mt9m111_set_pixfmt(icd, pixfmt); |
460 | return ret < 0 ? ret : 0; | 458 | return ret; |
461 | } | 459 | } |
462 | 460 | ||
463 | static int mt9m111_try_fmt_cap(struct soc_camera_device *icd, | 461 | static int mt9m111_try_fmt_cap(struct soc_camera_device *icd, |
@@ -644,7 +642,7 @@ static int mt9m111_set_global_gain(struct soc_camera_device *icd, int gain) | |||
644 | if ((gain >= 64 * 2) && (gain < 63 * 2 * 2)) | 642 | if ((gain >= 64 * 2) && (gain < 63 * 2 * 2)) |
645 | val = (1 << 10) | (1 << 9) | (gain / 4); | 643 | val = (1 << 10) | (1 << 9) | (gain / 4); |
646 | else if ((gain >= 64) && (gain < 64 * 2)) | 644 | else if ((gain >= 64) && (gain < 64 * 2)) |
647 | val = (1<<9) | (gain / 2); | 645 | val = (1 << 9) | (gain / 2); |
648 | else | 646 | else |
649 | val = gain; | 647 | val = gain; |
650 | 648 | ||
@@ -661,7 +659,7 @@ static int mt9m111_set_autoexposure(struct soc_camera_device *icd, int on) | |||
661 | else | 659 | else |
662 | ret = reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN); | 660 | ret = reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOEXPO_EN); |
663 | 661 | ||
664 | if (ret >= 0) | 662 | if (!ret) |
665 | mt9m111->autoexposure = on; | 663 | mt9m111->autoexposure = on; |
666 | 664 | ||
667 | return ret; | 665 | return ret; |
@@ -711,7 +709,7 @@ static int mt9m111_set_control(struct soc_camera_device *icd, | |||
711 | { | 709 | { |
712 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); | 710 | struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); |
713 | const struct v4l2_queryctrl *qctrl; | 711 | const struct v4l2_queryctrl *qctrl; |
714 | int ret = 0; | 712 | int ret; |
715 | 713 | ||
716 | qctrl = soc_camera_find_qctrl(&mt9m111_ops, ctrl->id); | 714 | qctrl = soc_camera_find_qctrl(&mt9m111_ops, ctrl->id); |
717 | 715 | ||
@@ -739,7 +737,7 @@ static int mt9m111_set_control(struct soc_camera_device *icd, | |||
739 | ret = -EINVAL; | 737 | ret = -EINVAL; |
740 | } | 738 | } |
741 | 739 | ||
742 | return ret < 0 ? -EIO : 0; | 740 | return ret; |
743 | } | 741 | } |
744 | 742 | ||
745 | int mt9m111_restore_state(struct soc_camera_device *icd) | 743 | int mt9m111_restore_state(struct soc_camera_device *icd) |
@@ -763,10 +761,10 @@ static int mt9m111_resume(struct soc_camera_device *icd) | |||
763 | 761 | ||
764 | if (mt9m111->powered) { | 762 | if (mt9m111->powered) { |
765 | ret = mt9m111_enable(icd); | 763 | ret = mt9m111_enable(icd); |
766 | if (ret >= 0) | 764 | if (!ret) |
767 | mt9m111_reset(icd); | 765 | ret = mt9m111_reset(icd); |
768 | if (ret >= 0) | 766 | if (!ret) |
769 | mt9m111_restore_state(icd); | 767 | ret = mt9m111_restore_state(icd); |
770 | } | 768 | } |
771 | return ret; | 769 | return ret; |
772 | } | 770 | } |
@@ -778,15 +776,15 @@ static int mt9m111_init(struct soc_camera_device *icd) | |||
778 | 776 | ||
779 | mt9m111->context = HIGHPOWER; | 777 | mt9m111->context = HIGHPOWER; |
780 | ret = mt9m111_enable(icd); | 778 | ret = mt9m111_enable(icd); |
781 | if (ret >= 0) | 779 | if (!ret) |
782 | mt9m111_reset(icd); | 780 | ret = mt9m111_reset(icd); |
783 | if (ret >= 0) | 781 | if (!ret) |
784 | mt9m111_set_context(icd, mt9m111->context); | 782 | ret = mt9m111_set_context(icd, mt9m111->context); |
785 | if (ret >= 0) | 783 | if (!ret) |
786 | mt9m111_set_autoexposure(icd, mt9m111->autoexposure); | 784 | ret = mt9m111_set_autoexposure(icd, mt9m111->autoexposure); |
787 | if (ret < 0) | 785 | if (ret) |
788 | dev_err(&icd->dev, "mt9m111 init failed: %d\n", ret); | 786 | dev_err(&icd->dev, "mt9m111 init failed: %d\n", ret); |
789 | return ret ? -EIO : 0; | 787 | return ret; |
790 | } | 788 | } |
791 | 789 | ||
792 | static int mt9m111_release(struct soc_camera_device *icd) | 790 | static int mt9m111_release(struct soc_camera_device *icd) |
@@ -797,7 +795,7 @@ static int mt9m111_release(struct soc_camera_device *icd) | |||
797 | if (ret < 0) | 795 | if (ret < 0) |
798 | dev_err(&icd->dev, "mt9m111 release failed: %d\n", ret); | 796 | dev_err(&icd->dev, "mt9m111 release failed: %d\n", ret); |
799 | 797 | ||
800 | return ret ? -EIO : 0; | 798 | return ret; |
801 | } | 799 | } |
802 | 800 | ||
803 | /* | 801 | /* |