@@ -150,10 +150,8 @@ static void snd_cs8427_free(struct snd_i2c_device *device)
150150 kfree (device -> private_data );
151151}
152152
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 )
157155{
158156 static unsigned char initvals1 [] = {
159157 CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC ,
@@ -200,22 +198,10 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
200198 Inhibit E->F transfers. */
201199 CS8427_UD | CS8427_EFTUI | CS8427_DETUI ,
202200 };
201+ struct cs8427 * chip = device -> private_data ;
203202 int err ;
204- struct cs8427 * chip ;
205- struct snd_i2c_device * device ;
206203 unsigned char buf [24 ];
207204
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-
219205 snd_i2c_lock (bus );
220206 err = snd_cs8427_reg_read (device , CS8427_REG_ID_AND_VER );
221207 if (err != CS8427_VER8427A ) {
@@ -264,10 +250,44 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
264250 snd_i2c_unlock (bus );
265251
266252 /* 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+
267284 if (reset_timeout < 1 )
268285 reset_timeout = 1 ;
269286 chip -> reset_timeout = reset_timeout ;
270- snd_cs8427_reset (device );
287+
288+ err = snd_cs8427_init (bus , device );
289+ if (err )
290+ goto __fail ;
271291
272292#if 0 // it's nice for read tests
273293 {
@@ -286,7 +306,6 @@ int snd_cs8427_create(struct snd_i2c_bus *bus,
286306 return 0 ;
287307
288308 __fail :
289- snd_i2c_unlock (bus );
290309 snd_i2c_device_free (device );
291310 return err < 0 ? err : - EIO ;
292311}
0 commit comments