{"id":811968,"url":"http://patchwork.ozlabs.org/api/patches/811968/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170909171606.20029-2-robdclark@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170909171606.20029-2-robdclark@gmail.com>","list_archive_url":null,"date":"2017-09-09T17:15:52","name":"[U-Boot,v3,1/9] fs/fat: split out helper to init fsdata","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9d37654ce94ec7f037c357d5c9f0bb6ec22a109c","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/?format=json","name":"Rob Clark","email":"robdclark@gmail.com"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170909171606.20029-2-robdclark@gmail.com/mbox/","series":[{"id":2355,"url":"http://patchwork.ozlabs.org/api/series/2355/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2355","date":"2017-09-09T17:15:51","name":"fs/fat: cleanups + readdir implementation","version":3,"mbox":"http://patchwork.ozlabs.org/series/2355/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811968/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811968/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"YjDjuXA1\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xqLTy3swlz9t16\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 10 Sep 2017 03:17:26 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 1D39CC21E54; Sat,  9 Sep 2017 17:16:32 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A7B4DC21F14;\n\tSat,  9 Sep 2017 17:16:29 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 22AA7C21DBF; Sat,  9 Sep 2017 17:16:26 +0000 (UTC)","from mail-qt0-f193.google.com (mail-qt0-f193.google.com\n\t[209.85.216.193])\n\tby lists.denx.de (Postfix) with ESMTPS id E558AC21D65\n\tfor <u-boot@lists.denx.de>; Sat,  9 Sep 2017 17:16:22 +0000 (UTC)","by mail-qt0-f193.google.com with SMTP id k2so3284744qte.5\n\tfor <u-boot@lists.denx.de>; Sat, 09 Sep 2017 10:16:22 -0700 (PDT)","from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\ti41sm3280727qta.23.2017.09.09.10.16.20\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 09 Sep 2017 10:16:20 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Rwe9iiSkwfR2II8s0SPmCSJtn3Oys4FC2KKNrCSa/Uk=;\n\tb=YjDjuXA1CRdDG6CYPmL5tIGUSOU+BDThIdrMO/ixH7Q3aJoF8bL+59LiEKSSHJTw+h\n\tKZKkrd9pCXAwgtNeuM2hCj9ApV3u6aThiUcmbUYkzNflMzApy+c1O0GZ91Mxpe+B9JlT\n\tL3DcEhYModVqjaGAr/oDoklvLidWdx95sgHUfZ3kwXCWYx4Hu/6ifmn0g4hKN9mKcsAB\n\tp1OYfOXqonRWZGxmpGZRLzYjlF0wIC2cTq51AP0nr2DU3QF3/PDxLuKatB75WxCKCI15\n\tgusOcmo5WwSpJJXqYeT7NqfPXvV6NL/mMkDptxqhpxot/C/W4e49tVVZVf65TbR2zB1m\n\t3wgA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Rwe9iiSkwfR2II8s0SPmCSJtn3Oys4FC2KKNrCSa/Uk=;\n\tb=XtZQjTT/28ohqAPRzli9cB1ccNXp+FEDDmRxq64AVq6ZvbQO7DZezZLefPwslrLt/g\n\twgMK4buYX7rjkQVmwju+vrtehSEg/Y08vPhyqgop9/PaM2z3U/Oo0EmIM6dYfyYlKBeL\n\t9turubiQPsruEzoLvW2LDaFCUdZQLXoCYEP2FDdYx1MyL3Qb0oB7m+RPHrgQW8DTi4Wx\n\t3JPxRcdT4Z+QXgrv/qPygHIIc6JWrTN3qqWMi7KRH+GctGauwTozh4LlCnk0yaWT4wkr\n\tWxaJvdfzu0Y/EdgcHLjK2bY91Dwcorg5yu6YwWzoUGh96DeBoqIBZzudMu4/lRn0mATr\n\t8czg==","X-Gm-Message-State":"AHPjjUiGGMIUPT/sQ2CDyynibNiiU23U7Fu0zDGW/uZZcmgkiqEHXx9L\n\t1JMCH8T9Nzb0vg+0tqw=","X-Google-Smtp-Source":"AOwi7QCf7eutxCXgxzJ8iaf7eiRJ2u3N1zYAdxgiwaZhP5JHBTcsOxsPfrIq3+htlLa5fInnk49Mpg==","X-Received":"by 10.200.34.167 with SMTP id f36mr9297204qta.236.1504977381643; \n\tSat, 09 Sep 2017 10:16:21 -0700 (PDT)","From":"Rob Clark <robdclark@gmail.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sat,  9 Sep 2017 13:15:52 -0400","Message-Id":"<20170909171606.20029-2-robdclark@gmail.com>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170909171606.20029-1-robdclark@gmail.com>","References":"<20170909171606.20029-1-robdclark@gmail.com>","MIME-Version":"1.0","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>,\n\tGenevieve Chan <ccheauya@altera.com>, Tien Fong Chee <tfchee@altera.com>","Subject":"[U-Boot] [PATCH v3 1/9] fs/fat: split out helper to init fsdata","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Want to re-use this in fat dirent iterator in next patch.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\nReviewed-by: Łukasz Majewski <lukma@denx.de>\nReviewed-by: Simon Glass <sjg@chromium.org>\n---\n fs/fat/fat.c  | 73 +++++++++++++++++++++++++++++++++++------------------------\n include/fat.h |  1 +\n 2 files changed, 44 insertions(+), 30 deletions(-)","diff":"diff --git a/fs/fat/fat.c b/fs/fat/fat.c\nindex 465a6875ed..e1c0a15dc7 100644\n--- a/fs/fat/fat.c\n+++ b/fs/fat/fat.c\n@@ -808,35 +808,17 @@ exit:\n \treturn ret;\n }\n \n-__u8 do_fat_read_at_block[MAX_CLUSTSIZE]\n-\t__aligned(ARCH_DMA_MINALIGN);\n-\n-int do_fat_read_at(const char *filename, loff_t pos, void *buffer,\n-\t\t   loff_t maxsize, int dols, int dogetsize, loff_t *size)\n+static int get_fs_info(fsdata *mydata)\n {\n-\tchar fnamecopy[2048];\n \tboot_sector bs;\n \tvolume_info volinfo;\n-\tfsdata datablock;\n-\tfsdata *mydata = &datablock;\n-\tdir_entry *dentptr = NULL;\n-\t__u16 prevcksum = 0xffff;\n-\tchar *subname = \"\";\n-\t__u32 cursect;\n-\tint idx, isdir = 0;\n-\tint files = 0, dirs = 0;\n-\tint ret = -1;\n-\tint firsttime;\n \t__u32 root_cluster = 0;\n-\t__u32 read_blk;\n-\tint rootdir_size = 0;\n-\tint buffer_blk_cnt;\n-\tint do_read;\n-\t__u8 *dir_ptr;\n+\tint ret;\n \n-\tif (read_bootsectandvi(&bs, &volinfo, &mydata->fatsize)) {\n+\tret = read_bootsectandvi(&bs, &volinfo, &mydata->fatsize);\n+\tif (ret) {\n \t\tdebug(\"Error: reading boot sector\\n\");\n-\t\treturn -1;\n+\t\treturn ret;\n \t}\n \n \tif (mydata->fatsize == 32) {\n@@ -848,8 +830,7 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,\n \n \tmydata->fat_sect = bs.reserved;\n \n-\tcursect = mydata->rootdir_sect\n-\t\t= mydata->fat_sect + mydata->fatlength * bs.fats;\n+\tmydata->rootdir_sect = mydata->fat_sect + mydata->fatlength * bs.fats;\n \n \tmydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];\n \tmydata->clust_size = bs.cluster_size;\n@@ -863,12 +844,12 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,\n \t\tmydata->data_begin = mydata->rootdir_sect -\n \t\t\t\t\t(mydata->clust_size * 2);\n \t} else {\n-\t\trootdir_size = ((bs.dir_entries[1]  * (int)256 +\n-\t\t\t\t bs.dir_entries[0]) *\n-\t\t\t\t sizeof(dir_entry)) /\n-\t\t\t\t mydata->sect_size;\n+\t\tmydata->rootdir_size = ((bs.dir_entries[1]  * (int)256 +\n+\t\t\t\t\t bs.dir_entries[0]) *\n+\t\t\t\t\t sizeof(dir_entry)) /\n+\t\t\t\t\t mydata->sect_size;\n \t\tmydata->data_begin = mydata->rootdir_sect +\n-\t\t\t\t\trootdir_size -\n+\t\t\t\t\tmydata->rootdir_size -\n \t\t\t\t\t(mydata->clust_size * 2);\n \t}\n \n@@ -893,6 +874,38 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer,\n \tdebug(\"Sector size: %d, cluster size: %d\\n\", mydata->sect_size,\n \t      mydata->clust_size);\n \n+\treturn 0;\n+}\n+\n+__u8 do_fat_read_at_block[MAX_CLUSTSIZE]\n+\t__aligned(ARCH_DMA_MINALIGN);\n+\n+int do_fat_read_at(const char *filename, loff_t pos, void *buffer,\n+\t\t   loff_t maxsize, int dols, int dogetsize, loff_t *size)\n+{\n+\tchar fnamecopy[2048];\n+\tfsdata datablock;\n+\tfsdata *mydata = &datablock;\n+\tdir_entry *dentptr = NULL;\n+\t__u16 prevcksum = 0xffff;\n+\tchar *subname = \"\";\n+\t__u32 cursect;\n+\tint idx, isdir = 0;\n+\tint files = 0, dirs = 0;\n+\tint ret = -1;\n+\tint firsttime;\n+\t__u32 root_cluster = 0;\n+\t__u32 read_blk;\n+\tint rootdir_size = 0;\n+\tint buffer_blk_cnt;\n+\tint do_read;\n+\t__u8 *dir_ptr;\n+\n+\tif (get_fs_info(mydata))\n+\t\treturn -1;\n+\n+\tcursect = mydata->rootdir_sect;\n+\n \t/* \"cwd\" is always the root... */\n \twhile (ISDIRDELIM(*filename))\n \t\tfilename++;\ndiff --git a/include/fat.h b/include/fat.h\nindex 71879f01ca..b671ee8f81 100644\n--- a/include/fat.h\n+++ b/include/fat.h\n@@ -174,6 +174,7 @@ typedef struct {\n \t__u16\tclust_size;\t/* Size of clusters in sectors */\n \tint\tdata_begin;\t/* The sector of the first cluster, can be negative */\n \tint\tfatbufnum;\t/* Used by get_fatent, init to -1 */\n+\tint\trootdir_size;\t/* Size of root dir for non-FAT32 */\n } fsdata;\n \n typedef int\t(file_detectfs_func)(void);\n","prefixes":["U-Boot","v3","1/9"]}