From patchwork Fri May 26 14:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp529535vqr; Fri, 26 May 2023 07:44:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M1wyhpYqd1QtfifZwV/SHBJHYF5YeQOOpBWVmhGfx7RAj6E6oWE1yenbCOGQO7/k2MvXW X-Received: by 2002:a05:6a21:9214:b0:102:f6f2:c962 with SMTP id tl20-20020a056a21921400b00102f6f2c962mr2351640pzb.54.1685112292872; Fri, 26 May 2023 07:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685112292; cv=none; d=google.com; s=arc-20160816; b=PHlUtu8gL5571YREIcCO3XjFh6M23+knVNaV/R+/Lf/az812keHtJBIB5XCoc3g9An GpVY1nSzup1vAm7A3UW4UUmGAphO5oBR6tPkChsBZAw02/XS9ceZqnViiowbspITUI8G 5w1LcBuazYv6ZQG5lb3KMaB3qU73PYkAvEGv1wgezOEGmPg2V75PzGWhsKG2+fZZ+0XM I71dIk5UWIpaQ8+XY9cRna9zBch5OU8bIiad6L1cgwxAyV5ColK9OdHRv5XSATEEvXMg 1BYvPf35WcvhvX3CJWiikVkL9jK6U9+4mhtxdgvCrPNMFjDU1UGaW5epgNrw15sE612M g3fw== 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=Y+yqAgEVRVUUB3f5eL90/ZY0oOly65J84Yw/HEeUjmc=; b=mmEmF+4QT6cv35cHKzn61Cd6JOs9nDpJvfsoqNglfmlGVMxVNmK7yb8N8Oo6AWx6hH tP5ZbSlzhkARvvHLPRBLWgMdTAtP6N4dPtWgrO2HyJ3Gm48uDRNeZlm7NU9GKGk0DocU cPecvsPp17XyE706Dj6bI0ZBhkhev2HI+pGrPrgkCK6jMNx+v+JPEVZeL+mP5e/6yYgx syeGdmj+lhgIfzotZgcrpgsGvk1C23KioB6BiUYQcYBuqLKpf+T2DepqoLxk0Cv2b0eK l00iINyvb6nI3w6HFxoIKhWWmQHzO7luUN7Xwq3CEuN2dFvj+QlEXhk/MKmQ1mlOISTW eNXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ooPFcAWn; 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 a6-20020a655c86000000b0053eee37e16asi736254pgt.522.2023.05.26.07.44.39; Fri, 26 May 2023 07:44:52 -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=ooPFcAWn; 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 S243857AbjEZObG (ORCPT + 99 others); Fri, 26 May 2023 10:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243851AbjEZObD (ORCPT ); Fri, 26 May 2023 10:31:03 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47A9187; Fri, 26 May 2023 07:31:01 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-510d6e1f1abso1500433a12.2; Fri, 26 May 2023 07:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111460; x=1687703460; 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=Y+yqAgEVRVUUB3f5eL90/ZY0oOly65J84Yw/HEeUjmc=; b=ooPFcAWnZ/mUrcrLFs7lwlZcCRAPr2FI1Z6G8d1M4rM7loUiF6CMNiBWVDVIwEm4Du HD0zjKT+FlNa/Xs3HeJZ8waZG86qaN9tZ3AWoS0ZUwpAvxhFsYWDITZryo82fDGRapZ5 q17shjmAIpbwRke2BnKvrIDiG1um4diFP7peLuRpCzQsFpouSVI3zbqXnsTlwX+AxqzU 3c6zACTfPdNd9EgTuoEODjVbPfgzDd0KdTaOVK3zo6RkguSKWgy8/iHTGAxkqs5k2ux5 Jm+na/w5Ch8q79daBTckpZt956+sARmw/FlcqdxVPJinE9H61+zfeShGB6qV3Rx2gXZU PI0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111460; x=1687703460; 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=Y+yqAgEVRVUUB3f5eL90/ZY0oOly65J84Yw/HEeUjmc=; b=BriSc7sqz+bSn3lr4X/JvIfxFVftJD4bvQUNwvJCYadcqkRvcGCqlj4q0/1B+BTx/j Ym9MsjhkxVt3jFxQHsjrFlDzA0AjrIVTqgTCWOdPfAFWoCalrvkv1fSMBylcXtMUYfke S8CJvFCxOlJZRo2LptSqHtjRIDQKWIhK2XPAMLWwvq7EnlDwYy+86VJ6P9QydKVB75OY z+K7xaz+5hbmIaTPh5VfB8XcBy6ct+5shVtkkiPLMXicLARY5F0takRLrU5y38ZJt1Dd 1XXdYHxDiq7pG4QnCap64QS6uZl2FB6qFA8b6AunvXFwt+VuF11//UYyGHfLiqtU/CS6 Y6Vw== X-Gm-Message-State: AC+VfDx/C1xkvTS+dmFkyR61+3gCBjWbtic00E17BsAcBE1phEkKjLns 7wfCfeLywOt6HkP5Vs2nBaY= X-Received: by 2002:a17:907:9306:b0:96f:aed9:2535 with SMTP id bu6-20020a170907930600b0096faed92535mr2120955ejc.9.1685111460160; Fri, 26 May 2023 07:31:00 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:30: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 , Krzysztof Kozlowski Subject: [PATCH v4 1/7] dt-bindings: iio: Add KX132-1211 accelerometer Date: Fri, 26 May 2023 16:30:42 +0200 Message-Id: <0d6051ad217f91c7de0883c4ca1516bdacc343ce.1685109507.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,T_SCC_BODY_TEXT_LINE, 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766968307370932048?= X-GMAIL-MSGID: =?utf-8?q?1766968307370932048?= 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 --- 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 Fri May 26 14:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp521978vqr; Fri, 26 May 2023 07:33:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4U+7/PBZitt6X1yVLx4ZPaUxGuxjFIAZ/BsS/xAzBptEhkLBBXIejvDvkmTBjDPvbaGBve X-Received: by 2002:a05:6a20:244f:b0:104:873:c3be with SMTP id t15-20020a056a20244f00b001040873c3bemr2612746pzc.12.1685111614980; Fri, 26 May 2023 07:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685111614; cv=none; d=google.com; s=arc-20160816; b=HgyFva/R3g11XOUX1YBqzZCYThORNPgW2kCIrNBkP46CwqXBWwjjnzLtYt8ShAj+7x /b3giHYlFd5aLKgD+HXBweFuf3P7RojoTJA0iJTsUdeGIYvL2xulNDS8JC7D4Pj3Wig9 tPdetxuxDRp/kn/zdTDi+QY5pqhSnsxe5ueqPo/S6QIP/6ZlUA7GAh7x5DoEnAz8ym0h AsCi4eftyqUJ4ZGVQc5CiYdmeTwmUTL7B0F80sN6rdwkrImHWKOihtYyeYmsD5k6uMdM 0jv+TMkiMykbKO3iyfZYQvORGuXbRiGtE0ywUqQfUUq/QwCG3Udi4ny42TPRpFzL6IzM Dz7g== 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=Y+9f25ca4rz+2FZ8Gemnn0XEwiBdFXDfccTa66p6xkM=; b=k1uQ+b4fvH9xWj0J5m0ojWn+jW1oZfMQwqGejoiIHpRu4WYBlM7wjJUE4GodlSRP6e iX/QeOqukSor/L7LTZwlHgJdPSN2M/9VOLbthMur7fZYm/54/YL8ZT5g3Jh2LvUKX4/m ggWAz7qt7pd4sYud4cX/QlQtRu8b/K7o/MCerGdot1TOAdvcNp72XztzAVGYLa87Debs F0yO3EGl2IrPQcH+SFsUM+g7vzfV2jErdiaE3Q80Zgfk/c5Amp/dgs1sJEBf+7wizcX9 OCP+pJLEWNpa7UJEZLnGgz+4KNAVA+aHUW2u6zcOxzOryHvqOJ8Wnps3pdY9JWdAzw98 BcUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KNPC1AAb; 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 w129-20020a623087000000b006452ad45992si3963561pfw.3.2023.05.26.07.33.21; Fri, 26 May 2023 07:33:34 -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=KNPC1AAb; 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 S243865AbjEZObI (ORCPT + 99 others); Fri, 26 May 2023 10:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243856AbjEZObG (ORCPT ); Fri, 26 May 2023 10:31:06 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B15D187; Fri, 26 May 2023 07:31:04 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-510eb3dbaaeso1353382a12.1; Fri, 26 May 2023 07:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111462; x=1687703462; 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=Y+9f25ca4rz+2FZ8Gemnn0XEwiBdFXDfccTa66p6xkM=; b=KNPC1AAbof+1iiPmBhT4VAQevOf5BP8bYKrBgPD0zSvHenFGnDLyuZDzoRiPscc6Ny 3oPhDzs1Zcddh03E+0AkwklXkxiAnIaP57MSrI6zw+N1kLO7Qwf2odJ2KsV4+V1o5DBZ gf7UMaQBtIRtPR8f7FZUg7kV/GHnoyE8DpU60QaAHUf1Hnff9c0qrM85gDouFrn7w84j Pj6fgYg1419Vhq5bJwq44Uvzr5DXGBndclQ6j57KWvgVUwvaO1oAGw/6DuJHlf365E6A cqlHAC3hUq3TOi1/lBx+dhSnunC2a2FgTogOuaYI2O29ySPiQftuYqjOuzJV72uxwoRD a8wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111462; x=1687703462; 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=Y+9f25ca4rz+2FZ8Gemnn0XEwiBdFXDfccTa66p6xkM=; b=SvywFLEjB/LlhvCB2MtnmglD1IKm1xAhxJac14W4Oh9h1jRiQYjXPijCLdtecUJ5fj LIHFsa/9hfgZXEULmJa000bHHQD28FHGWTCOEQ5+eujc6frrYX81Bo5jjQp1DqAi+4lw fA+SlunXhZocgdl4Nwd/+yyAKQrPToXeN3vu6TAmxd4euy7VjzCUCeGwF9T0vXLGc4SU vPBmU5L4wJlkcU+SzOdTh49+reDQuYXMfD69ehNfUp0aCcOG45znVC5ESfaqpKnyD7F0 5edXKJ0KUz6e1PAUHwk4+13iD5dQu7GTfImOnIgqSYeqeZd3pnCa+r+VHne2XyK3PlgE aEbA== X-Gm-Message-State: AC+VfDwzz5pUdEC7dPDdBlUvjVp/gS/QGP83kyyizLLG8iomr+BdIKmH OTRYnadI3xK7uCQdhxF/vyM= X-Received: by 2002:a17:906:7310:b0:966:1fef:22d8 with SMTP id di16-20020a170906731000b009661fef22d8mr2487662ejc.7.1685111462538; Fri, 26 May 2023 07:31:02 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31: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 v4 2/7] iio: accel: kionix-kx022a: Remove blank lines Date: Fri, 26 May 2023 16:30:43 +0200 Message-Id: <40c033bc4c139fe450d8785c327f500f6f3ca965.1685109507.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,T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766967596521342502?= X-GMAIL-MSGID: =?utf-8?q?1766967596521342502?= Remove blank lines pointed out by the checkpatch script. Reviewed-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- 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 Fri May 26 14:30:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp522045vqr; Fri, 26 May 2023 07:33:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bimbJFQBvqRAW+h+rTHKyjm6LsO2ZAytQ+HX+c0BIR8QjiP+KBULiklViRjrWNfjIqwKk X-Received: by 2002:a05:6a20:7da5:b0:f2:57da:7f45 with SMTP id v37-20020a056a207da500b000f257da7f45mr3018196pzj.8.1685111620567; Fri, 26 May 2023 07:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685111620; cv=none; d=google.com; s=arc-20160816; b=PUkfciH1viQsOe7HiHBj9nP495qanaCyQEaZsJL+WHerfeA+3dlL5AJ+ZbdGJNQA0M o/3w7HCd5v4w2a79Yry3OT9rPQaHzi8zGferpju4pCVFi7ms5WtxgGAKKypF7K5LKkNB HMRP+CmEf+J+4CbbstZHhv6jv6476BB8ErFOKfgJlJOT7OgNY9XLXerDYDAbaptKmnVi wQAY7oVX+hWWJ9Rt2f32uQZ3dQTVPPPsIYnvCebRYk4zcp+baA8lh73tIQ9xbupxQrQE pk9d0uHdtrT9sHA3NsfBK8/52D/r2XNo+1Gim6glKsGHoalSb6xf+wIQXA9fx9jr7Dpy QFog== 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=bR+n0r4xZA3l73V+FeeZfa6IV+HvrfUxq6BwqD6x6q0=; b=yw2rMG8Fe8Vqj87a6ID3j5pG1uR4RY5UYCQk5LiSFsZrY8OLu+Fj+DK5e/wqqxshWf jXpwbUhGrS/fQQU54DXucqDm0bAHBlxCYS+yUS54amGoZYfTNOLUs1n2sDkpOoa40OA6 VsVrrA5h1scZBzRS9V89Dw329K0DpKa5FlYIiqrfafVMJT65UyAeXkRkZsuLKo0xQnCD UPB5ILBB32j/iEtVEeV2yr5t9syBk3sTCGfGr8le4rlZRdvse9OUprioBMl84YSDNG04 7nQb5tdpzIbIUH61nQF26hIoeawuJc9RGTm5BW9kx6t/xxIbC23sDtCGtkyfxc9if7HG PcJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Kw55PJEy; 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 h191-20020a6383c8000000b0053472db4f53si3810623pge.667.2023.05.26.07.33.26; Fri, 26 May 2023 07:33:40 -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=Kw55PJEy; 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 S237293AbjEZObN (ORCPT + 99 others); Fri, 26 May 2023 10:31:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243862AbjEZObH (ORCPT ); Fri, 26 May 2023 10:31:07 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4615E187; Fri, 26 May 2023 07:31:06 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-96ff9c0a103so115085466b.0; Fri, 26 May 2023 07:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111464; x=1687703464; 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=bR+n0r4xZA3l73V+FeeZfa6IV+HvrfUxq6BwqD6x6q0=; b=Kw55PJEypdtQz6vZ8Q/UJvVmm0DoUjDrSczqfSyImvq2WDIrGza0xXCKvNk0Am6ZZD y8efE2xA7ZiSCvLfdPe78SSInwCL64spuPe7kdwU0faHUAEb3noMNexXxvxq/JVr3yoi HFYfLy8H8FGPQBSGJyTvaTbAEHoDrhOcp91CD3X3yzY+wuVv6tGgUDvnkLOj0HBq+fs8 zdR12Kx6EWqxCjlkqxJrXGbADHA84wxhYybO3Xebg5z2J5UFUD5oZdHJob91A1TT+hKW TYB6ye3mqGJcHYAkVe0uJeD3uSRrs/qHN9RCcBtSp6XOtxdSq43YYoS6Prgiu8mxrdb6 crAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111464; x=1687703464; 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=bR+n0r4xZA3l73V+FeeZfa6IV+HvrfUxq6BwqD6x6q0=; b=fUSyIC4K0flr5AlRJ3uhzj/TsPvMzn9NeDQYUFPYSdLwkQdNZnto0H0K5BNyi0qIMw U0s/c9iu71/3HDyduSUsOsq1W1vsvNleyGUcbpsXWfA12/qNmdN4jS3RTFJM7ZnTF4LG Wia0gP2R+zAxK8MR3c9raxa2ZeLOAgakVvjCYpHPAwakkqRsmilUeCtEQAVcxijRUXvW NsPosI8EKKP4DruwhYKc3NiaI1c3wKJW1gntrQI+f9Re8TXO0SLr1iOrTztIJdEeA96y bGIMW54Vd7MjWLzyOIkId7X5Pr6IvHgKlfbsPkex8r0XpMnUq5M2JLAbN8UuBGsRcsdA rbAA== X-Gm-Message-State: AC+VfDxGgo6kWR8DgsEDsfdXPySRYHGCZt7ibow61nuiBHoaxNOUC0qH HNxwUODepVLowqlTheZUsao= X-Received: by 2002:a17:907:9445:b0:965:6cb9:b768 with SMTP id dl5-20020a170907944500b009656cb9b768mr1987558ejc.31.1685111464232; Fri, 26 May 2023 07:31:04 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31:03 -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 v4 3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility Date: Fri, 26 May 2023 16:30:44 +0200 Message-Id: <18574aeeb9b66a9799972763ea6b8019fe7ffc35.1685109507.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,T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766967602536095220?= X-GMAIL-MSGID: =?utf-8?q?1766967602536095220?= 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 --- 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 Fri May 26 14:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp522182vqr; Fri, 26 May 2023 07:33:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dQG1/YuDuyGfOrDxfy93KF8rjBeSVlt/BbCxTBq/pUZoBuQhib5zIilIooQ3xzf/VqsCx X-Received: by 2002:a17:90a:304f:b0:252:7f38:ad86 with SMTP id q15-20020a17090a304f00b002527f38ad86mr2872011pjl.12.1685111629015; Fri, 26 May 2023 07:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685111629; cv=none; d=google.com; s=arc-20160816; b=FvWmaaF/x0ixQqbqfQxmWBkMcbB1yGgzz0mOYjrB06YyKWhooTQxFMut1wW/GUR5O4 mft4J8QDcohchKtD9CvqEz4g5EARN6qWKBwetzaKPG6/aHN4XkNTNj9t64Nr0xsvmC9T Kan7AOSvFvtXXFNYUvYLavvJJDWjb2CZlg5LMZcLq9iKmT2ELggM4NnMPOe90RtFWgWJ o2oJjbkk005DRzfSgghXk/KyoTBIodKdgzMS4eYxHutlq6D3jV4Ta/tdSaZXkGmPkg0e Rrs9ZUxHMd9Hmo/4g8p7oTzCSCQm6vu7KOvnfKv1bPnOF9zDad7WpfA9yQhNSsRqjlxb pMgQ== 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=Emss/vVgehkGPlk0MWd1pRNn8uU75rHhNKdy8MFJSnM=; b=lB+H2oJ9too3TFC8Rm50LdoCbYADe9PePd0vJigVDvSIF1QUVMKOzxKHUzPnbfWteR iosf0MEnZSjhEdRvl5g4BxY7PRAK1FwkSoA3GViJ9yH54FchsO0flze3qIHUfW6YCgeP /QTtX5uArVYnltrjoIjkyZ+YfmDiTmlXfKwD/vrNAa+uj4yDQt0FqN6PkoSODdzVbalG eltb1j8hzKJUmqfD87pFhpo3jt+S3a1seaQCnNZJp9qzb0iqhONohJwZYUhQYIyYLt1a T1vFc4T10PeUjkkqgLaHMc+lLF+igFpItjzxodbgVCtmROh8UKCwFqAnR/c4gdKSTYkS StlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gsR38iCE; 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 f12-20020a63380c000000b005360d7da569si3599344pga.634.2023.05.26.07.33.34; Fri, 26 May 2023 07:33:48 -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=gsR38iCE; 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 S243886AbjEZObQ (ORCPT + 99 others); Fri, 26 May 2023 10:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243869AbjEZObJ (ORCPT ); Fri, 26 May 2023 10:31:09 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D7E199; Fri, 26 May 2023 07:31:07 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-97000a039b2so134277966b.2; Fri, 26 May 2023 07:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111466; x=1687703466; 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=Emss/vVgehkGPlk0MWd1pRNn8uU75rHhNKdy8MFJSnM=; b=gsR38iCEZDGns9v9iLjxW+SBA4awvzGbW5RP5d0vNxz74tKf5Uh9zrTogcniRJJZ2D bjxHMrNwJdrgvAmcxjQIqU+KL6+cMLbyvC+oXohThlbFhCf+n9CW1jUnbtPkZLtA/oYp pXqSnbupDGqFAmXJ2UFmHG09BU16hr0jV1FilQWeTBT1BcKpzulB6mY8otfelP+WQSZL domvyhCRZyC5l2P4iFKgf57qvFWiztXqP2Bbrtb/KZh2TMkaRYvJGWY7LxcSAR1tfXDK wqkWTimbMX5D0Exzl0/b57cEANNsLJYjdSkDFzp0KztDfey6gQvnRIuP/9IuXVpKoGr+ jGdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111466; x=1687703466; 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=Emss/vVgehkGPlk0MWd1pRNn8uU75rHhNKdy8MFJSnM=; b=OkvnTDslWP74PnyEJzZ99g6cU3brszhabNqLzbnRciVcuqRv9iyicbRWw1n7aifUwa 3ifiqiQ2ZO7yfqxoB4/D9VxVCXqueQME5X67woCccr1Zj3zQpwmTRtYf73bIET1IJAF2 B8DqbwoiBGnxNA5NsTAnsqvcgIdFi1dPsRgxkfbl31jp6/0w3vDMCWFhzVFQ/3RTSZjM aNNAMANFLuxlGlgvedzEFnfg+KneeTaFTUcYh83U+epzjE3gVLHv0CFBJ1Po4aHIxIm/ lwIjKQfWRxdWRsf9KjVbrhTlJog8/a+Ph+cNKk4hbk+2TTJHg/6xIhr6g+rSeIi+wRDH H24g== X-Gm-Message-State: AC+VfDyq6QmkngRT34f8mH+NpkOOID2/CAi63vD+NF3xEVOU77Z3Pged 3YZj1zbkV68kK+kgIueCAkc= X-Received: by 2002:a17:907:31c1:b0:94f:3bf7:dacf with SMTP id xf1-20020a17090731c100b0094f3bf7dacfmr2027006ejb.71.1685111466157; Fri, 26 May 2023 07:31:06 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31:05 -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 v4 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table Date: Fri, 26 May 2023 16:30:45 +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_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766967611765715485?= X-GMAIL-MSGID: =?utf-8?q?1766967611765715485?= Add the missing i2c device id. Signed-off-by: Mehdi Djait Acked-by: Matti Vaittinen --- 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 Fri May 26 14:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp529152vqr; Fri, 26 May 2023 07:44:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hqmZrUgY4Rt4ivnKWmOYrysD+q5wW4/8UUURGga1PUg15LrELqm+EBAwfetNWlXMUFVpq X-Received: by 2002:a05:6a20:7f88:b0:101:9344:bf82 with SMTP id d8-20020a056a207f8800b001019344bf82mr3015053pzj.15.1685112256457; Fri, 26 May 2023 07:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685112256; cv=none; d=google.com; s=arc-20160816; b=AjNR6aO1+ltR6/qTj1D7eoUZLsJ5ayaYYXeEVS5tynoMKm7CAbQYw7rAp/eNSKhz8y rxn451oWr8ORNa3DP5hEvyDp4abs8XzZzymceEAS4zU5srhrizdgoVsXGrCeEFyd2MAO +yMwmvzi9/p8eHpuevB31Si2IDJE0XbOj3gKVON4vz7/b1YUZLFo1uKUpJIetvkxzaZ0 kfh5MKX4YaSxppaTCUVFTixIZgXZdxiUWcLsS+1Mwbo8nnll4tIpaSlyVf9uZa+5Uw/E CmsK687mBkFEzGXeV5i1rDcHRl2ulElwVuAUqpA2aBLOg15e+j5ShsGx/cQFO2rv+EXW Q3/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=toievH7/+oWyZHlrb0+yliCY3sKDSRPleuDV5Z+osM4=; b=dCecWwQ4LsWHcwsg9ijyivuIUI6iYrMzz2DfPcgI/5CJ6oujJi0UNL/6PwTL06KuzK xL87P6j7aHnMgEsI2ChBvo3B32g/Z2Z3KypawZRpQNzeeUlp9PmQGoNT/ksa4IFX0MlP jueP2nmcTpD4+3U+FKLejf/uS0a84jGMxWJidvAJpcuvzT5bHOSzMl9jr4XyUBs/xLLK sS+EBrMKPY7RenYufOMU3faMDLbXUcoSxVwKdGnUm/gtUUlKN9wJ3uuQLrDfxcpm4/af d5KQ0uRkOwk8x8gKXSq5nmUUeIy6UP0HtNcLQdsP+5tqAAtssq1YoAVVv2jwOesDPTUh AEuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=aU1NZTMh; 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 s23-20020a17090aba1700b0024bda568513si1105167pjr.123.2023.05.26.07.43.59; Fri, 26 May 2023 07:44:16 -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=aU1NZTMh; 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 S243684AbjEZObV (ORCPT + 99 others); Fri, 26 May 2023 10:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243877AbjEZObO (ORCPT ); Fri, 26 May 2023 10:31:14 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6027194; Fri, 26 May 2023 07:31:09 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-96f0678de80so133204666b.3; Fri, 26 May 2023 07:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111468; x=1687703468; 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=toievH7/+oWyZHlrb0+yliCY3sKDSRPleuDV5Z+osM4=; b=aU1NZTMhKJLFPS6KVGl973X0vHX09BPaQQFS64r9rNN/13IO4ARQiMAnICfNQkNT2z JYNhThL+XZ8VDK8mAS0dmJ1iH6HUuhcjjDyfMnREMD8X+IoDvtfdBuU8zySJElXe05nH 306wajUKn5wqog2OKoM7fZGYDY+e7v6sGvuc76neRP8/uXqVzpn/EfGe/8hSIQmQqT/O h7+pTtAGtt9oTNIOVbpdqLbtAMtxIe8Wbes5LWVb9kwbnX4XnGBtgl+eMyCMrtWvWV4y S1wuKtLZledgZc1ID6mhDI56i5s6lwPTyGPd+7Rl9iKLbwYtSy7oVxDNqz+Ty4Qqjo9j vqKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111468; x=1687703468; 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=toievH7/+oWyZHlrb0+yliCY3sKDSRPleuDV5Z+osM4=; b=b2tHwtVBO76oQAI7VOUgJD1o+heOk+BTg9zw/SHhURTG5rCaeKgh6ceNv3R1VT4czs UrEu6Q/PdGDk02o1/K0eeEwkohUhzX0bg5EAhQca3UMQrWXAUZIybcHNGTWIPNtW/5/p rrdcrx+s4u0iq9GqfVwvwVjUmSxkLkCir42sAKMILtWwgYVFaLdiR7iqe/kGFrFf027j u3ZQWyUp9M+XaMADvHtVOWDjYeFG5C/5+qMuwFCvE+Yls+UyGkm8EpTVQUoSGsHFjswW M8xAyhV3G14HpFMuD2IApfov9fxdu19L7o34jFc8P2IwK6w2QSFnc0nXxwdCSnaUL6Tv ZYpw== X-Gm-Message-State: AC+VfDzpIZ3nVNFTmNk6tWrtBxchZIdsGpm7G5LQmAHp1IRMeceQDX+Z IC/YLtFa0dkuoi+Sci7AgOI= X-Received: by 2002:a17:907:6d0d:b0:94f:5847:8ac with SMTP id sa13-20020a1709076d0d00b0094f584708acmr2320361ejc.51.1685111467753; Fri, 26 May 2023 07:31:07 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31:07 -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 v4 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure Date: Fri, 26 May 2023 16:30:46 +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_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766968269381228954?= X-GMAIL-MSGID: =?utf-8?q?1766968269381228954?= 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. Signed-off-by: Mehdi Djait --- 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 v2: - mentioned the introduction of the i2c_device_id table in the commit - get i2c_/spi_get_device_id only when device get match fails - removed the generic KX_define - removed the kx022a_device_type enum - added comments for the chip_info struct elements - fixed errors pointed out by the kernel test robot drivers/iio/accel/kionix-kx022a-i2c.c | 15 +++- drivers/iio/accel/kionix-kx022a-spi.c | 11 ++- drivers/iio/accel/kionix-kx022a.c | 118 +++++++++++++++++--------- drivers/iio/accel/kionix-kx022a.h | 53 +++++++++++- 4 files changed, 145 insertions(+), 52 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a-i2c.c b/drivers/iio/accel/kionix-kx022a-i2c.c index b5a85ce3a891..ce299d0446f7 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,28 @@ 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; + } + + 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..1e4b9d4b4b8d 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,24 @@ 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); + + 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..69c22071c731 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,9 +149,9 @@ 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 { + const struct kx022a_chip_info *chip_info; struct regmap *regmap; struct iio_trigger *trig; struct device *dev; @@ -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,8 @@ 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; + if (val > data->chip_info->fifo_length) + val = data->chip_info->fifo_length; mutex_lock(&data->mutex); data->watermark = val; @@ -592,7 +594,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 +602,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 +680,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[0], 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 +733,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); } @@ -762,6 +763,8 @@ static int kx022a_fifo_disable(struct kx022a_data *data) { int ret = 0; + kfree(data->fifo_buffer); + ret = kx022a_turn_off_lock(data); if (ret) return ret; @@ -770,7 +773,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; @@ -801,6 +804,12 @@ 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 +820,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 +866,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 +914,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 +967,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 +977,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 +987,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 +1004,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 +1055,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 +1066,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 +1092,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..c23b6f03409e 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -76,7 +76,56 @@ 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; + u16 buf_smp_lvl_mask; + 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 Fri May 26 14:30:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99534 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp543087vqr; Fri, 26 May 2023 08:04:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZQ21neu9V/kkFeu42lAKP219fAJrnnoRT3s6sawDDRQ5c5Mbw4xd5Q8SpdRjdxhTF06jr X-Received: by 2002:aa7:8887:0:b0:64d:632a:d0ac with SMTP id z7-20020aa78887000000b0064d632ad0acmr3997087pfe.25.1685113449867; Fri, 26 May 2023 08:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685113449; cv=none; d=google.com; s=arc-20160816; b=g/dDmVGhruPEWwQypGZ2zUSibWdgVSTFepxY7+niH1vvjK80+k6LAUUuU+tSC5hKiC mYPC4F+D1W6FjSjQI+izWbkFx7M5lx4AT4g8dNG/WNZsTT2c33+MlI1+v/IUqwgiWsna dIEhYWs5NGLHDbWC0sSShex20bnqxCqk28SH8P5B6aNEK58xeS7BSfJuGBJI3irObLiK IdLmnsD0VEImFKw3Y5r/5zzCXKStnYFb1rk1Yk7u1GqdtuHtxYA1Nvkl67TJtMvgBr7Q BRgeUWYvQQobReULNnlc+JwiG37MfOE1AEyGZVMzc1Ny4r3rz1s/rZ7p5WOWu7yb8JAQ HXkQ== 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=QoqhjUFkGgsChUUR4qfnQGTApxV2QixLW8z4bQQp3E0=; b=H25YY5xnX3DeB4q12k9QlDj6U2d17ozy9raBfdUlpPPGsojQZmmbYnAfvCz2DxC9t3 1DJGbZX1H8fI3/HuF0eVXuZ2MW+pPIyZN8jexad0QfhoNJ0YxXD5fl2Mv5S9qZKvvi84 8e9MoI0HjORaalBeUXJ0oNVSQbT1pKu9nnn3Q8y70WlGhNBZ5MlZ8GH7+B3d8KYANYIU 5tsag7J3jFRkAjGGNQCB8xKWNFJn32ULfSWN4KIHDtuT83IiVomUN9YoBI9Yp9dpOxto DWSXsBMcapbAOLFl0TqSOitGE/1NFwVhSNC6JRPjNdLZ3PLwR2C/XxD4/8Gy2hXk4LkI 5aUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ixPnPwkA; 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 c8-20020a056a00008800b006293f8330fcsi4229178pfj.322.2023.05.26.08.03.51; Fri, 26 May 2023 08:04:09 -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=ixPnPwkA; 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 S243893AbjEZObU (ORCPT + 99 others); Fri, 26 May 2023 10:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243878AbjEZObO (ORCPT ); Fri, 26 May 2023 10:31:14 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742AF19A; Fri, 26 May 2023 07:31:11 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-514859f3ffbso59606a12.1; Fri, 26 May 2023 07:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111470; x=1687703470; 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=QoqhjUFkGgsChUUR4qfnQGTApxV2QixLW8z4bQQp3E0=; b=ixPnPwkAxNpY8S5hjRG5ZShjKsvrFZ7mPVHL0NBAYCXpHRnctUNNpyeHwSEmJtHycN ZDuQ8c9bB5ytuNe191BaNF8XGag8gOv70M0PIwpqb/75P3of4TuXupbAHpFNOM+svIGQ njOwdT9dHjZdKr0gU1lRK+YXxaoBIoHbiFd8X7x5oRrki6UIibUf75UuO7MnYsEtFVlc wsSMOCZjqmG5NS7j7pwe474dePYn9Q59+Tx7BH05EcQ0Px/Sfh6x+kM4AFVUiC0r6208 ckqWXv+d6h5kcwCoXsean7u+x8RmLWjwT772Wec8ok5kVY7on13YcILdg9khL7KC9dP0 Lstw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111470; x=1687703470; 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=QoqhjUFkGgsChUUR4qfnQGTApxV2QixLW8z4bQQp3E0=; b=lwixFvALVBIMxARAEAd7z9XoZ+Cvc8XnGdBLiKZzoSKrcVzf4MAF53H70uQ1nZB2Jc hapB/n7vMzRBvt6BnIgeNdLZiuzHRuleaaLux3r/mBURcxpAUTpWV7Dx7RwZDzNp9pNC v8KB0JZ++OwZHWsyFzMNYOfH/2iHKhsrT7524F4aQXGr9J4aW6QH4VCe3ovpf2BYdn5h eC5bYugs5I36VURTkzxxf1AkcoIdhckzcxl+tmF8mUc2ICellKFx4I6GJB6W6RcmtaZJ o3pCSBw2cssFH5hN/1fBQzHiTr52IhtHMoF9tvPv/OaEWAf2NFF5Ye/45amN2yPIQ4LB tojA== X-Gm-Message-State: AC+VfDzJmPLZldNBf2Ay2IWqHLjxnVccdp3+rgDDseic+JKwtYm4jj/K 5ccZkk0Zy3488kBzANInkAs= X-Received: by 2002:a17:906:eec5:b0:958:4c75:705e with SMTP id wu5-20020a170906eec500b009584c75705emr2314665ejb.17.1685111469649; Fri, 26 May 2023 07:31:09 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31:09 -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 v4 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer Date: Fri, 26 May 2023 16:30:47 +0200 Message-Id: <564e55936a0abe7c07a7fe51605e298a5264e56f.1685109507.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,T_SCC_BODY_TEXT_LINE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766969520731095774?= X-GMAIL-MSGID: =?utf-8?q?1766969520731095774?= 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 --- 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 69c22071c731..20f5965e878c 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -597,26 +597,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) + fifo_bytes = 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"); @@ -1025,6 +1032,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 c23b6f03409e..7792907534b5 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; @@ -122,6 +125,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 Fri May 26 14:30:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 99509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp522354vqr; Fri, 26 May 2023 07:34:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PURrTK79Hf5KEwAcgWSGY5huwVrxXtLPuUq8soFt8iRa8ok7WkzjWR8t8nI/kamvpIYiz X-Received: by 2002:a05:6a20:8427:b0:105:f8e4:7214 with SMTP id c39-20020a056a20842700b00105f8e47214mr2931423pzd.42.1685111639928; Fri, 26 May 2023 07:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685111639; cv=none; d=google.com; s=arc-20160816; b=nOw6BxlcYneES5hMjVTTGHXfreQf6euySEgg5e2S9SsNVLPrD7VbO2CPyNw6m7RO+d vf5KXuEsqMUn6JA/I4+7tabYzAzAyiGv+Y+i4HPYUJbcLYZJb+jwDnqySUoHJh4VO/DI 1k5GrbzDV8wLGlAWipR9Kg1kcB4MYG0c0SCtB/suGs0B2rJUMS86IK4YSh0HNlz3qxYP HxShRvYCf5V1A8mM3gRS6XGmiGA2pb+VzgmVwo1tISRT4+x+FIQY0pzCqfdruOna++Kk suB7bgK7RjYIizPY15uPQxBcB+0tGPLYpCK4my4m3NT7WDeGvXoL9LqWRyoxwx7EDZQS Xn/A== 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=EGV0mdVcz1xVYs2otFvs3Di4K9A5VIf5zYdZmBKvdos=; b=Eodq08MOER4le7nCjTsCb1EfJATDtAxKKaHMLCLeO2HW6LEmCYylLeXRfkSrfhQVi9 hD57hYutAZdlvplRpZ5HTRT7E/IMgD9LkzfkVeWcUNDApFRpUV0jEZ2g/KYilvBX4ry2 Cq8yyQJQ8kiY81AJGtftf2dnuTL3UnH+tftb6f47G3IRvd6l/xQ6TBS3PW2jGS4lFPVe XDaQqM0GvJY2C3nGzgv8NSV8f/EvGp0Wq9Z7+YxdaA0yftzkFV+4w/O/VJxis4FVZg4U /NjlCx/J7lFFXeyUA3RKwoC37mFvA5wsvcj4LVz1S4JWjJF8A8AE2OUQpmrYs0HSNmmo 9JLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="mMn/i2Nn"; 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 t192-20020a6378c9000000b005074cff89b9si4059036pgc.250.2023.05.26.07.33.45; Fri, 26 May 2023 07:33:59 -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="mMn/i2Nn"; 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 S243891AbjEZObZ (ORCPT + 99 others); Fri, 26 May 2023 10:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243869AbjEZObT (ORCPT ); Fri, 26 May 2023 10:31:19 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60C921B0; Fri, 26 May 2023 07:31:13 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-96f818c48fbso145228866b.0; Fri, 26 May 2023 07:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685111471; x=1687703471; 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=EGV0mdVcz1xVYs2otFvs3Di4K9A5VIf5zYdZmBKvdos=; b=mMn/i2NnZXkk1Kt4GLropus7vapmfW9CVwpNxwPjaMCmoyY171QHYbl92+Lb6RbkwT vUWgtOofmZsexyjmnv+kdr+4WsaXCzdQ1SKQzOxgCJMsT8f4NYQHxkgn3C8NDjAurspr aJx6NEizkAXhb9RolZT99K2lFX3iwOE1NFzF5DoF2hsP2SPPU+HU2FrLurWLYHSLtqDo HEbQsIZAhQ68j8mlMNsdX1Mzx891YwA1UprEBp9C7qeaw8QM4vhk8PbEgc7L6ZLCC9ug He3scilDxbNcavnYCGrpRKjj2clPmzcetURZ0ri0T1H+41NeC5gCfmJEa/HGZRL3LjaC Uh6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685111471; x=1687703471; 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=EGV0mdVcz1xVYs2otFvs3Di4K9A5VIf5zYdZmBKvdos=; b=k07XqdKlV1GswKLGC/VCyuXR+ITSihcidbsmH+oD9zNm8W5FK54nNztzA26PlxPtv3 w1BrNq/JheHqmL4aWqmreC6ZpMFgkbnJVhySj18zm5bEmD63HYLowsRIF+W56coSoG6E GuII0OLOa7r/QXVEMAMnehFRmWAeKp8In/MKTXTgn+ETg8MX8YF6+sY/GOygxSt47aTf u/OhkDs5ov7R7RjoyW32TCCK8Ul1uUR6TSlozIGNjiMnP42uQo+01WUFF4av4cSQMu/J /ceBOpj1Ra+VFeASl94d2exWlitHGpdoGb0Xq/EE70QuSuM1SKXH+hFmn+/s/ZQUm/T3 OHsg== X-Gm-Message-State: AC+VfDx9w3cX06tK50RvnXCNGcAX28v0WLjRPFfRrGcQesheSzM3ecZf 31nOY4CFIQlrEw5QYilTJ/0= X-Received: by 2002:a17:907:3e0c:b0:961:b0:3dfd with SMTP id hp12-20020a1709073e0c00b0096100b03dfdmr2616636ejc.7.1685111471455; Fri, 26 May 2023 07:31:11 -0700 (PDT) Received: from carbian.corp.quobyte.com ([2a02:8109:aa3f:ead8::d8a0]) by smtp.gmail.com with ESMTPSA id r20-20020a170906365400b0094e7d196aa4sm2157023ejb.160.2023.05.26.07.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 07:31:11 -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 v4 7/7] iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer Date: Fri, 26 May 2023 16:30:48 +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_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766967623007824030?= X-GMAIL-MSGID: =?utf-8?q?1766967623007824030?= 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 Signed-off-by: Mehdi Djait Acked-by: Matti Vaittinen Reviewed-by: Andy Shevchenko --- 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 | 162 ++++++++++++++++++++++++++ drivers/iio/accel/kionix-kx022a.h | 52 +++++++++ 5 files changed, 222 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 ce299d0446f7..4ea28d2482ec 100644 --- a/drivers/iio/accel/kionix-kx022a-i2c.c +++ b/drivers/iio/accel/kionix-kx022a-i2c.c @@ -39,12 +39,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 1e4b9d4b4b8d..3fb673ffcdeb 100644 --- a/drivers/iio/accel/kionix-kx022a-spi.c +++ b/drivers/iio/accel/kionix-kx022a-spi.c @@ -35,12 +35,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 20f5965e878c..327412a8a395 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 { const struct kx022a_chip_info *chip_info; struct regmap *regmap; @@ -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 @@ -613,6 +731,24 @@ 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; + + return fifo_bytes; +} + static int __kx022a_fifo_flush(struct iio_dev *idev, unsigned int samples, bool irq) { @@ -1036,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 7792907534b5..351867a95f8c 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; @@ -131,5 +182,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