未验证 提交 79a8ccbd 编写于 作者: M Mark Brown

ASoC: Replace sprintf() with sysfs_emit()

Merge series from Takashi Iwai <tiwai@suse.de>:

This is a patch set for rather simple conversions from the plain
sprintf() & co to the new helpers, sysfs_emit() and sysfs_emit_at().
No functional changes are expected.
...@@ -1666,10 +1666,9 @@ static int cs43130_show_dc(struct device *dev, char *buf, u8 ch) ...@@ -1666,10 +1666,9 @@ static int cs43130_show_dc(struct device *dev, char *buf, u8 ch)
struct cs43130_private *cs43130 = i2c_get_clientdata(client); struct cs43130_private *cs43130 = i2c_get_clientdata(client);
if (!cs43130->hpload_done) if (!cs43130->hpload_done)
return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n"); return sysfs_emit(buf, "NO_HPLOAD\n");
else else
return scnprintf(buf, PAGE_SIZE, "%u\n", return sysfs_emit(buf, "%u\n", cs43130->hpload_dc[ch]);
cs43130->hpload_dc[ch]);
} }
static ssize_t hpload_dc_l_show(struct device *dev, static ssize_t hpload_dc_l_show(struct device *dev,
...@@ -1705,7 +1704,7 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch) ...@@ -1705,7 +1704,7 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch)
if (cs43130->hpload_done && cs43130->ac_meas) { if (cs43130->hpload_done && cs43130->ac_meas) {
for (i = 0; i < ARRAY_SIZE(cs43130_ac_freq); i++) { for (i = 0; i < ARRAY_SIZE(cs43130_ac_freq); i++) {
tmp = scnprintf(buf + j, PAGE_SIZE - j, "%u\n", tmp = sysfs_emit_at(buf, j, "%u\n",
cs43130->hpload_ac[i][ch]); cs43130->hpload_ac[i][ch]);
if (!tmp) if (!tmp)
break; break;
...@@ -1715,7 +1714,7 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch) ...@@ -1715,7 +1714,7 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch)
return j; return j;
} else { } else {
return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n"); return sysfs_emit(buf, "NO_HPLOAD\n");
} }
} }
......
...@@ -271,7 +271,7 @@ static ssize_t keyclick_show(struct device *dev, ...@@ -271,7 +271,7 @@ static ssize_t keyclick_show(struct device *dev,
freq = (125 << ((val >> 8) & 0x7)) >> 1; freq = (125 << ((val >> 8) & 0x7)) >> 1;
len = 2 * (1 + ((val >> 4) & 0xf)); len = 2 * (1 + ((val >> 4) & 0xf));
return sprintf(buf, "amp=%x freq=%iHz len=%iclks\n", amp, freq, len); return sysfs_emit(buf, "amp=%x freq=%iHz len=%iclks\n", amp, freq, len);
} }
/* Any write to the keyclick attribute will trigger the keyclick event */ /* Any write to the keyclick attribute will trigger the keyclick event */
......
...@@ -242,9 +242,9 @@ static ssize_t firmware_version_show(struct device *dev, ...@@ -242,9 +242,9 @@ static ssize_t firmware_version_show(struct device *dev,
if (ctx->fw_version.type == 0 && ctx->fw_version.major == 0 && if (ctx->fw_version.type == 0 && ctx->fw_version.major == 0 &&
ctx->fw_version.minor == 0 && ctx->fw_version.build == 0) ctx->fw_version.minor == 0 && ctx->fw_version.build == 0)
return sprintf(buf, "FW not yet loaded\n"); return sysfs_emit(buf, "FW not yet loaded\n");
else else
return sprintf(buf, "v%02x.%02x.%02x.%02x\n", return sysfs_emit(buf, "v%02x.%02x.%02x.%02x\n",
ctx->fw_version.type, ctx->fw_version.major, ctx->fw_version.type, ctx->fw_version.major,
ctx->fw_version.minor, ctx->fw_version.build); ctx->fw_version.minor, ctx->fw_version.build);
......
...@@ -27,7 +27,7 @@ static ssize_t fw_version_show(struct device *dev, ...@@ -27,7 +27,7 @@ static ssize_t fw_version_show(struct device *dev,
if (ret) if (ret)
return CATPT_IPC_ERROR(ret); return CATPT_IPC_ERROR(ret);
return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major, return sysfs_emit(buf, "%d.%d.%d.%d\n", version.type, version.major,
version.minor, version.build); version.minor, version.build);
} }
static DEVICE_ATTR_RO(fw_version); static DEVICE_ATTR_RO(fw_version);
...@@ -37,7 +37,7 @@ static ssize_t fw_info_show(struct device *dev, ...@@ -37,7 +37,7 @@ static ssize_t fw_info_show(struct device *dev,
{ {
struct catpt_dev *cdev = dev_get_drvdata(dev); struct catpt_dev *cdev = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", cdev->ipc.config.fw_info); return sysfs_emit(buf, "%s\n", cdev->ipc.config.fw_info);
} }
static DEVICE_ATTR_RO(fw_info); static DEVICE_ATTR_RO(fw_info);
......
...@@ -61,7 +61,7 @@ static ssize_t platform_id_show(struct device *dev, ...@@ -61,7 +61,7 @@ static ssize_t platform_id_show(struct device *dev,
nhlt->header.oem_revision); nhlt->header.oem_revision);
skl_nhlt_trim_space(platform_id); skl_nhlt_trim_space(platform_id);
return sprintf(buf, "%s\n", platform_id); return sysfs_emit(buf, "%s\n", platform_id);
} }
static DEVICE_ATTR_RO(platform_id); static DEVICE_ATTR_RO(platform_id);
......
...@@ -72,7 +72,7 @@ static ssize_t pmdown_time_show(struct device *dev, ...@@ -72,7 +72,7 @@ static ssize_t pmdown_time_show(struct device *dev,
{ {
struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
return sprintf(buf, "%ld\n", rtd->pmdown_time); return sysfs_emit(buf, "%ld\n", rtd->pmdown_time);
} }
static ssize_t pmdown_time_store(struct device *dev, static ssize_t pmdown_time_store(struct device *dev,
......
...@@ -2386,11 +2386,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, ...@@ -2386,11 +2386,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power); EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
char *buf) char *buf, int count)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
int count = 0;
char *state = "not set"; char *state = "not set";
/* card won't be set for the dummy component, as a spot fix /* card won't be set for the dummy component, as a spot fix
...@@ -2423,7 +2422,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, ...@@ -2423,7 +2422,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
case snd_soc_dapm_pinctrl: case snd_soc_dapm_pinctrl:
case snd_soc_dapm_clock_supply: case snd_soc_dapm_clock_supply:
if (w->name) if (w->name)
count += sprintf(buf + count, "%s: %s\n", count += sysfs_emit_at(buf, count, "%s: %s\n",
w->name, w->power ? "On":"Off"); w->name, w->power ? "On":"Off");
break; break;
default: default:
...@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, ...@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
state = "Off"; state = "Off";
break; break;
} }
count += sprintf(buf + count, "PM State: %s\n", state); count += sysfs_emit_at(buf, count, "PM State: %s\n", state);
return count; return count;
} }
...@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev,
for_each_rtd_codec_dais(rtd, i, codec_dai) { for_each_rtd_codec_dais(rtd, i, codec_dai) {
struct snd_soc_component *cmpnt = codec_dai->component; struct snd_soc_component *cmpnt = codec_dai->component;
count += dapm_widget_show_component(cmpnt, buf + count); count = dapm_widget_show_component(cmpnt, buf, count);
} }
mutex_unlock(&rtd->card->dapm_mutex); mutex_unlock(&rtd->card->dapm_mutex);
......
...@@ -244,10 +244,10 @@ static ssize_t st_taps_show(struct device *dev, ...@@ -244,10 +244,10 @@ static ssize_t st_taps_show(struct device *dev,
spin_lock_irq(&mcbsp->lock); spin_lock_irq(&mcbsp->lock);
for (i = 0; i < st_data->nr_taps; i++) for (i = 0; i < st_data->nr_taps; i++)
status += sprintf(&buf[status], (i ? ", %d" : "%d"), status += sysfs_emit_at(buf, status, (i ? ", %d" : "%d"),
st_data->taps[i]); st_data->taps[i]);
if (i) if (i)
status += sprintf(&buf[status], "\n"); status += sysfs_emit_at(buf, status, "\n");
spin_unlock_irq(&mcbsp->lock); spin_unlock_irq(&mcbsp->lock);
return status; return status;
......
...@@ -517,7 +517,7 @@ static ssize_t prop##_show(struct device *dev, \ ...@@ -517,7 +517,7 @@ static ssize_t prop##_show(struct device *dev, \
{ \ { \
struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); \ struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); \
\ \
return sprintf(buf, "%u\n", mcbsp->prop); \ return sysfs_emit(buf, "%u\n", mcbsp->prop); \
} \ } \
\ \
static ssize_t prop##_store(struct device *dev, \ static ssize_t prop##_store(struct device *dev, \
...@@ -560,11 +560,11 @@ static ssize_t dma_op_mode_show(struct device *dev, ...@@ -560,11 +560,11 @@ static ssize_t dma_op_mode_show(struct device *dev,
for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) { for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
if (dma_op_mode == i) if (dma_op_mode == i)
len += sprintf(buf + len, "[%s] ", *s); len += sysfs_emit_at(buf, len, "[%s] ", *s);
else else
len += sprintf(buf + len, "%s ", *s); len += sysfs_emit_at(buf, len, "%s ", *s);
} }
len += sprintf(buf + len, "\n"); len += sysfs_emit_at(buf, len, "\n");
return len; return len;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册