From patchwork Tue Sep 11 06:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 146401 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3312074ljw; Tue, 11 Sep 2018 00:01:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaHK5lZcxbK06BCHHrSvs2ynsTNOcPxmxn8t5gXbAoTTNrtttANlnCUZ6i+WkMax85hoBuh X-Received: by 2002:a50:8c45:: with SMTP id p63-v6mr27582974edp.84.1536649292689; Tue, 11 Sep 2018 00:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536649292; cv=none; d=google.com; s=arc-20160816; b=naLqbKfo3nbHT8hVFMtIMhoUl+bDibWKR0Y10MKc2DhhNeXuz92coK5tQNVgSdNNoE tFC15b1YroOAC2VTsusmDxLhpAFBkEk/JWZnvHLBY5mtihqw+09lLzokUnInhybslzZ4 d4a6ghI1fp9c9d3hXe5kWT+cc99Rr8/zUWUGrYIjy/Iu9t30f4j77zESebsK7ODb+Z5l qlNICtt4dNu0g/PwarIy1eS96MZVNWb8TFBw98kJ0BIK9jUfCkAD4MIFapDr4XASEDe3 8INidNNOHHScl/AGvWYYuPoADmL+9LBDYcR6iB9zaO6ikbpvoxFH+TvxNrFAphflskGI xY1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=tzB2IUfkFv0dI2X8ODgcB5F+fxFpj4Kr00n3DZhDEAc=; b=pdZBLDr5xmZBkmjWLLr0eED6AAdlS+ChDnMCCDZqcC2bVNXhiL78ODUi81oMa6jwSs tbPEjqeBW+yQ/xfyE9WlOVCWXqSgPeHgXVzt5UsUtOEHx1FmdU1fxxU0lnGJ/535q3mJ J2BS2Ed1ZXFen0EoZL6IP0+njTwbJroqUdncFd3lxcSj5NjLlYRdYD2nhIGqIy25Qpm3 uE9fWfwunqNQQzmngY5ei0sws/qgcPyIcpro+tkUME6vhnHl25XygVnQFafWbSuu4VwC dHklctsP+pzqNbLW4SaL07fxgkUnyLRspLFVtGEw3P747JWW/1iDLmk5pJK3lrHdgsl8 78GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Bbawzelu; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id b23si1533297edx.434.2018.09.11.00.01.32; Tue, 11 Sep 2018 00:01:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Bbawzelu; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id C8A7DC21E62; Tue, 11 Sep 2018 06:59:58 +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 D36EEC21E7D; Tue, 11 Sep 2018 06:59:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 47183C21ED6; Tue, 11 Sep 2018 06:59:19 +0000 (UTC) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by lists.denx.de (Postfix) with ESMTPS id 4CF1BC21E79 for ; Tue, 11 Sep 2018 06:59:10 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id i190-v6so11753982pgc.6 for ; Mon, 10 Sep 2018 23:59:10 -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=z4gXz1vdK4z2DA9GIQPVd2IabDXK127OgHrbIcURAZw=; b=BbawzeluXs7PLUFIXQAZZhbPdrIiZjPa5Lp2lIkLj9CT/hejq5WIM1aXLnfZyoXSGg Ta/ihfbLoWsg8674Sp5dVK6kp+TtfwoMrZJscyIDYGrfWhd8TgVm2SQxXHj/2l3z9iL2 vnvD/gv7JbIrgLs7K0BGy+89A5Rcir3FVTZmw= 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=z4gXz1vdK4z2DA9GIQPVd2IabDXK127OgHrbIcURAZw=; b=Gnjk51OfktvsLHdnyb2S56ugCwQdXaGwiplhDRFnv8I2qQTdNR0juDHfFmEFmePxrG eCF6KRbb8vOuVNxpGhb1F/Am27hDsxnPBtcMSDcc4HfR7F55I8mYYe9kw8pKlvytzRk8 Co4WBiZlCFq3wku4tuza+bMfBB/i7EFAZlZdnt7x0jcJ3/2b4lvty1fuNGCSvZHeaXop RtZ/AMTU7wfioAg8DOvOB1kbgZe/wEObRQm9sgXLHeohLa/nK/nrgzKOvNIvc7cfOnn5 +wjYZgVOhQev1ya1pTB+uHcVYrPHaw9fYfCQ5aqLvqD8h/bQQfmnUmBWpkFTb83dY30k zkTw== X-Gm-Message-State: APzg51AtNqQpkjzzdCihCQEeKzDqH6dZakTZ+gInb3ItJyB9WH3ICHe1 1yrcggBjKRiCBPWO4lZtyPWBRQ== X-Received: by 2002:a63:141c:: with SMTP id u28-v6mr26707831pgl.247.1536649148927; Mon, 10 Sep 2018 23:59:08 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o34-v6sm22697430pgm.44.2018.09.10.23.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 23:59:08 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com Date: Tue, 11 Sep 2018 15:58:58 +0900 Message-Id: <20180911065922.19141-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180911065922.19141-1-takahiro.akashi@linaro.org> References: <20180911065922.19141-1-takahiro.akashi@linaro.org> Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [PATCH v3 02/26] 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" From: AKASHI Takahiro 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)