From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Murphy Subject: Re: [PATCH v2 3/9] soc: samsung: Add Exynos Adaptive Supply Voltage driver Date: Thu, 8 Aug 2019 13:48:24 +0100 Message-ID: <669c6b25-eb7e-ed3a-72a2-ee155a568363@arm.com> References: <20190718143044.25066-1-s.nawrocki@samsung.com> <20190718143044.25066-4-s.nawrocki@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org To: Krzysztof Kozlowski , Sylwester Nawrocki Cc: devicetree@vger.kernel.org, "linux-samsung-soc@vger.kernel.org" , linux-pm@vger.kernel.org, pankaj.dubey@samsung.com, =?UTF-8?Q?Bart=c5=82omiej_=c5=bbo=c5=82nierkiewicz?= , "linux-kernel@vger.kernel.org" , robh+dt@kernel.org, kgene@kernel.org, vireshk@kernel.org, linux-arm-kernel@lists.infradead.org, Marek Szyprowski List-Id: devicetree@vger.kernel.org On 08/08/2019 13:31, Krzysztof Kozlowski wrote: > On Thu, 8 Aug 2019 at 14:07, Sylwester Nawrocki wrote: >>>> +static unsigned int exynos5422_asv_parse_table(struct exynos_asv *asv, >>>> + unsigned int pkg_id) >>>> +{ >>>> + return (pkg_id >> EXYNOS5422_TABLE_OFFSET) & EXYNOS5422_TABLE_MASK; >>>> +} >>>> + >>>> +static bool exynos5422_asv_parse_bin2(struct exynos_asv *asv, >>>> + unsigned int pkg_id) >>>> +{ >>>> + return (pkg_id >> EXYNOS5422_BIN2_OFFSET) & EXYNOS5422_BIN2_MASK; >>> >>> return !!() for converting to boolean. >> >> I'm not convinced it is needed, the return type of the function is bool >> and value of the expression will be implicitly converted to that type. >> Is there any compiler warning related to that? > > Yeah, but bool is int so there will be no implicit conversion... I > guess it is a convention. In theory !! is the proper conversion to > bool but if bool==int then it's essentially conversion to 1. I am not > sure what's the benefit, maybe for some wrong code which would do > comparisons on result like if (exynos5422_asv_parse_bin2() == TRUE)... Not so - since we use "-std=gnu89", we have C99-like _Bool, which our bool is a typedef of. Conversions, either implicit or explicit, are well-defined: "6.3.1.2 Boolean type When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1." This is even called out in Documentation/process/coding-style.rst: "When using bool types the !! construction is not needed, which eliminates a class of bugs." Robin.