Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: core: simplify return code

File contains multiple functions doing variations on the same thing,
sdio_readb(), sdio_writeb()f, sdio_readw(), sdio_writew()
etc. Although the functions have very similar logic the code is laid
out in a variety of ways. This makes it overly complicated to
read. There is a already a nice clean chunk of code, if we use this
format for all instances then we will have cleaned up the code,
reduced the line count and lessened the cognitive load required while
reading. Less lines equals less bugs.

Pick the most simple and clear code flow and change all functions to
be the same.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

tcharding and committed by
Ulf Hansson
8e11b284 9b980d95

+13 -29
+13 -29
drivers/mmc/core/sdio_io.c
··· 378 378 return 0xFF; 379 379 } 380 380 381 - if (err_ret) 382 - *err_ret = 0; 383 - 384 381 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, 0, &val); 385 - if (ret) { 386 - if (err_ret) 387 - *err_ret = ret; 382 + if (err_ret) 383 + *err_ret = ret; 384 + if (ret) 388 385 return 0xFF; 389 - } 390 386 391 387 return val; 392 388 } ··· 439 443 if (err_ret) 440 444 *err_ret = ret; 441 445 if (ret) 442 - val = 0xff; 446 + return 0xff; 443 447 444 448 return val; 445 449 } ··· 527 531 { 528 532 int ret; 529 533 530 - if (err_ret) 531 - *err_ret = 0; 532 - 533 534 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 2); 534 - if (ret) { 535 - if (err_ret) 536 - *err_ret = ret; 535 + if (err_ret) 536 + *err_ret = ret; 537 + if (ret) 537 538 return 0xFFFF; 538 - } 539 539 540 540 return le16_to_cpup((__le16 *)func->tmpbuf); 541 541 } ··· 575 583 { 576 584 int ret; 577 585 578 - if (err_ret) 579 - *err_ret = 0; 580 - 581 586 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 4); 582 - if (ret) { 583 - if (err_ret) 584 - *err_ret = ret; 587 + if (err_ret) 588 + *err_ret = ret; 589 + if (ret) 585 590 return 0xFFFFFFFF; 586 - } 587 591 588 592 return le32_to_cpup((__le32 *)func->tmpbuf); 589 593 } ··· 630 642 return 0xFF; 631 643 } 632 644 633 - if (err_ret) 634 - *err_ret = 0; 635 - 636 645 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val); 637 - if (ret) { 638 - if (err_ret) 639 - *err_ret = ret; 646 + if (err_ret) 647 + *err_ret = ret; 648 + if (ret) 640 649 return 0xFF; 641 - } 642 650 643 651 return val; 644 652 }