Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2447490rwi; Fri, 21 Oct 2022 04:05:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41SQAXeXR/yshSVR5NeWUcK1K6NX3wtXDE5GyIm4/gA+XBJwxSi9PiRhVE8LvT6u2fui3A X-Received: by 2002:a17:90b:3e82:b0:20d:2fa1:d08d with SMTP id rj2-20020a17090b3e8200b0020d2fa1d08dmr58467670pjb.162.1666350355626; Fri, 21 Oct 2022 04:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666350355; cv=none; d=google.com; s=arc-20160816; b=CkI2C5+5y6sX0RHmM85me6uXu0QoMpVB3chKKx9p9znuZgUfApvJh0ryK3VvlM36in 1IL7lXyH1I5+FyFORWK7QWFY+SywpN/37j0S6BvQptJkRpXkt8W8g1WcXxRrtLsEnLg5 81EVnCT67D3Z89GDT45IhpXajsIGIiEmQb4c3aaxMF+wQJSCCztM6lhft9mSkLizZL3l j6h7PTnjNPlONjE+B9ct2NAi9ved9ZbuLo0uTSdeNpiuSSQmJ8/Im5ihcvVd6K29Y3ym 6lEJryAaE/mvC1A7zzSv5Gpsd2icGv9OHuj2JMpcZTTCYnbG2zNA169uFtR2ZazD+5ru +bOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Z3a0xNztgetwF8HZWPI4kyyUqsikK1g0JT52UiPLwTM=; b=mF3gJJA/KFG8bv4wk/+9nJYFBEwAAknjh/JW9dThFv3aYpReN4FFF4Xun0YQ+KsVaG 1tRh68QHzeYzBd04SQi+t94Yyidj5tGlmnUez/QYzET6jjD7d3N4b3tpKL99wvxHlxrL dlmze3gVDftfce2mbyMnjP8mYH5hCjRauFjtFJfY/eNwLx1/vbmSjSWMMtDTW9E6Fmi7 ZCK7J45ipER4sEQhQ8miO8laJZKEItKaDBh/oyo64KpWZjk1tFUVfNKoWbE2fpVi7NqB GtgyZlvIo+DHHVcLvb5V64EOuiAO0hMg1y/frK3uXch1QkajHTx7eTpQUWX/NJ+tB5w7 HXRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a5P3ItN1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a17090a458d00b001fe280041e8si5984602pjg.37.2022.10.21.04.05.38; Fri, 21 Oct 2022 04:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a5P3ItN1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbiJUKuO (ORCPT + 99 others); Fri, 21 Oct 2022 06:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbiJUKtl (ORCPT ); Fri, 21 Oct 2022 06:49:41 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73FCBDE; Fri, 21 Oct 2022 03:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666349361; x=1697885361; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=w0a33PigWSTiQkXsbRap1wdMtX5M30vWOtN5yDWKwAk=; b=a5P3ItN1PE4ZxpTrwEnRlk4OKdTZiiNfH/3JYqmqsdzIDgL58H9F6iHn JhqTqTjndFgEJhHJhAAM+EbP9x1J70ClKUdsS2nE8jScRMzaQjVdYLG0g ZuIXRhbmT+I01cbBEnAN21T7lV8O+AggLcnpAExrMfxUc1BCN9Qj++ecc /RnxvGOzC29H2wsOczg9EQ/xcD5GiyR2ef9btyPyWf8w4YgFo+bJZ+uHj oh9vFoIm6GBKPzofUPtoRLv8M9p0V3deyvHR/Os2d4rJPoT32L8R5+BEk UV8RrlXCeep47fWGCfygL7KCvW6qLIGgMVCmIaBbPc/XNhBy1k2gewY5p A==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="308070032" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="308070032" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2022 03:49:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632863745" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="632863745" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga007.fm.intel.com with ESMTP; 21 Oct 2022 03:49:17 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1olpaV-00B6rD-0Q; Fri, 21 Oct 2022 13:49:15 +0300 Date: Fri, 21 Oct 2022 13:49:14 +0300 From: Andy Shevchenko To: Matti Vaittinen Cc: Matti Vaittinen , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Nikita Yushchenko , Dmitry Rokosov , Jagath Jog J , Cosmin Tanislav , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/3] iio: accel: Support Kionix/ROHM KX022A accelerometer Message-ID: References: <5000bd61650554658d13619c8244f02cedbc182a.1666263249.git.mazziesaccount@gmail.com> <2cad533d-32d1-5ca1-74e6-e2debcbdad81@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2cad533d-32d1-5ca1-74e6-e2debcbdad81@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 21, 2022 at 10:10:08AM +0300, Matti Vaittinen wrote: > On 10/20/22 17:34, Andy Shevchenko wrote: > > On Thu, Oct 20, 2022 at 02:37:15PM +0300, Matti Vaittinen wrote: ... > > > + ret = regmap_bulk_read(data->regmap, chan->address, &data->buffer, > > > + sizeof(__le16)); > > > + if (ret) > > > + return ret; > > > + > > > + *val = le16_to_cpu(data->buffer[0]); > > > > 'p'-variant of the above would look better > > > > *val = le16_to_cpup(data->buffer); > > > > since it will be the same as above address without any additional arithmetics. > > > > I guess there is no significant performance difference? To my eye the > le16_to_cpu(data->buffer[0]) is much more clear. I see right from the call > that we have an array here and use the first member. If there is no obvious > technical merit for using le16_to_cpup(data->buffer) over > le16_to_cpu(data->buffer[0]), then I do really prefer the latter for > clarity. Then you probably wanted to have &data->buffer[0] as a parameter to regmap_bulk_read()? ... > > > + if (data->trigger_enabled) { > > > + iio_trigger_poll_chained(data->trig); > > > + ret = IRQ_HANDLED; > > > + } > > > + > > > + if (data->state & KX022A_STATE_FIFO) { > > > > > + ret = __kx022a_fifo_flush(idev, KX022A_FIFO_LENGTH, true); > > > + if (ret > 0) > > > + ret = IRQ_HANDLED; > > > > I don't like it. Perhaps > > > > bool handled = false; > > int ret; > > > > ... > > ret = ... > > if (ret > 0) > > handled = true; > > ... > > > > return IRQ_RETVAL(handled); > > I don't see the benefit of adding another variable 'handled'. > If I understand correctly, it just introduces one extra 'if' in IRQ thread > handling while hiding the return value in IRQ_RETVAL() - macro. > > I do like seeing the IRQ_NONE being returned by default and IRQ_HANDLED only > when "handlers" are successfully executed. Adding extra variable just > obfuscates this (from my eyes) while adding also the additional 'if'. You assigning semantically different values to the same variable inside the function. -- With Best Regards, Andy Shevchenko