From patchwork Tue Jan 27 21:14:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 20513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A0B1DE03F for ; Wed, 28 Jan 2009 08:17:59 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LRvHD-0004u4-7S; Tue, 27 Jan 2009 21:15:19 +0000 Received: from smtp1.linux-foundation.org ([140.211.169.13]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1LRvH8-0004LG-8u for linux-mtd@lists.infradead.org; Tue, 27 Jan 2009 21:15:17 +0000 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n0RLEum5021046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Jan 2009 13:14:57 -0800 Received: from akpm.corp.google.com (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with SMTP id n0RLEsrF029545; Tue, 27 Jan 2009 13:14:55 -0800 Date: Tue, 27 Jan 2009 13:14:54 -0800 From: Andrew Morton To: Atsushi Nemoto Subject: Re: [PATCH 2/5] RBTX4939: Add MTD support Message-Id: <20090127131454.d2f147df.akpm@linux-foundation.org> In-Reply-To: <1232460738-4714-2-git-send-email-anemo@mba.ocn.ne.jp> References: <1232460738-4714-2-git-send-email-anemo@mba.ocn.ne.jp> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, hits=-3.428 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 X-Spam-Score: 0.0 (/) Cc: linux-mips@linux-mips.org, linux-mtd@lists.infradead.org, dwmw2@infradead.org, ralf@linux-mips.org, linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Tue, 20 Jan 2009 23:12:16 +0900 Atsushi Nemoto wrote: > +static void rbtx4939_flash_copy_from(struct map_info *map, void *to, > + unsigned long from, ssize_t len) > +{ > + u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f; > + unsigned char shift; > + ssize_t curlen; > + > + from += (unsigned long)map->virt; > + if (bdipsw & 8) { > + /* BOOT Mode: USER ROM1 / USER ROM2 */ > + shift = bdipsw & 3; > + while (len) { > + curlen = min((unsigned long)len, > + 0x400000 - (from & (0x400000 - 1))); > + memcpy(to, > + (void *)((from & ~0xc00000) | > + ((((from >> 22) + shift) & 3) << 22)), > + curlen); > + len -= curlen; > + from += curlen; > + to += curlen; > + } > + return; > + } > +#ifdef __BIG_ENDIAN > + if (bdipsw == 0) { > + /* BOOT Mode: Monitor ROM */ > + while (len) { > + curlen = min((unsigned long)len, > + 0x400000 - (from & (0x400000 - 1))); > + memcpy(to, (void *)(from ^ 0x400000), curlen); > + len -= curlen; > + from += curlen; > + to += curlen; > + } > + return; > + } > +#endif > + memcpy(to, (void *)from, len); > +} min_t is the preferred way of preventing that warning. Well. Actually the preferred way is to get the types right - often the code simply goofed, and people use casts/min_t to hide that. But in this case, yes, casting literal constants to ssize_t would be a bit silly. --- a/arch/mips/txx9/rbtx4939/setup.c~mtd-rbtx4939-add-mtd-support-fix +++ a/arch/mips/txx9/rbtx4939/setup.c @@ -335,7 +335,7 @@ static void rbtx4939_flash_copy_from(str /* BOOT Mode: USER ROM1 / USER ROM2 */ shift = bdipsw & 3; while (len) { - curlen = min((unsigned long)len, + curlen = min_t(unsigned long, len, 0x400000 - (from & (0x400000 - 1))); memcpy(to, (void *)((from & ~0xc00000) | @@ -351,7 +351,7 @@ static void rbtx4939_flash_copy_from(str if (bdipsw == 0) { /* BOOT Mode: Monitor ROM */ while (len) { - curlen = min((unsigned long)len, + curlen = min_t(unsigned long, len, 0x400000 - (from & (0x400000 - 1))); memcpy(to, (void *)(from ^ 0x400000), curlen); len -= curlen;