mfd: rtsx: Fix checkpatch warning
[deliverable/linux.git] / drivers / mfd / rtsx_pcr.c
index 7a7b0bda4618926fffea21dc23a3f386e1303777..4897c39cfb7bc93544c6fbc9e611e37680b5cfae 100644 (file)
@@ -325,7 +325,6 @@ static void rtsx_pci_add_sg_tbl(struct rtsx_pcr *pcr,
        val = ((u64)addr << 32) | ((u64)len << 12) | option;
 
        put_unaligned_le64(val, ptr);
-       ptr++;
        pcr->sgi++;
 }
 
@@ -591,7 +590,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
                u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk)
 {
        int err, clk;
-       u8 N, min_N, max_N, clk_divider;
+       u8 n, min_n, max_n, clk_divider;
        u8 mcu_cnt, div, max_div;
        u8 depth[] = {
                [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M,
@@ -616,8 +615,8 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
        card_clock /= 1000000;
        dev_dbg(&(pcr->pci->dev), "Switch card clock to %dMHz\n", card_clock);
 
-       min_N = 80;
-       max_N = 208;
+       min_n = 80;
+       max_n = 208;
        max_div = CLK_DIV_8;
 
        clk = card_clock;
@@ -630,21 +629,31 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
        if (clk == pcr->cur_clock)
                return 0;
 
-       N = (u8)(clk - 2);
-       if ((clk <= 2) || (N > max_N))
+       if (pcr->ops->conv_clk_and_div_n)
+               n = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N);
+       else
+               n = (u8)(clk - 2);
+       if ((clk <= 2) || (n > max_n))
                return -EINVAL;
 
        mcu_cnt = (u8)(125/clk + 3);
        if (mcu_cnt > 15)
                mcu_cnt = 15;
 
-       /* Make sure that the SSC clock div_n is equal or greater than min_N */
+       /* Make sure that the SSC clock div_n is equal or greater than min_n */
        div = CLK_DIV_1;
-       while ((N < min_N) && (div < max_div)) {
-               N = (N + 2) * 2 - 2;
+       while ((n < min_n) && (div < max_div)) {
+               if (pcr->ops->conv_clk_and_div_n) {
+                       int dbl_clk = pcr->ops->conv_clk_and_div_n(n,
+                                       DIV_N_TO_CLK) * 2;
+                       n = (u8)pcr->ops->conv_clk_and_div_n(dbl_clk,
+                                       CLK_TO_DIV_N);
+               } else {
+                       n = (n + 2) * 2 - 2;
+               }
                div++;
        }
-       dev_dbg(&(pcr->pci->dev), "N = %d, div = %d\n", N, div);
+       dev_dbg(&(pcr->pci->dev), "n = %d, div = %d\n", n, div);
 
        ssc_depth = depth[ssc_depth];
        if (double_clk)
@@ -661,7 +670,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
        rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0);
        rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL2,
                        SSC_DEPTH_MASK, ssc_depth);
-       rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, N);
+       rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, n);
        rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB);
        if (vpclk) {
                rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL,
@@ -703,6 +712,15 @@ int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card)
 }
 EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off);
 
+int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
+{
+       if (pcr->ops->switch_output_voltage)
+               return pcr->ops->switch_output_voltage(pcr, voltage);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(rtsx_pci_switch_output_voltage);
+
 unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr)
 {
        unsigned int val;
@@ -767,10 +785,10 @@ static void rtsx_pci_card_detect(struct work_struct *work)
 
        spin_unlock_irqrestore(&pcr->lock, flags);
 
-       if (card_detect & SD_EXIST)
+       if ((card_detect & SD_EXIST) && pcr->slots[RTSX_SD_CARD].card_event)
                pcr->slots[RTSX_SD_CARD].card_event(
                                pcr->slots[RTSX_SD_CARD].p_dev);
-       if (card_detect & MS_EXIST)
+       if ((card_detect & MS_EXIST) && pcr->slots[RTSX_MS_CARD].card_event)
                pcr->slots[RTSX_MS_CARD].card_event(
                                pcr->slots[RTSX_MS_CARD].p_dev);
 }
@@ -1011,6 +1029,10 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
                pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device,
                (int)pcidev->revision);
 
+       ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32));
+       if (ret < 0)
+               return ret;
+
        ret = pci_enable_device(pcidev);
        if (ret)
                return ret;
This page took 0.027408 seconds and 5 git commands to generate.