At Thu, 15 Jan 2009 10:06:53 +0000, Ian Molton wrote: > > +static unsigned int ac97_read(struct snd_soc_codec *codec, unsigned int > reg) > +{ > + u16 *cache = codec->reg_cache; > + > + switch (reg) { > + case AC97_RESET: > + case AC97_VENDOR_ID1: > + case AC97_VENDOR_ID2: > + return soc_ac97_ops.read(codec->ac97, reg); > + default: > + reg = reg >> 1; > + > + if (reg > (ARRAY_SIZE(wm9705_reg))) > + return -EIO; Shouldn't be this "reg >= ARRAY_SIZE(wm9705_reg)" ? > +static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, > + unsigned int val) > +{ > + u16 *cache = codec->reg_cache; > + > + soc_ac97_ops.write(codec->ac97, reg, val); > + reg = reg >> 1; > + if (reg <= (ARRAY_SIZE(wm9705_reg))) > + cache[reg] = val; Ditto, should be "reg < ARRAY_SIZE(wm9705_reg)". > +static int wm9705_soc_probe(struct platform_device *pdev) > +{ > + struct snd_soc_device *socdev = platform_get_drvdata(pdev); > + struct snd_soc_codec *codec; > + int ret = 0; > + > + printk(KERN_INFO "WM9705 SoC Audio Codec\n"); > + > + socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); > + if (socdev->codec == NULL) > + return -ENOMEM; > + codec = socdev->codec; > + mutex_init(&codec->mutex); > + > + codec->reg_cache = > + kzalloc(sizeof(u16) * ARRAY_SIZE(wm9705_reg), GFP_KERNEL); > + if (codec->reg_cache == NULL) { > + ret = -ENOMEM; > + goto cache_err; > + } > + memcpy(codec->reg_cache, wm9705_reg, > + sizeof(u16) * ARRAY_SIZE(wm9705_reg)); You can use kmemdup() here. thanks, Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel