Received: by 10.223.185.116 with SMTP id b49csp1867605wrg; Sun, 4 Mar 2018 11:58:18 -0800 (PST) X-Google-Smtp-Source: AG47ELsHZCFdsIOuRziT4gRsZoluZJw6bKPiqLdqFvqiEewnAYmOSn8y+yoQxM9etiA9U616y+sl X-Received: by 2002:a17:902:9a45:: with SMTP id x5-v6mr1353618plv.18.1520193498201; Sun, 04 Mar 2018 11:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520193498; cv=none; d=google.com; s=arc-20160816; b=bDMPcHBhqerUToW/BvNFUilBX75IbG8SKO+GaRRim/n/PnM7n9KWvlVtiwJ5lsd34e DT1Ay+kjwbs3ldNiI1a9g6aI6TEEhpmRpZxTFCGb0y7LEcZzSrCUwI5BMtHrf4ktPkMF 330ZDS+arzj9A20MImbKBNiypD7y6TDnhu50jesn/fnBN7wQ14wEPhNM7c8Rl8mLBVwf sFt+2tLpDYRFSjDAfIA9nftjcuT+sbqK5H1IfN+1KrW6DaIgG7gPk5QZP0w2sH4kwytF kOaBM5J3qK4t1yH41E3JXTTixy+xwZ3EVfTlR+3Y0nDzUj+zvoe30wc/iCuw9PgVecgM L3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=dziCyEmyv+PmBO5kEYg28IZZRXKaC/0mk976eWBQV38=; b=Wo57Wfb3g/NLHMhVUi2oVzee5Kd84eLxDpLBinEut3qNmRIPEAorN/U0Xl47ZRT35c 7uynCCaZVAIeyA3aw5tEpnfRj0JnBN6aTnxb5+2U13swMEw4Ts7GMtDQOyoxzATgMNYm 7RD1+zhxt2CswEzYMVEctbGox6PTHiBBObRSUoQir0OdR++RwFBXtZ6cD01+AHgkn3QJ c3M2jP+My0XqSIeqDji4lWsDCGEYTEL96oiy9FEHxhL5vfdijHbZzkqNz9gMI6FbUY+7 suPdC8NCnA57122Yxbcg+IxOAvhy7+pl2oEB+P7VJBbbta9ICcndldapAFLcjL6migwx lfnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=aSn/Jz3e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si7397526pgr.53.2018.03.04.11.58.04; Sun, 04 Mar 2018 11:58:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=aSn/Jz3e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kempniu.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932165AbeCDToe (ORCPT + 99 others); Sun, 4 Mar 2018 14:44:34 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:41765 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084AbeCDTob (ORCPT ); Sun, 4 Mar 2018 14:44:31 -0500 Received: by mail-lf0-f46.google.com with SMTP id m69so20130662lfe.8 for ; Sun, 04 Mar 2018 11:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=dziCyEmyv+PmBO5kEYg28IZZRXKaC/0mk976eWBQV38=; b=aSn/Jz3ejIaeftmPhqmM9efA7ke4pi9o7w5gjVLCXhWXAYJHrQzEVTtoyIKnVm5S5S rzl8G2AHmKUuRrOs5jqNAy9DiQbIvDnpOzKl7nL+HeDmEm8qbL1rCeCi4b199ZxDZRGY FO8dJAh1D3f4i19ppDnJGMRFItTI/81/Hpfsc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=dziCyEmyv+PmBO5kEYg28IZZRXKaC/0mk976eWBQV38=; b=JSimt+qIrVJ6f24wn+oNyV/oCC6qMMSOC7Co5oGNvOltZAxbKCa8AMCRjJL6JHfw5E sb8D2ZALssM+S0YF9Drp9876gWqe+9ynsWno2A9sfV8fpiTshu/o54IjwVekVKW/KmYj 2jighc4GZ70nUltvnJQ76vFGRlaDexQr3J0X4fBWFOTww6pi52XsPagnv7P9V4K7Y4ov zY6UqyxQ8h1XLESYZ8/Bqma+zdhzOACleD6LMTZrG2ehFdyzQxONbsijgbMFw6pM93D3 eexQjuQQoas+CVzg8jsqPctO4vSwL6/cCoIQfMZaFW3iQVMSWqV1PYx+7ZHFfH3d9k2u xf9g== X-Gm-Message-State: APf1xPDQT8rFuOrzhZT/ziHZyy4hv8uGOz3Cy6WY1EQ1uDzDz2Mdwnd5 ZmuXtnw8VDUcqaO4Z8/E4aR2LA== X-Received: by 10.46.9.150 with SMTP id 144mr8531362ljj.117.1520192669597; Sun, 04 Mar 2018 11:44:29 -0800 (PST) Received: from kmp-mobile.hq.kempniu.pl (kmp-mobile.hq.kempniu.pl. [2001:470:64df:111::d0d7]) by smtp.gmail.com with ESMTPSA id v29sm2360510ljv.11.2018.03.04.11.44.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Mar 2018 11:44:28 -0800 (PST) Date: Sun, 4 Mar 2018 20:44:26 +0100 From: =?utf-8?B?TWljaGHFgiBLxJlwaWXFhA==?= To: Jonathan Woithe Cc: Andy Shevchenko , Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List Subject: Re: [PATCH 1/7] platform/x86: fujitsu-laptop: Define constants for FUNC operations Message-ID: <20180304194426.GA1428@kmp-mobile.hq.kempniu.pl> References: <20180227211539.5708-1-kernel@kempniu.pl> <20180227211539.5708-2-kernel@kempniu.pl> <20180304050813.GA3129@marvin.atrad.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180304050813.GA3129@marvin.atrad.com.au> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Wed, Feb 28, 2018 at 06:08:52PM +0200, Andy Shevchenko wrote: > > On Tue, Feb 27, 2018 at 11:15 PM, Micha?? K??pie?? wrote: > > > Various functions exposed by the firmware through the FUNC interface > > > tend to use a consistent set of integers for denoting the type of > > > operation to be performed for a specified feature. Use named constants > > > instead of integers in each call_fext_func() invocation in order to more > > > clearly convey the intent of each call. > > > > > > Note that FUNC_FLAGS is a bit peculiar: > > > > > +/* FUNC interface - operations */ > > > +#define OP_GET BIT(1) > > > +#define OP_GET_CAPS 0 > > > +#define OP_GET_EVENTS BIT(0) > > > +#define OP_GET_EXT BIT(2) > > > +#define OP_SET BIT(0) > > > +#define OP_SET_EXT (BIT(2) | BIT(0)) > > > > Hmm... this looks unordered a bit. > > It seems to be ordered alphabetically on the identifier. Andy, is it > preferred to order defines like this based on resolved numeric order? Just to expand on what Jonathan wrote above: if you take a peek at the end result of the patch series, you will notice a pattern: constants in each section are ordered alphabetically by their name. I wanted all sections to be consistently ordered. If you would rather have me order things by the bit index, sure, no problem, just please note that the order above is not accidental. > There is a lack of apparent consistency in the numeric mapping; for example, > OP_SET_EXT includes the OP_SET bit, but OP_GET_EXT does not include the > OP_GET bit. However, after inspecting the code I think this is simply > reflecting what the hardware expects. Exactly, I could not find any rule which would explain the way the integers hardcoded into the various firmware functions could be mapped to their purpose. The whole point of this series is just to give someone looking at the module code a quick hint about the purpose of each call; with plain integers used instead of constants, these calls look a bit too arbitrary for my taste. > > And plain 0 doesn't look right in this concept (something like (0 << > > 0) would probably do it). > > Given that all other definitions are in terms of BIT(), to my eye "(0 << 0)" > looks as much out of place as plain "0". However, if the convention in this > case would be to use the former then I have no objections. I presume the > "(0 << 0)" idea comes from the fact that BIT() ultimately expands to some > form of shift. Yes, I would guess so. The syntax suggested by Andy looked odd and superfluous to me at first, but grepping the tree for this construct seems to suggest that it is a pretty common thing. So no problem, I will tweak this in v2. I understand I should apply the same concept in these cases: +/* Constants related to FUNC_BACKLIGHT */ +#define FEAT_BACKLIGHT_POWER BIT(2) +#define STATE_BACKLIGHT_OFF (BIT(0) | BIT(1)) +#define STATE_BACKLIGHT_ON 0 +#define FEAT_RADIO_LED BIT(5) +#define STATE_RADIO_LED_OFF 0 +#define STATE_RADIO_LED_ON BIT(5) Right? -- Best regards, Michał Kępień