diff options
author | Takashi Iwai <tiwai@suse.de> | 2022-08-01 19:56:38 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2022-08-02 17:03:47 +0300 |
commit | 17daae7ac47aa870e7042aa7eeaff987feab92c6 (patch) | |
tree | 324e6f6b1c3197014c3932936ade22fcc239af78 /sound/pci/hda/hda_sysfs.c | |
parent | 01043e3e14d3e17acf563e0ce27abd73c6edde7f (diff) | |
download | linux-17daae7ac47aa870e7042aa7eeaff987feab92c6.tar.xz |
ALSA: hda: Replace sprintf() with sysfs_emit()
For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co. This patch replaces those usages
straightforwardly with new helpers, sysfs_emit() and sysfs_emit_at().
Link: https://lore.kernel.org/r/20220801165639.26030-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_sysfs.c')
-rw-r--r-- | sound/pci/hda/hda_sysfs.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_sysfs.c b/sound/pci/hda/hda_sysfs.c index d5ffcba794e5..bf951c10ae61 100644 --- a/sound/pci/hda/hda_sysfs.c +++ b/sound/pci/hda/hda_sysfs.c @@ -33,7 +33,7 @@ static ssize_t power_on_acct_show(struct device *dev, { struct hda_codec *codec = dev_get_drvdata(dev); snd_hda_update_power_acct(codec); - return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct)); + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct)); } static ssize_t power_off_acct_show(struct device *dev, @@ -42,7 +42,7 @@ static ssize_t power_off_acct_show(struct device *dev, { struct hda_codec *codec = dev_get_drvdata(dev); snd_hda_update_power_acct(codec); - return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct)); + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct)); } static DEVICE_ATTR_RO(power_on_acct); @@ -55,7 +55,7 @@ static ssize_t type##_show(struct device *dev, \ char *buf) \ { \ struct hda_codec *codec = dev_get_drvdata(dev); \ - return sprintf(buf, "0x%x\n", codec->field); \ + return sysfs_emit(buf, "0x%x\n", codec->field); \ } #define CODEC_INFO_STR_SHOW(type, field) \ @@ -64,8 +64,8 @@ static ssize_t type##_show(struct device *dev, \ char *buf) \ { \ struct hda_codec *codec = dev_get_drvdata(dev); \ - return sprintf(buf, "%s\n", \ - codec->field ? codec->field : ""); \ + return sysfs_emit(buf, "%s\n", \ + codec->field ? codec->field : ""); \ } CODEC_INFO_SHOW(vendor_id, core.vendor_id); @@ -85,8 +85,8 @@ static ssize_t pin_configs_show(struct hda_codec *codec, int i, len = 0; mutex_lock(&codec->user_mutex); snd_array_for_each(list, i, pin) { - len += sprintf(buf + len, "0x%02x 0x%08x\n", - pin->nid, pin->cfg); + len += sysfs_emit_at(buf, len, "0x%02x 0x%08x\n", + pin->nid, pin->cfg); } mutex_unlock(&codec->user_mutex); return len; @@ -222,9 +222,8 @@ static ssize_t init_verbs_show(struct device *dev, int i, len = 0; mutex_lock(&codec->user_mutex); snd_array_for_each(&codec->init_verbs, i, v) { - len += scnprintf(buf + len, PAGE_SIZE - len, - "0x%02x 0x%03x 0x%04x\n", - v->nid, v->verb, v->param); + len += sysfs_emit_at(buf, len, "0x%02x 0x%03x 0x%04x\n", + v->nid, v->verb, v->param); } mutex_unlock(&codec->user_mutex); return len; @@ -272,8 +271,8 @@ static ssize_t hints_show(struct device *dev, int i, len = 0; mutex_lock(&codec->user_mutex); snd_array_for_each(&codec->hints, i, hint) { - len += scnprintf(buf + len, PAGE_SIZE - len, - "%s = %s\n", hint->key, hint->val); + len += sysfs_emit_at(buf, len, "%s = %s\n", + hint->key, hint->val); } mutex_unlock(&codec->user_mutex); return len; |