Received: by 2002:a25:730a:0:0:0:0:0 with SMTP id o10csp4146108ybc; Fri, 25 Oct 2019 15:29:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp61AkDKFCUHo7Ec7cPHAsf/G6AESBwB2gUhdJfQz6QURcYYKy5DCWP/CN77pmsWPUW+IH X-Received: by 2002:a50:90a6:: with SMTP id c35mr6701926eda.22.1572042582122; Fri, 25 Oct 2019 15:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572042582; cv=none; d=google.com; s=arc-20160816; b=cB7ahYV5OBfx9wwe7CLZxdGeiKKGcmtiMQXXxrfKuc2bRPbbXWxL5+VUDeWy5XF9ml d5IOLCy49waEkkH/URdLKUKZLG1tFUnAvUYsPZE4nz1F/Z14kiReamRls5D0/Gb1eJ/f CzGpkMXF3uy2aN5EvJweJffmy4TdWi6vBHzBhZ3CXASJfZVo8NRkz9dQdmet8k5Tatm7 JYg4/kR8E79PfVD4Kwzxw9uOrmMLghtJK4A6NamRaOrgkjpUoEkDN4wwQWG6wZlZATV3 CesDN0ipDYhACaMqNFyOaYKV5+jL3kkcLWKnd635SpmTYSx8e5qB95/0uYYlyocMSUiB oKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=deSs9dYm2yXfqGx1BbD3wk2SB3s9iZim6z1K4V9oGak=; b=xWiNWY/7gHRw3cah4rCD+lOjHBXpJOytQdriIO6STSxL1XW2QoYx0ayWcxESDa8ix9 i7Psu3/7jNctsKIVs9W0xFPCutz/jeXSKIk4MsfuGDIb50eQGybORYoWcIT4mhD1sjwu AP+ZOrCRApEPVA/mgpz8arq+HEqoMntJvyEO6FJ4Nw2FNLd3xe1monaYWkMc+99Bi/7Q urlsmsTGICPsscUtzNyS/ItfYBtXeqB40bnsXFAqJME3xsDbOZdAgyMobWUBsuioDDhL nNPHrhVPjRHMcN5jrPN2Kn6xInCQFpG8/M6/i4FNUoZK7RR/iZDJk4enZRyt2OBD+NmK 4NPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si2577605edd.282.2019.10.25.15.29.19; Fri, 25 Oct 2019 15:29:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409140AbfJYKM2 (ORCPT + 99 others); Fri, 25 Oct 2019 06:12:28 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:47940 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409097AbfJYKMY (ORCPT ); Fri, 25 Oct 2019 06:12:24 -0400 X-IronPort-AV: E=Sophos;i="5.68,228,1569276000"; d="scan'208";a="408167341" Received: from portablejulia.rsr.lip6.fr ([132.227.76.63]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2019 12:12:22 +0200 Date: Fri, 25 Oct 2019 12:12:23 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Wambui Karuga cc: dri-devel@lists.freedesktop.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com Subject: Re: [Outreachy kernel] [Outreachy][PATCH] drm: use DIV_ROUND_UP helper macro for calculations In-Reply-To: <20191025094907.3582-1-wambui.karugax@gmail.com> Message-ID: References: <20191025094907.3582-1-wambui.karugax@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Oct 2019, Wambui Karuga wrote: > Replace open coded divisor calculations with the DIV_ROUND_UP kernel > macro for better readability. > Issue found using coccinelle: > @@ > expression n,d; > @@ > ( > - ((n + d - 1) / d) > + DIV_ROUND_UP(n,d) > | > - ((n + (d - 1)) / d) > + DIV_ROUND_UP(n,d) > ) > > Signed-off-by: Wambui Karuga Acked-by: Julia Lawall > --- > drivers/gpu/drm/drm_agpsupport.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c > index 6e09f27fd9d6..4c7ad46fdd21 100644 > --- a/drivers/gpu/drm/drm_agpsupport.c > +++ b/drivers/gpu/drm/drm_agpsupport.c > @@ -212,7 +212,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) > if (!entry) > return -ENOMEM; > > - pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; > + pages = DIV_ROUND_UP(request->size, PAGE_SIZE); > type = (u32) request->type; > memory = agp_allocate_memory(dev->agp->bridge, pages, type); > if (!memory) { > @@ -325,7 +325,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) > entry = drm_agp_lookup_entry(dev, request->handle); > if (!entry || entry->bound) > return -EINVAL; > - page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; > + page = DIV_ROUND_UP(request->offset, PAGE_SIZE); > retcode = drm_bind_agp(entry->memory, page); > if (retcode) > return retcode; > -- > 2.23.0 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20191025094907.3582-1-wambui.karugax%40gmail.com. >