From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751995AbbHGI2I (ORCPT ); Fri, 7 Aug 2015 04:28:08 -0400 Received: from smtprelay0160.hostedemail.com ([216.40.44.160]:35978 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750889AbbHGI2C (ORCPT ); Fri, 7 Aug 2015 04:28:02 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2692:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3872:4321:4401:5007:6261:6742:10004:10400:10848:11026:11232:11473:11658:11914:12043:12295:12296:12438:12517:12519:12740:13069:13161:13229:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: glue18_b88377f9df60 X-Filterd-Recvd-Size: 2915 Message-ID: <1438936078.2322.29.camel@perches.com> Subject: Re: [PATCH] [v2] surface pro 3: Add support driver for Surface Pro 3 buttons From: Joe Perches To: Chen Yu Cc: dvhart@infradead.org, akpm@linux-foundation.org, arnd@arndb.de, mchehab@osg.samsung.com, gregkh@linuxfoundation.org, jslaby@suse.com, rui.zhang@intel.com, rafael.j.wysocki@intel.com, mika.westerberg@intel.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Date: Fri, 07 Aug 2015 01:27:58 -0700 In-Reply-To: <1438934272-17959-1-git-send-email-yu.c.chen@intel.com> References: <1438934272-17959-1-git-send-email-yu.c.chen@intel.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2015-08-07 at 15:57 +0800, Chen Yu wrote: > Since Surface Pro 3 does not follow the specs of "Windows ACPI Design > Guide for SoC Platform", code in drivers/input/misc/soc_array.c can > not detect these buttons on it. The comments below are all just style trivia and can be ignored entirely. > diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c [] > +#define handle_surface_button_notify(type, code) \ > +({ \ > + int ret = 0; \ > + if (SURFACE_BUTTON_NOTIFY_PRESS_##type == event) \ > + pressed = true; \ > + if (pressed || \ > + (SURFACE_BUTTON_NOTIFY_RELEASE_##type == event)) { \ > + key_code = code; \ > + ret = 1; \ > + } else \ > + ret = 0; \ > + ret; \ > +}) This seems a bit complicated. The else ret = 0 isn't necessary as it's initialized to 0. bool might be better than int. > +static void surface_button_notify(struct acpi_device *device, u32 event) > +{ > + struct surface_button *button = acpi_driver_data(device); > + struct input_dev *input; > + int key_code = KEY_RESERVED; > + bool pressed = false; > + > + if (!handle_surface_button_notify(POWER, KEY_POWER) && > + !handle_surface_button_notify(HOME, KEY_LEFTMETA) && > + !handle_surface_button_notify(VOLUME_UP, KEY_VOLUMEUP) && > + !handle_surface_button_notify(VOLUME_DOWN, KEY_VOLUMEDOWN)) > + dev_info_ratelimited(&device->dev, > + "Unsupported event [0x%x]\n", event); Some might prefer alignment to the open parenthesis: if (!handle_surface_button_notify(POWER, KEY_POWER) && !handle_surface_button_notify(HOME, KEY_LEFTMETA) && !handle_surface_button_notify(VOLUME_UP, KEY_VOLUMEUP) && !handle_surface_button_notify(VOLUME_DOWN, KEY_VOLUMEDOWN)) I think the older switch/case was easier to understand.