From patchwork Tue Sep 4 07:49:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 965801 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eJxWPKOz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 424Jv71jLPz9rvt for ; Tue, 4 Sep 2018 17:51:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id AEA23C21F3C; Tue, 4 Sep 2018 07:50:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D6573C21F00; Tue, 4 Sep 2018 07:50:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D6455C21DA6; Tue, 4 Sep 2018 07:50:07 +0000 (UTC) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by lists.denx.de (Postfix) with ESMTPS id 10092C21F24 for ; Tue, 4 Sep 2018 07:50:07 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id l9-v6so1270728pff.9 for ; Tue, 04 Sep 2018 00:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3qrr9QH6inJDbghfQTPCEefOHDyZ8p0CbM4DD7Np98c=; b=eJxWPKOzKZGBivwX8oer+YhGAafi9W8uVblp71/ioprob9CKN83gDe+qQtdGp6Jupb D3/UPfmkerS3TtRFeDxEwQ2JqsjZT7d/eh/uJffQa4Ja153nZFqeTGzq4ZltE0gtrru9 lHAuBb7fq6LHeC3ckU0LfkkR/gvYmSHs6x5lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3qrr9QH6inJDbghfQTPCEefOHDyZ8p0CbM4DD7Np98c=; b=NUdRNqrtxpdEP2YO824wFDf6AidRh+y9/v4obmb99ao4rfyPfHJX8bYnEu1iMvdTKz dxeuY7fQzG2nmmFaG3tSfTUJ0PFB4gDy/4roFQkLHOngNod8+nkE2C/4qiUctb2UtSvS 3Q67OFHhzJF6mbNz2/4srFzkyPVzNKbnOiRO6qrUmWn2sDyTitVN0dcGa/0zh4KVgg9H wqsNJOyT8Q1VX34dyr8f+2FObeEIZYNyeR0ocKqE0oYpSDBQy0UgLFn/R2kolJ69JTCs PR3evfEzAD5Uwk/mnS1no3B7D4UY3tiyg/me2PlUnD7kGiUyHYgkiqbzU5PSpyDBgNzJ lMvA== X-Gm-Message-State: APzg51BItPwvqtoX0u3frxQ1s4JJlBr+N4ZoSKGJKDGi3ubByPRTeCJe tkCSX5Mqz3N8cQ/YhUwPPUYy3w== X-Google-Smtp-Source: ANB0VdaswdTi4ld0ZbjbHUn2BoIROjbojx6bXgRVJSqlnSmMVWVstN+/XRKoUjBxmQNMPx8wDSwzxg== X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr28902917pga.181.1536047405732; Tue, 04 Sep 2018 00:50:05 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p19-v6sm24517679pgh.60.2018.09.04.00.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 00:50:05 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Tue, 4 Sep 2018 16:49:27 +0900 Message-Id: <20180904074948.18146-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904074948.18146-1-takahiro.akashi@linaro.org> References: <20180904074948.18146-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 02/23] fs: fat: extend get_fs_info() for write use X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" get_fs_info() was introduced in major re-work of read operation by Rob. We want to reuse this function in write operation by extending it with additional members in fsdata structure. Signed-off-by: AKASHI Takahiro --- fs/fat/fat.c | 7 +++++++ include/fat.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 4efe8a3edaf1..0576658dde09 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -558,10 +558,17 @@ static int get_fs_info(fsdata *mydata) if (mydata->fatsize == 32) { mydata->fatlength = bs.fat32_length; + mydata->total_sect = bs.total_sect; } else { mydata->fatlength = bs.fat_length; + mydata->total_sect = (bs.sectors[1] << 8) + bs.sectors[0]; + if (!mydata->total_sect) + mydata->total_sect = bs.total_sect; } + if (!mydata->total_sect) /* unlikely */ + mydata->total_sect = (u32)cur_part_info.size; + mydata->fats = bs.fats; mydata->fat_sect = bs.reserved; mydata->rootdir_sect = mydata->fat_sect + mydata->fatlength * bs.fats; diff --git a/include/fat.h b/include/fat.h index c02839dcb040..127e6622a9b0 100644 --- a/include/fat.h +++ b/include/fat.h @@ -175,6 +175,8 @@ typedef struct { int fatbufnum; /* Used by get_fatent, init to -1 */ int rootdir_size; /* Size of root dir for non-FAT32 */ __u32 root_cluster; /* First cluster of root dir for FAT32 */ + u32 total_sect; /* Number of sectors */ + int fats; /* Number of FATs */ } fsdata; static inline u32 clust_to_sect(fsdata *fsdata, u32 clust)