ALSA: hda - Use strict_strtoul()
Rewrite the codes to use strict_strtoul() instead of simple_strtoul(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
@@ -293,8 +293,11 @@ static ssize_t type##_store(struct device *dev, \
|
|||||||
{ \
|
{ \
|
||||||
struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
|
struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
|
||||||
struct hda_codec *codec = hwdep->private_data; \
|
struct hda_codec *codec = hwdep->private_data; \
|
||||||
char *after; \
|
unsigned long val; \
|
||||||
codec->type = simple_strtoul(buf, &after, 0); \
|
int err = strict_strtoul(buf, 0, &val); \
|
||||||
|
if (err < 0) \
|
||||||
|
return err; \
|
||||||
|
codec->type = val; \
|
||||||
return count; \
|
return count; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4159,43 +4159,47 @@ static void stac92xx_power_down(struct hda_codec *codec)
|
|||||||
static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
|
static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
|
||||||
int enable);
|
int enable);
|
||||||
|
|
||||||
|
static inline int get_int_hint(struct hda_codec *codec, const char *key,
|
||||||
|
int *valp)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
p = snd_hda_get_hint(codec, key);
|
||||||
|
if (p) {
|
||||||
|
unsigned long val;
|
||||||
|
if (!strict_strtoul(p, 0, &val)) {
|
||||||
|
*valp = val;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* override some hints from the hwdep entry */
|
/* override some hints from the hwdep entry */
|
||||||
static void stac_store_hints(struct hda_codec *codec)
|
static void stac_store_hints(struct hda_codec *codec)
|
||||||
{
|
{
|
||||||
struct sigmatel_spec *spec = codec->spec;
|
struct sigmatel_spec *spec = codec->spec;
|
||||||
const char *p;
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = snd_hda_get_bool_hint(codec, "hp_detect");
|
val = snd_hda_get_bool_hint(codec, "hp_detect");
|
||||||
if (val >= 0)
|
if (val >= 0)
|
||||||
spec->hp_detect = val;
|
spec->hp_detect = val;
|
||||||
p = snd_hda_get_hint(codec, "gpio_mask");
|
if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
|
||||||
if (p) {
|
|
||||||
spec->gpio_mask = simple_strtoul(p, NULL, 0);
|
|
||||||
spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
|
spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
|
||||||
spec->gpio_mask;
|
spec->gpio_mask;
|
||||||
}
|
}
|
||||||
p = snd_hda_get_hint(codec, "gpio_dir");
|
if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
|
||||||
if (p)
|
spec->gpio_mask &= spec->gpio_mask;
|
||||||
spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
|
if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
|
||||||
p = snd_hda_get_hint(codec, "gpio_data");
|
spec->gpio_dir &= spec->gpio_mask;
|
||||||
if (p)
|
if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
|
||||||
spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
|
spec->eapd_mask &= spec->gpio_mask;
|
||||||
p = snd_hda_get_hint(codec, "eapd_mask");
|
if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
|
||||||
if (p)
|
spec->gpio_mute &= spec->gpio_mask;
|
||||||
spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
|
|
||||||
p = snd_hda_get_hint(codec, "gpio_mute");
|
|
||||||
if (p)
|
|
||||||
spec->gpio_mute = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
|
|
||||||
val = snd_hda_get_bool_hint(codec, "eapd_switch");
|
val = snd_hda_get_bool_hint(codec, "eapd_switch");
|
||||||
if (val >= 0)
|
if (val >= 0)
|
||||||
spec->eapd_switch = val;
|
spec->eapd_switch = val;
|
||||||
p = snd_hda_get_hint(codec, "gpio_led_polarity");
|
get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
|
||||||
if (p)
|
if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
|
||||||
spec->gpio_led_polarity = simple_strtoul(p, NULL, 0);
|
|
||||||
p = snd_hda_get_hint(codec, "gpio_led");
|
|
||||||
if (p) {
|
|
||||||
spec->gpio_led = simple_strtoul(p, NULL, 0);
|
|
||||||
spec->gpio_mask |= spec->gpio_led;
|
spec->gpio_mask |= spec->gpio_led;
|
||||||
spec->gpio_dir |= spec->gpio_led;
|
spec->gpio_dir |= spec->gpio_led;
|
||||||
if (spec->gpio_led_polarity)
|
if (spec->gpio_led_polarity)
|
||||||
|
Reference in New Issue
Block a user