From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10444C433F5 for ; Sat, 14 May 2022 15:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233687AbiENPDE (ORCPT ); Sat, 14 May 2022 11:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbiENPDD (ORCPT ); Sat, 14 May 2022 11:03:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3BF62E6; Sat, 14 May 2022 08:03:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC5F860F90; Sat, 14 May 2022 15:03:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1C84C34115; Sat, 14 May 2022 15:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652540581; bh=jrynMDebaFTvWo4V2CiUg7ZFUbJHNgkLbj8yXQzhq1E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nzaMar0L++m05lyExWvFgD/W/tIxhcTWy41ETyJEBbv7uWrOONMCWuA9a5RqaOjMi 9ux04gKJ6v3SRU05gbdiv5nHJ5qkKfXFlcxSua9cLMicSRueOG6Zp4olEXhV6it8xV SPBZAaghxdG+1v1ieRxlgCj5Mwlphb4UjC+ASFm6bQtz1m1+upRq3zTV5qMrxL+Rg6 zI/ZTbfu0s5tgJ7ekl/1dHqctIyHsenn07VB+qseO8WJqMJMOrp2zYehMunGHN+SQQ d6QDQrmx1biMtJ/lIYlMnsmmtdPYY96n18NbrXYs/GD0vJB8TsB1LPf6qspos1YUXs SinN7pqOTm4Aw== Date: Sat, 14 May 2022 16:11:36 +0100 From: Jonathan Cameron To: Antoniu Miclaus Cc: , , Jonathan Cameron Subject: Re: [PATCH v2] iio: freq: admv1014: Fix warning about dubious x & !y and improve readability Message-ID: <20220514161136.772fd848@jic23-huawei> In-Reply-To: <20220511090006.90502-1-antoniu.miclaus@analog.com> References: <20220511090006.90502-1-antoniu.miclaus@analog.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Wed, 11 May 2022 12:00:06 +0300 Antoniu Miclaus wrote: > The warning comes from __BF_FIELD_CHECK() > specifically > > BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ > ~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \ > _pfx "value too large for the field"); \ > > The code was using !(enum value) which is not particularly easy to follow > so replace that with explicit matching and use of ? 0 : 1; or ? 1 : 0; > to improve readability. > > Signed-off-by: Jonathan Cameron > Signed-off-by: Antoniu Miclaus Thanks. Applied tot he fixes-togreg branch of iio.git. Thanks, Jonathan > --- > changes in v2: > - fix the logic for the input mode set bits > drivers/iio/frequency/admv1014.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/frequency/admv1014.c b/drivers/iio/frequency/admv1014.c > index a7994f8e6b9b..1aac5665b5de 100644 > --- a/drivers/iio/frequency/admv1014.c > +++ b/drivers/iio/frequency/admv1014.c > @@ -700,8 +700,10 @@ static int admv1014_init(struct admv1014_state *st) > ADMV1014_DET_EN_MSK; > > enable_reg = FIELD_PREP(ADMV1014_P1DB_COMPENSATION_MSK, st->p1db_comp ? 3 : 0) | > - FIELD_PREP(ADMV1014_IF_AMP_PD_MSK, !(st->input_mode)) | > - FIELD_PREP(ADMV1014_BB_AMP_PD_MSK, st->input_mode) | > + FIELD_PREP(ADMV1014_IF_AMP_PD_MSK, > + (st->input_mode == ADMV1014_IF_MODE) ? 0 : 1) | > + FIELD_PREP(ADMV1014_BB_AMP_PD_MSK, > + (st->input_mode == ADMV1014_IF_MODE) ? 1 : 0) | > FIELD_PREP(ADMV1014_DET_EN_MSK, st->det_en); > > return __admv1014_spi_update_bits(st, ADMV1014_REG_ENABLE, enable_reg_msk, enable_reg);