public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm] parse_integer: convert sound/
@ 2015-07-20 22:16 Alexey Dobriyan
  2015-07-21  7:35 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2015-07-20 22:16 UTC (permalink / raw)
  To: akpm; +Cc: tiwai, perex, linux-kernel

Convert sound/ directory from deprecated simple_strto*()
to parse_integer()/kstrto*() functions.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 sound/core/oss/mixer_oss.c  |    2 +-
 sound/core/oss/pcm_oss.c    |    4 ++--
 sound/core/pcm.c            |    2 +-
 sound/core/pcm_memory.c     |    3 ++-
 sound/pci/ac97/ac97_codec.c |    8 ++++++--
 sound/soc/soc-core.c        |    9 ++++++---
 6 files changed, 18 insertions(+), 10 deletions(-)

--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -1200,7 +1200,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
 			continue;
 		}
 		snd_info_get_str(idxstr, cptr, sizeof(idxstr));
-		idx = simple_strtoul(idxstr, NULL, 10);
+		parse_integer(idxstr, 10, (unsigned int *)&idx);
 		if (idx >= 0x4000) { /* too big */
 			pr_err("ALSA: mixer_oss: invalid index %d\n", idx);
 			continue;
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2892,9 +2892,9 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
 			}
 		}
 		ptr = snd_info_get_str(str, ptr, sizeof(str));
-		template.periods = simple_strtoul(str, NULL, 10);
+		parse_integer(str, 10, &template.periods);
 		ptr = snd_info_get_str(str, ptr, sizeof(str));
-		template.period_size = simple_strtoul(str, NULL, 10);
+		parse_integer(str, 10, &template.period_size);
 		for (idx1 = 31; idx1 >= 0; idx1--)
 			if (template.period_size & (1 << idx1))
 				break;
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -507,7 +507,7 @@ static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry,
 	struct snd_pcm_str *pstr = entry->private_data;
 	char line[64];
 	if (!snd_info_get_line(buffer, line, sizeof(line)))
-		pstr->xrun_debug = simple_strtoul(line, NULL, 10);
+		parse_integer(line, 10, &pstr->xrun_debug);
 }
 #endif
 
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -167,7 +167,8 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry,
 	}
 	if (!snd_info_get_line(buffer, line, sizeof(line))) {
 		snd_info_get_str(str, line, sizeof(str));
-		size = simple_strtoul(str, NULL, 10) * 1024;
+		parse_integer(str, 10, &size);
+		size *= 1024;
 		if ((size != 0 && size < 8192) || size > substream->dma_max) {
 			buffer->error = -EINVAL;
 			return;
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -2884,8 +2884,12 @@ static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr)
 			return apply_quirk(ac97, i);
 	}
 	/* for compatibility, accept the numbers, too */
-	if (*typestr >= '0' && *typestr <= '9')
-		return apply_quirk(ac97, (int)simple_strtoul(typestr, NULL, 10));
+	if (*typestr >= '0' && *typestr <= '9') {
+		int type;
+
+		parse_integer(typestr, 10, &type);
+		return apply_quirk(ac97, type);
+	}
 	return -EINVAL;
 }
 
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -250,7 +250,7 @@ static ssize_t codec_reg_write_file(struct file *file,
 	char buf[32];
 	size_t buf_size;
 	char *start = buf;
-	unsigned long reg, value;
+	unsigned int reg, value;
 	struct snd_soc_codec *codec = file->private_data;
 	int ret;
 
@@ -261,10 +261,13 @@ static ssize_t codec_reg_write_file(struct file *file,
 
 	while (*start == ' ')
 		start++;
-	reg = simple_strtoul(start, &start, 16);
+	ret = parse_integer(start, 16, &reg);
+	if (ret < 0)
+		return ret;
+	start += ret;
 	while (*start == ' ')
 		start++;
-	ret = kstrtoul(start, 16, &value);
+	ret = kstrtouint(start, 16, &value);
 	if (ret)
 		return ret;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -mm] parse_integer: convert sound/
  2015-07-20 22:16 [PATCH -mm] parse_integer: convert sound/ Alexey Dobriyan
@ 2015-07-21  7:35 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2015-07-21  7:35 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: akpm, perex, linux-kernel

On Tue, 21 Jul 2015 00:16:06 +0200,
Alexey Dobriyan wrote:
> 
> Convert sound/ directory from deprecated simple_strto*()
> to parse_integer()/kstrto*() functions.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

Sorry, this is NAK.  If we convert, it should handle the error
properly, too.

Also, align the subject to the commits in sound subtree.


thanks,

Takashi

> ---
> 
>  sound/core/oss/mixer_oss.c  |    2 +-
>  sound/core/oss/pcm_oss.c    |    4 ++--
>  sound/core/pcm.c            |    2 +-
>  sound/core/pcm_memory.c     |    3 ++-
>  sound/pci/ac97/ac97_codec.c |    8 ++++++--
>  sound/soc/soc-core.c        |    9 ++++++---
>  6 files changed, 18 insertions(+), 10 deletions(-)
> 
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -1200,7 +1200,7 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,
>  			continue;
>  		}
>  		snd_info_get_str(idxstr, cptr, sizeof(idxstr));
> -		idx = simple_strtoul(idxstr, NULL, 10);
> +		parse_integer(idxstr, 10, (unsigned int *)&idx);
>  		if (idx >= 0x4000) { /* too big */
>  			pr_err("ALSA: mixer_oss: invalid index %d\n", idx);
>  			continue;
> --- a/sound/core/oss/pcm_oss.c
> +++ b/sound/core/oss/pcm_oss.c
> @@ -2892,9 +2892,9 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
>  			}
>  		}
>  		ptr = snd_info_get_str(str, ptr, sizeof(str));
> -		template.periods = simple_strtoul(str, NULL, 10);
> +		parse_integer(str, 10, &template.periods);
>  		ptr = snd_info_get_str(str, ptr, sizeof(str));
> -		template.period_size = simple_strtoul(str, NULL, 10);
> +		parse_integer(str, 10, &template.period_size);
>  		for (idx1 = 31; idx1 >= 0; idx1--)
>  			if (template.period_size & (1 << idx1))
>  				break;
> --- a/sound/core/pcm.c
> +++ b/sound/core/pcm.c
> @@ -507,7 +507,7 @@ static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry,
>  	struct snd_pcm_str *pstr = entry->private_data;
>  	char line[64];
>  	if (!snd_info_get_line(buffer, line, sizeof(line)))
> -		pstr->xrun_debug = simple_strtoul(line, NULL, 10);
> +		parse_integer(line, 10, &pstr->xrun_debug);
>  }
>  #endif
>  
> --- a/sound/core/pcm_memory.c
> +++ b/sound/core/pcm_memory.c
> @@ -167,7 +167,8 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry,
>  	}
>  	if (!snd_info_get_line(buffer, line, sizeof(line))) {
>  		snd_info_get_str(str, line, sizeof(str));
> -		size = simple_strtoul(str, NULL, 10) * 1024;
> +		parse_integer(str, 10, &size);
> +		size *= 1024;
>  		if ((size != 0 && size < 8192) || size > substream->dma_max) {
>  			buffer->error = -EINVAL;
>  			return;
> --- a/sound/pci/ac97/ac97_codec.c
> +++ b/sound/pci/ac97/ac97_codec.c
> @@ -2884,8 +2884,12 @@ static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr)
>  			return apply_quirk(ac97, i);
>  	}
>  	/* for compatibility, accept the numbers, too */
> -	if (*typestr >= '0' && *typestr <= '9')
> -		return apply_quirk(ac97, (int)simple_strtoul(typestr, NULL, 10));
> +	if (*typestr >= '0' && *typestr <= '9') {
> +		int type;
> +
> +		parse_integer(typestr, 10, &type);
> +		return apply_quirk(ac97, type);
> +	}
>  	return -EINVAL;
>  }
>  
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -250,7 +250,7 @@ static ssize_t codec_reg_write_file(struct file *file,
>  	char buf[32];
>  	size_t buf_size;
>  	char *start = buf;
> -	unsigned long reg, value;
> +	unsigned int reg, value;
>  	struct snd_soc_codec *codec = file->private_data;
>  	int ret;
>  
> @@ -261,10 +261,13 @@ static ssize_t codec_reg_write_file(struct file *file,
>  
>  	while (*start == ' ')
>  		start++;
> -	reg = simple_strtoul(start, &start, 16);
> +	ret = parse_integer(start, 16, &reg);
> +	if (ret < 0)
> +		return ret;
> +	start += ret;
>  	while (*start == ' ')
>  		start++;
> -	ret = kstrtoul(start, 16, &value);
> +	ret = kstrtouint(start, 16, &value);
>  	if (ret)
>  		return ret;
>  
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-21  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-20 22:16 [PATCH -mm] parse_integer: convert sound/ Alexey Dobriyan
2015-07-21  7:35 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox