mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
EDAC/mc_sysfs: Convert sprintf()/snprintf() to sysfs_emit()
Per Documentation/filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Generated by: make coccicheck M=<path/to/file> MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended. [ bp: Massage. ] Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20240314084628.1322006-1-lizhijian@fujitsu.com
This commit is contained in:
parent
c8d37084e9
commit
d7518ad4ed
@ -146,7 +146,7 @@ static ssize_t csrow_ue_count_show(struct device *dev,
|
||||
{
|
||||
struct csrow_info *csrow = to_csrow(dev);
|
||||
|
||||
return sprintf(data, "%u\n", csrow->ue_count);
|
||||
return sysfs_emit(data, "%u\n", csrow->ue_count);
|
||||
}
|
||||
|
||||
static ssize_t csrow_ce_count_show(struct device *dev,
|
||||
@ -154,7 +154,7 @@ static ssize_t csrow_ce_count_show(struct device *dev,
|
||||
{
|
||||
struct csrow_info *csrow = to_csrow(dev);
|
||||
|
||||
return sprintf(data, "%u\n", csrow->ce_count);
|
||||
return sysfs_emit(data, "%u\n", csrow->ce_count);
|
||||
}
|
||||
|
||||
static ssize_t csrow_size_show(struct device *dev,
|
||||
@ -166,7 +166,7 @@ static ssize_t csrow_size_show(struct device *dev,
|
||||
|
||||
for (i = 0; i < csrow->nr_channels; i++)
|
||||
nr_pages += csrow->channels[i]->dimm->nr_pages;
|
||||
return sprintf(data, "%u\n", PAGES_TO_MiB(nr_pages));
|
||||
return sysfs_emit(data, "%u\n", PAGES_TO_MiB(nr_pages));
|
||||
}
|
||||
|
||||
static ssize_t csrow_mem_type_show(struct device *dev,
|
||||
@ -174,7 +174,7 @@ static ssize_t csrow_mem_type_show(struct device *dev,
|
||||
{
|
||||
struct csrow_info *csrow = to_csrow(dev);
|
||||
|
||||
return sprintf(data, "%s\n", edac_mem_types[csrow->channels[0]->dimm->mtype]);
|
||||
return sysfs_emit(data, "%s\n", edac_mem_types[csrow->channels[0]->dimm->mtype]);
|
||||
}
|
||||
|
||||
static ssize_t csrow_dev_type_show(struct device *dev,
|
||||
@ -182,7 +182,7 @@ static ssize_t csrow_dev_type_show(struct device *dev,
|
||||
{
|
||||
struct csrow_info *csrow = to_csrow(dev);
|
||||
|
||||
return sprintf(data, "%s\n", dev_types[csrow->channels[0]->dimm->dtype]);
|
||||
return sysfs_emit(data, "%s\n", dev_types[csrow->channels[0]->dimm->dtype]);
|
||||
}
|
||||
|
||||
static ssize_t csrow_edac_mode_show(struct device *dev,
|
||||
@ -191,7 +191,7 @@ static ssize_t csrow_edac_mode_show(struct device *dev,
|
||||
{
|
||||
struct csrow_info *csrow = to_csrow(dev);
|
||||
|
||||
return sprintf(data, "%s\n", edac_caps[csrow->channels[0]->dimm->edac_mode]);
|
||||
return sysfs_emit(data, "%s\n", edac_caps[csrow->channels[0]->dimm->edac_mode]);
|
||||
}
|
||||
|
||||
/* show/store functions for DIMM Label attributes */
|
||||
@ -207,8 +207,7 @@ static ssize_t channel_dimm_label_show(struct device *dev,
|
||||
if (!rank->dimm->label[0])
|
||||
return 0;
|
||||
|
||||
return snprintf(data, sizeof(rank->dimm->label) + 1, "%s\n",
|
||||
rank->dimm->label);
|
||||
return sysfs_emit(data, "%s\n", rank->dimm->label);
|
||||
}
|
||||
|
||||
static ssize_t channel_dimm_label_store(struct device *dev,
|
||||
@ -243,7 +242,7 @@ static ssize_t channel_ce_count_show(struct device *dev,
|
||||
unsigned int chan = to_channel(mattr);
|
||||
struct rank_info *rank = csrow->channels[chan];
|
||||
|
||||
return sprintf(data, "%u\n", rank->ce_count);
|
||||
return sysfs_emit(data, "%u\n", rank->ce_count);
|
||||
}
|
||||
|
||||
/* cwrow<id>/attribute files */
|
||||
@ -515,7 +514,7 @@ static ssize_t dimmdev_label_show(struct device *dev,
|
||||
if (!dimm->label[0])
|
||||
return 0;
|
||||
|
||||
return snprintf(data, sizeof(dimm->label) + 1, "%s\n", dimm->label);
|
||||
return sysfs_emit(data, "%s\n", dimm->label);
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_label_store(struct device *dev,
|
||||
@ -546,7 +545,7 @@ static ssize_t dimmdev_size_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%u\n", PAGES_TO_MiB(dimm->nr_pages));
|
||||
return sysfs_emit(data, "%u\n", PAGES_TO_MiB(dimm->nr_pages));
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_mem_type_show(struct device *dev,
|
||||
@ -554,7 +553,7 @@ static ssize_t dimmdev_mem_type_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%s\n", edac_mem_types[dimm->mtype]);
|
||||
return sysfs_emit(data, "%s\n", edac_mem_types[dimm->mtype]);
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_dev_type_show(struct device *dev,
|
||||
@ -562,7 +561,7 @@ static ssize_t dimmdev_dev_type_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%s\n", dev_types[dimm->dtype]);
|
||||
return sysfs_emit(data, "%s\n", dev_types[dimm->dtype]);
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_edac_mode_show(struct device *dev,
|
||||
@ -571,7 +570,7 @@ static ssize_t dimmdev_edac_mode_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%s\n", edac_caps[dimm->edac_mode]);
|
||||
return sysfs_emit(data, "%s\n", edac_caps[dimm->edac_mode]);
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_ce_count_show(struct device *dev,
|
||||
@ -580,7 +579,7 @@ static ssize_t dimmdev_ce_count_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%u\n", dimm->ce_count);
|
||||
return sysfs_emit(data, "%u\n", dimm->ce_count);
|
||||
}
|
||||
|
||||
static ssize_t dimmdev_ue_count_show(struct device *dev,
|
||||
@ -589,7 +588,7 @@ static ssize_t dimmdev_ue_count_show(struct device *dev,
|
||||
{
|
||||
struct dimm_info *dimm = to_dimm(dev);
|
||||
|
||||
return sprintf(data, "%u\n", dimm->ue_count);
|
||||
return sysfs_emit(data, "%u\n", dimm->ue_count);
|
||||
}
|
||||
|
||||
/* dimm/rank attribute files */
|
||||
@ -758,7 +757,7 @@ static ssize_t mci_sdram_scrub_rate_show(struct device *dev,
|
||||
return bandwidth;
|
||||
}
|
||||
|
||||
return sprintf(data, "%d\n", bandwidth);
|
||||
return sysfs_emit(data, "%d\n", bandwidth);
|
||||
}
|
||||
|
||||
/* default attribute files for the MCI object */
|
||||
@ -768,7 +767,7 @@ static ssize_t mci_ue_count_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%u\n", mci->ue_mc);
|
||||
return sysfs_emit(data, "%u\n", mci->ue_mc);
|
||||
}
|
||||
|
||||
static ssize_t mci_ce_count_show(struct device *dev,
|
||||
@ -777,7 +776,7 @@ static ssize_t mci_ce_count_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%u\n", mci->ce_mc);
|
||||
return sysfs_emit(data, "%u\n", mci->ce_mc);
|
||||
}
|
||||
|
||||
static ssize_t mci_ce_noinfo_show(struct device *dev,
|
||||
@ -786,7 +785,7 @@ static ssize_t mci_ce_noinfo_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%u\n", mci->ce_noinfo_count);
|
||||
return sysfs_emit(data, "%u\n", mci->ce_noinfo_count);
|
||||
}
|
||||
|
||||
static ssize_t mci_ue_noinfo_show(struct device *dev,
|
||||
@ -795,7 +794,7 @@ static ssize_t mci_ue_noinfo_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%u\n", mci->ue_noinfo_count);
|
||||
return sysfs_emit(data, "%u\n", mci->ue_noinfo_count);
|
||||
}
|
||||
|
||||
static ssize_t mci_seconds_show(struct device *dev,
|
||||
@ -804,7 +803,7 @@ static ssize_t mci_seconds_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ);
|
||||
return sysfs_emit(data, "%ld\n", (jiffies - mci->start_time) / HZ);
|
||||
}
|
||||
|
||||
static ssize_t mci_ctl_name_show(struct device *dev,
|
||||
@ -813,7 +812,7 @@ static ssize_t mci_ctl_name_show(struct device *dev,
|
||||
{
|
||||
struct mem_ctl_info *mci = to_mci(dev);
|
||||
|
||||
return sprintf(data, "%s\n", mci->ctl_name);
|
||||
return sysfs_emit(data, "%s\n", mci->ctl_name);
|
||||
}
|
||||
|
||||
static ssize_t mci_size_mb_show(struct device *dev,
|
||||
@ -833,7 +832,7 @@ static ssize_t mci_size_mb_show(struct device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages));
|
||||
return sysfs_emit(data, "%u\n", PAGES_TO_MiB(total_pages));
|
||||
}
|
||||
|
||||
static ssize_t mci_max_location_show(struct device *dev,
|
||||
|
Loading…
Reference in New Issue
Block a user