From patchwork Wed Nov 27 12:27:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 3247541 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 336749F3A0 for ; Wed, 27 Nov 2013 12:27:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C06D205D4 for ; Wed, 27 Nov 2013 12:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7FCA205CB for ; Wed, 27 Nov 2013 12:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608Ab3K0M1s (ORCPT ); Wed, 27 Nov 2013 07:27:48 -0500 Received: from mga09.intel.com ([134.134.136.24]:2997 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575Ab3K0M1r (ORCPT ); Wed, 27 Nov 2013 07:27:47 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 27 Nov 2013 04:24:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,782,1378882800"; d="scan'208";a="415891955" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by orsmga001.jf.intel.com with ESMTP; 27 Nov 2013 04:27:46 -0800 Received: from irsmsx151.ger.corp.intel.com (163.33.192.59) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 27 Nov 2013 12:27:42 +0000 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.66]) by IRSMSX151.ger.corp.intel.com ([169.254.4.126]) with mapi id 14.03.0123.003; Wed, 27 Nov 2013 12:27:42 +0000 From: "Shevchenko, Andriy" To: Laurent Pinchart CC: "linux-sh@vger.kernel.org" , "Guennadi Liakhovetski" , "Koul, Vinod" , "dmaengine@vger.kernel.org" Subject: Re: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Thread-Topic: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Thread-Index: AQHO62wRYXrPAclo002YHAmbmSoKvw== Date: Wed, 27 Nov 2013 12:27:41 +0000 Message-ID: <1385555235.1871.16.camel@smile> References: <1385512192-10303-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> In-Reply-To: <1385512192-10303-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.237.72.173] Content-ID: MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2013-11-27 at 01:29 +0100, Laurent Pinchart wrote: > Use the %zu printk specifier to print size_t variables, and cast > pointers to unsigned long instead of unsigned int where applicable. This > fixes warnings on platforms where pointers and/or dma_addr_t have a > different size than int. Few comments below. > diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c > index 2e7b394..b37d584 100644 > --- a/drivers/dma/sh/shdma-base.c > +++ b/drivers/dma/sh/shdma-base.c > @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg) > struct shdma_chan *schan = to_shdma_chan(chan); > struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); > const struct shdma_ops *ops = sdev->ops; > - int match = (int)arg; > + int match = (long)arg; As far as I understand this will lose data on 64bit platforms. Are you aware of it? Otherwise I don't see the advantage of such conversion. As far as I understand you may cast void * easily to long and back, otherwise you lost data. > int ret; > > if (match < 0) > @@ -491,9 +491,9 @@ static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan, > } > > dev_dbg(schan->dev, > - "chaining (%u/%u)@%x -> %x with %p, cookie %d\n", > - copy_size, *len, *src, *dst, &new->async_tx, > - new->async_tx.cookie); > + "chaining (%zu/%zu)@%lx -> %lx with %p, cookie %d\n", > + copy_size, *len, (unsigned long)*src, (unsigned long)*dst, > + &new->async_tx, new->async_tx.cookie); Instead of dancing with casting (actually for dma_addr_t it should be ULL type), we can extend %pa to do this job for us: case 'D': Thus, use %paD. > > new->mark = DESC_PREPARED; > new->async_tx.flags = flags; > @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan, > goto err_get_desc; > > do { > - dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n", > + dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n", > i, sg, len, (unsigned long long)sg_addr); > > if (direction == DMA_DEV_TO_MEM) > diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c > index 06473a0..7fdb67b 100644 > --- a/drivers/dma/sh/shdma-of.c > +++ b/drivers/dma/sh/shdma-of.c > @@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec, > /* Only slave DMA channels can be allocated via DT */ > dma_cap_set(DMA_SLAVE, mask); > > - chan = dma_request_channel(mask, shdma_chan_filter, (void *)id); > + chan = dma_request_channel(mask, shdma_chan_filter, > + (void *)(unsigned long)id); > if (chan) > to_shdma_chan(chan)->hw_req = id; > > diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c > index c7e9cdf..2112ed2 100644 > --- a/drivers/dma/sh/sudmac.c > +++ b/drivers/dma/sh/sudmac.c > @@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan, > struct sudmac_chan *sc = to_chan(schan); > struct sudmac_desc *sd = to_desc(sdesc); > > - dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n", > - __func__, src, dst, *len); > + dev_dbg(sc->shdma_chan.dev, "%s: src=%lx, dst=%lx, len=%zu\n", > + __func__, (unsigned long)src, (unsigned long)dst, *len); > > if (*len > schan->max_xfer_len) > *len = schan->max_xfer_len; -- Andy Shevchenko Intel Finland Oy --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 10909c5..0806bf0 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1354,10 +1354,17 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, break; case 'a': spec.flags |= SPECIAL | SMALL | ZEROPAD; - spec.field_width = sizeof(phys_addr_t) * 2 + 2; spec.base = 16; - return number(buf, end, - (unsigned long long) *((phys_addr_t *)ptr), spec); + switch (fmt[1]) { + case 'D': + spec.field_width = sizeof(dma_addr_t) * 2 + 2; + return number(buf, end, + (unsigned long long)*((dma_addr_t *)ptr), spec); + default: + spec.field_width = sizeof(phys_addr_t) * 2 + 2; + return number(buf, end, + (unsigned long long)*((phys_addr_t *)ptr), spec); + } case 'd': return dentry_name(buf, end, ptr, spec, fmt);