Commit a9291f46 authored by Jérémy Lefaure's avatar Jérémy Lefaure Committed by Takashi Iwai

ALSA: hda/ca0132 - use ARRAY_SIZE

Using the ARRAY_SIZE macro improves the readability of the code.

Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
 (sizeof(E)@p /sizeof(*E))
|
 (sizeof(E)@p /sizeof(E[...]))
|
 (sizeof(E)@p /sizeof(T))
)
Signed-off-by: default avatarJérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8ed5d192
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/kernel.h>
#include <sound/core.h> #include <sound/core.h>
#include "hda_codec.h" #include "hda_codec.h"
#include "hda_local.h" #include "hda_local.h"
...@@ -3605,8 +3606,7 @@ static int ca0132_vnode_switch_set(struct snd_kcontrol *kcontrol, ...@@ -3605,8 +3606,7 @@ static int ca0132_vnode_switch_set(struct snd_kcontrol *kcontrol,
static int ca0132_voicefx_info(struct snd_kcontrol *kcontrol, static int ca0132_voicefx_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo) struct snd_ctl_elem_info *uinfo)
{ {
unsigned int items = sizeof(ca0132_voicefx_presets) unsigned int items = ARRAY_SIZE(ca0132_voicefx_presets);
/ sizeof(struct ct_voicefx_preset);
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1; uinfo->count = 1;
...@@ -3635,10 +3635,8 @@ static int ca0132_voicefx_put(struct snd_kcontrol *kcontrol, ...@@ -3635,10 +3635,8 @@ static int ca0132_voicefx_put(struct snd_kcontrol *kcontrol,
struct ca0132_spec *spec = codec->spec; struct ca0132_spec *spec = codec->spec;
int i, err = 0; int i, err = 0;
int sel = ucontrol->value.enumerated.item[0]; int sel = ucontrol->value.enumerated.item[0];
unsigned int items = sizeof(ca0132_voicefx_presets)
/ sizeof(struct ct_voicefx_preset);
if (sel >= items) if (sel >= ARRAY_SIZE(ca0132_voicefx_presets))
return 0; return 0;
codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n", codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment