diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2014-04-03 08:49:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-04-03 08:59:48 -0400 |
commit | 9229bc1500100226ef4d2dbe51446fd8472a3cea (patch) | |
tree | 5c07a2fd2fe5a8842e5c1db633090d5eaeb8e9e3 /sound/i2c | |
parent | 415d555e6b398b00fc1733f0113065a54df9106a (diff) |
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>
Diffstat (limited to 'sound/i2c')
-rw-r--r-- | sound/i2c/cs8427.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index 6c2dc3863ac0..7e21621e492a 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c | |||
@@ -150,10 +150,8 @@ static void snd_cs8427_free(struct snd_i2c_device *device) | |||
150 | kfree(device->private_data); | 150 | kfree(device->private_data); |
151 | } | 151 | } |
152 | 152 | ||
153 | int snd_cs8427_create(struct snd_i2c_bus *bus, | 153 | int snd_cs8427_init(struct snd_i2c_bus *bus, |
154 | unsigned char addr, | 154 | struct snd_i2c_device *device) |
155 | unsigned int reset_timeout, | ||
156 | struct snd_i2c_device **r_cs8427) | ||
157 | { | 155 | { |
158 | static unsigned char initvals1[] = { | 156 | static unsigned char initvals1[] = { |
159 | CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, | 157 | CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, |
@@ -200,22 +198,10 @@ int snd_cs8427_create(struct snd_i2c_bus *bus, | |||
200 | Inhibit E->F transfers. */ | 198 | Inhibit E->F transfers. */ |
201 | CS8427_UD | CS8427_EFTUI | CS8427_DETUI, | 199 | CS8427_UD | CS8427_EFTUI | CS8427_DETUI, |
202 | }; | 200 | }; |
201 | struct cs8427 *chip = device->private_data; | ||
203 | int err; | 202 | int err; |
204 | struct cs8427 *chip; | ||
205 | struct snd_i2c_device *device; | ||
206 | unsigned char buf[24]; | 203 | unsigned char buf[24]; |
207 | 204 | ||
208 | if ((err = snd_i2c_device_create(bus, "CS8427", | ||
209 | CS8427_ADDR | (addr & 7), | ||
210 | &device)) < 0) | ||
211 | return err; | ||
212 | chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
213 | if (chip == NULL) { | ||
214 | snd_i2c_device_free(device); | ||
215 | return -ENOMEM; | ||
216 | } | ||
217 | device->private_free = snd_cs8427_free; | ||
218 | |||
219 | snd_i2c_lock(bus); | 205 | snd_i2c_lock(bus); |
220 | err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER); | 206 | err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER); |
221 | if (err != CS8427_VER8427A) { | 207 | if (err != CS8427_VER8427A) { |
@@ -264,10 +250,44 @@ int snd_cs8427_create(struct snd_i2c_bus *bus, | |||
264 | snd_i2c_unlock(bus); | 250 | snd_i2c_unlock(bus); |
265 | 251 | ||
266 | /* turn on run bit and rock'n'roll */ | 252 | /* turn on run bit and rock'n'roll */ |
253 | snd_cs8427_reset(device); | ||
254 | |||
255 | return 0; | ||
256 | |||
257 | __fail: | ||
258 | snd_i2c_unlock(bus); | ||
259 | |||
260 | return err; | ||
261 | } | ||
262 | EXPORT_SYMBOL(snd_cs8427_init); | ||
263 | |||
264 | int snd_cs8427_create(struct snd_i2c_bus *bus, | ||
265 | unsigned char addr, | ||
266 | unsigned int reset_timeout, | ||
267 | struct snd_i2c_device **r_cs8427) | ||
268 | { | ||
269 | int err; | ||
270 | struct cs8427 *chip; | ||
271 | struct snd_i2c_device *device; | ||
272 | |||
273 | err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), | ||
274 | &device); | ||
275 | if (err < 0) | ||
276 | return err; | ||
277 | chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
278 | if (chip == NULL) { | ||
279 | snd_i2c_device_free(device); | ||
280 | return -ENOMEM; | ||
281 | } | ||
282 | device->private_free = snd_cs8427_free; | ||
283 | |||
267 | if (reset_timeout < 1) | 284 | if (reset_timeout < 1) |
268 | reset_timeout = 1; | 285 | reset_timeout = 1; |
269 | chip->reset_timeout = reset_timeout; | 286 | chip->reset_timeout = reset_timeout; |
270 | snd_cs8427_reset(device); | 287 | |
288 | err = snd_cs8427_init(bus, device); | ||
289 | if (err) | ||
290 | goto __fail; | ||
271 | 291 | ||
272 | #if 0 // it's nice for read tests | 292 | #if 0 // it's nice for read tests |
273 | { | 293 | { |
@@ -286,7 +306,6 @@ int snd_cs8427_create(struct snd_i2c_bus *bus, | |||
286 | return 0; | 306 | return 0; |
287 | 307 | ||
288 | __fail: | 308 | __fail: |
289 | snd_i2c_unlock(bus); | ||
290 | snd_i2c_device_free(device); | 309 | snd_i2c_device_free(device); |
291 | return err < 0 ? err : -EIO; | 310 | return err < 0 ? err : -EIO; |
292 | } | 311 | } |