Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1039982ybc; Tue, 12 Nov 2019 13:15:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxPfARMVzqWkX4QNCBR64HphsYt4h/t2MwlDJfIJbtHozT1TkfaIziMxQNiht8PKjYDPys1 X-Received: by 2002:a17:906:b6c3:: with SMTP id ec3mr10904582ejb.27.1573593346224; Tue, 12 Nov 2019 13:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573593346; cv=none; d=google.com; s=arc-20160816; b=E3+rXsVpH2DUhSb8daIz4VDbD52B9MFsVBf/WqFbZq6kmMHUEEBJemkHzjMQyIe77S ZVXLop8NdE0CfnuKhExnMevacKNJ3HiVJWPuCyV6AkepQEeUm5Qs6uvSfxC6Ezn4Ji1u Hi1HRxSBaT1wuJ55XwScVVYs5D6DkKAotFdLxMh22OhEXiCXzplTru6wegy6jBRTSGtU ZYsNIT83HiCfnts5hjOl12Y+jF4fkGnvhF3NkxIWt3hxX/JIlBLZjP74lbZqQ7KGIxlq 69iYUjVDkkX0rWOLBPMVHQMUpRIL1qP/5KMFV7BZg45UlHVK8bgwdNhPLOy7RuPBrEzM cf6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=wN3d2kdOZvUd019MrkFxf+wV1r/QbnQ8i3gbsIy65Ko=; b=gbl7AdBQZDctP5o4KJyTUVFX0Mqok8CAoFM0KsH5fOz6eQHUHYevgS4Z5flpOe9HTw aE7AUsfAGi2ewZ+DsB8uEbt+q2IryZmzrKUKY7/hSsSHSFDil1XsZjCkzJz5ypcAM2pA yE5eNpoXKGkTROUGTIL0v5Ba/UXgJnxwF3cN1VUKuholD3M/h468zBIFgV6vhPrsCOga TcBTohlJnWVOdeYRtFtEv6wTuvw5dGmB+2SNCGm2RtYoYunzYJrHHGeljBiJb0ABZfIO Uf1WPZt7kN052Dts+IcXU8zgGjYuugLlrSSvyFc3e+wK9VzrDtyGYC4tiWxtHaFpBPKG o5Aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si782171eje.298.2019.11.12.13.15.18; Tue, 12 Nov 2019 13:15:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vt.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbfKLVN6 (ORCPT + 99 others); Tue, 12 Nov 2019 16:13:58 -0500 Received: from outbound.smtp.vt.edu ([198.82.183.121]:44518 "EHLO omr1.cc.vt.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727530AbfKLVNy (ORCPT ); Tue, 12 Nov 2019 16:13:54 -0500 Received: from mr1.cc.vt.edu (junk.cc.ipv6.vt.edu [IPv6:2607:b400:92:9:0:9d:8fcb:4116]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id xACLDqj6012847 for ; Tue, 12 Nov 2019 16:13:52 -0500 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mr1.cc.vt.edu (8.14.7/8.14.7) with ESMTP id xACLDl53021662 for ; Tue, 12 Nov 2019 16:13:52 -0500 Received: by mail-qv1-f72.google.com with SMTP id bz8so7471017qvb.9 for ; Tue, 12 Nov 2019 13:13:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wN3d2kdOZvUd019MrkFxf+wV1r/QbnQ8i3gbsIy65Ko=; b=mdmdRiV7wn2jTG0uzWdM5NvWfUor4+cfUcpw9ge8ybYggZJJfQxB2vfsjDFb5opFSW SPFk8uo8OxsKbUT8mbAcc0bu7i5zDiZWXOpGHTg63hyIsC8K3a/0lXZs/X812gNMctoW NszjI1pIeeWiblO27ph7h6o7FhO1bZC3Nt7RT4N5c4cRdf8bby++oAkkRV/EnspBIM2Q Y00v1r5f0k0wDpx9Ujx2je9NA4zdJ9a/rXenOYUkObgRDCGW7ObHxnVmEHK7XZp1tp86 e/TCj/2HGFALTYsme+Omhyhz9uBp6BbAsIRCzL04eI7pzf8ummd4joS02Zkni9DgOrJF T60w== X-Gm-Message-State: APjAAAUJmb+pDrUFqxIEMMVG3NHgpeQxlAKxUvzXNSMxWbqgLE+Nd9PE Sd+bpx+2hql0+wfnvDb2Wwd6+CedQBhLO82ditB0gE4XCrferd8tt5pYWEpcHnLBlAwHjgj+0IJ fkSZ935AVoftPJU45WEoeaatDc+D2IkrMNms= X-Received: by 2002:ac8:7948:: with SMTP id r8mr30671912qtt.91.1573593227568; Tue, 12 Nov 2019 13:13:47 -0800 (PST) X-Received: by 2002:ac8:7948:: with SMTP id r8mr30671872qtt.91.1573593227202; Tue, 12 Nov 2019 13:13:47 -0800 (PST) Received: from turing-police.lan ([2601:5c0:c001:c9e1::359]) by smtp.gmail.com with ESMTPSA id 130sm9674214qkd.33.2019.11.12.13.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 13:13:46 -0800 (PST) From: Valdis Kletnieks X-Google-Original-From: Valdis Kletnieks Cc: Valdis Kletnieks , Valdis Kletnieks , Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] staging: exfat: Clean up the namespace pollution part 5 Date: Tue, 12 Nov 2019 16:12:35 -0500 Message-Id: <20191112211238.156490-10-Valdis.Kletnieks@vt.edu> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191112211238.156490-1-Valdis.Kletnieks@vt.edu> References: <20191112211238.156490-1-Valdis.Kletnieks@vt.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some more functions that can be moved and made static Signed-off-by: Valdis Kletnieks --- drivers/staging/exfat/exfat.h | 3 - drivers/staging/exfat/exfat_core.c | 182 ++++++++++++++--------------- 2 files changed, 91 insertions(+), 94 deletions(-) diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 48267dd11e9d..c41fc3ec9f29 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -764,9 +764,6 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ s32 load_alloc_bitmap(struct super_block *sb); void free_alloc_bitmap(struct super_block *sb); -s32 set_alloc_bitmap(struct super_block *sb, u32 clu); -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); -u32 test_alloc_bitmap(struct super_block *sb, u32 clu); void sync_alloc_bitmap(struct super_block *sb); /* upcase table management functions */ diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 24700b251acb..8d38f70c9726 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -156,6 +156,97 @@ static s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } +static s32 set_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); +} + +static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; +#ifdef CONFIG_EXFAT_DISCARD + struct exfat_sb_info *sbi = EXFAT_SB(sb); + struct exfat_mount_options *opts = &sbi->options; + int ret; +#endif /* CONFIG_EXFAT_DISCARD */ + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); + +#ifdef CONFIG_EXFAT_DISCARD + if (opts->discard) { + ret = sb_issue_discard(sb, START_SECTOR(clu), + (1 << p_fs->sectors_per_clu_bits), + GFP_NOFS, 0); + if (ret == -EOPNOTSUPP) { + pr_warn("discard not supported by device, disabling"); + opts->discard = 0; + } + } +#endif /* CONFIG_EXFAT_DISCARD */ +} + +static u32 test_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, map_i, map_b; + u32 clu_base, clu_free; + u8 k, clu_mask; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + clu_base = (clu & ~(0x7)) + 2; + clu_mask = (1 << (clu - clu_base + 2)) - 1; + + map_i = clu >> (p_bd->sector_size_bits + 3); + map_b = (clu >> 3) & p_bd->sector_size_mask; + + for (i = 2; i < p_fs->num_clusters; i += 8) { + k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); + if (clu_mask > 0) { + k |= clu_mask; + clu_mask = 0; + } + if (k < 0xFF) { + clu_free = clu_base + free_bit[k]; + if (clu_free < p_fs->num_clusters) + return clu_free; + } + clu_base += 8; + + if (((++map_b) >= p_bd->sector_size) || + (clu_base >= p_fs->num_clusters)) { + if ((++map_i) >= p_fs->map_sectors) { + clu_base = 2; + map_i = 0; + } + map_b = 0; + } + } + + return CLUSTER_32(~0); +} + static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { @@ -468,97 +559,6 @@ void free_alloc_bitmap(struct super_block *sb) p_fs->vol_amap = NULL; } -s32 set_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); -} - -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; -#ifdef CONFIG_EXFAT_DISCARD - struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_mount_options *opts = &sbi->options; - int ret; -#endif /* CONFIG_EXFAT_DISCARD */ - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); - -#ifdef CONFIG_EXFAT_DISCARD - if (opts->discard) { - ret = sb_issue_discard(sb, START_SECTOR(clu), - (1 << p_fs->sectors_per_clu_bits), - GFP_NOFS, 0); - if (ret == -EOPNOTSUPP) { - pr_warn("discard not supported by device, disabling"); - opts->discard = 0; - } - } -#endif /* CONFIG_EXFAT_DISCARD */ -} - -u32 test_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, map_i, map_b; - u32 clu_base, clu_free; - u8 k, clu_mask; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - clu_base = (clu & ~(0x7)) + 2; - clu_mask = (1 << (clu - clu_base + 2)) - 1; - - map_i = clu >> (p_bd->sector_size_bits + 3); - map_b = (clu >> 3) & p_bd->sector_size_mask; - - for (i = 2; i < p_fs->num_clusters; i += 8) { - k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); - if (clu_mask > 0) { - k |= clu_mask; - clu_mask = 0; - } - if (k < 0xFF) { - clu_free = clu_base + free_bit[k]; - if (clu_free < p_fs->num_clusters) - return clu_free; - } - clu_base += 8; - - if (((++map_b) >= p_bd->sector_size) || - (clu_base >= p_fs->num_clusters)) { - if ((++map_i) >= p_fs->map_sectors) { - clu_base = 2; - map_i = 0; - } - map_b = 0; - } - } - - return CLUSTER_32(~0); -} - void sync_alloc_bitmap(struct super_block *sb) { int i; -- 2.24.0