Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2222360/?format=api
{ "id": 2222360, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2222360/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260411080148.471335-19-kwilczynski@kernel.org/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.2/projects/2/?format=api", "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": "<20260411080148.471335-19-kwilczynski@kernel.org>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260411080148.471335-19-kwilczynski@kernel.org/", "date": "2026-04-11T08:01:42", "name": "[v4,18/24] alpha/PCI: Convert resource files to static attributes", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4a9c10cb67225df9e65912c89202e9dd680d0962", "submitter": { "id": 86709, "url": "http://patchwork.ozlabs.org/api/1.2/people/86709/?format=api", "name": "Krzysztof Wilczyński", "email": "kwilczynski@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260411080148.471335-19-kwilczynski@kernel.org/mbox/", "series": [ { "id": 499538, "url": "http://patchwork.ozlabs.org/api/1.2/series/499538/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=499538", "date": "2026-04-11T08:01:24", "name": "PCI: Convert all dynamic sysfs attributes to static", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/499538/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222360/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222360/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linuxppc-dev+bounces-19638-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=THltVLN5;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19638-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)", "lists.ozlabs.org;\n arc=none smtp.remote-ip=172.105.4.254", "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=THltVLN5;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=172.105.4.254; helo=tor.source.kernel.org;\n envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org)" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\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 4ft5mJ5bYpz1yCx\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 18:04:16 +1000 (AEST)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4ft5kr5S2Vz2yqt;\n\tSat, 11 Apr 2026 18:03:00 +1000 (AEST)", "from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254])\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 4ft5kq5SvJz2yk6\n\tfor <linuxppc-dev@lists.ozlabs.org>; Sat, 11 Apr 2026 18:02:59 +1000 (AEST)", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id 90738600AE;\n\tSat, 11 Apr 2026 08:02:57 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 64178C19425;\n\tSat, 11 Apr 2026 08:02:53 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775894580;\n\tcv=none;\n b=OT5malrwMWcAQ5npwavT1nrdyGUettYmT30YBYkCqsJ6DeN+pync5hYivd7LsQY6l0H0f3S9NM98TBOdfC+PIiODG+MK1TJVrlfqr8Gu1alt5GQttsHPdsaVk+3QnfzsdEFxUjeuoLhG6SGN1KQ/GsY9Ja7DNsI374LuC0CkgGU7udpG6ezQVpsGC60/ABJ8BzeOQ+wOvcDHzmvIGlkly5bz8s0vAfTrXNy8xTAxaqWWZClynwkxc49ly63zeIutbiwn8UWy36m9E4zfZM7rukWvAt+EVk18S2M5VZzFXKJWwkNGyC8nut59lCuxXHHJ+zOaUzLdE4V7emNLxvXkSA==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775894580; c=relaxed/relaxed;\n\tbh=G4uNYCte00wsySlCz0Q0d18Bom3+tKhcCy8JQmqtuc8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=ZVSbYeHgb5Mnza99GmnjhiD8FrJ2vkjxnScYWICs6vW2pn+MSxtlc94OzzEIpl9D3jYOgV5kvWmz6YqmNJc725t3Wi2wsSpP8DznwSHssLfqbOywIY0DGm/Ih74GMSm21H0DgjjWiFGyiyp74XhGQjc3BqcCTUVBjhrqHFw+p7Qin9gfccZsCjSjarMIVCIfoHyKokoZIWJ9p+HE5SHgmub23ra3LFO6NR9OHgNY4A2YTWDDFFHtIteinKnOoTHOmhQyc22c6NJnbVB7KGTL29lORdxyExSd2X8OuFfX5rwY35GsHTrcpLa3aDiH29Y8xNaXyNsF9zft8GqcUccWUg==", "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=THltVLN5; dkim-atps=neutral;\n spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org;\n 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=1775894577;\n\tbh=ocjaMC/cFB2ZxwF5rprN/B+KYvKRSUt96wKw5H8ob1w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=THltVLN5zXlFHCA8fvR4IxMQ1j3OWTiIcvpEDp4p1XfhuYxunNF5YcVG3h3wlde21\n\t s+V+7D1IdcUSKMlEp+UQLs1ZEbu+BP/Na7vbuDiCgAxn2e0+hgjDxdaFaRBHiR92di\n\t 4e7reM1s7zZfCYX2ISIcUorL4hW89KZKScA97Qw8BoW6X0xRlEnZBXM4SvrvoN2V3S\n\t JAd9n1kLzTalq9K3BCf0q9b0Y94FtfJihfbxsGL805f38WSJLzA7frh6ufiavC0zMv\n\t 0JBfbmIkFrDNasETvAL1NI96NAQOBsoiS2bs7YRv5gZMjoJiZqBu1eQ060TG95TYeA\n\t xLXqOcN++rewA==", "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 v4 18/24] alpha/PCI: Convert resource files to static\n attributes", "Date": "Sat, 11 Apr 2026 08:01:42 +0000", "Message-ID": "<20260411080148.471335-19-kwilczynski@kernel.org>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260411080148.471335-1-kwilczynski@kernel.org>", "References": "<20260411080148.471335-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 resource length, has_sparse(), and sparse_mem_mmap_fits(). A\n.bin_size callback provides the resource size to the kernfs node, with\nthe sparse variant 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\nUse the new pci_resource_is_mem() helper for the type check, replacing\nthe open-coded bitwise flag test.\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 | 291 +++++++++++++++++++---------------\n 2 files changed, 172 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 824e514c4adb..2e9693e5abe1 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,166 @@ 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_is_mem(pdev, bar) ? pci_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": [ "v4", "18/24" ] }