From patchwork Wed Aug 9 19:11:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp45730vqi; Wed, 9 Aug 2023 15:28:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIDXrPft36xPlLjUt+7MDTM2NgWzVjtlRxGCSJNrPVNNdBCA1ybhWlSXMecxcLvwDYJo90 X-Received: by 2002:a17:906:4d1:b0:98e:2b01:ab97 with SMTP id g17-20020a17090604d100b0098e2b01ab97mr329407eja.68.1691620085151; Wed, 09 Aug 2023 15:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691620085; cv=none; d=google.com; s=arc-20160816; b=XJt5f1zrjttWwvScmO+56Ro9WrwF1EuoHCnSK1aACEH09okrIAeHFPQcqAIPBTcdlm /v/BWKvgpwHJKcBnq5tnnpa0BMLQ++NZGFhlNvdyffjENzOd4MdaL8kj+sZ5q43G8ZHM V3J/5SxLAfv9zhuNGkO6e94VjOqwMW0bwk2nIlZMe8RUDHaI/S2KRIe5C+Tq4Syiuk61 CldIBGLhgT9OnInYPlZaL9TRQFeqlAOKYcP995ojRUoV/atfiGRLqL2civnV2AZnD6MQ rXH7+iQ/bTrYkfLU8fVg1EGMaoOOoaJTUDUpyiMmUw5FLrr6s5i5RT1JBSD2PIUZSwhO Z2+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hHOxYEOCiaK7yG+Kbl87/DBR8ScHUJdXSuGCuLAA+rY=; fh=i6Yy972OO273jc6nhvXsVnJz9vndMdlyv2i9YjwnXJ0=; b=eE8MDpcUzGUljxnDsO1rQDucDByJvfjojbyTigG2im2NEYuGeoQr89aVv1qtJ/qqCd ekr3kRU94rZ0iLP6P/cdvHJU6gGHHyzJJ7LxJZ3pVgqy2nxuldA/D1YVYZ5OWWMrrxbq G7bQHOgDnnp9W/N78JpL0IYNVtKDqt/qFiAnpbfCbiaMQlDs8oDeA+BQaouW0xId9z6r j7JsEFhfLJ3NDpcoYjZct4nDv/fa61kAJozHlNPzJPGHCx4z1Axilsgrvo7F/IyKjHy9 m+RZjwaIp0MURcWeJ0SYcr9NOU9eELOS1BIC1hehbJt0N/4GOczviSwSqngACsrbQUVi CGww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="QlsqP/Vo"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id os6-20020a170906af6600b0099b41f2c735si147798ejb.921.2023.08.09.15.27.38; Wed, 09 Aug 2023 15:28:05 -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=20221208 header.b="QlsqP/Vo"; 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 S232135AbjHITMR (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233059AbjHITLy (ORCPT ); Wed, 9 Aug 2023 15:11:54 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3EC82683; Wed, 9 Aug 2023 12:11:51 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3110ab7110aso167684f8f.3; Wed, 09 Aug 2023 12:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608310; x=1692213110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hHOxYEOCiaK7yG+Kbl87/DBR8ScHUJdXSuGCuLAA+rY=; b=QlsqP/VoV81B2dlMesBtI3mtix4KC3W2Qi+yda7E+MGj6TQgQhG0ANxw2CRtgOObYs eloWWS5x3MFaF+jGHl2ZQLoM30nSn3A56MjvSotZQ1ho/cSPKxSMAbBwhmOdZsKHJcXr 0AZuFcA+SWbf/oqFtNqvpfeXJF1s26z59L+n2AyZzmRFTFOMOf9286DKT861Fl8oam+0 lwtSq1k7TeLDHhobEW0Ne1pZEKws4uUyCEB4pln8of74IebkVuS0UbeFkJ1fsnanklzf /lWRhj0hht26KpJF8blUgzkqIMReV9TkdANFO7R2Zj1pidqKH6wVeNgcKTowyL1RJWz/ 4+8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608310; x=1692213110; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hHOxYEOCiaK7yG+Kbl87/DBR8ScHUJdXSuGCuLAA+rY=; b=DE6uBgMO90FgcFiVIM2xQmiQLuK/kA8n4YT45ZUTzB/eXr8rj9Vfg3M/B1JO2H8poM nwN5OoSigvWtfxd9ClJZRNISj3A71+S7xgP+rn9NUeivs5crPXQptpOfAtT1Mb4J3/5V UrAwc34jI2Sx2uY/AUUlJBTZPy0FU/z5OZULetq61kqjMNGxgb7QWbx/+e+lsu8qOeap BGGZWgpg4gwX+6hh7OpjlDoF2nU0HhnaswNSwMGBH9VBogltajXmNNVFRvcEEbrtT7pi 68ulb3pcl7r2UyXvrIFIcL25gXZs80ezixQtNSZapqM7xBtliH+B3e4DuRxvnqpFN5b/ 7teg== X-Gm-Message-State: AOJu0YwmtDOX2gfo60hjrBFjm7AddhqGJxMqdizOlhdBsw1/Z5H4hfQO ZEn4k7O4Mwgt412PYFFen5ZajZncl5Y6cA== X-Received: by 2002:a5d:6091:0:b0:317:6704:72c with SMTP id w17-20020a5d6091000000b003176704072cmr211016wrt.52.1691608310304; Wed, 09 Aug 2023 12:11:50 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:11:49 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait , Krzysztof Kozlowski Subject: [PATCH v7 1/7] dt-bindings: iio: Add KX132-1211 accelerometer Date: Wed, 9 Aug 2023 21:11:32 +0200 Message-Id: <0d6051ad217f91c7de0883c4ca1516bdacc343ce.1691607526.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773792222403859776 X-GMAIL-MSGID: 1773792222403859776 Extend the kionix,kx022a.yaml file to support the kx132-1211 device Acked-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: v6: v5: v4: v3: - no changes v2: - made the device name more specific from "kx132" to "kx132-1211" - removed the output data-rates mentioned and replaced them with "variable output data-rates" .../devicetree/bindings/iio/accel/kionix,kx022a.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml index 986df1a6ff0a..034b69614416 100644 --- a/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml +++ b/Documentation/devicetree/bindings/iio/accel/kionix,kx022a.yaml @@ -4,19 +4,21 @@ $id: http://devicetree.org/schemas/iio/accel/kionix,kx022a.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM/Kionix KX022A Accelerometer +title: ROHM/Kionix KX022A and KX132-1211 Accelerometers maintainers: - Matti Vaittinen description: | - KX022A is a 3-axis accelerometer supporting +/- 2G, 4G, 8G and 16G ranges, - output data-rates from 0.78Hz to 1600Hz and a hardware-fifo buffering. - KX022A can be accessed either via I2C or SPI. + KX022A and KX132-1211 are 3-axis accelerometers supporting +/- 2G, 4G, 8G and + 16G ranges, variable output data-rates and a hardware-fifo buffering. + KX022A and KX132-1211 can be accessed either via I2C or SPI. properties: compatible: - const: kionix,kx022a + enum: + - kionix,kx022a + - kionix,kx132-1211 reg: maxItems: 1 From patchwork Wed Aug 9 19:11:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3034426vqr; Wed, 9 Aug 2023 12:47:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3+O3HrBUnfQqVCR0lLRzHP31JKp/MfuoI3wV2AetUbD/FvVIpDM8StnVFmEEMNmEcWE34 X-Received: by 2002:a2e:990e:0:b0:2b9:453f:a383 with SMTP id v14-20020a2e990e000000b002b9453fa383mr143005lji.53.1691610471681; Wed, 09 Aug 2023 12:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610471; cv=none; d=google.com; s=arc-20160816; b=fWfx+F4dX1ZWZKWoqAP/Ay0EPX6tF8MIML61NhBc/GnIIR6czoFvvwpkwZlM7MiZq0 dSQgjmy7QweGXGexx6csnXhsm9E3xH1UJoEDzlEULfM/HHh/rX/RE4fh58QE+Z/rhTdE U14o7iFDs8ywEYKlVgoLLaZb6QBBWa95GeRQzcvUc9ODhoRzNcaQnVe6ix1dfSXKxIQf xNTtNGULrRcNZr2Y5yGEu2dLQZJbRDIl//EUdd861iUB3A6eEPUan9t5A/gV4VxiWaWj TjEtWbUScklClPI0LuFmgAagxF0oqc84hm6NBVJB+G5RdykOlSqw26Hueeo3M5CQlqJP 1rkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+PqilpSUTkskM+irx4vldFIwieHe/2PupeTH8Per9To=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=FbbcsVCnj2S22D2EtsFL7tgXQwaPzzg2reEp6RzMcxx/nLIJq/fVzL0MqfROzvt4Gu 6zO1Bm13fgcLritk+k3JUccJsfKK0pnnQqGxWfefwx2DPlEr12sUPjure9/hXsp6eoUY pUzynQ078qY6z1LEVopvfUwDXiq2VInVzwH3Y+eHAiHEaJbClWmPfAU3lRuwQ0IhAL0t abo65K6AYTp4MB/B8/K4nVZXsvOonaMF4rZ33BMTySFVcHvwiaseNuQ6tzblnEd3qj5z ZIQiswaZDWooVE8CHM0N0sIqn3HuPgQigA+QNLs2mP+QgRdMHwdXE5Zfn+DzzMFCEBJX QplA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=F2XvfTVM; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p14-20020a170906838e00b0099363f18293si7085833ejx.124.2023.08.09.12.47.27; Wed, 09 Aug 2023 12:47:51 -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=20221208 header.b=F2XvfTVM; 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 S233293AbjHITMP (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjHITL4 (ORCPT ); Wed, 9 Aug 2023 15:11:56 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FD572697; Wed, 9 Aug 2023 12:11:54 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-317c3ac7339so190161f8f.0; Wed, 09 Aug 2023 12:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608312; x=1692213112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+PqilpSUTkskM+irx4vldFIwieHe/2PupeTH8Per9To=; b=F2XvfTVMThkpml7GfTzYiNS5SwGN2I3hdtDs/xhBN+cNW50SAhKj3XK9W0JRnKbbQ5 L185/XbGhDAz+kmkf8vV71gU+X00S+3gJAyDgGREGiLu/l8Fw9wGz/EUS+WS595z9wk+ pxDAMbogfabBJLZZ2uQdvfX2rg+7jWoHNRVn7EhV7NpY7IIS0y62Y7wbBXrUXwQ7Jtw2 uAI3pneGm+EKxCjTc9xBJKDCpGJJ2bV+n3y3vb+Rh+1wG6JMfK4vljyEHEDzqyBxOi8s GROvmK2t/ETeli6wParrzol2jb55LTviB9fwFto8SHqqmPWRiwnCk8YxNHR1kL+emJkt t9hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608312; x=1692213112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+PqilpSUTkskM+irx4vldFIwieHe/2PupeTH8Per9To=; b=S32ASy43v9wobYDoZoPQl8mUr83yp1G6aGtMVsga5xbrd1nMkPZ4NyYnVZgCfvzkzA hL2GhPy9+BrtUwElUSRm8NjaFmwi3Zc9M/QGlyBsz88V7IFbsxCw/YWgbnwcQK5dEn+D InZ97Ie8jMTLNqivq0ZdsonfJoh1qm6zw156aerG5cjsP7ZZAkblcc4vSZDGgi6Beo9V RgBccwqL8wbOEsspP++h2MLtHZmYSwVXU4CoAHDKC6ALnLjgBjZLqlAVJCNRnB6syoVW pTksycNAzbeCqJlmb7aQ87OUzl2ttpucFigLT1G9KCfRNBqpx/sh2WsmCbbjJrcQ4DzX u81Q== X-Gm-Message-State: AOJu0YynXRWdnGerq3XwT148lVp65vogiKo47VJeDXFMwcBXVy4wxWS3 uUFThgk9s62Bzg6PU/dGmM8UzW7O5JNtZQ== X-Received: by 2002:adf:fd44:0:b0:315:a91c:1a8c with SMTP id h4-20020adffd44000000b00315a91c1a8cmr223155wrs.22.1691608312341; Wed, 09 Aug 2023 12:11:52 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:11:52 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 2/7] iio: accel: kionix-kx022a: Remove blank lines Date: Wed, 9 Aug 2023 21:11:33 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773782141887441272 X-GMAIL-MSGID: 1773782141887441272 Remove blank lines pointed out by the checkpatch script Reviewed-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: v6: v5: v4: - no changes v3: - no changes, this patch is introduced in the v2 drivers/iio/accel/kionix-kx022a.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index f98393d74666..ff8aa7b9568e 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -341,7 +341,6 @@ static int kx022a_turn_on_off_unlocked(struct kx022a_data *data, bool on) dev_err(data->dev, "Turn %s fail %d\n", str_on_off(on), ret); return ret; - } static int kx022a_turn_off_lock(struct kx022a_data *data) @@ -1121,7 +1120,6 @@ int kx022a_probe_internal(struct device *dev) if (ret) return dev_err_probe(data->dev, ret, "Could not request IRQ\n"); - ret = devm_iio_trigger_register(dev, indio_trig); if (ret) return dev_err_probe(data->dev, ret, From patchwork Wed Aug 9 19:11:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3032654vqr; Wed, 9 Aug 2023 12:44:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLmY8X0/kiCNjel9w1hgaQ+idBkeRwl7/ssA5cL/arLDxKQtw/1VX8rXSqfdGyABA+XhhF X-Received: by 2002:adf:f20e:0:b0:317:6175:95fd with SMTP id p14-20020adff20e000000b00317617595fdmr299326wro.43.1691610240235; Wed, 09 Aug 2023 12:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610240; cv=none; d=google.com; s=arc-20160816; b=vK6CmEWTnY77NALLGXspkRXP+PT/V+wHR3NtMB4H29gTSThB8u1Nr8w0VuxvFatWNi a2djVRYlDMFF/TCBUL98BR9ugYQP34rQ+Lj578qnb/9KB88yEijxCm04VP4mZN40yw9R wZoDiNdSTiMQ1vefHEX2zbPcqa4/TsYKsBML2catd4qjzNUEGncuqcM/Mzw/LqqJKkix lf2y+HwfasLBBcEh/Ff/RGo9zQgRJqzzIFrgOv6scetYZKXHpmDIvBo2Nu1aGFEnEpV0 vOj4cGhrI0TKM/lD2DKJSiUNKdqT23WXUTw+c8a/fQwAZuf+l//KIpwl7J4z4ZaQ8l/L JfGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3xhlXRebsXbSxUbfqBN5lh6qztABqKEYUhQQm4iljog=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=aSL25V6d967qtCPQ5y8CO88imvDLrOIxCrCQEaKb4sWqbr8v9FyyWifR9rQ7iGDeh3 PuTDTKOodnG/0Jco20BNSi2YHQS1t5FFZZN2dUV9G7WJqlhpBOZu30+4jxiR5MRQ2prV ix+lp0GmYbLMuRQ0MXFEjtArGo2T+K04IlC7ASdZrtBlLf/q+wv4jlhIaL6F4R6Y3X9Z VX61HW0b/wPoM4V/AmMq4+9TeJOBjSBD9rAtp4yimxz7IacYJH7vYc9pTBRVqptbsnPV o/5NGec/SvS+LBzmiynuhJyrormSfRhZAogq68aRl2oXGvO8y6Vq+MHtq379wUyBJFKy hQFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PmobMLJm; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a056402151800b005233fa16a39si3828419edw.123.2023.08.09.12.43.35; Wed, 09 Aug 2023 12:44:00 -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=20221208 header.b=PmobMLJm; 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 S233273AbjHITMO (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233101AbjHITL5 (ORCPT ); Wed, 9 Aug 2023 15:11:57 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E8D62123; Wed, 9 Aug 2023 12:11:55 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-317715ec496so182176f8f.3; Wed, 09 Aug 2023 12:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608314; x=1692213114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3xhlXRebsXbSxUbfqBN5lh6qztABqKEYUhQQm4iljog=; b=PmobMLJmic2QNvJGOsFjS1ZoKyARB2rmxdOBbA/jcYani3BMlpHyyS40EBRIG1+qH1 ifJ2Lt5yd9bdh/D9332e0pcTKXFZ7aGc+46JPe7lY26+Fyx1VFQ31iA16tNCOurWt+qj KY5JiTaUK/S3CiLzFSWEnStmXXnOc0nEpULsxPFZ6yFSMOjBZCTwgahHkW6WABAhTYq7 ZE4rV/ibz80hSo/S105RniIxz8jglyQ41IJR3L/+nezLwYH75LQh/hzE6UD+q1dogYOW ww6vtNs8rBNT3FmtCH5qNn78RCKdiz/H7cEBm/RWerEPYVufZKrTDrIqPCMk+vSO0V3H WYFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608314; x=1692213114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3xhlXRebsXbSxUbfqBN5lh6qztABqKEYUhQQm4iljog=; b=OQPwaHr6n3uBIZXU/4YomZwyG0sLzKgloGg5eCI12Xxh/tfMgAhdf19kJR/DrQOZUS 4fwSJk7xRVxIzFt/0PRBOnGjgKVxcyHguE4wpJqi37QhSYWpiqrgsrLr0T1KUt36he9f sb56IPYH/1fcqoiN/daAXDon7po3RbHY1q+qEQrXxH1WhKlzzVqkG5tKEhvpx3oQpNuT kCQGac21Bl5MuDF7B69b96Qx+mW71AHz/YpazFuWEGUPO4n0nlFb/WoSvZ8KG8wODeEQ 99wrPnbWfxRifhRN/zRXw5B7ZiD/rel4y+6nEm0ZVMYZNPusepkIxSelX8yUIZsDXfgJ 3JgQ== X-Gm-Message-State: AOJu0YzBPVeTjoKfrZ0C16vKNJKS06ZzlolGI6qJ4tRAAHMuYzvQmIVV paAIkVLH8FRqfEfR5/ORvtM= X-Received: by 2002:a05:6000:1b0a:b0:313:f9a0:c530 with SMTP id f10-20020a0560001b0a00b00313f9a0c530mr215855wrz.52.1691608314065; Wed, 09 Aug 2023 12:11:54 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:11:53 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility Date: Wed, 9 Aug 2023 21:11:34 +0200 Message-Id: <2c69e918cb6dfab663bb62952c554b6b72f58390.1691607526.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773781899331316556 X-GMAIL-MSGID: 1773781899331316556 Avoid error returns on a failure to match and instead just warn with assumption that we have a correct dt-binding telling us that some new device with a different ID is backwards compatible. Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: v6: v5: v4: - no changes v3: - changed from 'unsupported' to 'unknown' - removed the opening bracket v2: - no changes, this patch is introduced in the v2 drivers/iio/accel/kionix-kx022a.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index ff8aa7b9568e..494e81ba1da9 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -1036,10 +1036,8 @@ int kx022a_probe_internal(struct device *dev) if (ret) return dev_err_probe(dev, ret, "Failed to access sensor\n"); - if (chip_id != KX022A_ID) { - dev_err(dev, "unsupported device 0x%x\n", chip_id); - return -EINVAL; - } + if (chip_id != KX022A_ID) + dev_warn(dev, "unknown device 0x%x\n", chip_id); irq = fwnode_irq_get_byname(fwnode, "INT1"); if (irq > 0) { From patchwork Wed Aug 9 19:11:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3032674vqr; Wed, 9 Aug 2023 12:44:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH9ro2553c+evsUa8Tel+Qb5LalIU2HpxxZfiqzYhEL7GFuAyw9JSVBr+FIBx2M9TekfFZ X-Received: by 2002:a05:6870:f298:b0:1b0:3cd4:76d5 with SMTP id u24-20020a056870f29800b001b03cd476d5mr264433oap.37.1691610242468; Wed, 09 Aug 2023 12:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610242; cv=none; d=google.com; s=arc-20160816; b=qBFe3hMOCa8UYJwUYzyiDbBTWYKYaZssSJG0qvqDrbUGfeaOiqrF44g0CHwSEUEVsS OiejJwlddTczMJpkVWLfyk5oKtKahP32Asfpay3B2rA3nEWCkjjv1z/+7GNFoVgm7a0j TAh5Ovdwqmr15bpUfAJ3OdzFG5JlByEF6agUtCtoUh36v4bnZwbUpcDBCw2IAuYX6XWu HISXhBzSiK2u4mne6YZc5tQpjutgCRn1m0gYOL0K2CCQHE6nE1s+tJvJH+7ogBHwxj6m jahMwU8bkmdB5zhK7bbhw1wBNkY0FOS4FBD9Rt1K9s4ODmRoVAILoELav1bdz3vvSZNB anbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3uDePqqh1JbI0eVu6iP8bx2DCZtrWcLofkePNuUdzG4=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=eWuHp9SBa/pBhi93y+1TsXMezuxe0ADeVn8LFlHswlmFbOozhWJMwVCvzu1rQkHh5c VPyp/9ul4APOLIFRaeyXskte58DEt6L5uEsg22aNf+PymnnBlSC3MiCex4m0lwTb1ipk M7RXoNNaB2JJ2FN7MPshiRdNKV44z8o3nfFDjGlukJapks2XtwvREyjerXaKk779mDVK z6Vf/2uRUm4OcjwlWZe2IcRlrZeHiCfsDfd+BbraC/6kRMO/oadOmQXQMEYT7Nu9K0rj BGsZLWUTTYrmEEtdd4sbRfDh7WVuaHnrq1hpwCRWpfQn0XzCncpisd9CJNgXf2bvuj1O rrMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Cu1Mxwme; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s30-20020a63925e000000b005652bd27e9csi3026214pgn.460.2023.08.09.12.43.48; Wed, 09 Aug 2023 12:44:02 -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=20221208 header.b=Cu1Mxwme; 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 S232788AbjHITMH (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233252AbjHITL7 (ORCPT ); Wed, 9 Aug 2023 15:11:59 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EFC010EC; Wed, 9 Aug 2023 12:11:57 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe2d218eedso939315e9.0; Wed, 09 Aug 2023 12:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608316; x=1692213116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3uDePqqh1JbI0eVu6iP8bx2DCZtrWcLofkePNuUdzG4=; b=Cu1Mxwme5j0rBg2KV9UVIw/WIr5x/eEVM3MKKni8/vYUB2/KiH/pyrW4kB/d1LFFv+ 89zJjZdvrwIUByfLwOJKgTwHby9R6ZED0RxqcKI2i7TzQYYKcqhBq3GUxUTRxXqRrDaV DMinuHD47XdSyIxbS66ChpdLg5mzSU+q+HM0heDYpBnvtF6Z28KZ/Efs6G4AqgybUM/T i9tai2/JF/WY0FU/6D51fiWz70BuKM18Vw6q1zFtWinw9EsHgYgciWEoQCcll+5eLDg8 o4ABpyyZuVFa8wOgtGj/wxSJddHGqNC3hMSk4eo/fpyrx0f0ml+840ekZ1mRGHlmGyw5 6NuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608316; x=1692213116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3uDePqqh1JbI0eVu6iP8bx2DCZtrWcLofkePNuUdzG4=; b=U/7Eq/6pPsb6aS21Mc/FcSF67BUTDYHj/YmImkMsM7ARCIbYUhD7b1oWlsvR2EeSdq QNsPma8/3F+i+gK27wbx6OjxJmCQphy1O4r6PN61RVYSiWqZNzkJCEOAvg5ZLA1Z8Lv7 VFm3HECI1RcNYJHCCEWdPzps/EydhZqICUVM9Z762D1umWzHt3cryQbZfz1bddzoQgPX uTf6P7vpD1vCkrL1kbiCLAMRPtF24Sigu6RHw6Bj3L8maiHGKQtVM6xV7KcINxTKwwWt xQUdsav9b3VKNO/RSpIcxaMbxX4amhaWT5NPMfII0PHhywcAWbYU2rc+Uyf2ukPqgCv0 ox4Q== X-Gm-Message-State: AOJu0Yw1tFhSAzkp4jwQw1xqa0CM0XgQAJpVwjxmL8jni/JHTqFK5ztU CrvoFfRw/6oHSShGIOMg16w= X-Received: by 2002:a5d:4683:0:b0:317:3f0c:b40e with SMTP id u3-20020a5d4683000000b003173f0cb40emr240404wrq.58.1691608315839; Wed, 09 Aug 2023 12:11:55 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:11:55 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table Date: Wed, 9 Aug 2023 21:11:35 +0200 Message-Id: <9950e3963600465e1177a20ad8a93a3927c026ef.1691607526.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773781901191036237 X-GMAIL-MSGID: 1773781901191036237 Add the missing i2c device id. Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: v6: v5: v4: - no changes v3: - no changes, this patch is introduced in the v2 drivers/iio/accel/kionix-kx022a-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index e6fd02d931b6..b5a85ce3a891 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -30,6 +30,12 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) return kx022a_probe_internal(dev); } +static const struct i2c_device_id kx022a_i2c_id[] = { + { .name = "kx022a" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); + static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", }, { } @@ -42,6 +48,7 @@ static struct i2c_driver kx022a_i2c_driver = { .of_match_table = kx022a_of_match, }, .probe_new = kx022a_i2c_probe, + .id_table = kx022a_i2c_id, }; module_i2c_driver(kx022a_i2c_driver); From patchwork Wed Aug 9 21:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp97790vqi; Wed, 9 Aug 2023 17:39:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFng/Mu0Umg0y3+gh+UITSLXTJyCjgEuSzpSQRqAJhbSASy7hpIGVs8cb6O5zQpjCwEwfuX X-Received: by 2002:a17:902:bd0b:b0:1b2:4852:9a5f with SMTP id p11-20020a170902bd0b00b001b248529a5fmr602409pls.54.1691627961576; Wed, 09 Aug 2023 17:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691627961; cv=none; d=google.com; s=arc-20160816; b=Evs3n4q058ku0d/rIPrirWFo7iyEADYN1KHZDeCVfrqO1mIZFb8Gc05HwxNu0mIX/h V2efYyPgGBwWUThAHk9d5E7mz5OzKswc4fKjJbzuFSG7wiR1YIRj0NP150i4pHoqI3wh 9xNGN0ZGanhcqYHs2nIHO5sRe3T3ZzQAbyc6tPRLRz9HD7PTxkTGSfPfGZrVLGkszFj9 MiXeZjz9MxzQeGQFPN4nUYrCRchGMd7i06CqGF6Tyv8cIJD24er5z7AvON+85BzvsrtA wtHRe/t1oNvrckuQP84PW9e72JImCrKQb5WUHcEYDn1WqfPuaXikVIZhT/FbrjuhTJ6x VJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7bqzS9h0CgvDS8ZZVemKv+0rs4fFcra0nUU+EHxfMg4=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=h3TZzzjw7QMR03ZPQ3V0F4QujchZ69NNZx5157MxOA9wPmRFMIBzTtprOeXyq/7rNw 9D3RY5hInEb27lHe8o8ktWZ/0Kj1dKwmbfG++O1VqwpT6dxV+VdKYYDkVUD67I4eBzss g3uu1+VzqVt8vd3WBQBNROFK2cbSfBt51JE2EPKn16hpZn1LTko7fp8Mm9g48W7ku/MW bHCWFfnKQ9ls71ob+advJwRlOgyPtpP7SGK2vVt7B26b7GE9n2XXspmis8vXA3XExOzC n+Ms+y8OaDOfQkEp/NhIoKFbWuzHFkr4VIw54nXBeoEiDrPZXc1vdetzaa7O7mtBGKEB JegA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rlBo7cjR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170902e80d00b001baff05d89csi315247plg.130.2023.08.09.17.39.08; Wed, 09 Aug 2023 17:39:21 -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=20221208 header.b=rlBo7cjR; 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 S233074AbjHIVHi (ORCPT + 99 others); Wed, 9 Aug 2023 17:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbjHIVHg (ORCPT ); Wed, 9 Aug 2023 17:07:36 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F176A1724; Wed, 9 Aug 2023 14:07:34 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fe45481edfso1906195e9.1; Wed, 09 Aug 2023 14:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691615253; x=1692220053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7bqzS9h0CgvDS8ZZVemKv+0rs4fFcra0nUU+EHxfMg4=; b=rlBo7cjR38Vqk8lSB8hWlpnA7bMCH99C+Ygb3oH0XMLpKjcyS8mrqH7t348tCiAllm zk2qdjcjKu/qaoZabD5usCU1dXsY1gX0itLik9BQnzX5922ZPf5SOZrKjNzHvDcJyuL1 1g8azk0jZhwHxafZNU7+5+WZIqAvQD95Y4lgFe8wTj2zBrba5fkxYCX89GaeSafuPVyH 8NlKHSe6qp4sPjomHoE9aYrKaOngWB4xHdyjRCju0sIpYP2DtzFRDyrP1y5h06wK1uHK 0JQXe9npVKgJUqpCefOlBUnM6hAZQ6d0SEimOjwsKtylaXVnBLNOpBUMQfRp8sxsz8rN iTdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691615253; x=1692220053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7bqzS9h0CgvDS8ZZVemKv+0rs4fFcra0nUU+EHxfMg4=; b=KBvnBKAOU8KOGNOPkUQFzGA1O1FtdD/cTOy4jVt0shlsGWGeVV8H1BSldNfjdlryZL 10ESJb3EeasSsH2z2z/MZVydzrlyn2MvmlquctOEIXjDCzHe6OWJSiaET+O64jZn0Y7B 5adKovV0wrRcgQtWYi/C+8cehQo0UFg3cU6UFw+sXgx/EOi6tGX2ehFxmjmRDOJbjtx4 UjAA6zKsi2jsAHFGyy2U9NW8O0Lt8PeeBLSxsWHZGXfAtUadR0ciL1bxYGbHVpPDbJis ne07DF9X3LDlvjMSXoqVNI4oseGLMDihIP9XQnbqn8OKLOw40uBGyxaLy2NvbabfHj0M PVQA== X-Gm-Message-State: AOJu0YwaZRmscQoQLDx0d+YTs6FUGDc1VwShrEZ1bkjJ4lMNIJk+zzhF L7YcSnvcFGdliwn3bsXlKbxnip1aUJlRtw== X-Received: by 2002:a05:600c:2196:b0:3fe:2e0d:b715 with SMTP id e22-20020a05600c219600b003fe2e0db715mr276221wme.18.1691615253191; Wed, 09 Aug 2023 14:07:33 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id t21-20020a1c7715000000b003fe0bb31a6asm59170wmi.43.2023.08.09.14.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 14:07:32 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure Date: Wed, 9 Aug 2023 23:05:39 +0200 Message-Id: <8fb74f21bda4949a862bcb4bb1ed4f0acb135948.1691607526.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773800481346844041 X-GMAIL-MSGID: 1773800481346844041 Add the chip_info structure to the driver's private data to hold all the device specific infos. Refactor the kx022a driver implementation to make it more generic and extensible. Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: - no changes v6: - placed chip_info after the regmap elemnt in kx022a_data struct to save memory as suggested by Andy - added a check for the availability of chip_info for the SPI case as suggested by Andy v5: - moved the "kfree" call to match the reverse of what happens in kx022a_fifo_enable() as suggested by Matti and Jonathan - used min_t, checked for availability of chip_info as suggested by Andy v4: - allocating and freeing the buffer moved to the kx022a_fifo{enable, disable} functions - used the spi_get_device_match_data helper function v3: - added the change of the buffer's allocation in the __kx022a_fifo_flush to this patch - added the chip_info to the struct kx022a_data drivers/iio/accel/kionix-kx022a-i2c.c | 17 +++- drivers/iio/accel/kionix-kx022a-spi.c | 13 ++- drivers/iio/accel/kionix-kx022a.c | 116 ++++++++++++++++---------- drivers/iio/accel/kionix-kx022a.h | 52 +++++++++++- 4 files changed, 146 insertions(+), 52 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index b5a85ce3a891..c59558fc6493 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -15,6 +15,7 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; + const struct kx022a_chip_info *chip_info; struct regmap *regmap; if (!i2c->irq) { @@ -22,22 +23,30 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) return -EINVAL; } - regmap = devm_regmap_init_i2c(i2c, &kx022a_regmap); + chip_info = device_get_match_data(&i2c->dev); + if (!chip_info) { + const struct i2c_device_id *id = i2c_client_get_device_id(i2c); + chip_info = (const struct kx022a_chip_info *)id->driver_data; + if (!chip_info) + return -EINVAL; + } + + regmap = devm_regmap_init_i2c(i2c, chip_info->regmap_config); if (IS_ERR(regmap)) return dev_err_probe(dev, PTR_ERR(regmap), "Failed to initialize Regmap\n"); - return kx022a_probe_internal(dev); + return kx022a_probe_internal(dev, chip_info); } static const struct i2c_device_id kx022a_i2c_id[] = { - { .name = "kx022a" }, + { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); static const struct of_device_id kx022a_of_match[] = { - { .compatible = "kionix,kx022a", }, + { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a-spi.c b/drivers/iio/accel/kionix-kx022a-spi.c index 9cd047f7b346..896b57866fc9 100644 --- a/drivers/iio/accel/kionix-kx022a-spi.c +++ b/drivers/iio/accel/kionix-kx022a-spi.c @@ -15,6 +15,7 @@ static int kx022a_spi_probe(struct spi_device *spi) { struct device *dev = &spi->dev; + const struct kx022a_chip_info *chip_info; struct regmap *regmap; if (!spi->irq) { @@ -22,22 +23,26 @@ static int kx022a_spi_probe(struct spi_device *spi) return -EINVAL; } - regmap = devm_regmap_init_spi(spi, &kx022a_regmap); + chip_info = spi_get_device_match_data(spi); + if (!chip_info) + return -EINVAL; + + regmap = devm_regmap_init_spi(spi, chip_info->regmap_config); if (IS_ERR(regmap)) return dev_err_probe(dev, PTR_ERR(regmap), "Failed to initialize Regmap\n"); - return kx022a_probe_internal(dev); + return kx022a_probe_internal(dev, chip_info); } static const struct spi_device_id kx022a_id[] = { - { "kx022a" }, + { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, kx022a_id); static const struct of_device_id kx022a_of_match[] = { - { .compatible = "kionix,kx022a", }, + { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index 494e81ba1da9..0bab3f109e4e 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -48,7 +48,7 @@ enum { KX022A_STATE_FIFO, }; -/* Regmap configs */ +/* kx022a Regmap configs */ static const struct regmap_range kx022a_volatile_ranges[] = { { .range_min = KX022A_REG_XHP_L, @@ -138,7 +138,7 @@ static const struct regmap_access_table kx022a_nir_regs = { .n_yes_ranges = ARRAY_SIZE(kx022a_noinc_read_ranges), }; -const struct regmap_config kx022a_regmap = { +static const struct regmap_config kx022a_regmap_config = { .reg_bits = 8, .val_bits = 8, .volatile_table = &kx022a_volatile_regs, @@ -149,10 +149,10 @@ const struct regmap_config kx022a_regmap = { .max_register = KX022A_MAX_REGISTER, .cache_type = REGCACHE_RBTREE, }; -EXPORT_SYMBOL_NS_GPL(kx022a_regmap, IIO_KX022A); struct kx022a_data { struct regmap *regmap; + const struct kx022a_chip_info *chip_info; struct iio_trigger *trig; struct device *dev; struct iio_mount_matrix orientation; @@ -175,6 +175,8 @@ struct kx022a_data { struct mutex mutex; u8 watermark; + __le16 *fifo_buffer; + /* 3 x 16bit accel data + timestamp */ __le16 buffer[8] __aligned(IIO_DMA_MINALIGN); struct { @@ -208,7 +210,7 @@ static const struct iio_chan_spec_ext_info kx022a_ext_info[] = { { } }; -#define KX022A_ACCEL_CHAN(axis, index) \ +#define KX022A_ACCEL_CHAN(axis, reg, index) \ { \ .type = IIO_ACCEL, \ .modified = 1, \ @@ -220,7 +222,7 @@ static const struct iio_chan_spec_ext_info kx022a_ext_info[] = { BIT(IIO_CHAN_INFO_SCALE) | \ BIT(IIO_CHAN_INFO_SAMP_FREQ), \ .ext_info = kx022a_ext_info, \ - .address = KX022A_REG_##axis##OUT_L, \ + .address = reg, \ .scan_index = index, \ .scan_type = { \ .sign = 's', \ @@ -231,9 +233,9 @@ static const struct iio_chan_spec_ext_info kx022a_ext_info[] = { } static const struct iio_chan_spec kx022a_channels[] = { - KX022A_ACCEL_CHAN(X, 0), - KX022A_ACCEL_CHAN(Y, 1), - KX022A_ACCEL_CHAN(Z, 2), + KX022A_ACCEL_CHAN(X, KX022A_REG_XOUT_L, 0), + KX022A_ACCEL_CHAN(Y, KX022A_REG_YOUT_L, 1), + KX022A_ACCEL_CHAN(Z, KX022A_REG_ZOUT_L, 2), IIO_CHAN_SOFT_TIMESTAMP(3), }; @@ -332,10 +334,10 @@ static int kx022a_turn_on_off_unlocked(struct kx022a_data *data, bool on) int ret; if (on) - ret = regmap_set_bits(data->regmap, KX022A_REG_CNTL, + ret = regmap_set_bits(data->regmap, data->chip_info->cntl, KX022A_MASK_PC1); else - ret = regmap_clear_bits(data->regmap, KX022A_REG_CNTL, + ret = regmap_clear_bits(data->regmap, data->chip_info->cntl, KX022A_MASK_PC1); if (ret) dev_err(data->dev, "Turn %s fail %d\n", str_on_off(on), ret); @@ -402,7 +404,7 @@ static int kx022a_write_raw(struct iio_dev *idev, break; ret = regmap_update_bits(data->regmap, - KX022A_REG_ODCNTL, + data->chip_info->odcntl, KX022A_MASK_ODR, n); data->odr_ns = kx022a_odrs[n]; kx022a_turn_on_unlock(data); @@ -423,7 +425,7 @@ static int kx022a_write_raw(struct iio_dev *idev, if (ret) break; - ret = regmap_update_bits(data->regmap, KX022A_REG_CNTL, + ret = regmap_update_bits(data->regmap, data->chip_info->cntl, KX022A_MASK_GSEL, n << KX022A_GSEL_SHIFT); kx022a_turn_on_unlock(data); @@ -445,7 +447,7 @@ static int kx022a_fifo_set_wmi(struct kx022a_data *data) threshold = data->watermark; - return regmap_update_bits(data->regmap, KX022A_REG_BUF_CNTL1, + return regmap_update_bits(data->regmap, data->chip_info->buf_cntl1, KX022A_MASK_WM_TH, threshold); } @@ -488,7 +490,7 @@ static int kx022a_read_raw(struct iio_dev *idev, return ret; case IIO_CHAN_INFO_SAMP_FREQ: - ret = regmap_read(data->regmap, KX022A_REG_ODCNTL, ®val); + ret = regmap_read(data->regmap, data->chip_info->odcntl, ®val); if (ret) return ret; @@ -503,7 +505,7 @@ static int kx022a_read_raw(struct iio_dev *idev, return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_SCALE: - ret = regmap_read(data->regmap, KX022A_REG_CNTL, ®val); + ret = regmap_read(data->regmap, data->chip_info->cntl, ®val); if (ret < 0) return ret; @@ -530,8 +532,7 @@ static int kx022a_set_watermark(struct iio_dev *idev, unsigned int val) { struct kx022a_data *data = iio_priv(idev); - if (val > KX022A_FIFO_LENGTH) - val = KX022A_FIFO_LENGTH; + val = min_t(unsigned int, data->chip_info->fifo_length, val); mutex_lock(&data->mutex); data->watermark = val; @@ -592,7 +593,7 @@ static int kx022a_drop_fifo_contents(struct kx022a_data *data) */ data->timestamp = 0; - return regmap_write(data->regmap, KX022A_REG_BUF_CLEAR, 0x0); + return regmap_write(data->regmap, data->chip_info->buf_clear, 0x0); } static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, @@ -600,7 +601,6 @@ static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, { struct kx022a_data *data = iio_priv(idev); struct device *dev = regmap_get_device(data->regmap); - __le16 buffer[KX022A_FIFO_LENGTH * 3]; uint64_t sample_period; int count, fifo_bytes; bool renable = false; @@ -679,13 +679,13 @@ static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, } fifo_bytes = count * KX022A_FIFO_SAMPLES_SIZE_BYTES; - ret = regmap_noinc_read(data->regmap, KX022A_REG_BUF_READ, - &buffer[0], fifo_bytes); + ret = regmap_noinc_read(data->regmap, data->chip_info->buf_read, + data->fifo_buffer, fifo_bytes); if (ret) goto renable_out; for (i = 0; i < count; i++) { - __le16 *sam = &buffer[i * 3]; + __le16 *sam = &data->fifo_buffer[i * 3]; __le16 *chs; int bit; @@ -732,10 +732,10 @@ static const struct iio_info kx022a_info = { static int kx022a_set_drdy_irq(struct kx022a_data *data, bool en) { if (en) - return regmap_set_bits(data->regmap, KX022A_REG_CNTL, + return regmap_set_bits(data->regmap, data->chip_info->cntl, KX022A_MASK_DRDY); - return regmap_clear_bits(data->regmap, KX022A_REG_CNTL, + return regmap_clear_bits(data->regmap, data->chip_info->cntl, KX022A_MASK_DRDY); } @@ -770,7 +770,7 @@ static int kx022a_fifo_disable(struct kx022a_data *data) if (ret) goto unlock_out; - ret = regmap_clear_bits(data->regmap, KX022A_REG_BUF_CNTL2, + ret = regmap_clear_bits(data->regmap, data->chip_info->buf_cntl2, KX022A_MASK_BUF_EN); if (ret) goto unlock_out; @@ -779,6 +779,8 @@ static int kx022a_fifo_disable(struct kx022a_data *data) kx022a_drop_fifo_contents(data); + kfree(data->fifo_buffer); + return kx022a_turn_on_unlock(data); unlock_out: @@ -801,6 +803,11 @@ static int kx022a_fifo_enable(struct kx022a_data *data) { int ret; + data->fifo_buffer = kmalloc(data->chip_info->fifo_length * + KX022A_FIFO_SAMPLES_SIZE_BYTES, GFP_KERNEL); + if (!data->fifo_buffer) + return -ENOMEM; + ret = kx022a_turn_off_lock(data); if (ret) return ret; @@ -811,7 +818,7 @@ static int kx022a_fifo_enable(struct kx022a_data *data) goto unlock_out; /* Enable buffer */ - ret = regmap_set_bits(data->regmap, KX022A_REG_BUF_CNTL2, + ret = regmap_set_bits(data->regmap, data->chip_info->buf_cntl2, KX022A_MASK_BUF_EN); if (ret) goto unlock_out; @@ -857,7 +864,7 @@ static irqreturn_t kx022a_trigger_handler(int irq, void *p) struct kx022a_data *data = iio_priv(idev); int ret; - ret = regmap_bulk_read(data->regmap, KX022A_REG_XOUT_L, data->buffer, + ret = regmap_bulk_read(data->regmap, data->chip_info->xout_l, data->buffer, KX022A_FIFO_SAMPLES_SIZE_BYTES); if (ret < 0) goto err_read; @@ -905,7 +912,7 @@ static irqreturn_t kx022a_irq_thread_handler(int irq, void *private) if (data->state & KX022A_STATE_FIFO) { int ok; - ok = __kx022a_fifo_flush(idev, KX022A_FIFO_LENGTH, true); + ok = __kx022a_fifo_flush(idev, data->chip_info->fifo_length, true); if (ok > 0) ret = IRQ_HANDLED; } @@ -958,7 +965,7 @@ static int kx022a_chip_init(struct kx022a_data *data) int ret, val; /* Reset the senor */ - ret = regmap_write(data->regmap, KX022A_REG_CNTL2, KX022A_MASK_SRST); + ret = regmap_write(data->regmap, data->chip_info->cntl2, KX022A_MASK_SRST); if (ret) return ret; @@ -968,7 +975,7 @@ static int kx022a_chip_init(struct kx022a_data *data) */ msleep(1); - ret = regmap_read_poll_timeout(data->regmap, KX022A_REG_CNTL2, val, + ret = regmap_read_poll_timeout(data->regmap, data->chip_info->cntl2, val, !(val & KX022A_MASK_SRST), KX022A_SOFT_RESET_WAIT_TIME_US, KX022A_SOFT_RESET_TOTAL_WAIT_TIME_US); @@ -978,14 +985,14 @@ static int kx022a_chip_init(struct kx022a_data *data) return ret; } - ret = regmap_reinit_cache(data->regmap, &kx022a_regmap); + ret = regmap_reinit_cache(data->regmap, data->chip_info->regmap_config); if (ret) { dev_err(data->dev, "Failed to reinit reg cache\n"); return ret; } /* set data res 16bit */ - ret = regmap_set_bits(data->regmap, KX022A_REG_BUF_CNTL2, + ret = regmap_set_bits(data->regmap, data->chip_info->buf_cntl2, KX022A_MASK_BRES16); if (ret) { dev_err(data->dev, "Failed to set data resolution\n"); @@ -995,7 +1002,31 @@ static int kx022a_chip_init(struct kx022a_data *data) return kx022a_prepare_irq_pin(data); } -int kx022a_probe_internal(struct device *dev) +const struct kx022a_chip_info kx022a_chip_info = { + .name = "kx022-accel", + .regmap_config = &kx022a_regmap_config, + .channels = kx022a_channels, + .num_channels = ARRAY_SIZE(kx022a_channels), + .fifo_length = KX022A_FIFO_LENGTH, + .who = KX022A_REG_WHO, + .id = KX022A_ID, + .cntl = KX022A_REG_CNTL, + .cntl2 = KX022A_REG_CNTL2, + .odcntl = KX022A_REG_ODCNTL, + .buf_cntl1 = KX022A_REG_BUF_CNTL1, + .buf_cntl2 = KX022A_REG_BUF_CNTL2, + .buf_clear = KX022A_REG_BUF_CLEAR, + .buf_status1 = KX022A_REG_BUF_STATUS_1, + .buf_read = KX022A_REG_BUF_READ, + .inc1 = KX022A_REG_INC1, + .inc4 = KX022A_REG_INC4, + .inc5 = KX022A_REG_INC5, + .inc6 = KX022A_REG_INC6, + .xout_l = KX022A_REG_XOUT_L, +}; +EXPORT_SYMBOL_NS_GPL(kx022a_chip_info, IIO_KX022A); + +int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info) { static const char * const regulator_names[] = {"io-vdd", "vdd"}; struct iio_trigger *indio_trig; @@ -1022,6 +1053,7 @@ int kx022a_probe_internal(struct device *dev) return -ENOMEM; data = iio_priv(idev); + data->chip_info = chip_info; /* * VDD is the analog and digital domain voltage supply and @@ -1032,24 +1064,24 @@ int kx022a_probe_internal(struct device *dev) if (ret && ret != -ENODEV) return dev_err_probe(dev, ret, "failed to enable regulator\n"); - ret = regmap_read(regmap, KX022A_REG_WHO, &chip_id); + ret = regmap_read(regmap, chip_info->who, &chip_id); if (ret) return dev_err_probe(dev, ret, "Failed to access sensor\n"); - if (chip_id != KX022A_ID) + if (chip_id != chip_info->id) dev_warn(dev, "unknown device 0x%x\n", chip_id); irq = fwnode_irq_get_byname(fwnode, "INT1"); if (irq > 0) { - data->inc_reg = KX022A_REG_INC1; - data->ien_reg = KX022A_REG_INC4; + data->inc_reg = chip_info->inc1; + data->ien_reg = chip_info->inc4; } else { irq = fwnode_irq_get_byname(fwnode, "INT2"); if (irq <= 0) return dev_err_probe(dev, irq, "No suitable IRQ\n"); - data->inc_reg = KX022A_REG_INC5; - data->ien_reg = KX022A_REG_INC6; + data->inc_reg = chip_info->inc5; + data->ien_reg = chip_info->inc6; } data->regmap = regmap; @@ -1058,9 +1090,9 @@ int kx022a_probe_internal(struct device *dev) data->odr_ns = KX022A_DEFAULT_PERIOD_NS; mutex_init(&data->mutex); - idev->channels = kx022a_channels; - idev->num_channels = ARRAY_SIZE(kx022a_channels); - idev->name = "kx022-accel"; + idev->channels = chip_info->channels; + idev->num_channels = chip_info->num_channels; + idev->name = chip_info->name; idev->info = &kx022a_info; idev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; idev->available_scan_masks = kx022a_scan_masks; diff --git a/drivers/iio/accel/kionix-kx022a.h b/drivers/iio/accel/kionix-kx022a.h index 12424649d438..0e5026019213 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -76,7 +76,55 @@ struct device; -int kx022a_probe_internal(struct device *dev); -extern const struct regmap_config kx022a_regmap; +/** + * struct kx022a_chip_info - Kionix accelerometer chip specific information + * + * @name: name of the device + * @regmap_config: pointer to register map configuration + * @channels: pointer to iio_chan_spec array + * @num_channels: number of iio_chan_spec channels + * @fifo_length: number of 16-bit samples in a full buffer + * @who: WHO_AM_I register + * @id: WHO_AM_I register value + * @cntl: control register 1 + * @cntl2: control register 2 + * @odcntl: output data control register + * @buf_cntl1: buffer control register 1 + * @buf_cntl2: buffer control register 2 + * @buf_clear: buffer clear register + * @buf_status1: buffer status register 1 + * @buf_read: buffer read register + * @inc1: interrupt control register 1 + * @inc4: interrupt control register 4 + * @inc5: interrupt control register 5 + * @inc6: interrupt control register 6 + * @xout_l: x-axis output least significant byte + */ +struct kx022a_chip_info { + const char *name; + const struct regmap_config *regmap_config; + const struct iio_chan_spec *channels; + unsigned int num_channels; + unsigned int fifo_length; + u8 who; + u8 id; + u8 cntl; + u8 cntl2; + u8 odcntl; + u8 buf_cntl1; + u8 buf_cntl2; + u8 buf_clear; + u8 buf_status1; + u8 buf_read; + u8 inc1; + u8 inc4; + u8 inc5; + u8 inc6; + u8 xout_l; +}; + +int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info); + +extern const struct kx022a_chip_info kx022a_chip_info; #endif From patchwork Wed Aug 9 19:11:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp3034733vqr; Wed, 9 Aug 2023 12:48:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOrNNXYrHUS9An7keYPQAqHZdtekOmr9WCwD2GDOVZ/UsdijT/sjtJK8tIFHrNU4lUPZWU X-Received: by 2002:a05:6512:3c88:b0:4fe:279b:7609 with SMTP id h8-20020a0565123c8800b004fe279b7609mr104585lfv.17.1691610511802; Wed, 09 Aug 2023 12:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691610511; cv=none; d=google.com; s=arc-20160816; b=Oc3GglGRUfFhd1dWXl7dD6FGNxRG39Xjzq0dG/qGby36Yb2u3skKOv8DNiWRDYKi3L u0nixGIfQcxaDp+j/gbVykijy4SoCEyGS2NVmK6M3AxYR8MCc6nPn+HnpIInum3Tvwue GAxuo1wpyNJDWiSFWuQMFKrTkeXTmJJxK1hd3WecCYj31Rb2xmSswWiTpT1n4UZ95EjT DKOUrACj68T94Eq04RCFa7hauDco2/yDX8CJtgiHJjgrZuQfeR7F+NwoF3eob8wdcKQg Va19kpg8iwdkieky4zths1CUSBlhaaLm6jWGorQx0kUsAy1j9y3hCofAt1Yml0O74VIf emYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8GXHD9z3QbTzRtcNSHsxh75zMlKi3WfnQYnJg7fdwt4=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=Go+2X4vklzpww7bEoghSrlVQEk3hUeLvO9wlPw+6F9UBzhOuaeWJGbl2HY/iiaiKYd 6ks6ArdDUrkNimEYo6UUkhgJLbjn4b0FZnCIEL+TD8ozkVpoJpY5hP+U4xJhnjn2kA0m vNe03vAlhRY87R/SJNhCmOAlMzQTiTF9X5GRCaux/jEs8zAmD54QbNegkQU7sPEJ34f8 y3/nIMw6Gt7u0Rf97tmPlu1CG7a4CBYIeXjyvX94OsEkkPxFH1334zFcobTc2ACGqfft aorSsplQK1a47yHlsgbCcrPewS/lcjfVh2lptM1atmfyIsV2g8DQBWTBW9O1hk1UQtO4 pXlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PwDY2MIX; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a1709064a4900b0099bcb3ad50csi8910315ejv.504.2023.08.09.12.47.44; Wed, 09 Aug 2023 12:48:31 -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=20221208 header.b=PwDY2MIX; 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 S232424AbjHITMV (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233379AbjHITME (ORCPT ); Wed, 9 Aug 2023 15:12:04 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6E47212B; Wed, 9 Aug 2023 12:12:01 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso709525e9.2; Wed, 09 Aug 2023 12:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608320; x=1692213120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8GXHD9z3QbTzRtcNSHsxh75zMlKi3WfnQYnJg7fdwt4=; b=PwDY2MIX6ELKje2/CPgWrHbbFN9FLx5GpWgJizSfvDItlBiAERDDT4eaoVVTyOGtYR 3P8Espud1LSbEAxJOg0pOJvXBcVq8wnEBFSjwjtg9J4XrnrY0QpHQ53SVPPHlcbHjk4X HMBrALmaZrHKNFxFvKUG0IQPnZp2dDL0QTNNS5VwpbCDe17oKkueMDjFt8xzKKAJZa+W u2SHAgBDBwP3paaBG2aaVc0mHUr1w0JCFlZHolrDiwrlsZxqQt5leFlL/8LQuKq87MPy y5gmxkdzmE0+LRTHRRF53/SJmcKMW6zBw0vqrXLvZIDbpQRpYYuS810umGyQazhWubDL OWYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608320; x=1692213120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8GXHD9z3QbTzRtcNSHsxh75zMlKi3WfnQYnJg7fdwt4=; b=UP+TOVfuCLtNqGPAXPAupR+zscRlaFgqzLZV9tOvq8Dcxrz4tBxqcmkOFiavO71wPj JfSycqC7Z0nAzP0VwOq583XD7iPMqN2boEdEtdADAEpP7yda4cvFTlhG1tOslwY5X2Vn 5uidDCZOp6cm68WdoaJXrW6u8phZN6QD1brAtQv1jsmWa8v8DiabCq9NGUHoOWnGqzsj 16pua8lOvAuxMrp1h1ne702w64oHleSWjo4ZmW/BUNJP4TRNKWXb5S36R3edlvDnIM/s 0PchyYNf4Ypyt8oU4+yrrKvJy6BrgQ3ISf+NsbDYLfvmAJpopI/qECV3yxp7eLvIpAQf JNdA== X-Gm-Message-State: AOJu0Yxjqjb8RbBPuodMwfStan+ywQJeaC1Fl4aoD9Rpny1MiYDHx1TZ IS/1jIhf8QDoLI4rI/mglS4kMLkpXVF1kg== X-Received: by 2002:a5d:4241:0:b0:317:e7e0:8528 with SMTP id s1-20020a5d4241000000b00317e7e08528mr226123wrr.50.1691608320286; Wed, 09 Aug 2023 12:12:00 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:11:59 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer Date: Wed, 9 Aug 2023 21:11:37 +0200 Message-Id: <11d8bcef77a563804c125ed4de1127253e98f3be.1691607526.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773782183843801003 X-GMAIL-MSGID: 1773782183843801003 Since Kionix accelerometers use various numbers of bits to report data, a device-specific function is required. Implement the function as a callback in the device-specific chip_info structure Reviewed-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- v7: - no changes v6: - directly return KX022A_FIFO_MAX_BYTES as suggested by Andy v5: - no changes v4: - removed the comment about "bogus value from i2c" - removed regmap_get_device(data->regmap); dev is present in the driver's private data v3: - no changes v2: - separated this change from the chip_info introduction and made it a patch in v2 - changed the function from generic implementation for to device-specific one - removed blank lines pointed out by checkpatch - changed the allocation of the "buffer" array in __kx022a_fifo_flush drivers/iio/accel/kionix-kx022a.c | 28 ++++++++++++++++++---------- drivers/iio/accel/kionix-kx022a.h | 4 ++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index 0bab3f109e4e..0b0f14dca17f 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -596,26 +596,33 @@ static int kx022a_drop_fifo_contents(struct kx022a_data *data) return regmap_write(data->regmap, data->chip_info->buf_clear, 0x0); } +static int kx022a_get_fifo_bytes(struct kx022a_data *data) +{ + int ret, fifo_bytes; + + ret = regmap_read(data->regmap, KX022A_REG_BUF_STATUS_1, &fifo_bytes); + if (ret) { + dev_err(data->dev, "Error reading buffer status\n"); + return ret; + } + + if (fifo_bytes == KX022A_FIFO_FULL_VALUE) + return KX022A_FIFO_MAX_BYTES; + + return fifo_bytes; +} + static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, bool irq) { struct kx022a_data *data = iio_priv(idev); - struct device *dev = regmap_get_device(data->regmap); uint64_t sample_period; int count, fifo_bytes; bool renable = false; int64_t tstamp; int ret, i; - ret = regmap_read(data->regmap, KX022A_REG_BUF_STATUS_1, &fifo_bytes); - if (ret) { - dev_err(dev, "Error reading buffer status\n"); - return ret; - } - - /* Let's not overflow if we for some reason get bogus value from i2c */ - if (fifo_bytes == KX022A_FIFO_FULL_VALUE) - fifo_bytes = KX022A_FIFO_MAX_BYTES; + fifo_bytes = data->chip_info->get_fifo_bytes(data); if (fifo_bytes % KX022A_FIFO_SAMPLES_SIZE_BYTES) dev_warn(data->dev, "Bad FIFO alignment. Data may be corrupt\n"); @@ -1023,6 +1030,7 @@ const struct kx022a_chip_info kx022a_chip_info = { .inc5 = KX022A_REG_INC5, .inc6 = KX022A_REG_INC6, .xout_l = KX022A_REG_XOUT_L, + .get_fifo_bytes = kx022a_get_fifo_bytes, }; EXPORT_SYMBOL_NS_GPL(kx022a_chip_info, IIO_KX022A); diff --git a/drivers/iio/accel/kionix-kx022a.h b/drivers/iio/accel/kionix-kx022a.h index 0e5026019213..c9f9aee7e597 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -76,6 +76,8 @@ struct device; +struct kx022a_data; + /** * struct kx022a_chip_info - Kionix accelerometer chip specific information * @@ -99,6 +101,7 @@ struct device; * @inc5: interrupt control register 5 * @inc6: interrupt control register 6 * @xout_l: x-axis output least significant byte + * @get_fifo_bytes: function pointer to get number of bytes in the FIFO buffer */ struct kx022a_chip_info { const char *name; @@ -121,6 +124,7 @@ struct kx022a_chip_info { u8 inc5; u8 inc6; u8 xout_l; + int (*get_fifo_bytes)(struct kx022a_data *); }; int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info); From patchwork Wed Aug 9 19:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 133521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:9d8d:b0:139:fa0d:b2d with SMTP id d13csp146658rwo; Wed, 9 Aug 2023 14:11:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjNkd1fR1QQAbzftyzb4dcBsKEvuqgMEX5iEh7QFAjFNe85tRBDBjeJ9wMHK+0Ohdkym05 X-Received: by 2002:a17:90a:290:b0:25f:20f:2f7d with SMTP id w16-20020a17090a029000b0025f020f2f7dmr458256pja.2.1691615506985; Wed, 09 Aug 2023 14:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691615506; cv=none; d=google.com; s=arc-20160816; b=LSVoiMDm34bOxbONqBdML/6Azw8g4QWQqHztSqjRZe0PrDYz4Y0VHzk8B73W33EVN3 UPqK6UCVPe6Qbud+svXoxz/r0tIge62L7T5e9a1/3VTwoZQF5B0hq5/clraYGozD9DXT 9RJT4Eo/BxUvAvL+oM4OXX+5/riVWdZSVepyXp7ulKucXXrN9OCj6nkj5bbuw3xBVFpf f3gudt59tOVpuoHJLCdWLeln2OFrR2WwmO2dhrp148wkS0YuT/yRbjqa95JDIlemvXuq g8KhQUv/mgam7uYP/oGZpKFm8cK7L8+H1HDu+NC7Wzl1qLdm0oFZXfXBk91I47aHbSCf noOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QQFBWgxdN0XGoqMud/489Z/OrjH8bXxqiFdpbJqJQl4=; fh=rhXS++P111RItQq/xmcuKBWaqWxyScJoyxYs1vcDXxE=; b=Heh73ga2oJe6zjjjQcZ12ru74eOQjhSnluHzZg6KnbQGKW4+EqQpp1iUVrfTDw+FgX nSeJMc40z4BsZ/xClfzkd5ILiMPbP83ShaNcPIDDst9wR72Tak2mtSYp/ISLx7toLoBM xK/iotxY9Zk21zTjDcDrSXCo4aB825tMCF3VP67DIQfY9di/JbjtmE3iEgHLULp7vuet /eaTiGBSWQnsqGZfSaplm1s/NVEEHnTyHMt80H/RHdzRjLeinuD0B37DxhRPR6Okim8d weDkCVrsINOtNgoJpPnvaoD4EI+23SoW+gOdZGJeig0RZ0JRzJlDhafYSFzMDazXEvQs X7Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gu0a3VdP; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a17090ad79100b0026826148914si83254pju.32.2023.08.09.14.11.26; Wed, 09 Aug 2023 14:11:46 -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=20221208 header.b=gu0a3VdP; 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 S233369AbjHITMY (ORCPT + 99 others); Wed, 9 Aug 2023 15:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbjHITMG (ORCPT ); Wed, 9 Aug 2023 15:12:06 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AE772126; Wed, 9 Aug 2023 12:12:04 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbea147034so884495e9.0; Wed, 09 Aug 2023 12:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691608323; x=1692213123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QQFBWgxdN0XGoqMud/489Z/OrjH8bXxqiFdpbJqJQl4=; b=gu0a3VdPqeCE17z1yqWvyCWnslmrJ4TOQZoHdVX0P1ZoSrIP3maV4qVcHHRhGNIyTz EyNCsMhA1IA9YU+CockSTtIwj+opyjDu3iaREGXIo6w7edIKASlWdN4vHO50EDqWgHBt hv5cM+SJx6XoUZmRjIbKQShca8slGH7eEt7iUDHh3U41CZ3FCWOkWVH8EEyJWkL+6zJZ em1kT1mgRiwrDKrPTuuFoKnt1Yhs4AA9oKxLreLeTaUVTn9kGQbeytteCClCiPpzlCNk 7OPk2iQEx64kX3qPno9uubK85QZJzAOPb6auMzeHuipsj4aUjsjTJbGqAtdfIlULXrR9 eu3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691608323; x=1692213123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QQFBWgxdN0XGoqMud/489Z/OrjH8bXxqiFdpbJqJQl4=; b=UMwLUKufjWIFz8yXpTGeBU6zHkwTSkZUmoCPe8p3uYXa2VcHJshQo7+tWEwxgPvMPQ eQnj2P4qR8jghUrNavzzDU1YrCbuGeGFa32so+/8VunBtPQuHDFBR0n+Nrg7NU1gCyQ6 3J791pJr0+fCSq8Mne9WILqzi/3h46QoWCHKeH01/hGyLr2cicnN7skJ3GfrXHugnoTF gmn4XD3seBKKn230oMRUq3pcIWzTuqR8GKISYJTCp+AMY67oY1DsIGbMe2DAwAgatrsF erehTHCjyTdDX6BBl5qXiQtn4y63IhUXgXpXCo+hZypmY6uQqy5C2iHudDjNHw8/8jTR jn5A== X-Gm-Message-State: AOJu0YyTaibNDrKgmi9H+l4gGILAu4y99mlsJ05HAkUTrdcWgGM9Lj31 mDnvbMmEflmoJYUMrMHKE+zQar1Db/+87g== X-Received: by 2002:a05:6000:910:b0:317:f702:70d8 with SMTP id cw16-20020a056000091000b00317f70270d8mr167261wrb.67.1691608322477; Wed, 09 Aug 2023 12:12:02 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:bb2:6df0:64ae:3840:3a64:b26a]) by smtp.gmail.com with ESMTPSA id f6-20020adfdb46000000b003177074f830sm17582681wrj.59.2023.08.09.12.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 12:12:02 -0700 (PDT) From: Mehdi Djait To: jic23@kernel.org, mazziesaccount@gmail.com Cc: krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, robh+dt@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mehdi Djait Subject: [PATCH v7 7/7] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer Date: Wed, 9 Aug 2023 21:11:38 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773787422038733297 X-GMAIL-MSGID: 1773787422038733297 Kionix KX132-1211 is a tri-axis 16-bit accelerometer that can support ranges from ±2G to ±16G, digital output through I²C/SPI. Add support for basic accelerometer features such as reading acceleration via IIO using raw reads, triggered buffer (data-ready), or the WMI IRQ. Datasheet: https://kionixfs.azureedge.net/en/document/KX132-1211-Technical-Reference-Manual-Rev-5.0.pdf Acked-by: Matti Vaittinen Reviewed-by: Andy Shevchenko Signed-off-by: Mehdi Djait --- v7: - added a min_t in kx132_get_fifo_bytes to ensure that we don't that the fifo_bytes is never bigger than the fifo_length * KX022A_FIFO_SAMPLES_SIZE_BYTES - no matter what we read from I2C as suggested by Matti v6: - no changes v5: - moved the position of u16 buf_smp_lvl_mask as suggested by Andy - introduced buf_smp_lvl_mask in Patch 7 as suggested by Jonathan v4: - added KX132_REG_CNTL5 to the volatile ranges - added the kionix reserved regs to the read_only ranges - removed KX132_REG_MAN_WAKEUP from the write_only ranges v3: - fixed the warning of the kernel test robot in kx132_get_fifo_bytes (invalid assignment: &=, left side has type restricted __le16 right side has type unsigned short) v2: - mentioned the kx132-1211 in the Kconfig - added a kx132-specific get_fifo_bytes function - changed the device name from "kx132" to "kx132-1211 drivers/iio/accel/Kconfig | 8 +- drivers/iio/accel/kionix-kx022a-i2c.c | 2 + drivers/iio/accel/kionix-kx022a-spi.c | 2 + drivers/iio/accel/kionix-kx022a.c | 164 ++++++++++++++++++++++++++ drivers/iio/accel/kionix-kx022a.h | 54 +++++++++ 5 files changed, 226 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index b6b45d359f28..d8cc6e6f2bb9 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -418,8 +418,8 @@ config IIO_KX022A_SPI select IIO_KX022A select REGMAP_SPI help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to SPI interface. config IIO_KX022A_I2C tristate "Kionix KX022A tri-axis digital accelerometer I2C interface" @@ -427,8 +427,8 @@ config IIO_KX022A_I2C select IIO_KX022A select REGMAP_I2C help - Enable support for the Kionix KX022A digital tri-axis - accelerometer connected to I2C interface. + Enable support for the Kionix KX022A, KX132-1211 digital tri-axis + accelerometers connected to I2C interface. config KXSD9 tristate "Kionix KXSD9 Accelerometer Driver" diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index c59558fc6493..0f4729c55d29 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -41,12 +41,14 @@ static int kx022a_i2c_probe(struct i2c_client *i2c) static const struct i2c_device_id kx022a_i2c_id[] = { { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, + { .name = "kx132-1211", .driver_data = (kernel_ulong_t)&kx132_chip_info }, { } }; MODULE_DEVICE_TABLE(i2c, kx022a_i2c_id); static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, + { .compatible = "kionix,kx132-1211", .data = &kx132_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a-spi.c b/drivers/iio/accel/kionix-kx022a-spi.c index 896b57866fc9..c7766492bcd9 100644 --- a/drivers/iio/accel/kionix-kx022a-spi.c +++ b/drivers/iio/accel/kionix-kx022a-spi.c @@ -37,12 +37,14 @@ static int kx022a_spi_probe(struct spi_device *spi) static const struct spi_device_id kx022a_id[] = { { .name = "kx022a", .driver_data = (kernel_ulong_t)&kx022a_chip_info }, + { .name = "kx132-1211", .driver_data = (kernel_ulong_t)&kx132_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, kx022a_id); static const struct of_device_id kx022a_of_match[] = { { .compatible = "kionix,kx022a", .data = &kx022a_chip_info }, + { .compatible = "kionix,kx132-1211", .data = &kx132_chip_info }, { } }; MODULE_DEVICE_TABLE(of, kx022a_of_match); diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index 0b0f14dca17f..6a9e6d850ec0 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -150,6 +150,117 @@ static const struct regmap_config kx022a_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +/* Regmap configs kx132 */ +static const struct regmap_range kx132_volatile_ranges[] = { + { + .range_min = KX132_REG_XADP_L, + .range_max = KX132_REG_COTR, + }, { + .range_min = KX132_REG_TSCP, + .range_max = KX132_REG_INT_REL, + }, { + /* The reset bit will be cleared by sensor */ + .range_min = KX132_REG_CNTL2, + .range_max = KX132_REG_CNTL2, + }, { + .range_min = KX132_REG_CNTL5, + .range_max = KX132_REG_CNTL5, + }, { + .range_min = KX132_REG_BUF_STATUS_1, + .range_max = KX132_REG_BUF_READ, + }, +}; + +static const struct regmap_access_table kx132_volatile_regs = { + .yes_ranges = &kx132_volatile_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_volatile_ranges), +}; + +static const struct regmap_range kx132_precious_ranges[] = { + { + .range_min = KX132_REG_INT_REL, + .range_max = KX132_REG_INT_REL, + }, +}; + +static const struct regmap_access_table kx132_precious_regs = { + .yes_ranges = &kx132_precious_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_precious_ranges), +}; + +static const struct regmap_range kx132_read_only_ranges[] = { + { + .range_min = KX132_REG_XADP_L, + .range_max = KX132_REG_INT_REL, + }, { + .range_min = KX132_REG_BUF_STATUS_1, + .range_max = KX132_REG_BUF_STATUS_2, + }, { + .range_min = KX132_REG_BUF_READ, + .range_max = KX132_REG_BUF_READ, + }, { + /* Kionix reserved registers: should not be written */ + .range_min = 0x28, + .range_max = 0x28, + }, { + .range_min = 0x35, + .range_max = 0x36, + }, { + .range_min = 0x3c, + .range_max = 0x48, + }, { + .range_min = 0x4e, + .range_max = 0x5c, + }, { + .range_min = 0x77, + .range_max = 0x7f, + }, +}; + +static const struct regmap_access_table kx132_ro_regs = { + .no_ranges = &kx132_read_only_ranges[0], + .n_no_ranges = ARRAY_SIZE(kx132_read_only_ranges), +}; + +static const struct regmap_range kx132_write_only_ranges[] = { + { + .range_min = KX132_REG_SELF_TEST, + .range_max = KX132_REG_SELF_TEST, + }, { + .range_min = KX132_REG_BUF_CLEAR, + .range_max = KX132_REG_BUF_CLEAR, + }, +}; + +static const struct regmap_access_table kx132_wo_regs = { + .no_ranges = &kx132_write_only_ranges[0], + .n_no_ranges = ARRAY_SIZE(kx132_write_only_ranges), +}; + +static const struct regmap_range kx132_noinc_read_ranges[] = { + { + .range_min = KX132_REG_BUF_READ, + .range_max = KX132_REG_BUF_READ, + }, +}; + +static const struct regmap_access_table kx132_nir_regs = { + .yes_ranges = &kx132_noinc_read_ranges[0], + .n_yes_ranges = ARRAY_SIZE(kx132_noinc_read_ranges), +}; + +static const struct regmap_config kx132_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .volatile_table = &kx132_volatile_regs, + .rd_table = &kx132_wo_regs, + .wr_table = &kx132_ro_regs, + .rd_noinc_table = &kx132_nir_regs, + .precious_table = &kx132_precious_regs, + .max_register = KX132_MAX_REGISTER, + .cache_type = REGCACHE_RBTREE, +}; + struct kx022a_data { struct regmap *regmap; const struct kx022a_chip_info *chip_info; @@ -239,6 +350,13 @@ static const struct iio_chan_spec kx022a_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; +static const struct iio_chan_spec kx132_channels[] = { + KX022A_ACCEL_CHAN(X, KX132_REG_XOUT_L, 0), + KX022A_ACCEL_CHAN(Y, KX132_REG_YOUT_L, 1), + KX022A_ACCEL_CHAN(Z, KX132_REG_ZOUT_L, 2), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + /* * The sensor HW can support ODR up to 1600 Hz, which is beyond what most of the * Linux CPUs can handle without dropping samples. Also, the low power mode is @@ -612,6 +730,26 @@ static int kx022a_get_fifo_bytes(struct kx022a_data *data) return fifo_bytes; } +static int kx132_get_fifo_bytes(struct kx022a_data *data) +{ + __le16 buf_status; + int ret, fifo_bytes; + + ret = regmap_bulk_read(data->regmap, data->chip_info->buf_status1, + &buf_status, sizeof(buf_status)); + if (ret) { + dev_err(data->dev, "Error reading buffer status\n"); + return ret; + } + + fifo_bytes = le16_to_cpu(buf_status); + fifo_bytes &= data->chip_info->buf_smp_lvl_mask; + fifo_bytes = min_t(int, fifo_bytes, data->chip_info->fifo_length * + KX022A_FIFO_SAMPLES_SIZE_BYTES); + + return fifo_bytes; +} + static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, bool irq) { @@ -1034,6 +1172,32 @@ const struct kx022a_chip_info kx022a_chip_info = { }; EXPORT_SYMBOL_NS_GPL(kx022a_chip_info, IIO_KX022A); +const struct kx022a_chip_info kx132_chip_info = { + .name = "kx132-1211", + .regmap_config = &kx132_regmap_config, + .channels = kx132_channels, + .num_channels = ARRAY_SIZE(kx132_channels), + .fifo_length = KX132_FIFO_LENGTH, + .who = KX132_REG_WHO, + .id = KX132_ID, + .cntl = KX132_REG_CNTL, + .cntl2 = KX132_REG_CNTL2, + .odcntl = KX132_REG_ODCNTL, + .buf_cntl1 = KX132_REG_BUF_CNTL1, + .buf_cntl2 = KX132_REG_BUF_CNTL2, + .buf_clear = KX132_REG_BUF_CLEAR, + .buf_status1 = KX132_REG_BUF_STATUS_1, + .buf_smp_lvl_mask = KX132_MASK_BUF_SMP_LVL, + .buf_read = KX132_REG_BUF_READ, + .inc1 = KX132_REG_INC1, + .inc4 = KX132_REG_INC4, + .inc5 = KX132_REG_INC5, + .inc6 = KX132_REG_INC6, + .xout_l = KX132_REG_XOUT_L, + .get_fifo_bytes = kx132_get_fifo_bytes, +}; +EXPORT_SYMBOL_NS_GPL(kx132_chip_info, IIO_KX022A); + int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info) { static const char * const regulator_names[] = {"io-vdd", "vdd"}; diff --git a/drivers/iio/accel/kionix-kx022a.h b/drivers/iio/accel/kionix-kx022a.h index c9f9aee7e597..ea6202d29303 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -74,6 +74,57 @@ #define KX022A_REG_SELF_TEST 0x60 #define KX022A_MAX_REGISTER 0x60 +#define KX132_REG_WHO 0x13 +#define KX132_ID 0x3d + +#define KX132_FIFO_LENGTH 86 + +#define KX132_REG_CNTL 0x1b +#define KX132_REG_CNTL2 0x1c +#define KX132_REG_CNTL5 0x1f +#define KX132_MASK_RES BIT(6) +#define KX132_GSEL_2 0x0 +#define KX132_GSEL_4 BIT(3) +#define KX132_GSEL_8 BIT(4) +#define KX132_GSEL_16 GENMASK(4, 3) + +#define KX132_REG_INS2 0x17 +#define KX132_MASK_INS2_WMI BIT(5) + +#define KX132_REG_XADP_L 0x02 +#define KX132_REG_XOUT_L 0x08 +#define KX132_REG_YOUT_L 0x0a +#define KX132_REG_ZOUT_L 0x0c +#define KX132_REG_COTR 0x12 +#define KX132_REG_TSCP 0x14 +#define KX132_REG_INT_REL 0x1a + +#define KX132_REG_ODCNTL 0x21 + +#define KX132_REG_BTS_WUF_TH 0x4a + +#define KX132_REG_BUF_CNTL1 0x5e +#define KX132_REG_BUF_CNTL2 0x5f +#define KX132_REG_BUF_STATUS_1 0x60 +#define KX132_REG_BUF_STATUS_2 0x61 +#define KX132_MASK_BUF_SMP_LVL GENMASK(9, 0) +#define KX132_REG_BUF_CLEAR 0x62 +#define KX132_REG_BUF_READ 0x63 +#define KX132_ODR_SHIFT 3 +#define KX132_FIFO_MAX_WMI_TH 86 + +#define KX132_REG_INC1 0x22 +#define KX132_REG_INC5 0x26 +#define KX132_REG_INC6 0x27 +#define KX132_IPOL_LOW 0 +#define KX132_IPOL_HIGH KX022A_MASK_IPOL +#define KX132_ITYP_PULSE KX022A_MASK_ITYP + +#define KX132_REG_INC4 0x25 + +#define KX132_REG_SELF_TEST 0x5d +#define KX132_MAX_REGISTER 0x76 + struct device; struct kx022a_data; @@ -86,6 +137,7 @@ struct kx022a_data; * @channels: pointer to iio_chan_spec array * @num_channels: number of iio_chan_spec channels * @fifo_length: number of 16-bit samples in a full buffer + * @buf_smp_lvl_mask: buffer sample level mask * @who: WHO_AM_I register * @id: WHO_AM_I register value * @cntl: control register 1 @@ -109,6 +161,7 @@ struct kx022a_chip_info { const struct iio_chan_spec *channels; unsigned int num_channels; unsigned int fifo_length; + u16 buf_smp_lvl_mask; u8 who; u8 id; u8 cntl; @@ -130,5 +183,6 @@ struct kx022a_chip_info { int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info); extern const struct kx022a_chip_info kx022a_chip_info; +extern const struct kx022a_chip_info kx132_chip_info; #endif