Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2457287rwi; Fri, 21 Oct 2022 04:12:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eP6bHLAjOkcAYHLFuNuhO1uA8FRo1ODW0/SNDSxCxSS4uf1VWIIigHXBpTUn56i/ai5cu X-Received: by 2002:a17:907:97cc:b0:797:c389:de5f with SMTP id js12-20020a17090797cc00b00797c389de5fmr6352804ejc.627.1666350755550; Fri, 21 Oct 2022 04:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666350755; cv=none; d=google.com; s=arc-20160816; b=FZskVHmC8GAm92jp4jnSl5sKHr8v1xOvptaOMittgr6ElfKkML4K8914MBGpdAa9zG Uu70HuZ8XLurj8+amiUijutVm9hwPfVC81NJiNdZH3aqCEuP2N+VW8aK7JteMOuEJQfB 2bwSSwrwZw1ymFeNoFfBkuFbwvX5l/K1rRYYtW3GpeXMo8PG8IJbbWASCY6/5oaemd1a m8zN9ZPhimzOmt7a5bKEHSBvdgfCCFCSGwv0umfP68ArAmEy8Xs5ggH/GscNfTKRi/2V fmzOl5PUo6jf7ZPzzbI3pnxBJnkOzWkKy7FVRQf7epE3BCiqSXTivZUupsQbh+FToo6S 7Tjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=SFdV7NP8C6yU75td1dUeGU+HXX+EEy+aRc6V3zFsqbQ=; b=bvZqTkOJ7E9eNfKUh/trA6+8vo+NSHLNAJWf0xcYVAIa7KNv7014pQGLEYLuGjvmWQ be2+HAP4CcaHWSoGE3iNtru6YswrzQTgdxlEolKztZAxyHzZtOOPVYNUQkW49Q1Ru5me dBynv75K1IrGnhdTNKK3swpJA61utgjaS4CRY0jsUx2/x8NVZnQg7U3tJj+LVRG4ja+p KSZpDgi7Ny69ftLFn+ylB6sqnOhHty4EMuOaDIfHLygeZaCHUKRb0o91A1PBcR1lx0lc 7RjyvK4GW1Q6I2qdmZWCkyeintO964AvoN8RchBZhfPsMI6j5C2QTceRtO3GSkqdFwZs HvMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TbrKe9Qg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a50eb84000000b0045a26e5d4b6si17861558edr.78.2022.10.21.04.12.10; Fri, 21 Oct 2022 04:12:35 -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=@gmail.com header.s=20210112 header.b=TbrKe9Qg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbiJULCP (ORCPT + 99 others); Fri, 21 Oct 2022 07:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbiJULCM (ORCPT ); Fri, 21 Oct 2022 07:02:12 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63EC725CD9D; Fri, 21 Oct 2022 04:02:11 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id bu25so4503019lfb.3; Fri, 21 Oct 2022 04:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=SFdV7NP8C6yU75td1dUeGU+HXX+EEy+aRc6V3zFsqbQ=; b=TbrKe9Qg0GPwKzMi3kwTM4dL5RNZV1TQ5V11/AQn2rXbqCq4oBbY0SSCJPub7j+C73 jWdO5tOoH6ji0OOtj4jwOpsmZbhta54THzLL00sHw6F1SP55asX4yHfgsO4gWslOISiA U6b2Ome03rzJjYqNZot8UjOHnClqQXxa4O6Vx9dO/e/0l6JrCA8TOyp/GrJEF1XeX+hK ChYX9++MUSiyCmk+BaC4YitsXyooNPNaq5BH+ymjseOBUs8MFG91V/hC5S2UB6WbbKUB dP4vD7szodW+LiEN4HsiYeEWEIlHVe4mNQUj014q262hTaV53KDdwzbpDCCuh6Ch4mb2 GrcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SFdV7NP8C6yU75td1dUeGU+HXX+EEy+aRc6V3zFsqbQ=; b=tylJ2ImkStjRM/TjULMQh7zwCftG+mY7kIz5T84trhr2N9PJumilSUk2hBZp/ueo24 UNtbz5bhxQyp5Ye+J3vk2/MacANh3xMeBACbPt9mQMYYOzBt2Yl8CSy5Qy+4mobFRGz1 tO7bkpkG2KT29+FgcJ9SZ56zeWwHJdXDZ4ymSg0vmId2s2GQYVm0hg4cYnynAIAFZUqT G4i/M+9DhUjBaJel+8oXOPOHIqPtwiCMBwELlqjy8cGk5UfezzW/FVaIW5d52I5ZbOi2 2pOmZ7DFoyDUN7kI4Qvb0gNvt+BeEgE0SmBCwd5uy8RmUNzJEMnXuVbzWqL0BzuElM/5 26tw== X-Gm-Message-State: ACrzQf2t0x9Gt9tUd/tGhAXGJXtZ0c0XZepdd7EMl56raFnsF5K9BsHP BbVovuEPd6fZJq88hNWTAFw= X-Received: by 2002:a19:8c5e:0:b0:4a2:2d7b:eef with SMTP id i30-20020a198c5e000000b004a22d7b0eefmr6294463lfj.206.1666350129577; Fri, 21 Oct 2022 04:02:09 -0700 (PDT) Received: from ?IPV6:2001:14ba:16f3:4a00::2? (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id q2-20020a2eb4a2000000b00275aeff36dbsm379738ljm.110.2022.10.21.04.02.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Oct 2022 04:02:08 -0700 (PDT) Message-ID: Date: Fri, 21 Oct 2022 14:02:08 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-US To: Andy Shevchenko 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 References: <5000bd61650554658d13619c8244f02cedbc182a.1666263249.git.mazziesaccount@gmail.com> <2cad533d-32d1-5ca1-74e6-e2debcbdad81@gmail.com> From: Matti Vaittinen Subject: Re: [PATCH v3 2/3] iio: accel: Support Kionix/ROHM KX022A accelerometer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 10/21/22 13:49, Andy Shevchenko wrote: > 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()? Yes! Thanks. > > ... > >>>> + 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. Ah, yes! This was really a bug making it way in. I guess you may just have saved me from some not-that-funny debugging session... Well spotted! I still don't like hiding the IRQ_HANDLED / IRQ_NONE. I'll just go for if (data->state & KX022A_STATE_FIFO) { int ok; ok = __kx022a_fifo_flush(idev, KX022A_FIFO_LENGTH, true); if (ok > 0) ret = IRQ_HANDLED; } for v4. (Which I try to send still today before my memory is flushed by the weekend :]) Thanks a lot! Yours -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~