Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2028787ybh; Fri, 24 Jul 2020 02:35:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Vk1MjYnV4aujQQiuy9HjowVr9ry2Rba+OvuLM9eOyKZ14+dTaXuw2Y/AvaUpm5hVPgbv X-Received: by 2002:a17:906:3b91:: with SMTP id u17mr4137620ejf.305.1595583333954; Fri, 24 Jul 2020 02:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595583333; cv=none; d=google.com; s=arc-20160816; b=bfuUl8wg3RdrTNcuUOziqB0qyewO15fBrdyZ5LrqSoa2lKS/auCUCK7xcxbkfMqyDA ZSLI9m0c+/2IBQXr2y9nZ7ZkWYvF3EB5JOxUjcUjmKjiiZcVPiXcym3LBmGU7KXRkHWd g8CEzTXAVyz7dyzk/iU/ezi91hgLy+Tlp/2gkAh1XZX4tyNI1uYEqvFSLu6oYEnWAUCp vll72YfG1Y6i98eTE/UMPNhufvl/mBQUPsZf42F+XA1UzBck2Q+MAQFoTQlrc0lQ3HP9 uxRp4y5xHBn1qZ5Y2VsYjr8LA25IdeAPNJgVWW8CEWRcVTws75qEW0Bs222eXqfvBqe6 l+lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:from:references:cc:to:subject :reply-to:dkim-signature; bh=cEG7BQpwaqclOdMULlyZnXntoBpykQyiS6obi0d0nsg=; b=WEIMRqqZFpRJy8ywKAmhLZEBBT5YXeSnUQ6I1auTk0RSm4gJUdLqiPXvLBQ2MmB3Nd gbR739jR9SkztLsud9g5eXpy+slcCvHn54CCAOYtvJWYayQPiBFDQ1ils7u145EKUCPj H3oM1iEGL9hIPC85cS+R4vw84FBZh55Ghur1km/G31whJgWKxnx4IBAl+DocfYTWg6NA CxS0zfrH0RdvvAhmbEG+JnmjTwb1Ob6A17utuPJiVjXlvTnEOGb3FFzildTWFjyaxD1W YfwkBJMdUaxa90pxB81iMtYjwd//RFsho9LLS7GePD+9IIvlMUWtnhhPdCHXTksKeiYB acLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BkDiNIBu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a19si165520edt.160.2020.07.24.02.35.11; Fri, 24 Jul 2020 02:35:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BkDiNIBu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727012AbgGXJcV (ORCPT + 99 others); Fri, 24 Jul 2020 05:32:21 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:38330 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbgGXJcU (ORCPT ); Fri, 24 Jul 2020 05:32:20 -0400 Received: from [192.168.0.20] (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 14338538; Fri, 24 Jul 2020 11:32:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1595583135; bh=Cips7pSNDfpgtho04Lh5hkgIg9jLAxz9Mcu4eoJKuVk=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=BkDiNIBu4JegKCJlagORd38wBDCf/q38XsYr8zuBBtfqozbk6l1G2t8g1CabBy36Y 9gkHAUfJATMx/WTnK7/INcawcOn1d558KpBclNGYEbvMtdWQI/2bYC7u+J+Ufsf9zZ oKagvrLZc6f4Lq1NBTd2uwIBtQiRnFVSq5g813hE= Reply-To: kieran.bingham@ideasonboard.com Subject: Re: [PATCH v10 2/4] media: i2c: Add MAX9286 driver To: Sakari Ailus Cc: Kieran Bingham , linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Laurent Pinchart , Jacopo Mondi , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Hans Verkuil , Hyun Kwon , Manivannan Sadhasivam , Rob Herring , Linus Walleij , Jacopo Mondi , Laurent Pinchart , =?UTF-8?Q?Niklas_S=c3=b6derlund?= References: <20200612144713.502006-1-kieran.bingham+renesas@ideasonboard.com> <20200612144713.502006-3-kieran.bingham+renesas@ideasonboard.com> <1fb4a023-d177-744f-41f4-755aafbfa7f2@ideasonboard.com> <20200723222834.GC829@valkosipuli.retiisi.org.uk> From: Kieran Bingham Autocrypt: addr=kieran.bingham@ideasonboard.com; keydata= mQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat V/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC rRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C potzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ cSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf Kr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+z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B7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp ECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx S0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j sbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8 pQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc MW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU AfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4 WZw01QYHU/GUV/zHJSFk Organization: Ideas on Board Message-ID: Date: Fri, 24 Jul 2020 10:32:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200723222834.GC829@valkosipuli.retiisi.org.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sakari, On 23/07/2020 23:28, Sakari Ailus wrote: > Hi Kieran, > > On Thu, Jul 16, 2020 at 10:02:24AM +0100, Kieran Bingham wrote: >> Hi Sakari, >> >> This is the output of checkpatch --strict on this driver. Sorry for not >> detailing this in the commit or cover letter. > > No worries. > >> >>> ./patches/gmsl/v10/v10-0001-dt-bindings-media-i2c-Add-bindings-for-Maxim-Int.patch has style problems, please review. >>> -------------------------------------------------------------- >>> ./patches/gmsl/v10/v10-0002-media-i2c-Add-MAX9286-driver.patch >>> -------------------------------------------------------------- >>> CHECK: Prefer using the BIT macro >>> #246: FILE: drivers/media/i2c/max9286.c:40: >>> +#define MAX9286_FSYNCMODE_INT_OUT (1 << 6) >>> >>> CHECK: Prefer using the BIT macro >>> #251: FILE: drivers/media/i2c/max9286.c:45: >>> +#define MAX9286_FSYNCMETH_SEMI_AUTO (1 << 0) >>> >>> CHECK: Prefer using the BIT macro >>> #262: FILE: drivers/media/i2c/max9286.c:56: >>> +#define MAX9286_EDC_6BIT_CRC (1 << 5) >>> >>> CHECK: Prefer using the BIT macro >>> #268: FILE: drivers/media/i2c/max9286.c:62: >>> +#define MAX9286_HVSRC_D14 (1 << 0) >>> >>> CHECK: Prefer using the BIT macro >>> #286: FILE: drivers/media/i2c/max9286.c:80: >>> +#define MAX9286_DATATYPE_RGB565 (1 << 0) >>> >>> CHECK: Prefer using the BIT macro >>> #304: FILE: drivers/media/i2c/max9286.c:98: >>> +#define MAX9286_I2CSLVSH_469NS_234NS (1 << 5) >>> >>> CHECK: Prefer using the BIT macro >>> #312: FILE: drivers/media/i2c/max9286.c:106: >>> +#define MAX9286_I2CMSTBT_28KBPS (1 << 2) >>> >>> CHECK: Prefer using the BIT macro >>> #316: FILE: drivers/media/i2c/max9286.c:110: >>> +#define MAX9286_I2CSLVTO_256US (1 << 0) >> >> None of those are appropriate to use the BIT() macro, as they are all >> entries of a specific field with a shift, such as: >> >> #define MAX9286_FSYNCMODE_ECU (3 << 6) >> #define MAX9286_FSYNCMODE_EXT (2 << 6) >> #define MAX9286_FSYNCMODE_INT_OUT (1 << 6) >> #define MAX9286_FSYNCMODE_INT_HIZ (0 << 6) >> >> Checkpatch is only picking up on the "1 << x" variant of each entry. > > Ideally you should use "1U << x" everywhere. If you happen to have a > register with 31st bit signifying something, mayhem would follow. So the > practice is to make all such definitions unsigned. Just to clarify, because of the location you've put your x, which is not the variable in the above case. These definitions are possible field values with a shift (enum << y), not bit values (1 << x) They can of course be unsigned though. Is your statement that you would like to see these as: #define MAX9286_FSYNCMODE_ECU (3U << 6) #define MAX9286_FSYNCMODE_EXT (2U << 6) #define MAX9286_FSYNCMODE_INT_OUT (1U << 6) #define MAX9286_FSYNCMODE_INT_HIZ (0U << 6) Or that you would prefer a macro'ised version: #define FIELD_ENTRY(value, shift) (value U << shift) Or rather, I could just convert them all to use FIELD_PREP: #define MAX9286_FSYNCMODE GENMASK(7,6) #define MAX9286_FSYNCMODE_ECU FIELD_PREP(MAX9286_FSYNCMODE, 3) #define MAX9286_FSYNCMODE_EXT FIELD_PREP(MAX9286_FSYNCMODE, 2) #define MAX9286_FSYNCMODE_INT_OUT FIELD_PREP(MAX9286_FSYNCMODE, 1) #define MAX9286_FSYNCMODE_INT_HIZ FIELD_PREP(MAX9286_FSYNCMODE, 0) If you want me to change these entries, I suspect moving wholly to use FIELD_PREP/FIELD_GET throughout the driver would be the best course of action. A bit of churn, but I can do that if you wish. -- Kieran >>> CHECK: Macro argument reuse 'source' - possible side-effects? >>> #399: FILE: drivers/media/i2c/max9286.c:193: >>> +#define for_each_source(priv, source) \ >>> + for ((source) = NULL; ((source) = next_source((priv), (source))); ) >> >> This warns against possible side effects, but the 're-use' effects are >> desired ;-) >> >> If you'd prefer this macro to be re-written please let me know. > > Works for me. Some warnigns are just not useful. I bet quite a few macros > elsewhere in the kernel would trigger this. I think we'll just leave this one ;-) >>> CHECK: Lines should not end with a '(' >>> #1372: FILE: drivers/media/i2c/max9286.c:1166: >>> + ret = v4l2_fwnode_endpoint_parse( >> >> Full code block: >> >>> ret = v4l2_fwnode_endpoint_parse( >>> of_fwnode_handle(node), &vep); >>> if (ret) { >>> of_node_put(node); >>> return ret; >>> } >> >> That one is awkward, and I chose to keep it as a lesser evil. >> Of course now that we can officially go up to 120 chars, I could move >> this line up. >> >> If you'd like this to be moved to a single line now we can go over 80 >> chars, please confirm. > > I don't mind that. Mauro, any thoughts on this? And I'll let Mauro decide that as it will impact my line-length choices in the future ;-) -- Regards -- Kieran