@@ -84,6 +84,7 @@ static void i2sbus_release_dev(struct device *dev)
8484 for (i = aoa_resource_i2smmio ; i <= aoa_resource_rxdbdma ; i ++ )
8585 free_irq (i2sdev -> interrupts [i ], i2sdev );
8686 i2sbus_control_remove_dev (i2sdev -> control , i2sdev );
87+ of_node_put (i2sdev -> sound .ofdev .dev .of_node );
8788 mutex_destroy (& i2sdev -> lock );
8889 kfree (i2sdev );
8990}
@@ -147,7 +148,6 @@ static int i2sbus_get_and_fixup_rsrc(struct device_node *np, int index,
147148}
148149
149150/* Returns 1 if added, 0 for otherwise; don't return a negative value! */
150- /* FIXME: look at device node refcounting */
151151static int i2sbus_add_dev (struct macio_dev * macio ,
152152 struct i2sbus_control * control ,
153153 struct device_node * np )
@@ -178,8 +178,9 @@ static int i2sbus_add_dev(struct macio_dev *macio,
178178 i = 0 ;
179179 for_each_child_of_node (np , child ) {
180180 if (of_node_name_eq (child , "sound" )) {
181+ of_node_put (sound );
181182 i ++ ;
182- sound = child ;
183+ sound = of_node_get ( child ) ;
183184 }
184185 }
185186 if (i == 1 ) {
@@ -205,6 +206,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
205206 }
206207 }
207208 }
209+ of_node_put (sound );
208210 /* for the time being, until we can handle non-layout-id
209211 * things in some fabric, refuse to attach if there is no
210212 * layout-id property or we haven't been forced to attach.
@@ -219,7 +221,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
219221 mutex_init (& dev -> lock );
220222 spin_lock_init (& dev -> low_lock );
221223 dev -> sound .ofdev .archdata .dma_mask = macio -> ofdev .archdata .dma_mask ;
222- dev -> sound .ofdev .dev .of_node = np ;
224+ dev -> sound .ofdev .dev .of_node = of_node_get ( np ) ;
223225 dev -> sound .ofdev .dev .dma_mask = & dev -> sound .ofdev .archdata .dma_mask ;
224226 dev -> sound .ofdev .dev .parent = & macio -> ofdev .dev ;
225227 dev -> sound .ofdev .dev .release = i2sbus_release_dev ;
@@ -327,6 +329,7 @@ static int i2sbus_add_dev(struct macio_dev *macio,
327329 for (i = 0 ;i < 3 ;i ++ )
328330 release_and_free_resource (dev -> allocated_resource [i ]);
329331 mutex_destroy (& dev -> lock );
332+ of_node_put (dev -> sound .ofdev .dev .of_node );
330333 kfree (dev );
331334 return 0 ;
332335}
0 commit comments