bmi088: Fix mixed declarations and code

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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3330356
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Blake McHale <bmchale@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
This commit is contained in:
Jon Hunter
2025-03-28 14:23:06 +00:00
parent 454c782d5c
commit 673d69fe3a

View File

@@ -223,17 +223,18 @@ static ssize_t bmi_iio_attr_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(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); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct bmi_iio_state *st;
char *str; char *str;
s8 matrix[9]; s8 matrix[9];
unsigned int new; unsigned int new;
int ret; int ret;
if (!indio_dev)
return -EINVAL;
st = iio_priv(indio_dev);
if (!st || !this_attr) if (!st || !this_attr)
return -EINVAL; return -EINVAL;
@@ -280,14 +281,15 @@ static ssize_t bmi_iio_attr_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); 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) if (!indio_dev)
return -EINVAL; return -EINVAL;
struct bmi_iio_state *st = iio_priv(indio_dev); st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
ssize_t t = 0;
unsigned int i;
if (!st || !this_attr) if (!st || !this_attr)
return -EINVAL; return -EINVAL;