From patchwork Sat Sep 16 12:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 723712 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6B8B13ADC for ; Sat, 16 Sep 2023 12:39:06 +0000 (UTC) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1534CEF; Sat, 16 Sep 2023 05:39:05 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-500913779f5so4898977e87.2; Sat, 16 Sep 2023 05:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694867944; x=1695472744; darn=vger.kernel.org; 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=Q79fUZZbSUv3woTyk6fuaOdxQDm7PBUultk07mBos+4=; b=mgRIJ0a+yRHvOk2MXIASEWi4SCoaqfvBsezrBUFB9gWl7u7Z6V28ewtN7RAuCEyDYn BJzdZUNncLqQfa+3dvFRE2bjt3+WldIZ40pL05QJn+spnGjocV6K26gW428mN93f+Kw8 n/m0edWr1fwvDX+hupI+zeiFVMtAIcg6WZDzB88SX9GFHLBl6ObHzDQV3qEEdiCZD7xy UreoWrLfnuhHr0WfDR5KpS7iLoVAqY9pqntz81ERpZqguP2UmTEVQPCYBl+oekqnxDzB tbSFdQrbK9EIY1zunZnLV4Kza1O2wAIbf1nHPh+lw/GJ0sWcR7CxcgAQfrnQwca9U6g8 r3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694867944; x=1695472744; 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=Q79fUZZbSUv3woTyk6fuaOdxQDm7PBUultk07mBos+4=; b=VxK+WTygJgRbrSVn7e6qOqisETscPzMTFrKVqYgoOYFzX5sDElXLFFD0NUW9yIJ55u NUXd0gEOX5/s8I5ev1IPwdXBAyn2n0NXWU5XQcBXGb53+jFFCY4odPAdnLAJ3je6FVY4 keaCtNTT2sKaAhk8SKAydbKuPGzW9Vr6ftL8tw8KRDTftUi7ceQXcAM7TzR1V/HOC9rz TQn8uFOBkBeoQHzzD5QjU2l1iTqQp2jNv/z62INwGFFrydfQJSnCO5febav08VxcAWZo kbQpOf96mdLmkWTVe8MRiO3N+L0oBQrs8TgTHj8qvQ6i1IWTNKvlFiBJ4WTu0/hEr1Kr v8+A== X-Gm-Message-State: AOJu0YwGch3BJWEENOTD7x6QFqK8MVejZ/6kdJA6f4Xa5OG6qNlbbliy Wbd8tZDBih0LZaTwLOl7DS0= X-Google-Smtp-Source: AGHT+IGG6yNDr1u/yJrve6emYBkyCfBo5rXmedyP3fAucUQrIqExiENN7gWRJp/OitCxwnERHwWuTw== X-Received: by 2002:a05:6512:e96:b0:4f8:71cc:2b6e with SMTP id bi22-20020a0565120e9600b004f871cc2b6emr4423713lfb.33.1694867943947; Sat, 16 Sep 2023 05:39:03 -0700 (PDT) Received: from localhost.localdomain ([77.134.181.150]) by smtp.gmail.com with ESMTPSA id bo6-20020a0564020b2600b0052284228e3bsm3474064edb.8.2023.09.16.05.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 05:39: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 v9 2/7] iio: accel: kionix-kx022a: Remove blank lines Date: Sat, 16 Sep 2023 14:38:48 +0200 Message-Id: <3489099f653491e97b13b8f19fe86635b03020c8.1694867379.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Remove blank lines pointed out by the checkpatch script Reviewed-by: Andy Shevchenko Reviewed-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- 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 f164b09520c9..2f1e7da25460 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) @@ -1110,7 +1109,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 Sat Sep 16 12:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 723711 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C68E2134B4 for ; Sat, 16 Sep 2023 12:39:10 +0000 (UTC) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68FCCCEF; Sat, 16 Sep 2023 05:39:09 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-502fd1e1dd8so1166168e87.1; Sat, 16 Sep 2023 05:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694867947; x=1695472747; darn=vger.kernel.org; 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=fYNQU7FPTvydILSwaK5s6AQY8aSIkTxjQ7ZIxHmCX18=; b=U80BwZbCz5EV1V9Vf6yjraZPBoQCrty40RaH1ZfCj0PxEginJT2U74Ss4+yb21eSgT Z5BR27haIXf4BeQiJUHSk6T+bAMT4LW/WC0XKqwzgvAOTMAH41NrFbIFvbMpX3KTsYfk imFTCUVNEQL3mXVbQ84owb7Kkhb+p4e5x6dPdfy8btIk44wkVjIm4gnqjPvEPLy2awVn 87jom8j/UwXxQWmSGbJc0mo1zR3jBPMGZfqxsZCrustfU/zqKHWe5mtOP9a8eKY9NZ5c Kff3l5Azz77Q0qzcicUPDhRfzXY/PqtlXa8eTG+cRxRuZsx08SgFe5lTT2Sns9AgKdsD QJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694867947; x=1695472747; 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=fYNQU7FPTvydILSwaK5s6AQY8aSIkTxjQ7ZIxHmCX18=; b=BbsT7kAKBVQp4klRbBR7JCGenDcK6WNuOLJP0aczMUwHzKsnr0lbZuvwcTzKhsBpAa Wz/odZ1ykhIMvBp/O7e5wowhvpjcmPlz1+Oj4BDJiTzwYClxb3l2CYl2KNOqmKMh4QJt 5MaBUrhr845sLT+lzZJzytSevaNYSo4senPoDD852f2NoFfBybJLEvBgb5RZenzuzTtC R7SSVmkGMh3mAtbkcrQKz6YjwlFnnj9E4NUqBqiWrcv+mXHhRIt8yzpRI7gL4wkMwMQy LtDQTrHPOJM8pL4yt2qfCmhNjijEepJdjfx6f5V7nv0ar9YeF/eqj8WE9YOmYUoZW8Xv AOjg== X-Gm-Message-State: AOJu0YzkhZk5sS7yBrObu2vckia/upXMpdilDp0J6eSJ+U4+EG9Fmedd N3n23LJF031SjCT4jiANG3o= X-Google-Smtp-Source: AGHT+IGJ6r1XVtdmzsBBFUnIUyW7I4dm3Ai02tPH6LrH/oRvJKGpCOaHvoH8GnNDrSR1/tw4IXZwmg== X-Received: by 2002:a05:6512:3b27:b0:502:ff3b:766f with SMTP id f39-20020a0565123b2700b00502ff3b766fmr2027243lfv.6.1694867947453; Sat, 16 Sep 2023 05:39:07 -0700 (PDT) Received: from localhost.localdomain ([77.134.181.150]) by smtp.gmail.com with ESMTPSA id bo6-20020a0564020b2600b0052284228e3bsm3474064edb.8.2023.09.16.05.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 05:39: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 v9 4/7] iio: accel: kionix-kx022a: Add an i2c_device_id table Date: Sat, 16 Sep 2023 14:38:50 +0200 Message-Id: <61b43bbf35d602eac34b6d81b4d1b2d7ba39786f.1694867379.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Add the missing i2c device id. Acked-by: Matti Vaittinen Signed-off-by: Mehdi Djait --- 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 b0ac78e85dad..c0d0b69680f9 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", }, { } @@ -43,6 +49,7 @@ static struct i2c_driver kx022a_i2c_driver = { .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, .probe = kx022a_i2c_probe, + .id_table = kx022a_i2c_id, }; module_i2c_driver(kx022a_i2c_driver); From patchwork Sat Sep 16 12:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehdi Djait X-Patchwork-Id: 723710 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 386EC13ADE for ; Sat, 16 Sep 2023 12:39:18 +0000 (UTC) Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3CA1CF1; Sat, 16 Sep 2023 05:39:15 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2b703a0453fso50225871fa.3; Sat, 16 Sep 2023 05:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694867954; x=1695472754; darn=vger.kernel.org; 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=mj0S4IUhwKpm57k81UJh3FEAAmf45N8dx0cUdOy0h84=; b=SwQymvz72+L7um8VS20JF407Sg+WMxmAVOf97V9rkOzNVmu7a+gY382gVoCtYyy71H LnMm8xZ45zoc43fwDrWgiIc/egMzVTtO5oOzrnEXz9hDGyX6GJgiIQ4fl6V/cs6DW3Mc 2ay/QTJe+JAEW2C3IIGX8w7gJoqwK9RCu7gE/tZxqQVj6n3gQQ+MksUICK8YRIADdYgi hM1DeX9ICb/ymtDhby2mKQNcqzvsAcCJSdO610dP2MgNBkYEAEWk+OHr/1ubB25pn/NF seSO2OmkP1bZXQkJiAOZ4LP3TOJc4FLws1JtzqbdfJi8/16FteQJX9siLlEAjls4Gzld PoZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694867954; x=1695472754; 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=mj0S4IUhwKpm57k81UJh3FEAAmf45N8dx0cUdOy0h84=; b=LalrCoosV/xEMiDU74XujkgVNKTSwLBDleisnfZEonGinMrsfQspWv4ovnD8/gRVEn 5bXcIY8WfyFHU4+/s3uCsyNII3CQRgGfmrJs3Pm8km5LP5u+9VUDvJ/J3rhj0S38v98A n8SP8h90NrCvvEX5YV+KgaPoJu95uG6mxBW4RKpExyMSU+4MWHkFNws3X8AoXYsjKyJO RtIxKrqrZKfiyjtADHTTEOkr670iIPrwceBWP736ecPpSuEIwmHGzfiMCNouGtPTu474 5aY9pRuwEnX1VlWNNxe4LGSzaYH1iJrZsx92rSQnNngNNRStfXxUDjabaXkCa0bUJKqQ EQyw== X-Gm-Message-State: AOJu0YwRO6W98RDC/xnIBDGN9C2z43XOLywdhgUBFoPd/ee/9n77thw6 7/Yi+Rs+JDFJ00Mw/sLzI0ZO9xoWxskC8Q== X-Google-Smtp-Source: AGHT+IGj462tn+kYa6mnbmyhKe/vs8cE9HX/9bQ8DzXGvyzB7fNvA3hHUFOWswr9WHzVW3MwU/9tMg== X-Received: by 2002:ac2:58e2:0:b0:4fe:8c07:98eb with SMTP id v2-20020ac258e2000000b004fe8c0798ebmr3479948lfo.51.1694867953910; Sat, 16 Sep 2023 05:39:13 -0700 (PDT) Received: from localhost.localdomain ([77.134.181.150]) by smtp.gmail.com with ESMTPSA id bo6-20020a0564020b2600b0052284228e3bsm3474064edb.8.2023.09.16.05.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 05:39:13 -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 v9 6/7] iio: accel: kionix-kx022a: Add a function to retrieve number of bytes in buffer Date: Sat, 16 Sep 2023 14:38:52 +0200 Message-Id: <9c550fb28e34915d473e379f812c7753f7643bae.1694867379.git.mehdi.djait.k@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 --- drivers/iio/accel/kionix-kx022a.c | 68 +++++++++++++++++-------------- drivers/iio/accel/kionix-kx022a.h | 46 ++++++++++++--------- 2 files changed, 64 insertions(+), 50 deletions(-) diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c index ab3e5c8a19df..cc7134b1183b 100644 --- a/drivers/iio/accel/kionix-kx022a.c +++ b/drivers/iio/accel/kionix-kx022a.c @@ -585,26 +585,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_available(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_available(data); if (fifo_bytes % KX022A_FIFO_SAMPLES_SIZE_BYTES) dev_warn(data->dev, "Bad FIFO alignment. Data may be corrupt\n"); @@ -993,26 +1000,27 @@ static int kx022a_chip_init(struct kx022a_data *data) } 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, + .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, + .get_fifo_bytes_available = kx022a_get_fifo_bytes_available, }; 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..7ca48e6f2c49 100644 --- a/drivers/iio/accel/kionix-kx022a.h +++ b/drivers/iio/accel/kionix-kx022a.h @@ -76,29 +76,34 @@ struct device; +struct kx022a_data; + /** * 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 + * @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 + * @get_fifo_bytes_available: function pointer to get amount of acceleration + * data bytes currently stored in the sensor's FIFO + * buffer */ struct kx022a_chip_info { const char *name; @@ -121,6 +126,7 @@ struct kx022a_chip_info { u8 inc5; u8 inc6; u8 xout_l; + int (*get_fifo_bytes_available)(struct kx022a_data *); }; int kx022a_probe_internal(struct device *dev, const struct kx022a_chip_info *chip_info);