.. | .. |
---|
295 | 295 | if (!(func->card->quirks & MMC_QUIRK_NONSTD_SDIO)) |
---|
296 | 296 | sdio_free_func_cis(func); |
---|
297 | 297 | |
---|
| 298 | + /* |
---|
| 299 | + * We have now removed the link to the tuples in the |
---|
| 300 | + * card structure, so remove the reference. |
---|
| 301 | + */ |
---|
| 302 | + put_device(&func->card->dev); |
---|
| 303 | + |
---|
298 | 304 | kfree(func->info); |
---|
299 | 305 | kfree(func->tmpbuf); |
---|
300 | 306 | kfree(func); |
---|
.. | .. |
---|
324 | 330 | func->card = card; |
---|
325 | 331 | |
---|
326 | 332 | device_initialize(&func->dev); |
---|
| 333 | + |
---|
| 334 | + /* |
---|
| 335 | + * We may link to tuples in the card structure, |
---|
| 336 | + * we need make sure we have a reference to it. |
---|
| 337 | + */ |
---|
| 338 | + get_device(&func->card->dev); |
---|
327 | 339 | |
---|
328 | 340 | func->dev.parent = &card->dev; |
---|
329 | 341 | func->dev.bus = &sdio_bus_type; |
---|
.. | .. |
---|
378 | 390 | */ |
---|
379 | 391 | void sdio_remove_func(struct sdio_func *func) |
---|
380 | 392 | { |
---|
381 | | - if (!sdio_func_present(func)) |
---|
382 | | - return; |
---|
| 393 | + if (sdio_func_present(func)) |
---|
| 394 | + device_del(&func->dev); |
---|
383 | 395 | |
---|
384 | | - device_del(&func->dev); |
---|
385 | 396 | of_node_put(func->dev.of_node); |
---|
386 | 397 | put_device(&func->dev); |
---|
387 | 398 | } |
---|