|
Oliver Neukum |
924367 |
From a2258831d12d7845946f9c98f08d65aad9aa1121 Mon Sep 17 00:00:00 2001
|
|
Oliver Neukum |
924367 |
From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
|
|
Oliver Neukum |
924367 |
Date: Wed, 1 Sep 2021 14:09:17 +0900
|
|
Oliver Neukum |
924367 |
Subject: [PATCH] PCI: endpoint: Use sysfs_emit() in "show" functions
|
|
Oliver Neukum |
924367 |
MIME-Version: 1.0
|
|
Oliver Neukum |
924367 |
Content-Type: text/plain; charset=UTF-8
|
|
Oliver Neukum |
924367 |
Content-Transfer-Encoding: 8bit
|
|
Oliver Neukum |
924367 |
Git-commit: 2efc459d06f1630001e3984854848a5647086232
|
|
Oliver Neukum |
924367 |
References: jsc#SLE-19359
|
|
Oliver Neukum |
924367 |
Patch-mainline: v5.10-rc1
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
Convert sprintf() in sysfs "show" functions to sysfs_emit() in order to
|
|
Oliver Neukum |
924367 |
check for buffer overruns in sysfs outputs.
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
Link: https://lore.kernel.org/r/1630472957-26857-1-git-send-email-hayashi.kunihiko@socionext.com
|
|
Oliver Neukum |
924367 |
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
|
|
Oliver Neukum |
924367 |
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
|
|
Oliver Neukum |
924367 |
Reviewed-by: Krzysztof WilczyĆski <kw@linux.com>
|
|
Oliver Neukum |
924367 |
Signed-off-by: Oliver Neukum <oneukum@suse.com>
|
|
Oliver Neukum |
924367 |
---
|
|
Oliver Neukum |
924367 |
drivers/pci/endpoint/functions/pci-epf-ntb.c | 4 ++--
|
|
Oliver Neukum |
924367 |
drivers/pci/endpoint/pci-ep-cfs.c | 13 ++++++-------
|
|
Oliver Neukum |
924367 |
2 files changed, 8 insertions(+), 9 deletions(-)
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c
|
|
Oliver Neukum |
924367 |
index 8b4756159f15..99266f05739a 100644
|
|
Oliver Neukum |
924367 |
--- a/drivers/pci/endpoint/functions/pci-epf-ntb.c
|
|
Oliver Neukum |
924367 |
+++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c
|
|
Oliver Neukum |
924367 |
@@ -1937,7 +1937,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
|
|
Oliver Neukum |
924367 |
struct config_group *group = to_config_group(item); \
|
|
Oliver Neukum |
924367 |
struct epf_ntb *ntb = to_epf_ntb(group); \
|
|
Oliver Neukum |
924367 |
\
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "%d\n", ntb->_name); \
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "%d\n", ntb->_name); \
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
#define EPF_NTB_W(_name) \
|
|
Oliver Neukum |
924367 |
@@ -1968,7 +1968,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
|
|
Oliver Neukum |
924367 |
\
|
|
Oliver Neukum |
924367 |
sscanf(#_name, "mw%d", &win_no); \
|
|
Oliver Neukum |
924367 |
\
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "%lld\n", ntb->mws_size[win_no - 1]); \
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "%lld\n", ntb->mws_size[win_no - 1]); \
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
#define EPF_NTB_MW_W(_name) \
|
|
Oliver Neukum |
924367 |
diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
|
|
Oliver Neukum |
924367 |
index 999911801877..5a0394a38675 100644
|
|
Oliver Neukum |
924367 |
--- a/drivers/pci/endpoint/pci-ep-cfs.c
|
|
Oliver Neukum |
924367 |
+++ b/drivers/pci/endpoint/pci-ep-cfs.c
|
|
Oliver Neukum |
924367 |
@@ -198,8 +198,7 @@ static ssize_t pci_epc_start_store(struct config_item *item, const char *page,
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
static ssize_t pci_epc_start_show(struct config_item *item, char *page)
|
|
Oliver Neukum |
924367 |
{
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "%d\n",
|
|
Oliver Neukum |
924367 |
- to_pci_epc_group(item)->start);
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "%d\n", to_pci_epc_group(item)->start);
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
CONFIGFS_ATTR(pci_epc_, start);
|
|
Oliver Neukum |
924367 |
@@ -321,7 +320,7 @@ static ssize_t pci_epf_##_name##_show(struct config_item *item, char *page) \
|
|
Oliver Neukum |
924367 |
struct pci_epf *epf = to_pci_epf_group(item)->epf; \
|
|
Oliver Neukum |
924367 |
if (WARN_ON_ONCE(!epf->header)) \
|
|
Oliver Neukum |
924367 |
return -EINVAL; \
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "0x%04x\n", epf->header->_name); \
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "0x%04x\n", epf->header->_name); \
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
#define PCI_EPF_HEADER_W_u32(_name) \
|
|
Oliver Neukum |
924367 |
@@ -390,8 +389,8 @@ static ssize_t pci_epf_msi_interrupts_store(struct config_item *item,
|
|
Oliver Neukum |
924367 |
static ssize_t pci_epf_msi_interrupts_show(struct config_item *item,
|
|
Oliver Neukum |
924367 |
char *page)
|
|
Oliver Neukum |
924367 |
{
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "%d\n",
|
|
Oliver Neukum |
924367 |
- to_pci_epf_group(item)->epf->msi_interrupts);
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "%d\n",
|
|
Oliver Neukum |
924367 |
+ to_pci_epf_group(item)->epf->msi_interrupts);
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
|
|
Oliver Neukum |
924367 |
@@ -412,8 +411,8 @@ static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
|
|
Oliver Neukum |
924367 |
static ssize_t pci_epf_msix_interrupts_show(struct config_item *item,
|
|
Oliver Neukum |
924367 |
char *page)
|
|
Oliver Neukum |
924367 |
{
|
|
Oliver Neukum |
924367 |
- return sprintf(page, "%d\n",
|
|
Oliver Neukum |
924367 |
- to_pci_epf_group(item)->epf->msix_interrupts);
|
|
Oliver Neukum |
924367 |
+ return sysfs_emit(page, "%d\n",
|
|
Oliver Neukum |
924367 |
+ to_pci_epf_group(item)->epf->msix_interrupts);
|
|
Oliver Neukum |
924367 |
}
|
|
Oliver Neukum |
924367 |
|
|
Oliver Neukum |
924367 |
PCI_EPF_HEADER_R(vendorid)
|
|
Oliver Neukum |
924367 |
--
|
|
Oliver Neukum |
924367 |
2.26.2
|
|
Oliver Neukum |
924367 |
|