diff options
author | Wei WANG <wei_wang@realsil.com.cn> | 2013-01-29 02:21:36 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-02-13 18:22:57 -0500 |
commit | eebbe2541684da99bf0b179d5182dc8025f5f5b6 (patch) | |
tree | df2b0907ab20cf1a4ba19a8a7fd8286758008f71 /drivers/mfd/rtsx_pcr.c | |
parent | 678cacdfda800b0cdbfdd01350dcf5e3b767f6ed (diff) |
mfd: rtsx: Use macros to replace some variables
In function rtsx_pci_switch_clock, some variables, such as min_n, max_n,
and max_div, are not necessary. And those assigned values look very
obscure for others. It's more proper to use macro definitions here to
replace these variables.
Signed-off-by: Wei WANG <wei_wang@realsil.com.cn>
Acked-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/rtsx_pcr.c')
-rw-r--r-- | drivers/mfd/rtsx_pcr.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index 4897c39cfb7b..67bb34ef0ebd 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c | |||
@@ -590,8 +590,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, | |||
590 | u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) | 590 | u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) |
591 | { | 591 | { |
592 | int err, clk; | 592 | int err, clk; |
593 | u8 n, min_n, max_n, clk_divider; | 593 | u8 n, clk_divider, mcu_cnt, div; |
594 | u8 mcu_cnt, div, max_div; | ||
595 | u8 depth[] = { | 594 | u8 depth[] = { |
596 | [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, | 595 | [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, |
597 | [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M, | 596 | [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M, |
@@ -615,10 +614,6 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, | |||
615 | card_clock /= 1000000; | 614 | card_clock /= 1000000; |
616 | dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock); | 615 | dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock); |
617 | 616 | ||
618 | min_n = 80; | ||
619 | max_n = 208; | ||
620 | max_div = CLK_DIV_8; | ||
621 | |||
622 | clk = card_clock; | 617 | clk = card_clock; |
623 | if (!initial_mode && double_clk) | 618 | if (!initial_mode && double_clk) |
624 | clk = card_clock * 2; | 619 | clk = card_clock * 2; |
@@ -633,16 +628,16 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, | |||
633 | n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N); | 628 | n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N); |
634 | else | 629 | else |
635 | n = (u8)(clk - 2); | 630 | n = (u8)(clk - 2); |
636 | if ((clk <= 2) || (n > max_n)) | 631 | if ((clk <= 2) || (n > MAX_DIV_N_PCR)) |
637 | return -EINVAL; | 632 | return -EINVAL; |
638 | 633 | ||
639 | mcu_cnt = (u8)(125/clk + 3); | 634 | mcu_cnt = (u8)(125/clk + 3); |
640 | if (mcu_cnt > 15) | 635 | if (mcu_cnt > 15) |
641 | mcu_cnt = 15; | 636 | mcu_cnt = 15; |
642 | 637 | ||
643 | /* Make sure that the SSC clock div_n is equal or greater than min_n */ | 638 | /* Make sure that the SSC clock div_n is not less than MIN_DIV_N_PCR */ |
644 | div = CLK_DIV_1; | 639 | div = CLK_DIV_1; |
645 | while ((n < min_n) && (div < max_div)) { | 640 | while ((n < MIN_DIV_N_PCR) && (div < CLK_DIV_8)) { |
646 | if (pcr->ops->conv_clk_and_div_n) { | 641 | if (pcr->ops->conv_clk_and_div_n) { |
647 | int dbl_clk = pcr->ops->conv_clk_and_div_n(n, | 642 | int dbl_clk = pcr->ops->conv_clk_and_div_n(n, |
648 | DIV_N_TO_CLK) * 2; | 643 | DIV_N_TO_CLK) * 2; |