lkml.org 
[lkml]   [2014]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/8] eeepc-laptop: pull out eeepc_destroy_rfkill
From
On Tue, Oct 28, 2014 at 6:19 AM, Darren Hart <dvhart@infradead.org> wrote:
> On Wed, Oct 22, 2014 at 09:12:39PM +0200, Frans Klaver wrote:
>> In eeepc_rfkill_exit, we implement the same code four times. Pull out a
>> function that cleans up an rfkill object to get rid of the duplication.
>>
>> Signed-off-by: Frans Klaver <fransklaver@gmail.com>
>> ---
>> drivers/platform/x86/eeepc-laptop.c | 34 ++++++++++++++--------------------
>> 1 file changed, 14 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
>> index e92ea41..73e8d39 100644
>> --- a/drivers/platform/x86/eeepc-laptop.c
>> +++ b/drivers/platform/x86/eeepc-laptop.c
>> @@ -823,35 +823,29 @@ static char EEEPC_RFKILL_NODE_1[] = "\\_SB.PCI0.P0P5";
>> static char EEEPC_RFKILL_NODE_2[] = "\\_SB.PCI0.P0P6";
>> static char EEEPC_RFKILL_NODE_3[] = "\\_SB.PCI0.P0P7";
>>
>> +static inline void eeepc_destroy_rfkill(struct rfkill **rfkill)
>> +{
>> + if (!*rfkill)
>> + return;
>> + rfkill_unregister(*rfkill);
>> + rfkill_destroy(*rfkill);
>> + *rfkill = NULL;
>> +}
>
> In this case the savings is 6 lines at the cost of some legibility as double
> pointers are arguably harder to read, and definitely easier to screw up ;-)
>
> I appreciate the goal, but I'm not convinced it is worth it.

Fair enough. If anything the following would be slightly less complicated:

#define eeepc_destroy_rfkill(rfkill) \
do { \
if (rfkill) { \
rfkill_unregister(rfkill); \
rfkill_destroy(rfkill); \
rkfill = NULL; \
} \
} while (0);

I don't think any new eeepc's are being produced, so this code is
unlikely to change anyway. Let's leave it as is.

Thanks,
Frans


\
 
 \ /
  Last update: 2014-10-28 10:01    [W:0.047 / U:1.992 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site