.. | .. |
---|
424 | 424 | static int uwire_setup(struct spi_device *spi) |
---|
425 | 425 | { |
---|
426 | 426 | struct uwire_state *ust = spi->controller_state; |
---|
| 427 | + bool initial_setup = false; |
---|
| 428 | + int status; |
---|
427 | 429 | |
---|
428 | 430 | if (ust == NULL) { |
---|
429 | 431 | ust = kzalloc(sizeof(*ust), GFP_KERNEL); |
---|
430 | 432 | if (ust == NULL) |
---|
431 | 433 | return -ENOMEM; |
---|
432 | 434 | spi->controller_state = ust; |
---|
| 435 | + initial_setup = true; |
---|
433 | 436 | } |
---|
434 | 437 | |
---|
435 | | - return uwire_setup_transfer(spi, NULL); |
---|
| 438 | + status = uwire_setup_transfer(spi, NULL); |
---|
| 439 | + if (status && initial_setup) |
---|
| 440 | + kfree(ust); |
---|
| 441 | + |
---|
| 442 | + return status; |
---|
436 | 443 | } |
---|
437 | 444 | |
---|
438 | 445 | static void uwire_cleanup(struct spi_device *spi) |
---|
.. | .. |
---|
443 | 450 | static void uwire_off(struct uwire_spi *uwire) |
---|
444 | 451 | { |
---|
445 | 452 | uwire_write_reg(UWIRE_SR3, 0); |
---|
446 | | - clk_disable(uwire->ck); |
---|
| 453 | + clk_disable_unprepare(uwire->ck); |
---|
447 | 454 | spi_master_put(uwire->bitbang.master); |
---|
448 | 455 | } |
---|
449 | 456 | |
---|
.. | .. |
---|
475 | 482 | spi_master_put(master); |
---|
476 | 483 | return status; |
---|
477 | 484 | } |
---|
478 | | - clk_enable(uwire->ck); |
---|
| 485 | + clk_prepare_enable(uwire->ck); |
---|
479 | 486 | |
---|
480 | 487 | if (cpu_is_omap7xx()) |
---|
481 | 488 | uwire_idx_shift = 1; |
---|