Skip to contentSkip to conversation

V4L/DVB: videobuf-dma-sg: Use min_t(size_t, PAGE_SIZE ..)

PATCH In review Mauro Carvalho Chehab 2 participants 3 messages Oct 7, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 V4L/DVB: videobuf-dma-sg: Use min_t(size_t, PAGE_SIZE ..)

As pointed by Laurent:

I think min_t(size_t, PAGE_SIZE, size) is the preferred way.

Thanks-to: Laurent Pinchart <[email protected]>

drivers/media/video/videobuf-dma-sg.c +2 -2
index 7153e44..20f227e 100644
@@ -116,8 +116,8 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
 			goto nopage;
 		if (PageHighMem(pages[i]))
 			goto highmem;
-		sg_set_page(&sglist[i], pages[i], min((unsigned)PAGE_SIZE, size), 0);
-		size -= min((unsigned)PAGE_SIZE, size);
+		sg_set_page(&sglist[i], pages[i], min_t(size_t, PAGE_SIZE, size), 0);
+		size -= min_t(size_t, PAGE_SIZE, size);
 	}
 	return sglist;
 
Signature · 1 line
1.7.1
#1 lore raw

Hi Mauro,

Quoted 12 lines · On Thursday 07 October 2010 14:45:43 Mauro Carvalho Chehab wrote:

As pointed by Laurent:

I think min_t(size_t, PAGE_SIZE, size) is the preferred way.

Thanks-to: Laurent Pinchart <[email protected]>

(quoted diff) +0 -0

b/drivers/media/video/videobuf-dma-sg.c index 7153e44..20f227e 100644

drivers/media/video/videobuf-dma-sg.c static struct scatterlist *videobuf_pages_to_sg(struct · line 119

Quoted 6 lines
drivers/media/video/videobuf-dma-sg.c +1 -2
@@ -116,8 +116,8 @@ static struct scatterlist *videobuf_pages_to_sg(struct
 page **pages, goto nopage;
 		if (PageHighMem(pages[i]))
 			goto highmem;
-		sg_set_page(&sglist[i], pages[i], min((unsigned)PAGE_SIZE, size), 0);
-		size -= min((unsigned)PAGE_SIZE, size);
+		sg_set_page(&sglist[i], pages[i], min_t(size_t, PAGE_SIZE, size), 0);

This won't pass checkpatch.pl (line > 80 characters long).

Beside, this patch applies on top of the previous one whereas I suppose you'd want to replace the previous one.

Quoted 3 lines
drivers/media/video/videobuf-dma-sg.c +1 -0
+		size -= min_t(size_t, PAGE_SIZE, size);
 	}
 	return sglist;
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Em 07-10-2010 10:46, Laurent Pinchart escreveu:

Quoted 10 lines

Hi Mauro,

Quoted 7 lines · On Thursday 07 October 2010 14:45:43 Mauro Carvalho Chehab wrote:

As pointed by Laurent:

I think min_t(size_t, PAGE_SIZE, size) is the preferred way.

Thanks-to: Laurent Pinchart <[email protected]>

Quoted 13 lines

drivers/media/video/videobuf-dma-sg.c static struct scatterlist *videobuf_pages_to_sg(struct · line 119

Quoted 11 lines
(quoted diff) +0 -0

b/drivers/media/video/videobuf-dma-sg.c index 7153e44..20f227e 100644

drivers/media/video/videobuf-dma-sg.c +1 -2
@@ -116,8 +116,8 @@ static struct scatterlist *videobuf_pages_to_sg(struct
 page **pages, goto nopage;
 		if (PageHighMem(pages[i]))
 			goto highmem;
-		sg_set_page(&sglist[i], pages[i], min((unsigned)PAGE_SIZE, size), 0);
-		size -= min((unsigned)PAGE_SIZE, size);
+		sg_set_page(&sglist[i], pages[i], min_t(size_t, PAGE_SIZE, size), 0);

This won't pass checkpatch.pl (line > 80 characters long).

Yes, but the 80 char-long is not a hard limit. In this case, it seemed better to just have a longer line.

Quoted 2 lines

Beside, this patch applies on top of the previous one whereas I suppose you'd want to replace the previous one.

I'll eventually merge the two patches when sending upstream.

Quoted 4 lines

drivers/media/video/videobuf-dma-sg.c static struct scatterlist *videobuf_pages_to_sg(struct page **pages, · line 122

Quoted 3 lines
drivers/media/video/videobuf-dma-sg.c +1 -0
+		size -= min_t(size_t, PAGE_SIZE, size);
 	}
 	return sglist;

Cheers,
Mauro.