aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Ribalda <ricardo.ribalda@gmail.com>2013-11-26 03:31:42 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 05:02:39 -0500
commitf90580ca0133c533763a6cb3e632a21098a382df (patch)
tree05e66bbea641292153c2a78d781d49d866a16379
parentda4a733946aa360e2219ce2d33b8d25ce4aa1959 (diff)
[media] videodev2: Set vb2_rect's width and height as unsigned
As discussed on the media summit 2013, there is no reason for the width and height to be signed. Therefore this patch is an attempt to convert those fields from __s32 to __u32. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> (documentation and smiapp) Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml12
-rw-r--r--Documentation/DocBook/media/v4l/dev-overlay.xml9
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml10
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-cropcap.xml10
-rw-r--r--drivers/media/i2c/mt9m032.c16
-rw-r--r--drivers/media/i2c/mt9p031.c28
-rw-r--r--drivers/media/i2c/mt9t001.c26
-rw-r--r--drivers/media/i2c/mt9v032.c38
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c8
-rw-r--r--drivers/media/i2c/soc_camera/mt9m111.c4
-rw-r--r--drivers/media/i2c/tvp5150.c14
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c6
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c4
-rw-r--r--drivers/media/platform/soc_camera/soc_scale_crop.c4
-rw-r--r--include/uapi/linux/videodev2.h4
15 files changed, 108 insertions, 85 deletions
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 0c7195e3e093..c4cac6dbf9af 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2523,6 +2523,18 @@ that used it. It was originally scheduled for removal in 2.6.35.
2523 </orderedlist> 2523 </orderedlist>
2524 </section> 2524 </section>
2525 2525
2526 <section>
2527 <title>V4L2 in Linux 3.14</title>
2528 <orderedlist>
2529 <listitem>
2530 <para> In struct <structname>v4l2_rect</structname>, the type
2531of <structfield>width</structfield> and <structfield>height</structfield>
2532fields changed from _s32 to _u32.
2533 </para>
2534 </listitem>
2535 </orderedlist>
2536 </section>
2537
2526 <section id="other"> 2538 <section id="other">
2527 <title>Relation of V4L2 to other Linux multimedia APIs</title> 2539 <title>Relation of V4L2 to other Linux multimedia APIs</title>
2528 2540
diff --git a/Documentation/DocBook/media/v4l/dev-overlay.xml b/Documentation/DocBook/media/v4l/dev-overlay.xml
index 40d1d7681439..cc6e0c5c960c 100644
--- a/Documentation/DocBook/media/v4l/dev-overlay.xml
+++ b/Documentation/DocBook/media/v4l/dev-overlay.xml
@@ -346,17 +346,14 @@ rectangle, in pixels.</entry>
346rectangle, in pixels. Offsets increase to the right and down.</entry> 346rectangle, in pixels. Offsets increase to the right and down.</entry>
347 </row> 347 </row>
348 <row> 348 <row>
349 <entry>__s32</entry> 349 <entry>__u32</entry>
350 <entry><structfield>width</structfield></entry> 350 <entry><structfield>width</structfield></entry>
351 <entry>Width of the rectangle, in pixels.</entry> 351 <entry>Width of the rectangle, in pixels.</entry>
352 </row> 352 </row>
353 <row> 353 <row>
354 <entry>__s32</entry> 354 <entry>__u32</entry>
355 <entry><structfield>height</structfield></entry> 355 <entry><structfield>height</structfield></entry>
356 <entry>Height of the rectangle, in pixels. Width and 356 <entry>Height of the rectangle, in pixels.</entry>
357height cannot be negative, the fields are signed for hysterical
358reasons. <!-- video4linux-list@redhat.com on 22 Oct 2002 subject
359"Re:[V4L][patches!] Re:v4l2/kernel-2.5" --></entry>
360 </row> 357 </row>
361 </tbody> 358 </tbody>
362 </tgroup> 359 </tgroup>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 8469fe13945c..74b7f27af71a 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -141,6 +141,14 @@ structs, ioctls) must be noted in more detail in the history chapter
141applications. --> 141applications. -->
142 142
143 <revision> 143 <revision>
144 <revnumber>3.14</revnumber>
145 <date>2013-11-25</date>
146 <authorinitials>rr</authorinitials>
147 <revremark>Set width and height as unsigned on v4l2_rect.
148 </revremark>
149 </revision>
150
151 <revision>
144 <revnumber>3.11</revnumber> 152 <revnumber>3.11</revnumber>
145 <date>2013-05-26</date> 153 <date>2013-05-26</date>
146 <authorinitials>hv</authorinitials> 154 <authorinitials>hv</authorinitials>
@@ -501,7 +509,7 @@ and discussions on the V4L mailing list.</revremark>
501</partinfo> 509</partinfo>
502 510
503<title>Video for Linux Two API Specification</title> 511<title>Video for Linux Two API Specification</title>
504 <subtitle>Revision 3.11</subtitle> 512 <subtitle>Revision 3.14</subtitle>
505 513
506 <chapter id="common"> 514 <chapter id="common">
507 &sub-common; 515 &sub-common;
diff --git a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
index bf7cc979fdfa..1f5ed64cd75a 100644
--- a/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-cropcap.xml
@@ -133,18 +133,14 @@ rectangle, in pixels.</entry>
133rectangle, in pixels.</entry> 133rectangle, in pixels.</entry>
134 </row> 134 </row>
135 <row> 135 <row>
136 <entry>__s32</entry> 136 <entry>__u32</entry>
137 <entry><structfield>width</structfield></entry> 137 <entry><structfield>width</structfield></entry>
138 <entry>Width of the rectangle, in pixels.</entry> 138 <entry>Width of the rectangle, in pixels.</entry>
139 </row> 139 </row>
140 <row> 140 <row>
141 <entry>__s32</entry> 141 <entry>__u32</entry>
142 <entry><structfield>height</structfield></entry> 142 <entry><structfield>height</structfield></entry>
143 <entry>Height of the rectangle, in pixels. Width 143 <entry>Height of the rectangle, in pixels.</entry>
144and height cannot be negative, the fields are signed for
145hysterical reasons. <!-- video4linux-list@redhat.com
146on 22 Oct 2002 subject "Re:[V4L][patches!] Re:v4l2/kernel-2.5" -->
147</entry>
148 </row> 144 </row>
149 </tbody> 145 </tbody>
150 </tgroup> 146 </tgroup>
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 846b15f0bf64..85ec3bacdf1c 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -459,13 +459,15 @@ static int mt9m032_set_pad_crop(struct v4l2_subdev *subdev,
459 MT9M032_COLUMN_START_MAX); 459 MT9M032_COLUMN_START_MAX);
460 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9M032_ROW_START_MIN, 460 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9M032_ROW_START_MIN,
461 MT9M032_ROW_START_MAX); 461 MT9M032_ROW_START_MAX);
462 rect.width = clamp(ALIGN(crop->rect.width, 2), MT9M032_COLUMN_SIZE_MIN, 462 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
463 MT9M032_COLUMN_SIZE_MAX); 463 MT9M032_COLUMN_SIZE_MIN, MT9M032_COLUMN_SIZE_MAX);
464 rect.height = clamp(ALIGN(crop->rect.height, 2), MT9M032_ROW_SIZE_MIN, 464 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
465 MT9M032_ROW_SIZE_MAX); 465 MT9M032_ROW_SIZE_MIN, MT9M032_ROW_SIZE_MAX);
466 466
467 rect.width = min(rect.width, MT9M032_PIXEL_ARRAY_WIDTH - rect.left); 467 rect.width = min_t(unsigned int, rect.width,
468 rect.height = min(rect.height, MT9M032_PIXEL_ARRAY_HEIGHT - rect.top); 468 MT9M032_PIXEL_ARRAY_WIDTH - rect.left);
469 rect.height = min_t(unsigned int, rect.height,
470 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);
469 471
470 __crop = __mt9m032_get_pad_crop(sensor, fh, crop->which); 472 __crop = __mt9m032_get_pad_crop(sensor, fh, crop->which);
471 473
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 1c2303d18bf4..e5ddf47030fd 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -519,11 +519,13 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
519 519
520 /* Clamp the width and height to avoid dividing by zero. */ 520 /* Clamp the width and height to avoid dividing by zero. */
521 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 521 width = clamp_t(unsigned int, ALIGN(format->format.width, 2),
522 max(__crop->width / 7, MT9P031_WINDOW_WIDTH_MIN), 522 max_t(unsigned int, __crop->width / 7,
523 MT9P031_WINDOW_WIDTH_MIN),
523 __crop->width); 524 __crop->width);
524 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 525 height = clamp_t(unsigned int, ALIGN(format->format.height, 2),
525 max(__crop->height / 8, MT9P031_WINDOW_HEIGHT_MIN), 526 max_t(unsigned int, __crop->height / 8,
526 __crop->height); 527 MT9P031_WINDOW_HEIGHT_MIN),
528 __crop->height);
527 529
528 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 530 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
529 vratio = DIV_ROUND_CLOSEST(__crop->height, height); 531 vratio = DIV_ROUND_CLOSEST(__crop->height, height);
@@ -565,15 +567,17 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
565 MT9P031_COLUMN_START_MAX); 567 MT9P031_COLUMN_START_MAX);
566 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9P031_ROW_START_MIN, 568 rect.top = clamp(ALIGN(crop->rect.top, 2), MT9P031_ROW_START_MIN,
567 MT9P031_ROW_START_MAX); 569 MT9P031_ROW_START_MAX);
568 rect.width = clamp(ALIGN(crop->rect.width, 2), 570 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
569 MT9P031_WINDOW_WIDTH_MIN, 571 MT9P031_WINDOW_WIDTH_MIN,
570 MT9P031_WINDOW_WIDTH_MAX); 572 MT9P031_WINDOW_WIDTH_MAX);
571 rect.height = clamp(ALIGN(crop->rect.height, 2), 573 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
572 MT9P031_WINDOW_HEIGHT_MIN, 574 MT9P031_WINDOW_HEIGHT_MIN,
573 MT9P031_WINDOW_HEIGHT_MAX); 575 MT9P031_WINDOW_HEIGHT_MAX);
574 576
575 rect.width = min(rect.width, MT9P031_PIXEL_ARRAY_WIDTH - rect.left); 577 rect.width = min_t(unsigned int, rect.width,
576 rect.height = min(rect.height, MT9P031_PIXEL_ARRAY_HEIGHT - rect.top); 578 MT9P031_PIXEL_ARRAY_WIDTH - rect.left);
579 rect.height = min_t(unsigned int, rect.height,
580 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top);
577 581
578 __crop = __mt9p031_get_pad_crop(mt9p031, fh, crop->pad, crop->which); 582 __crop = __mt9p031_get_pad_crop(mt9p031, fh, crop->pad, crop->which);
579 583
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 796463466ef0..d41c70eaf838 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -291,10 +291,12 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
291 291
292 /* Clamp the width and height to avoid dividing by zero. */ 292 /* Clamp the width and height to avoid dividing by zero. */
293 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 293 width = clamp_t(unsigned int, ALIGN(format->format.width, 2),
294 max(__crop->width / 8, MT9T001_WINDOW_HEIGHT_MIN + 1), 294 max_t(unsigned int, __crop->width / 8,
295 MT9T001_WINDOW_HEIGHT_MIN + 1),
295 __crop->width); 296 __crop->width);
296 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 297 height = clamp_t(unsigned int, ALIGN(format->format.height, 2),
297 max(__crop->height / 8, MT9T001_WINDOW_HEIGHT_MIN + 1), 298 max_t(unsigned int, __crop->height / 8,
299 MT9T001_WINDOW_HEIGHT_MIN + 1),
298 __crop->height); 300 __crop->height);
299 301
300 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 302 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
@@ -339,15 +341,17 @@ static int mt9t001_set_crop(struct v4l2_subdev *subdev,
339 rect.top = clamp(ALIGN(crop->rect.top, 2), 341 rect.top = clamp(ALIGN(crop->rect.top, 2),
340 MT9T001_ROW_START_MIN, 342 MT9T001_ROW_START_MIN,
341 MT9T001_ROW_START_MAX); 343 MT9T001_ROW_START_MAX);
342 rect.width = clamp(ALIGN(crop->rect.width, 2), 344 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
343 MT9T001_WINDOW_WIDTH_MIN + 1, 345 MT9T001_WINDOW_WIDTH_MIN + 1,
344 MT9T001_WINDOW_WIDTH_MAX + 1); 346 MT9T001_WINDOW_WIDTH_MAX + 1);
345 rect.height = clamp(ALIGN(crop->rect.height, 2), 347 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
346 MT9T001_WINDOW_HEIGHT_MIN + 1, 348 MT9T001_WINDOW_HEIGHT_MIN + 1,
347 MT9T001_WINDOW_HEIGHT_MAX + 1); 349 MT9T001_WINDOW_HEIGHT_MAX + 1);
348 350
349 rect.width = min(rect.width, MT9T001_PIXEL_ARRAY_WIDTH - rect.left); 351 rect.width = min_t(unsigned int, rect.width,
350 rect.height = min(rect.height, MT9T001_PIXEL_ARRAY_HEIGHT - rect.top); 352 MT9T001_PIXEL_ARRAY_WIDTH - rect.left);
353 rect.height = min_t(unsigned int, rect.height,
354 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top);
351 355
352 __crop = __mt9t001_get_pad_crop(mt9t001, fh, crop->pad, crop->which); 356 __crop = __mt9t001_get_pad_crop(mt9t001, fh, crop->pad, crop->which);
353 357
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 0d2b4a8cf911..36c504b78f2c 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -305,8 +305,8 @@ mt9v032_update_hblank(struct mt9v032 *mt9v032)
305 305
306 if (mt9v032->version->version == MT9V034_CHIP_ID_REV1) 306 if (mt9v032->version->version == MT9V034_CHIP_ID_REV1)
307 min_hblank += (mt9v032->hratio - 1) * 10; 307 min_hblank += (mt9v032->hratio - 1) * 10;
308 min_hblank = max((int)mt9v032->model->data->min_row_time - crop->width, 308 min_hblank = max_t(unsigned int, (int)mt9v032->model->data->min_row_time - crop->width,
309 (int)min_hblank); 309 (int)min_hblank);
310 hblank = max_t(unsigned int, mt9v032->hblank, min_hblank); 310 hblank = max_t(unsigned int, mt9v032->hblank, min_hblank);
311 311
312 return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank); 312 return mt9v032_write(client, MT9V032_HORIZONTAL_BLANKING, hblank);
@@ -525,12 +525,14 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
525 format->which); 525 format->which);
526 526
527 /* Clamp the width and height to avoid dividing by zero. */ 527 /* Clamp the width and height to avoid dividing by zero. */
528 width = clamp_t(unsigned int, ALIGN(format->format.width, 2), 528 width = clamp(ALIGN(format->format.width, 2),
529 max(__crop->width / 4, MT9V032_WINDOW_WIDTH_MIN), 529 max_t(unsigned int, __crop->width / 4,
530 __crop->width); 530 MT9V032_WINDOW_WIDTH_MIN),
531 height = clamp_t(unsigned int, ALIGN(format->format.height, 2), 531 __crop->width);
532 max(__crop->height / 4, MT9V032_WINDOW_HEIGHT_MIN), 532 height = clamp(ALIGN(format->format.height, 2),
533 __crop->height); 533 max_t(unsigned int, __crop->height / 4,
534 MT9V032_WINDOW_HEIGHT_MIN),
535 __crop->height);
534 536
535 hratio = mt9v032_calc_ratio(__crop->width, width); 537 hratio = mt9v032_calc_ratio(__crop->width, width);
536 vratio = mt9v032_calc_ratio(__crop->height, height); 538 vratio = mt9v032_calc_ratio(__crop->height, height);
@@ -580,15 +582,17 @@ static int mt9v032_set_crop(struct v4l2_subdev *subdev,
580 rect.top = clamp(ALIGN(crop->rect.top + 1, 2) - 1, 582 rect.top = clamp(ALIGN(crop->rect.top + 1, 2) - 1,
581 MT9V032_ROW_START_MIN, 583 MT9V032_ROW_START_MIN,
582 MT9V032_ROW_START_MAX); 584 MT9V032_ROW_START_MAX);
583 rect.width = clamp(ALIGN(crop->rect.width, 2), 585 rect.width = clamp_t(unsigned int, ALIGN(crop->rect.width, 2),
584 MT9V032_WINDOW_WIDTH_MIN, 586 MT9V032_WINDOW_WIDTH_MIN,
585 MT9V032_WINDOW_WIDTH_MAX); 587 MT9V032_WINDOW_WIDTH_MAX);
586 rect.height = clamp(ALIGN(crop->rect.height, 2), 588 rect.height = clamp_t(unsigned int, ALIGN(crop->rect.height, 2),
587 MT9V032_WINDOW_HEIGHT_MIN, 589 MT9V032_WINDOW_HEIGHT_MIN,
588 MT9V032_WINDOW_HEIGHT_MAX); 590 MT9V032_WINDOW_HEIGHT_MAX);
589 591
590 rect.width = min(rect.width, MT9V032_PIXEL_ARRAY_WIDTH - rect.left); 592 rect.width = min_t(unsigned int,
591 rect.height = min(rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top); 593 rect.width, MT9V032_PIXEL_ARRAY_WIDTH - rect.left);
594 rect.height = min_t(unsigned int,
595 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top);
592 596
593 __crop = __mt9v032_get_pad_crop(mt9v032, fh, crop->pad, crop->which); 597 __crop = __mt9v032_get_pad_crop(mt9v032, fh, crop->pad, crop->which);
594 598
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index fbd48f04b5c8..8741cae9c9f2 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2027,8 +2027,8 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2027 sel->r.width = min(sel->r.width, src_size->width); 2027 sel->r.width = min(sel->r.width, src_size->width);
2028 sel->r.height = min(sel->r.height, src_size->height); 2028 sel->r.height = min(sel->r.height, src_size->height);
2029 2029
2030 sel->r.left = min(sel->r.left, src_size->width - sel->r.width); 2030 sel->r.left = min_t(int, sel->r.left, src_size->width - sel->r.width);
2031 sel->r.top = min(sel->r.top, src_size->height - sel->r.height); 2031 sel->r.top = min_t(int, sel->r.top, src_size->height - sel->r.height);
2032 2032
2033 *crops[sel->pad] = sel->r; 2033 *crops[sel->pad] = sel->r;
2034 2034
@@ -2120,8 +2120,8 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev,
2120 2120
2121 sel->r.left = max(0, sel->r.left & ~1); 2121 sel->r.left = max(0, sel->r.left & ~1);
2122 sel->r.top = max(0, sel->r.top & ~1); 2122 sel->r.top = max(0, sel->r.top & ~1);
2123 sel->r.width = max(0, SMIAPP_ALIGN_DIM(sel->r.width, sel->flags)); 2123 sel->r.width = SMIAPP_ALIGN_DIM(sel->r.width, sel->flags);
2124 sel->r.height = max(0, SMIAPP_ALIGN_DIM(sel->r.height, sel->flags)); 2124 sel->r.height = SMIAPP_ALIGN_DIM(sel->r.height, sel->flags);
2125 2125
2126 sel->r.width = max_t(unsigned int, 2126 sel->r.width = max_t(unsigned int,
2127 sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], 2127 sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE],
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c
index 6f4056668bbc..ccf59406a172 100644
--- a/drivers/media/i2c/soc_camera/mt9m111.c
+++ b/drivers/media/i2c/soc_camera/mt9m111.c
@@ -208,8 +208,8 @@ struct mt9m111 {
208 struct mt9m111_context *ctx; 208 struct mt9m111_context *ctx;
209 struct v4l2_rect rect; /* cropping rectangle */ 209 struct v4l2_rect rect; /* cropping rectangle */
210 struct v4l2_clk *clk; 210 struct v4l2_clk *clk;
211 int width; /* output */ 211 unsigned int width; /* output */
212 int height; /* sizes */ 212 unsigned int height; /* sizes */
213 struct mutex power_lock; /* lock to protect power_count */ 213 struct mutex power_lock; /* lock to protect power_count */
214 int power_count; 214 int power_count;
215 const struct mt9m111_datafmt *fmt; 215 const struct mt9m111_datafmt *fmt;
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 2ed05b67218b..542d2528b3f9 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -863,7 +863,7 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
863 struct v4l2_rect rect = a->c; 863 struct v4l2_rect rect = a->c;
864 struct tvp5150 *decoder = to_tvp5150(sd); 864 struct tvp5150 *decoder = to_tvp5150(sd);
865 v4l2_std_id std; 865 v4l2_std_id std;
866 int hmax; 866 unsigned int hmax;
867 867
868 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n", 868 v4l2_dbg(1, debug, sd, "%s left=%d, top=%d, width=%d, height=%d\n",
869 __func__, rect.left, rect.top, rect.width, rect.height); 869 __func__, rect.left, rect.top, rect.width, rect.height);
@@ -873,9 +873,9 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
873 873
874 /* tvp5150 has some special limits */ 874 /* tvp5150 has some special limits */
875 rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT); 875 rect.left = clamp(rect.left, 0, TVP5150_MAX_CROP_LEFT);
876 rect.width = clamp(rect.width, 876 rect.width = clamp_t(unsigned int, rect.width,
877 TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left, 877 TVP5150_H_MAX - TVP5150_MAX_CROP_LEFT - rect.left,
878 TVP5150_H_MAX - rect.left); 878 TVP5150_H_MAX - rect.left);
879 rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP); 879 rect.top = clamp(rect.top, 0, TVP5150_MAX_CROP_TOP);
880 880
881 /* Calculate height based on current standard */ 881 /* Calculate height based on current standard */
@@ -889,9 +889,9 @@ static int tvp5150_s_crop(struct v4l2_subdev *sd, const struct v4l2_crop *a)
889 else 889 else
890 hmax = TVP5150_V_MAX_OTHERS; 890 hmax = TVP5150_V_MAX_OTHERS;
891 891
892 rect.height = clamp(rect.height, 892 rect.height = clamp_t(unsigned int, rect.height,
893 hmax - TVP5150_MAX_CROP_TOP - rect.top, 893 hmax - TVP5150_MAX_CROP_TOP - rect.top,
894 hmax - rect.top); 894 hmax - rect.top);
895 895
896 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top); 896 tvp5150_write(sd, TVP5150_VERT_BLANKING_START, rect.top);
897 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP, 897 tvp5150_write(sd, TVP5150_VERT_BLANKING_STOP,
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index c2aaadcd9318..afcd53bfcf8e 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1126,9 +1126,9 @@ bttv_crop_calc_limits(struct bttv_crop *c)
1126 c->min_scaled_height = 32; 1126 c->min_scaled_height = 32;
1127 } else { 1127 } else {
1128 c->min_scaled_width = 1128 c->min_scaled_width =
1129 (max(48, c->rect.width >> 4) + 3) & ~3; 1129 (max_t(unsigned int, 48, c->rect.width >> 4) + 3) & ~3;
1130 c->min_scaled_height = 1130 c->min_scaled_height =
1131 max(32, c->rect.height >> 4); 1131 max_t(unsigned int, 32, c->rect.height >> 4);
1132 } 1132 }
1133 1133
1134 c->max_scaled_width = c->rect.width & ~3; 1134 c->max_scaled_width = c->rect.width & ~3;
@@ -2024,7 +2024,7 @@ limit_scaled_size_lock (struct bttv_fh * fh,
2024 /* We cannot scale up. When the scaled image is larger 2024 /* We cannot scale up. When the scaled image is larger
2025 than crop.rect we adjust the crop.rect as required 2025 than crop.rect we adjust the crop.rect as required
2026 by the V4L2 spec, hence cropcap.bounds are our limit. */ 2026 by the V4L2 spec, hence cropcap.bounds are our limit. */
2027 max_width = min(b->width, (__s32) MAX_HACTIVE); 2027 max_width = min_t(unsigned int, b->width, MAX_HACTIVE);
2028 max_height = b->height; 2028 max_height = b->height;
2029 2029
2030 /* We cannot capture the same line as video and VBI data. 2030 /* We cannot capture the same line as video and VBI data.
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 36026b1cb3f8..eb472b5b26a0 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1729,10 +1729,6 @@ static int saa7134_s_crop(struct file *file, void *f, const struct v4l2_crop *cr
1729 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && 1729 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1730 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) 1730 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
1731 return -EINVAL; 1731 return -EINVAL;
1732 if (crop->c.height < 0)
1733 return -EINVAL;
1734 if (crop->c.width < 0)
1735 return -EINVAL;
1736 1732
1737 if (res_locked(dev, RESOURCE_OVERLAY)) 1733 if (res_locked(dev, RESOURCE_OVERLAY))
1738 return -EBUSY; 1734 return -EBUSY;
diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c
index cbd3a34f4f3f..8e74fb7f2a07 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -141,8 +141,8 @@ int soc_camera_client_s_crop(struct v4l2_subdev *sd,
141 * Popular special case - some cameras can only handle fixed sizes like 141 * Popular special case - some cameras can only handle fixed sizes like
142 * QVGA, VGA,... Take care to avoid infinite loop. 142 * QVGA, VGA,... Take care to avoid infinite loop.
143 */ 143 */
144 width = max(cam_rect->width, 2); 144 width = max_t(unsigned int, cam_rect->width, 2);
145 height = max(cam_rect->height, 2); 145 height = max_t(unsigned int, cam_rect->height, 2);
146 146
147 /* 147 /*
148 * Loop as long as sensor is not covering the requested rectangle and 148 * Loop as long as sensor is not covering the requested rectangle and
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 437f1b0f8937..6ae7bbe988cc 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -207,8 +207,8 @@ enum v4l2_priority {
207struct v4l2_rect { 207struct v4l2_rect {
208 __s32 left; 208 __s32 left;
209 __s32 top; 209 __s32 top;
210 __s32 width; 210 __u32 width;
211 __s32 height; 211 __u32 height;
212}; 212};
213 213
214struct v4l2_fract { 214struct v4l2_fract {