Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: cs8427: separate HW initialization

Separate HW initialization from device creation.
This is needed for suspend/resume support.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Ondrej Zary and committed by
Takashi Iwai
9229bc15 415d555e

+39 -19
+1
include/sound/cs8427.h
··· 188 188 189 189 struct snd_pcm_substream; 190 190 191 + int snd_cs8427_init(struct snd_i2c_bus *bus, struct snd_i2c_device *device); 191 192 int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr, 192 193 unsigned int reset_timeout, struct snd_i2c_device **r_cs8427); 193 194 int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg,
+38 -19
sound/i2c/cs8427.c
··· 150 150 kfree(device->private_data); 151 151 } 152 152 153 - int snd_cs8427_create(struct snd_i2c_bus *bus, 154 - unsigned char addr, 155 - unsigned int reset_timeout, 156 - struct snd_i2c_device **r_cs8427) 153 + int snd_cs8427_init(struct snd_i2c_bus *bus, 154 + struct snd_i2c_device *device) 157 155 { 158 156 static unsigned char initvals1[] = { 159 157 CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, ··· 198 200 Inhibit E->F transfers. */ 199 201 CS8427_UD | CS8427_EFTUI | CS8427_DETUI, 200 202 }; 203 + struct cs8427 *chip = device->private_data; 201 204 int err; 202 - struct cs8427 *chip; 203 - struct snd_i2c_device *device; 204 205 unsigned char buf[24]; 205 206 206 - if ((err = snd_i2c_device_create(bus, "CS8427", 207 - CS8427_ADDR | (addr & 7), 208 - &device)) < 0) 209 - return err; 210 - chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); 211 - if (chip == NULL) { 212 - snd_i2c_device_free(device); 213 - return -ENOMEM; 214 - } 215 - device->private_free = snd_cs8427_free; 216 - 217 207 snd_i2c_lock(bus); 218 208 err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER); 219 209 if (err != CS8427_VER8427A) { ··· 250 264 snd_i2c_unlock(bus); 251 265 252 266 /* turn on run bit and rock'n'roll */ 267 + snd_cs8427_reset(device); 268 + 269 + return 0; 270 + 271 + __fail: 272 + snd_i2c_unlock(bus); 273 + 274 + return err; 275 + } 276 + EXPORT_SYMBOL(snd_cs8427_init); 277 + 278 + int snd_cs8427_create(struct snd_i2c_bus *bus, 279 + unsigned char addr, 280 + unsigned int reset_timeout, 281 + struct snd_i2c_device **r_cs8427) 282 + { 283 + int err; 284 + struct cs8427 *chip; 285 + struct snd_i2c_device *device; 286 + 287 + err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), 288 + &device); 289 + if (err < 0) 290 + return err; 291 + chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); 292 + if (chip == NULL) { 293 + snd_i2c_device_free(device); 294 + return -ENOMEM; 295 + } 296 + device->private_free = snd_cs8427_free; 297 + 253 298 if (reset_timeout < 1) 254 299 reset_timeout = 1; 255 300 chip->reset_timeout = reset_timeout; 256 - snd_cs8427_reset(device); 301 + 302 + err = snd_cs8427_init(bus, device); 303 + if (err) 304 + goto __fail; 257 305 258 306 #if 0 // it's nice for read tests 259 307 { ··· 306 286 return 0; 307 287 308 288 __fail: 309 - snd_i2c_unlock(bus); 310 289 snd_i2c_device_free(device); 311 290 return err < 0 ? err : -EIO; 312 291 }