Received: by 10.223.185.116 with SMTP id b49csp4281653wrg; Tue, 6 Mar 2018 13:00:39 -0800 (PST) X-Google-Smtp-Source: AG47ELtg7I+yrZ03GolcA0Xdbc8TympX1g8RRmofVWALAdR3WfqEAs26HwhuEGj5iZLpjbHtQne0 X-Received: by 10.99.139.199 with SMTP id j190mr16334714pge.334.1520370039142; Tue, 06 Mar 2018 13:00:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520370039; cv=none; d=google.com; s=arc-20160816; b=AS4JAV7AabP4PifaW9qNQOzYHhlo/4f3hHjUP9klgrenWPwx8Jp8Giv5xjCt3YMwCN whv4a3VuV5QXcsGKZIPAZdahDjyzUIquh4u5RtFqdUw4nBUz7RKzH4R6yYF+OekGAAvZ kwX0qRK1qlN+/DAbfe23DWMqnCtHsM5JVL62+VX2NNPAJbFBfK8rtkW732qpw6EKwmUT QEreMwZ+nBdEeSX3m4DJkjiGBiiO6VPBO4OimKvkLkNOEnokdxRstEJfOi0I3XRRZ3Uj VkkLmD8HJvUWZ4+/a1DQnzbnckdzC18F/9ECCGvWOM9YTylNRSwu+bVyLx58WD6Pp17V 69nw== 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=sWKBa81kSMcTJOwK7Jae4xzE/M1TVLhQG/rfC0ShLsY=; b=LqnMRBG06ks0y2q2YXGd08yKscxcd+Tk5gth1TwA/X/x2YPyk6kezQgwui4C5R/pa/ TvN4XMY9xh1SOFgcXRi86x99OGMQy6oq+J1dBb4I59SjhY7Cwr4nCpYI74GqUHQRNcbO SYboVgT0xW+eHtBzal137JIzr5Jx1HNKEnd8Kp9LHzI5PLf+1ioux3EKReNo6hPP9/Lt oI4qP1t9EI0/ACr5EQvzhKLMQpZHIFRXsdxb3VD4w1F+YL2mhAxkvIefPcUyEtgHfWXx 1+IiupMJUUFmODKIIpszpZEPWdoWCbTdBsc+ZZH6BSlg36UXKlvsZPn4ofu6JN8z2jLB bajA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kempniu.pl header.s=google header.b=BrIeouLY; 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 w12-v6si11784725pld.51.2018.03.06.13.00.24; Tue, 06 Mar 2018 13:00:39 -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=BrIeouLY; 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 S1754032AbeCFU70 (ORCPT + 99 others); Tue, 6 Mar 2018 15:59:26 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:35705 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753871AbeCFU7Z (ORCPT ); Tue, 6 Mar 2018 15:59:25 -0500 Received: by mail-lf0-f53.google.com with SMTP id 70-v6so34392lfw.2 for ; Tue, 06 Mar 2018 12:59:24 -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=sWKBa81kSMcTJOwK7Jae4xzE/M1TVLhQG/rfC0ShLsY=; b=BrIeouLYJily0JMJ0sxDllXftFCyHVuyYQqMg3UtwqXIXTva5XvEE66VewAm0GuNw6 bWBFcHhWfD2f/6qZ+P48Pd+Alwwa+Vc6vcnrO/csff8QMITicnXw0hYAq9JJNQlVHh4R 6YLyNMY1NCUi2x96UzSy26w5OqpM81pTCzIxY= 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=sWKBa81kSMcTJOwK7Jae4xzE/M1TVLhQG/rfC0ShLsY=; b=QuUhP5aoNZR0f7bVvaT8eo20PM7bV7VAG5LSm5FBioqcPc5Nt7uPAFD88p5UuHZ3GQ LwBLQI8S9sWI8ixA4pZZ9NEsOUkFrMUiaS5AM6gR1Sl+N1i519A9d5drJVavqzoubVty pODChC5n/zR9CDymHj9+Z1SxRWCmAqYNOrBlaGRmGFSIvflveHWNiVS8ShvTJJpUUQDu 7gGiKOuUaBtRhQjepvkLUC9G28amy1diasfLP3yju9Ks2RFlX0gHWUEXM//w6qiMnIFU wCWiwiIezgzWkqsF1hVzLO8jjyO+u+wQOBSjhAxxKI77BAoR7YjV09PN/bUEwUyPe164 DEHg== X-Gm-Message-State: AElRT7HFuiVTGe67+J+JTHfVJWvwj98KliDQ7lInkqBKE438EAI0trFW WeK8eWVphluryZEisgsz0ZaIvqXi X-Received: by 10.46.93.69 with SMTP id r66mr13606142ljb.88.1520369963641; Tue, 06 Mar 2018 12:59:23 -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 o14sm2697121ljc.52.2018.03.06.12.59.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 12:59:22 -0800 (PST) Date: Tue, 6 Mar 2018 21:59:20 +0100 From: =?utf-8?B?TWljaGHFgiBLxJlwaWXFhA==?= To: Andy Shevchenko Cc: Darren Hart , Jonathan Woithe , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List Subject: Re: [PATCH 1/7] platform/x86: fujitsu-laptop: Define constants for FUNC operations Message-ID: <20180306205920.GA786@kmp-mobile.hq.kempniu.pl> References: <20180227211539.5708-1-kernel@kempniu.pl> <20180227211539.5708-2-kernel@kempniu.pl> <20180304050813.GA3129@marvin.atrad.com.au> <20180304194426.GA1428@kmp-mobile.hq.kempniu.pl> <20180305231650.GA25693@fury> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy, > What I'm trying to tell is about consistency of style. I completely agree with all you wrote, those are all good suggestions. But you started your reasoning with: > So, imagine if we have two bitfields in some register, one with one > bit and the other with two. We are not looking at a hardware register here. Rather, I am trying to bring at least _some_ order to an arbitrary set of values that the vendor assumed would be fun to scatter around a dozen of firmware functions. Some hardware features are controlled by setting a specific bit in the value being passed to a function; in other cases entire integers are taken into account; in yet another case *two* bits in a value control state. There is no reason or order to be found here. In the case of OP_* constants, perhaps the simplest thing to do would be to define them as integers, not bitfields. But that still results in a mess: #define OP_GET 0x2 #define OP_GET_CAPS 0x0 #define OP_GET_EVENTS 0x1 #define OP_GET_EXT 0x4 #define OP_SET 0x1 #define OP_SET_EXT 0x5 or: #define OP_GET_CAPS 0x0 #define OP_GET_EVENTS 0x1 #define OP_SET 0x1 #define OP_GET 0x2 #define OP_GET_EXT 0x4 #define OP_SET_EXT 0x5 Even worse, what am I supposed to do with crap like radio LED control, where 0x20 (bit 5) is passed in one argument to select the desired feature and 0x20 or 0 is passed as another argument to select the desired state of that feature? How do I name and define constants that I can subsequently use in call_fext_func() invocations to spare the reader the need to learn the hard way that this: return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON, 0x0); is actually supposed to turn the radio LED *off*? This is the best I could come up with: #define FEAT_RADIO_LED BIT(5) #define STATE_RADIO_LED_OFF (0 << 0) #define STATE_RADIO_LED_ON BIT(5) Yes, it is ugly. But the resulting call is (IMHO) a lot more clear than the original one: return fext_flags(device, OP_SET_EXT, FEAT_RADIO_LED, STATE_RADIO_LED_OFF); All of the above is why I was inclined to just use alphabetic ordering for all constants defined in fujitsu-laptop. This approach brings at least _some_ consistency to this mess (which only the vendor is to blame for, of course). If you would rather have me take a different approach, I am all ears. -- Best regards, Michał Kępień