From patchwork Mon Dec 26 20:48:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9488789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14E4960839 for ; Mon, 26 Dec 2016 20:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 041DA1FF35 for ; Mon, 26 Dec 2016 20:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC31A1FFBD; Mon, 26 Dec 2016 20:49:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72C231FF35 for ; Mon, 26 Dec 2016 20:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755151AbcLZUtd (ORCPT ); Mon, 26 Dec 2016 15:49:33 -0500 Received: from mout.web.de ([212.227.15.3]:65275 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751918AbcLZUtc (ORCPT ); Mon, 26 Dec 2016 15:49:32 -0500 Received: from [192.168.1.2] ([77.182.133.191]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MgOUY-1cA9c62B0w-00Nipa; Mon, 26 Dec 2016 21:48:25 +0100 Subject: [PATCH 4/8] [media] videobuf-dma-sg: Adjust 24 checks for null values To: linux-media@vger.kernel.org, Dave Hansen , Jan Kara , Javier Martinez Canillas , "Kirill A. Shutemov" , Lorenzo Stoakes , Mauro Carvalho Chehab , Michal Hocko , Sakari Ailus References: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <7b963ec7-1ec7-5e44-e9ff-9385bc41aa48@users.sourceforge.net> Date: Mon, 26 Dec 2016 21:48:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> X-Provags-ID: V03:K0:1aYPZZ3xOSefm8O/+RGwbGfqsOylsaqM/mrRLFzvDUozbeuKyOt 7xHPTDBQ5ACTHlTBSu6eO6x8OZqDwbbtfRnwH9UjNifgph9OALpo1NNtJT/C4VhLqH6Meqi MM35TIqBNV8NV9i8cfxxP7fIs/s+y8H0wflNl/s9k/hx+IIj0bfGKdvbSrTUyG3F/ZGoDOa SBCzhb6T0aR7aBMv7GPmQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:9NnLreOaysg=:yJppv6l83OflxtCaZ+ShA0 0XqJBpuUi5GAIRUt5a8UpkpIZ1kbHQjpCoqfkd3OPrfU3n4DOfBpxNvO5g92GUF+QT2LQ9H9s gnLsOIl8Y517OQ66isZD9S2wsSHWpFB9TlQw9Dl3bHODBusdZIJ7gONi9T2mwrjZj2F+W37hm y4p4BZ+wsabpAaVeJCcjA/LSESELTWfKUqPxKdpXvGkDoy5LPz/Ay1HvLNmz/dHLv2qaPLnpX LZVlJyALYWq3DbY1tVhwRMEOzp7wPYCAfZDnjPJaqZSNcE5tkGq8K7xvxztCI0H90HWOEUVQV TOddph4kFrYgxpjpXjicqCs56wBIk/7YR4HHEd/otLiRtqnPshwquDMks2CD/PH5dFpzH3T87 yfdO0c1523i8/UIqJ8mVgNsjXGZL0YVQwQtsE1BmQUU7vSRljqUQp8VHXWihnkKfbwn11e4qM LVyta1kO3OhEoJOhNfK8GKu3oiV1PCWpKaCf5hu1sTC7PPAJdlNXnf0oyYzN9olDuKFl4msl+ NW67ZRNnGofSRvKkqJF/yAMdzhw0+ZWPOj2DKU0tB9fGWraxUrycQ1Y9V0eKEFD5t9PE2RyjU vH05dbFcBGuC7wKPG2DMBzoiul+rrYfHaZs23EqCYBIh7RFXgS8cO9tGiiz5fDCn1d2Z31LvD BahWeLOeLMIz+m9bL30SpWBuadEvyUCHkizxRsnhB2VUpD0z+n0W8YKZ4em/2dV14z8ZZmari 5JRek5O6lmd+ShFdkXkWW4xkUNJ9K7HLIMXRWJqAf3xcD/KJ0W+u4Szeowc4DgMeRhKWRSJaD 7ynKe+D Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 26 Dec 2016 20:30:19 +0100 Convert comparisons with the preprocessor symbol "NULL" or the value "0" to condition checks without it. Signed-off-by: Markus Elfring --- drivers/media/v4l2-core/videobuf-dma-sg.c | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index ab3c1f6a2ca1..9ccdc11aa016 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -70,12 +70,12 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt, int i; sglist = vzalloc(nr_pages * sizeof(*sglist)); - if (NULL == sglist) + if (!sglist) return NULL; sg_init_table(sglist, nr_pages); for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { pg = vmalloc_to_page(virt); - if (NULL == pg) + if (!pg) goto err; BUG_ON(PageHighMem(pg)); sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); @@ -98,10 +98,10 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages, struct scatterlist *sglist; int i; - if (NULL == pages[0]) + if (!pages[0]) return NULL; sglist = vmalloc(nr_pages * sizeof(*sglist)); - if (NULL == sglist) + if (!sglist) return NULL; sg_init_table(sglist, nr_pages); @@ -112,7 +112,7 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages, min_t(size_t, PAGE_SIZE - offset, size), offset); size -= min_t(size_t, PAGE_SIZE - offset, size); for (i = 1; i < nr_pages; i++) { - if (NULL == pages[i]) + if (!pages[i]) goto nopage; if (PageHighMem(pages[i])) goto highmem; @@ -178,7 +178,7 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, dma->pages = kmalloc_array(dma->nr_pages, sizeof(*dma->pages), GFP_KERNEL); - if (NULL == dma->pages) + if (!dma->pages) return -ENOMEM; if (rw == READ) @@ -233,14 +233,14 @@ static int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction, addr = dma_alloc_coherent(dma->dev, PAGE_SIZE, &(dma->dma_addr[i]), GFP_KERNEL); - if (addr == NULL) + if (!addr) goto out_free_pages; dma->vaddr_pages[i] = virt_to_page(addr); } dma->vaddr = vmap(dma->vaddr_pages, nr_pages, VM_MAP | VM_IOREMAP, PAGE_KERNEL); - if (NULL == dma->vaddr) { + if (!dma->vaddr) { dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); goto out_free_pages; } @@ -277,7 +277,7 @@ static int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, nr_pages, (unsigned long)addr); dma->direction = direction; - if (0 == addr) + if (!addr) return -EINVAL; dma->bus_addr = addr; @@ -289,7 +289,7 @@ static int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, static int videobuf_dma_map(struct device *dev, struct videobuf_dmabuf *dma) { MAGIC_CHECK(dma->magic, MAGIC_DMABUF); - BUG_ON(0 == dma->nr_pages); + BUG_ON(!dma->nr_pages); if (dma->pages) { dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages, @@ -301,7 +301,7 @@ static int videobuf_dma_map(struct device *dev, struct videobuf_dmabuf *dma) } if (dma->bus_addr) { dma->sglist = vmalloc(sizeof(*dma->sglist)); - if (NULL != dma->sglist) { + if (dma->sglist) { dma->sglen = 1; sg_dma_address(&dma->sglist[0]) = dma->bus_addr & PAGE_MASK; @@ -309,14 +309,14 @@ static int videobuf_dma_map(struct device *dev, struct videobuf_dmabuf *dma) sg_dma_len(&dma->sglist[0]) = dma->nr_pages * PAGE_SIZE; } } - if (NULL == dma->sglist) { + if (!dma->sglist) { dprintk(1, "scatterlist is NULL\n"); return -ENOMEM; } if (!dma->bus_addr) { dma->sglen = dma_map_sg(dev, dma->sglist, dma->nr_pages, dma->direction); - if (0 == dma->sglen) { + if (!dma->sglen) { printk(KERN_WARNING "%s: videobuf_map_sg failed\n", __func__); vfree(dma->sglist); @@ -406,11 +406,11 @@ static void videobuf_vm_close(struct vm_area_struct *vma) map->count, vma->vm_start, vma->vm_end); map->count--; - if (0 == map->count) { + if (!map->count) { dprintk(1, "munmap %p q=%p\n", map, q); videobuf_queue_lock(q); for (i = 0; i < VIDEO_MAX_FRAME; i++) { - if (NULL == q->bufs[i]) + if (!q->bufs[i]) continue; mem = q->bufs[i]->priv; if (!mem) @@ -518,20 +518,20 @@ static int __videobuf_iolock(struct videobuf_queue *q, switch (vb->memory) { case V4L2_MEMORY_MMAP: case V4L2_MEMORY_USERPTR: - if (0 == vb->baddr) { + if (!vb->baddr) { /* no userspace addr -- kernel bounce buffer */ pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; err = videobuf_dma_init_kernel(&mem->dma, DMA_FROM_DEVICE, pages); - if (0 != err) + if (err) return err; } else if (vb->memory == V4L2_MEMORY_USERPTR) { /* dma directly to userspace */ err = videobuf_dma_init_user(&mem->dma, DMA_FROM_DEVICE, vb->baddr, vb->bsize); - if (0 != err) + if (err) return err; } else { /* NOTE: HACK: videobuf_iolock on V4L2_MEMORY_MMAP @@ -542,12 +542,12 @@ static int __videobuf_iolock(struct videobuf_queue *q, err = videobuf_dma_init_user_locked(&mem->dma, DMA_FROM_DEVICE, vb->baddr, vb->bsize); - if (0 != err) + if (err) return err; } break; case V4L2_MEMORY_OVERLAY: - if (NULL == fbuf) + if (!fbuf) return -EINVAL; /* FIXME: need sanity checks for vb->boff */ /* @@ -559,14 +559,14 @@ static int __videobuf_iolock(struct videobuf_queue *q, pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; err = videobuf_dma_init_overlay(&mem->dma, DMA_FROM_DEVICE, bus, pages); - if (0 != err) + if (err) return err; break; default: BUG(); } err = videobuf_dma_map(q->dev, &mem->dma); - if (0 != err) + if (err) return err; return 0; @@ -621,12 +621,12 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, /* create mapping + update buffer list */ retval = -ENOMEM; map = kmalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); - if (NULL == map) + if (!map) goto done; size = 0; for (i = first; i <= last; i++) { - if (NULL == q->bufs[i]) + if (!q->bufs[i]) continue; q->bufs[i]->map = map; q->bufs[i]->baddr = vma->vm_start + size;