media: videobuf-dma-sg: number of pages should be unsigned long

As reported by smatch:

	drivers/media/v4l2-core/videobuf-dma-sg.c:245 videobuf_dma_init_kernel() warn: should 'nr_pages << 12' be a 64 bit type?

The printk should not be using %d for the number of pages.

After looking better, the real problem here is that the
number of pages should be long int.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2020-09-01 11:09:26 +02:00
parent 73c016543d
commit 1faa39e0f3
2 changed files with 13 additions and 11 deletions

View File

@ -180,7 +180,7 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,
if (rw == READ) if (rw == READ)
flags |= FOLL_WRITE; flags |= FOLL_WRITE;
dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n", dprintk(1, "init user [0x%lx+0x%lx => %lu pages]\n",
data, size, dma->nr_pages); data, size, dma->nr_pages);
err = pin_user_pages(data & PAGE_MASK, dma->nr_pages, err = pin_user_pages(data & PAGE_MASK, dma->nr_pages,
@ -188,7 +188,7 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,
if (err != dma->nr_pages) { if (err != dma->nr_pages) {
dma->nr_pages = (err >= 0) ? err : 0; dma->nr_pages = (err >= 0) ? err : 0;
dprintk(1, "pin_user_pages: err=%d [%d]\n", err, dprintk(1, "pin_user_pages: err=%d [%lu]\n", err,
dma->nr_pages); dma->nr_pages);
return err < 0 ? err : -EINVAL; return err < 0 ? err : -EINVAL;
} }
@ -208,11 +208,11 @@ static int videobuf_dma_init_user(struct videobuf_dmabuf *dma, int direction,
} }
static int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction, static int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
int nr_pages) unsigned long nr_pages)
{ {
int i; int i;
dprintk(1, "init kernel [%d pages]\n", nr_pages); dprintk(1, "init kernel [%lu pages]\n", nr_pages);
dma->direction = direction; dma->direction = direction;
dma->vaddr_pages = kcalloc(nr_pages, sizeof(*dma->vaddr_pages), dma->vaddr_pages = kcalloc(nr_pages, sizeof(*dma->vaddr_pages),
@ -238,11 +238,11 @@ static int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
dma->vaddr = vmap(dma->vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP, dma->vaddr = vmap(dma->vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP,
PAGE_KERNEL); PAGE_KERNEL);
if (NULL == dma->vaddr) { if (NULL == dma->vaddr) {
dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages);
goto out_free_pages; goto out_free_pages;
} }
dprintk(1, "vmalloc is at addr %p, size=%d\n", dprintk(1, "vmalloc is at addr %p, size=%lu\n",
dma->vaddr, nr_pages << PAGE_SHIFT); dma->vaddr, nr_pages << PAGE_SHIFT);
memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT); memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
@ -267,9 +267,9 @@ out_free_pages:
} }
static int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, static int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
dma_addr_t addr, int nr_pages) dma_addr_t addr, unsigned long nr_pages)
{ {
dprintk(1, "init overlay [%d pages @ bus 0x%lx]\n", dprintk(1, "init overlay [%lu pages @ bus 0x%lx]\n",
nr_pages, (unsigned long)addr); nr_pages, (unsigned long)addr);
dma->direction = direction; dma->direction = direction;
@ -500,9 +500,11 @@ static int __videobuf_iolock(struct videobuf_queue *q,
struct videobuf_buffer *vb, struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf) struct v4l2_framebuffer *fbuf)
{ {
int err, pages;
dma_addr_t bus;
struct videobuf_dma_sg_memory *mem = vb->priv; struct videobuf_dma_sg_memory *mem = vb->priv;
unsigned long pages;
dma_addr_t bus;
int err;
BUG_ON(!mem); BUG_ON(!mem);
MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); MAGIC_CHECK(mem->magic, MAGIC_SG_MEM);

View File

@ -60,7 +60,7 @@ struct videobuf_dmabuf {
/* common */ /* common */
struct scatterlist *sglist; struct scatterlist *sglist;
int sglen; int sglen;
int nr_pages; unsigned long nr_pages;
int direction; int direction;
}; };