From patchwork Wed Jan 1 17:49:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 11315545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E7E9109A for ; Thu, 2 Jan 2020 10:58:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E51C0215A4 for ; Thu, 2 Jan 2020 10:58:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E51C0215A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=inria.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DDC7189349; Thu, 2 Jan 2020 10:58:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73FC189B30 for ; Wed, 1 Jan 2020 18:26:27 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.69,382,1571695200"; d="scan'208";a="334542274" Received: from palace.rsr.lip6.fr (HELO palace.lip6.fr) ([132.227.105.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA256; 01 Jan 2020 19:26:24 +0100 From: Julia Lawall To: Kristoffer Ericson Subject: [PATCH 03/10] fbdev: s1d13xxxfb: use resource_size Date: Wed, 1 Jan 2020 18:49:43 +0100 Message-Id: <1577900990-8588-4-git-send-email-Julia.Lawall@inria.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1577900990-8588-1-git-send-email-Julia.Lawall@inria.fr> References: <1577900990-8588-1-git-send-email-Julia.Lawall@inria.fr> X-Mailman-Approved-At: Thu, 02 Jan 2020 10:58:15 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Bartlomiej Zolnierkiewicz MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use resource_size rather than a verbose computation on the end and start fields. The semantic patch that makes these changes is as follows: (http://coccinelle.lip6.fr/) @@ struct resource ptr; @@ - (ptr.end - ptr.start + 1) + resource_size(&ptr) Signed-off-by: Julia Lawall --- drivers/video/fbdev/s1d13xxxfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c index 8048499e398d..eaea8c373753 100644 --- a/drivers/video/fbdev/s1d13xxxfb.c +++ b/drivers/video/fbdev/s1d13xxxfb.c @@ -746,9 +746,9 @@ s1d13xxxfb_remove(struct platform_device *pdev) } release_mem_region(pdev->resource[0].start, - pdev->resource[0].end - pdev->resource[0].start +1); + resource_size(&pdev->resource[0])); release_mem_region(pdev->resource[1].start, - pdev->resource[1].end - pdev->resource[1].start +1); + resource_size(&pdev->resource[1])); return 0; } @@ -788,14 +788,14 @@ static int s1d13xxxfb_probe(struct platform_device *pdev) } if (!request_mem_region(pdev->resource[0].start, - pdev->resource[0].end - pdev->resource[0].start +1, "s1d13xxxfb mem")) { + resource_size(&pdev->resource[0]), "s1d13xxxfb mem")) { dev_dbg(&pdev->dev, "request_mem_region failed\n"); ret = -EBUSY; goto bail; } if (!request_mem_region(pdev->resource[1].start, - pdev->resource[1].end - pdev->resource[1].start +1, "s1d13xxxfb regs")) { + resource_size(&pdev->resource[1]), "s1d13xxxfb regs")) { dev_dbg(&pdev->dev, "request_mem_region failed\n"); ret = -EBUSY; goto bail; @@ -810,7 +810,7 @@ static int s1d13xxxfb_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); default_par = info->par; default_par->regs = ioremap(pdev->resource[1].start, - pdev->resource[1].end - pdev->resource[1].start +1); + resource_size(&pdev->resource[1])); if (!default_par->regs) { printk(KERN_ERR PFX "unable to map registers\n"); ret = -ENOMEM; @@ -819,7 +819,7 @@ static int s1d13xxxfb_probe(struct platform_device *pdev) info->pseudo_palette = default_par->pseudo_palette; info->screen_base = ioremap(pdev->resource[0].start, - pdev->resource[0].end - pdev->resource[0].start +1); + resource_size(&pdev->resource[0])); if (!info->screen_base) { printk(KERN_ERR PFX "unable to map framebuffer\n"); @@ -857,9 +857,9 @@ static int s1d13xxxfb_probe(struct platform_device *pdev) info->fix = s1d13xxxfb_fix; info->fix.mmio_start = pdev->resource[1].start; - info->fix.mmio_len = pdev->resource[1].end - pdev->resource[1].start + 1; + info->fix.mmio_len = resource_size(&pdev->resource[1]); info->fix.smem_start = pdev->resource[0].start; - info->fix.smem_len = pdev->resource[0].end - pdev->resource[0].start + 1; + info->fix.smem_len = resource_size(&pdev->resource[0]); printk(KERN_INFO PFX "regs mapped at 0x%p, fb %d KiB mapped at 0x%p\n", default_par->regs, info->fix.smem_len / 1024, info->screen_base); From patchwork Wed Jan 1 17:49:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 11315553 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72386138D for ; Thu, 2 Jan 2020 10:58:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AE02215A4 for ; Thu, 2 Jan 2020 10:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AE02215A4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=inria.fr Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACD5E6E059; Thu, 2 Jan 2020 10:58:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4561189B30 for ; Wed, 1 Jan 2020 18:26:28 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.69,382,1571695200"; d="scan'208";a="334542278" Received: from palace.rsr.lip6.fr (HELO palace.lip6.fr) ([132.227.105.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA256; 01 Jan 2020 19:26:25 +0100 From: Julia Lawall To: Bartlomiej Zolnierkiewicz Subject: [PATCH 07/10] video: fbdev: use resource_size Date: Wed, 1 Jan 2020 18:49:47 +0100 Message-Id: <1577900990-8588-8-git-send-email-Julia.Lawall@inria.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1577900990-8588-1-git-send-email-Julia.Lawall@inria.fr> References: <1577900990-8588-1-git-send-email-Julia.Lawall@inria.fr> X-Mailman-Approved-At: Thu, 02 Jan 2020 10:58:15 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use resource_size rather than a verbose computation on the end and start fields. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) @@ struct resource ptr; @@ - (ptr.end - ptr.start + 1) + resource_size(&ptr) Signed-off-by: Julia Lawall --- drivers/video/fbdev/cg14.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/fbdev/cg14.c b/drivers/video/fbdev/cg14.c index a620b51cf7d0..6a745eb46ca1 100644 --- a/drivers/video/fbdev/cg14.c +++ b/drivers/video/fbdev/cg14.c @@ -509,8 +509,7 @@ static int cg14_probe(struct platform_device *op) if (!par->regs || !par->clut || !par->cursor || !info->screen_base) goto out_unmap_regs; - is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == - (8 * 1024 * 1024)); + is_8mb = (resource_size(&op->resource[1]) == (8 * 1024 * 1024)); BUILD_BUG_ON(sizeof(par->mmap_map) != sizeof(__cg14_mmap_map));