[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <52B0F7A6.20601@realsil.com.cn>
Date: Wed, 18 Dec 2013 09:17:26 +0800
From: micky <micky_ching@...lsil.com.cn>
To: Dan Carpenter <dan.carpenter@...cle.com>
CC: <sameo@...ux.intel.com>, <gregkh@...uxfoundation.org>,
<linux-kernel@...r.kernel.org>, <wei_wang@...lsil.com.cn>,
<rogerable@...ltek.com>, <devel@...uxdriverproject.org>,
Lee Jones <lee.jones@...aro.org>
Subject: Re: [PATCH v3 1/2] mfd: rtsx: reduce code duplication in rtl8411
On 12/17/2013 03:28 PM, Dan Carpenter wrote:
> On Tue, Dec 17, 2013 at 10:36:58AM +0800, micky_ching@...lsil.com.cn wrote:
>> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
>> index 947e79b..26b52ec 100644
>> --- a/drivers/mfd/rtsx_pcr.h
>> +++ b/drivers/mfd/rtsx_pcr.h
>> @@ -63,4 +63,12 @@ static inline u8 map_sd_drive(int idx)
>> #define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07)
>> #define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03)
>>
>> +#define set_pull_ctrl_tables(__device) \
>> +do { \
>> + pcr->sd_pull_ctl_enable_tbl = __device##_sd_pull_ctl_enable_tbl; \
>> + pcr->sd_pull_ctl_disable_tbl = __device##_sd_pull_ctl_disable_tbl; \
>> + pcr->ms_pull_ctl_enable_tbl = __device##_ms_pull_ctl_enable_tbl; \
>> + pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
>> +} while (0)
>> +
>> #endif
> This is nasty... With readable code, you should understand just from
> looking at it what the code is doing but this obscures it completely.
> It shouldn't reference the "pcr" variable without passing it in as an
> argument but even with that cleanup I don't really like it.
>
> To be honest, I don't see the problem with the original code.
>
>
Using macro can reduce some code, and define as set_pull_ctl_tables(pcr,
dev)
is much better for understand
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists