mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
bmi088: add support for Linux v6.3+
Fixes two issues when using bmi088 driver on Linux v6.3+: - support i2c_device_id on kernel >6.3 - use dev_to_iio_dev instead of dev_get_drvdata to access iio information Change-Id: I70ad8b5d97d7b9a349f5387dbea60baf51cbbdb9 Signed-off-by: Blake McHale <bmchale@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3310726 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
/* Device tree example:
|
||||
*
|
||||
@@ -1500,10 +1500,12 @@ static int bmi_init(struct bmi_state *st, const struct i2c_device_id *id)
|
||||
|
||||
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
|
||||
static int bmi_probe(struct i2c_client *client)
|
||||
{
|
||||
const struct i2c_device_id *id = i2c_match_id(bmi_i2c_device_ids, client);
|
||||
#else
|
||||
static int bmi_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
#endif
|
||||
{
|
||||
#endif
|
||||
struct bmi_state *st;
|
||||
int ret;
|
||||
|
||||
@@ -1513,11 +1515,7 @@ static int bmi_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
|
||||
i2c_set_clientdata(client, st);
|
||||
st->i2c = client;
|
||||
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
|
||||
ret = bmi_init(st, NULL);
|
||||
#else
|
||||
ret = bmi_init(st, id);
|
||||
#endif
|
||||
if (ret) {
|
||||
bmi_remove(client);
|
||||
return ret;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
// SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
@@ -222,7 +222,11 @@ static ssize_t bmi_iio_attr_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
if (!indio_dev)
|
||||
return -EINVAL;
|
||||
|
||||
struct bmi_iio_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
char *str;
|
||||
@@ -230,7 +234,7 @@ static ssize_t bmi_iio_attr_store(struct device *dev,
|
||||
unsigned int new;
|
||||
int ret;
|
||||
|
||||
if (!indio_dev || !st || !this_attr)
|
||||
if (!st || !this_attr)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(BMI_MUTEX(indio_dev));
|
||||
@@ -275,13 +279,17 @@ static ssize_t bmi_iio_attr_store(struct device *dev,
|
||||
static ssize_t bmi_iio_attr_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
|
||||
if (!indio_dev)
|
||||
return -EINVAL;
|
||||
|
||||
struct bmi_iio_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
ssize_t t = 0;
|
||||
unsigned int i;
|
||||
|
||||
if (!indio_dev || !st || !this_attr)
|
||||
if (!st || !this_attr)
|
||||
return -EINVAL;
|
||||
|
||||
switch (this_attr->address) {
|
||||
|
||||
Reference in New Issue
Block a user