{"id":2221718,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2221718/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260410055040.39233-16-kwilczynski@kernel.org/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20260410055040.39233-16-kwilczynski@kernel.org>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20260410055040.39233-16-kwilczynski@kernel.org/","date":"2026-04-10T05:50:35","name":"[15/20] alpha/PCI: Convert resource files to static attributes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e26212b77f1ea689bde6f8e875cd3fc071afdaee","submitter":{"id":86709,"url":"http://patchwork.ozlabs.org/api/1.2/people/86709/?format=json","name":"Krzysztof Wilczyński","email":"kwilczynski@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260410055040.39233-16-kwilczynski@kernel.org/mbox/","series":[{"id":499413,"url":"http://patchwork.ozlabs.org/api/1.2/series/499413/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=499413","date":"2026-04-10T05:50:20","name":"PCI: Convert all dynamic sysfs attributes to static","version":1,"mbox":"http://patchwork.ozlabs.org/series/499413/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221718/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221718/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19547-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=eIY1trp1;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19547-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2600:3c04:e001:324:0:1991:8:25\"","lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=eIY1trp1;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org;\n envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsSkK5jJwz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 17:15:21 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fsSkJ0ds8z2yj1;\n\tFri, 10 Apr 2026 17:15:20 +1000 (AEST)","from tor.source.kernel.org (tor.source.kernel.org\n [IPv6:2600:3c04:e001:324:0:1991:8:25])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fsQsn6T0gz2yRl\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 10 Apr 2026 15:51:41 +1000 (AEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id AFC716015B;\n\tFri, 10 Apr 2026 05:51:39 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 8242EC2BC9E;\n\tFri, 10 Apr 2026 05:51:35 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775800302;\n\tcv=none;\n b=EdsquRJqNTmPI/0q7PZ5YoZe9FzHYmSwT+glf2TKjbcHHXD850hTUQ3bEgWOJ8PgFk8DB7yXxC+aaBO9o5TnPq042oPywWE50XnIlyjWm96DrjQeRz4Lo556IU3eXFiOSVq3gy5xYk3n9ldQH9PL1sgCLgv6Bt5IB61a0LKsmjX5UF740Ioq21IhyMNWPalM4sSXuEZFpwl6InGPyNwR/Rs/msu25wyvyO5yH9MpNkMfVLSyEknXHhvTwkVh9Wyn/ySVlr+H2/a+i9Pai2bZo2xwXVchypjVHvdUqwD/0LJKlUzK7ToBOdu91nRj5Kp99uO8OScOBnDGm7WQgbhk8w==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775800302; c=relaxed/relaxed;\n\tbh=8NYC+QD+HyGHX3YE1IJw2J11iijMuVzNfeMnCtdaf80=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=lVo7HmQtArMPkORBHvJPCJR7cNdXa26bK3bN8UJb2Nsr9sSL3nu9L1/pIvseP+DTtlR6/UBgmypTG5rXGQMH/B98wXu6hvzV8xFRXK7KgHgcXe4zqr/QPIhITu/x6VglsEXTyiUiBXkDUoSCRgXtFFO2kMzq7HHGQtWkDZAh4FENWVeDSAmltOxFTcLuTyUNjR/1WVmzfnERyL3KKuWNnRvJKHuXeVKkOE1KV56Mla4YujIoIRaB2Ndz/DVGss8IxtMsZCPnmAAFze+zFUR21Kc1CkF+1MmHqnEj4A/7OY5Y1AolUrytHqmLde2krRGMHE8yXQL3SWy2duKKSh7gLg==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=eIY1trp1; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c04:e001:324:0:1991:8:25;\n helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775800299;\n\tbh=VwxDCPHrFd12naEpS7Vz5emE8UOkZKepRm7XcdqKrB8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=eIY1trp1GPgA+Klc7GZ5OOthmAjs9Tx3c02Of689n70OAXMf3Rdcy0LoOM3pRGbMq\n\t MGLnIXqkUTIqBvSLmcfkhn80o3ecLuKXi5zYiUTwAUyEHFE6TsTLF5nUrpM/bG4s7o\n\t c5kiNJ0w0omfQ5NcrP6R07jN6LQKcNT3AXWjgaOYhy6BsZ1C54spVppD2lFTdekXUw\n\t KGwJ5HjmxTOqdKyN+EB1RNqKQGrywEs/22uDqKu1UUVi9vsjQcLbPu524bj8ey031y\n\t VWrHpnJYayCC3Z1nNT6/g4Vi2Ggn5fFR7ZpGoqWF4EZWVg+GTLGsDyNm+6uV4Y2v/8\n\t q1DSdiII/QUIg==","From":"=?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kwilczynski@kernel.org>","To":"Bjorn Helgaas <bhelgaas@google.com>","Cc":"Bjorn Helgaas <helgaas@kernel.org>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>,\n Magnus Lindholm <linmag7@gmail.com>, Matt Turner <mattst88@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Christophe Leroy <chleroy@kernel.org>,\n Madhavan Srinivasan <maddy@linux.ibm.com>,\n Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>,\n Dexuan Cui <decui@microsoft.com>,\n =?utf-8?q?Krzysztof_Ha=C5=82asa?= <khalasa@piap.pl>,\n Lukas Wunner <lukas@wunner.de>, \"Oliver O'Halloran\" <oohall@gmail.com>,\n Saurabh Singh Sengar <ssengar@microsoft.com>,\n Shuan He <heshuan@bytedance.com>, Srivatsa Bhat <srivatsabhat@microsoft.com>,\n\t=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>,\n linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org,\n linuxppc-dev@lists.ozlabs.org","Subject":"[PATCH 15/20] alpha/PCI: Convert resource files to static attributes","Date":"Fri, 10 Apr 2026 05:50:35 +0000","Message-ID":"<20260410055040.39233-16-kwilczynski@kernel.org>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260410055040.39233-1-kwilczynski@kernel.org>","References":"<20260410055040.39233-1-kwilczynski@kernel.org>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"},"content":"Currently, Alpha's PCI resource files (resourceN, resourceN_sparse,\nresourceN_dense) are dynamically created by pci_create_resource_files(),\nwhich overrides the generic __weak implementation.  The current code\nallocates bin_attributes at runtime and manages them via the res_attr[]\nand res_attr_wc[] fields in struct pci_dev.\n\nThus, convert to static const attributes with three attribute groups\n(plain, sparse, dense), each with an .is_bin_visible callback that\nchecks BAR length, has_sparse(), and sparse_mem_mmap_fits().  A .bin_size\ncallback provides the resource size to the kernfs node, with the sparse\nvariant shifting by 5 bits for byte-level addressing.\n\nRegister the groups via ARCH_PCI_DEV_GROUPS so the driver model handles\ncreation and removal automatically.\n\nFinally, remove pci_create_resource_files(), pci_remove_resource_files(),\npci_create_attr(), and pci_create_one_attr() which are no longer needed.\n\nSigned-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>\n---\n arch/alpha/include/asm/pci.h  |   9 ++\n arch/alpha/kernel/pci-sysfs.c | 292 +++++++++++++++++++---------------\n 2 files changed, 173 insertions(+), 128 deletions(-)","diff":"diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h\nindex 6c04fcbdc8ed..ef19295f2e33 100644\n--- a/arch/alpha/include/asm/pci.h\n+++ b/arch/alpha/include/asm/pci.h\n@@ -88,4 +88,13 @@ extern void pci_adjust_legacy_attr(struct pci_bus *bus,\n \t\t\t\t   enum pci_mmap_state mmap_type);\n #define HAVE_PCI_LEGACY\t1\n \n+extern const struct attribute_group pci_dev_resource_attr_group;\n+extern const struct attribute_group pci_dev_resource_sparse_attr_group;\n+extern const struct attribute_group pci_dev_resource_dense_attr_group;\n+\n+#define ARCH_PCI_DEV_GROUPS\t\t\\\n+\t&pci_dev_resource_attr_group,\t\\\n+\t&pci_dev_resource_sparse_attr_group,\t\\\n+\t&pci_dev_resource_dense_attr_group,\n+\n #endif /* __ALPHA_PCI_H */\ndiff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c\nindex 0e016b597b06..27adfe6dbd5e 100644\n--- a/arch/alpha/kernel/pci-sysfs.c\n+++ b/arch/alpha/kernel/pci-sysfs.c\n@@ -12,8 +12,6 @@\n \n #include <linux/sched.h>\n #include <linux/security.h>\n-#include <linux/stat.h>\n-#include <linux/slab.h>\n #include <linux/pci.h>\n \n static int hose_mmap_page_range(struct pci_controller *hose,\n@@ -124,34 +122,6 @@ pci_dev_resource##_bar##_suffix##_attr = {\t\t\t\t\\\n \t__pci_dev_resource_attr(_bar, resource##_bar##_dense, _dense,\t\\\n \t\t\t    pci_mmap_resource_dense)\n \n-/**\n- * pci_remove_resource_files - cleanup resource files\n- * @pdev: pci_dev to cleanup\n- *\n- * If we created resource files for @dev, remove them from sysfs and\n- * free their resources.\n- */\n-void pci_remove_resource_files(struct pci_dev *pdev)\n-{\n-\tint i;\n-\n-\tfor (i = 0; i < PCI_STD_NUM_BARS; i++) {\n-\t\tstruct bin_attribute *res_attr;\n-\n-\t\tres_attr = pdev->res_attr[i];\n-\t\tif (res_attr) {\n-\t\t\tsysfs_remove_bin_file(&pdev->dev.kobj, res_attr);\n-\t\t\tkfree(res_attr);\n-\t\t}\n-\n-\t\tres_attr = pdev->res_attr_wc[i];\n-\t\tif (res_attr) {\n-\t\t\tsysfs_remove_bin_file(&pdev->dev.kobj, res_attr);\n-\t\t\tkfree(res_attr);\n-\t\t}\n-\t}\n-}\n-\n static int sparse_mem_mmap_fits(struct pci_dev *pdev, int num)\n {\n \tstruct pci_bus_region bar;\n@@ -171,104 +141,6 @@ static int sparse_mem_mmap_fits(struct pci_dev *pdev, int num)\n \treturn bar.end < sparse_size;\n }\n \n-static int pci_create_one_attr(struct pci_dev *pdev, int num, char *name,\n-\t\t\t       char *suffix, struct bin_attribute *res_attr,\n-\t\t\t       unsigned long sparse)\n-{\n-\tsize_t size = pci_resource_len(pdev, num);\n-\n-\tsprintf(name, \"resource%d%s\", num, suffix);\n-\tres_attr->mmap = sparse ? pci_mmap_resource_sparse :\n-\t\t\t\t  pci_mmap_resource_dense;\n-\tres_attr->attr.name = name;\n-\tres_attr->attr.mode = S_IRUSR | S_IWUSR;\n-\tres_attr->size = sparse ? size << 5 : size;\n-\tres_attr->private = (void *)(unsigned long)num;\n-\treturn sysfs_create_bin_file(&pdev->dev.kobj, res_attr);\n-}\n-\n-static int pci_create_attr(struct pci_dev *pdev, int num)\n-{\n-\t/* allocate attribute structure, piggyback attribute name */\n-\tint retval, nlen1, nlen2 = 0, res_count = 1;\n-\tunsigned long sparse_base, dense_base;\n-\tstruct bin_attribute *attr;\n-\tstruct pci_controller *hose = pdev->sysdata;\n-\tchar *suffix, *attr_name;\n-\n-\tsuffix = \"\";\t/* Assume bwx machine, normal resourceN files. */\n-\tnlen1 = 10;\n-\n-\tif (pci_resource_flags(pdev, num) & IORESOURCE_MEM) {\n-\t\tsparse_base = hose->sparse_mem_base;\n-\t\tdense_base = hose->dense_mem_base;\n-\t\tif (sparse_base && !sparse_mem_mmap_fits(pdev, num)) {\n-\t\t\tsparse_base = 0;\n-\t\t\tsuffix = \"_dense\";\n-\t\t\tnlen1 = 16;\t/* resourceN_dense */\n-\t\t}\n-\t} else {\n-\t\tsparse_base = hose->sparse_io_base;\n-\t\tdense_base = hose->dense_io_base;\n-\t}\n-\n-\tif (sparse_base) {\n-\t\tsuffix = \"_sparse\";\n-\t\tnlen1 = 17;\n-\t\tif (dense_base) {\n-\t\t\tnlen2 = 16;\t/* resourceN_dense */\n-\t\t\tres_count = 2;\n-\t\t}\n-\t}\n-\n-\tattr = kzalloc(sizeof(*attr) * res_count + nlen1 + nlen2, GFP_ATOMIC);\n-\tif (!attr)\n-\t\treturn -ENOMEM;\n-\n-\t/* Create bwx, sparse or single dense file */\n-\tattr_name = (char *)(attr + res_count);\n-\tpdev->res_attr[num] = attr;\n-\tretval = pci_create_one_attr(pdev, num, attr_name, suffix, attr,\n-\t\t\t\t     sparse_base);\n-\tif (retval || res_count == 1)\n-\t\treturn retval;\n-\n-\t/* Create dense file */\n-\tattr_name += nlen1;\n-\tattr++;\n-\tpdev->res_attr_wc[num] = attr;\n-\treturn pci_create_one_attr(pdev, num, attr_name, \"_dense\", attr, 0);\n-}\n-\n-/**\n- * pci_create_resource_files - create resource files in sysfs for @pdev\n- * @pdev: pci_dev in question\n- *\n- * Walk the resources in @dev creating files for each resource available.\n- *\n- * Return: %0 on success, or negative error code\n- */\n-int pci_create_resource_files(struct pci_dev *pdev)\n-{\n-\tint i;\n-\tint retval;\n-\n-\t/* Expose the PCI resources from this device as files */\n-\tfor (i = 0; i < PCI_STD_NUM_BARS; i++) {\n-\n-\t\t/* skip empty resources */\n-\t\tif (!pci_resource_len(pdev, i))\n-\t\t\tcontinue;\n-\n-\t\tretval = pci_create_attr(pdev, i);\n-\t\tif (retval) {\n-\t\t\tpci_remove_resource_files(pdev);\n-\t\t\treturn retval;\n-\t\t}\n-\t}\n-\treturn 0;\n-}\n-\n /* Legacy I/O bus mapping stuff. */\n \n static int __legacy_mmap_fits(struct pci_controller *hose,\n@@ -388,3 +260,167 @@ int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, size_t size)\n \t}\n \treturn -EINVAL;\n }\n+\n+pci_dev_resource_attr(0);\n+pci_dev_resource_attr(1);\n+pci_dev_resource_attr(2);\n+pci_dev_resource_attr(3);\n+pci_dev_resource_attr(4);\n+pci_dev_resource_attr(5);\n+\n+pci_dev_resource_sparse_attr(0);\n+pci_dev_resource_sparse_attr(1);\n+pci_dev_resource_sparse_attr(2);\n+pci_dev_resource_sparse_attr(3);\n+pci_dev_resource_sparse_attr(4);\n+pci_dev_resource_sparse_attr(5);\n+\n+pci_dev_resource_dense_attr(0);\n+pci_dev_resource_dense_attr(1);\n+pci_dev_resource_dense_attr(2);\n+pci_dev_resource_dense_attr(3);\n+pci_dev_resource_dense_attr(4);\n+pci_dev_resource_dense_attr(5);\n+\n+static inline enum pci_mmap_state pci_bar_mmap_type(struct pci_dev *pdev,\n+\t\t\t\t\t\t    int bar)\n+{\n+\treturn (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) ?\n+\t\tpci_mmap_mem : pci_mmap_io;\n+}\n+\n+static inline umode_t __pci_dev_resource_is_visible(struct kobject *kobj,\n+\t\t\t\t\t\t    const struct bin_attribute *a,\n+\t\t\t\t\t\t    int bar)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\n+\tif (!pci_resource_len(pdev, bar))\n+\t\treturn 0;\n+\n+\treturn a->attr.mode;\n+}\n+\n+static umode_t pci_dev_resource_is_visible(struct kobject *kobj,\n+\t\t\t\t\t   const struct bin_attribute *a,\n+\t\t\t\t\t   int bar)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\tstruct pci_controller *hose = pdev->sysdata;\n+\n+\tif (has_sparse(hose, pci_bar_mmap_type(pdev, bar)))\n+\t\treturn 0;\n+\n+\treturn __pci_dev_resource_is_visible(kobj, a, bar);\n+}\n+\n+static umode_t pci_dev_resource_sparse_is_visible(struct kobject *kobj,\n+\t\t\t\t\t\t  const struct bin_attribute *a,\n+\t\t\t\t\t\t  int bar)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\tstruct pci_controller *hose = pdev->sysdata;\n+\tenum pci_mmap_state type = pci_bar_mmap_type(pdev, bar);\n+\n+\tif (!has_sparse(hose, type))\n+\t\treturn 0;\n+\n+\tif (type == pci_mmap_mem && !sparse_mem_mmap_fits(pdev, bar))\n+\t\treturn 0;\n+\n+\treturn __pci_dev_resource_is_visible(kobj, a, bar);\n+}\n+\n+static umode_t pci_dev_resource_dense_is_visible(struct kobject *kobj,\n+\t\t\t\t\t\t const struct bin_attribute *a,\n+\t\t\t\t\t\t int bar)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\tstruct pci_controller *hose = pdev->sysdata;\n+\tenum pci_mmap_state type = pci_bar_mmap_type(pdev, bar);\n+\tunsigned long dense_base;\n+\n+\tif (!has_sparse(hose, type))\n+\t\treturn 0;\n+\n+\tif (type == pci_mmap_mem && !sparse_mem_mmap_fits(pdev, bar))\n+\t\treturn __pci_dev_resource_is_visible(kobj, a, bar);\n+\n+\tdense_base = (type == pci_mmap_mem) ? hose->dense_mem_base :\n+\t\t\t\t\t      hose->dense_io_base;\n+\tif (!dense_base)\n+\t\treturn 0;\n+\n+\treturn __pci_dev_resource_is_visible(kobj, a, bar);\n+}\n+\n+static inline size_t __pci_dev_resource_bin_size(struct kobject *kobj,\n+\t\t\t\t\t\t int bar, bool sparse)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\tsize_t size = pci_resource_len(pdev, bar);\n+\n+\treturn sparse ? size << 5 : size;\n+}\n+\n+static size_t pci_dev_resource_bin_size(struct kobject *kobj,\n+\t\t\t\t\tconst struct bin_attribute *a,\n+\t\t\t\t\tint bar)\n+{\n+\treturn __pci_dev_resource_bin_size(kobj, bar, false);\n+}\n+\n+static size_t pci_dev_resource_sparse_bin_size(struct kobject *kobj,\n+\t\t\t\t\t       const struct bin_attribute *a,\n+\t\t\t\t\t       int bar)\n+{\n+\treturn __pci_dev_resource_bin_size(kobj, bar, true);\n+}\n+\n+static const struct bin_attribute *const pci_dev_resource_attrs[] = {\n+\t&pci_dev_resource0_attr,\n+\t&pci_dev_resource1_attr,\n+\t&pci_dev_resource2_attr,\n+\t&pci_dev_resource3_attr,\n+\t&pci_dev_resource4_attr,\n+\t&pci_dev_resource5_attr,\n+\tNULL,\n+};\n+\n+static const struct bin_attribute *const pci_dev_resource_sparse_attrs[] = {\n+\t&pci_dev_resource0_sparse_attr,\n+\t&pci_dev_resource1_sparse_attr,\n+\t&pci_dev_resource2_sparse_attr,\n+\t&pci_dev_resource3_sparse_attr,\n+\t&pci_dev_resource4_sparse_attr,\n+\t&pci_dev_resource5_sparse_attr,\n+\tNULL,\n+};\n+\n+static const struct bin_attribute *const pci_dev_resource_dense_attrs[] = {\n+\t&pci_dev_resource0_dense_attr,\n+\t&pci_dev_resource1_dense_attr,\n+\t&pci_dev_resource2_dense_attr,\n+\t&pci_dev_resource3_dense_attr,\n+\t&pci_dev_resource4_dense_attr,\n+\t&pci_dev_resource5_dense_attr,\n+\tNULL,\n+};\n+\n+const struct attribute_group pci_dev_resource_attr_group = {\n+\t.bin_attrs = pci_dev_resource_attrs,\n+\t.is_bin_visible = pci_dev_resource_is_visible,\n+\t.bin_size = pci_dev_resource_bin_size,\n+};\n+\n+const struct attribute_group pci_dev_resource_sparse_attr_group = {\n+\t.bin_attrs = pci_dev_resource_sparse_attrs,\n+\t.is_bin_visible = pci_dev_resource_sparse_is_visible,\n+\t.bin_size = pci_dev_resource_sparse_bin_size,\n+};\n+\n+const struct attribute_group pci_dev_resource_dense_attr_group = {\n+\t.bin_attrs = pci_dev_resource_dense_attrs,\n+\t.is_bin_visible = pci_dev_resource_dense_is_visible,\n+\t.bin_size = pci_dev_resource_bin_size,\n+};\n","prefixes":["15/20"]}