Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932772AbbESNv5 (ORCPT ); Tue, 19 May 2015 09:51:57 -0400 Received: from smtp.citrix.com ([66.165.176.89]:39494 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903AbbESNv4 (ORCPT ); Tue, 19 May 2015 09:51:56 -0400 X-IronPort-AV: E=Sophos;i="5.13,458,1427760000"; d="scan'208";a="264016341" Message-ID: <555B3FF6.4050902@citrix.com> Date: Tue, 19 May 2015 14:51:50 +0100 From: David Vrabel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-Version: 1.0 To: Julien Grall , CC: Wei Liu , , , , , David Vrabel , "Boris Ostrovsky" , Subject: Re: [Xen-devel] [RFC 02/23] xen/xenbus: client: Fix call of virt_to_mfn in xenbus_grant_ring References: <1431622863-28575-1-git-send-email-julien.grall@citrix.com> <1431622863-28575-3-git-send-email-julien.grall@citrix.com> In-Reply-To: <1431622863-28575-3-git-send-email-julien.grall@citrix.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-DLP: MIA2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1344 Lines: 40 On 14/05/15 18:00, Julien Grall wrote: > virt_to_mfn should take a void* rather an unsigned long. While it > doesn't really matter now, it would throw a compiler warning later when > virt_to_mfn will enforce the type. > > At the same time, avoid to compute new virtual address every time in the > loop and directly increment the parameter as we don't use it later. Reviewed-by: David Vrabel But... > --- a/drivers/xen/xenbus/xenbus_client.c > +++ b/drivers/xen/xenbus/xenbus_client.c > @@ -379,16 +379,16 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, > int i, j; > > for (i = 0; i < nr_pages; i++) { > - unsigned long addr = (unsigned long)vaddr + > - (PAGE_SIZE * i); > err = gnttab_grant_foreign_access(dev->otherend_id, > - virt_to_mfn(addr), 0); > + virt_to_mfn(vaddr), 0); > if (err < 0) { > xenbus_dev_fatal(dev, err, > "granting access to ring page"); > goto fail; > } > grefs[i] = err; > + > + vaddr = (char *)vaddr + PAGE_SIZE; You don't need the cast here since vaddr is a void *. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/