From 673d69fe3a5f30c4c1795b1d6d4b722f75130905 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 28 Mar 2025 14:23:06 +0000 Subject: [PATCH] bmi088: Fix mixed declarations and code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building the BMI088 driver with the compiler option '-Werror=declaration-after-statement' the build fails with the following errors ... drivers/bmi088/bmi088_iio.c: In function ‘bmi_iio_attr_store’: drivers/bmi088/bmi088_iio.c:226:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 226 | struct bmi_iio_state *st = iio_priv(indio_dev); | ^~~~~~ drivers/bmi088/bmi088_iio.c: In function ‘bmi_iio_attr_show’: drivers/bmi088/bmi088_iio.c:283:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 283 | struct bmi_iio_state *st = iio_priv(indio_dev); | ^~~~~~ Fix this by ensuring that all variables are defined at the start of the functions. Bug 4190630 Change-Id: I52e90fbc61d4d33ab8c1dfd4e551a54461aad788 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3330356 GVS: buildbot_gerritrpt Reviewed-by: Blake McHale Reviewed-by: svcacv --- drivers/bmi088/bmi088_iio.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/bmi088/bmi088_iio.c b/drivers/bmi088/bmi088_iio.c index 93c8f6ad..c822aa79 100644 --- a/drivers/bmi088/bmi088_iio.c +++ b/drivers/bmi088/bmi088_iio.c @@ -223,17 +223,18 @@ static ssize_t bmi_iio_attr_store(struct device *dev, const char *buf, size_t count) { 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); + struct bmi_iio_state *st; char *str; s8 matrix[9]; unsigned int new; int ret; + if (!indio_dev) + return -EINVAL; + + st = iio_priv(indio_dev); + if (!st || !this_attr) return -EINVAL; @@ -280,14 +281,15 @@ static ssize_t bmi_iio_attr_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct bmi_iio_state *st; + ssize_t t = 0; + unsigned int i; 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; + st = iio_priv(indio_dev); if (!st || !this_attr) return -EINVAL;