From nobody Tue Dec 16 21:12:00 2025 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD2927F01B for ; Thu, 10 Jul 2025 02:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752114034; cv=none; b=T5peFA6YqftCg91mN/8RotA4aTFb0nBVW6mQv7Qn0f9HD/nmC2iQ7x/ZezQpQVOAbQkLVJCLmenETSn3Kpbblqv6cwckywhLhyntIPxmG5zBmT2Syw3q7M3vFgcOTkNAuW7+ZdZMHxEsWXFXRCG2mSNpCLc9EOxVaPOYsW5FEYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752114034; c=relaxed/simple; bh=PrdYl6cL5ELmEcjkN1E1wVLyUoxLSD2mgLWQ/8TLt70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YiBSdAR9II1kcCjdIr4+QkVnaeJ7kuJtTpmjGGdkM1FNvFPFy5leeVDUfe3ADIaTBQNLVDWNoEpZQnRVQcMFWE+cFkXY4smgzNaED2vt/4tN/gJHgCM+ZUwxCt3zS/oCytJ0MHK1nP8j4bOENTJPf5Pcdt1oTtRWTfjgyloQ3To= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=uBUs+n7u; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="uBUs+n7u" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-6118b000506so128813eaf.0 for ; Wed, 09 Jul 2025 19:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1752114032; x=1752718832; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=La38bpNvym9P0SG4sHe+uHRcxOOSKpxAGmg4JaBHWlQ=; b=uBUs+n7uWPvdJzywIwtg2RnDgue6mQqp232seMWzRBJECTugH11a6eSocr+84pPCRM PsRwOXEyi18GeTfDgFwZvj77+XF1Tn0UOP/dT6eLMyrOS14UQvuZoEuQbFLPWSWtJhoM RtVNmMe4jkVzhK2+EyvEViDNQfshTPhbe8fHNcreV1eAx7TjjCzRiMnP1Pm34FiYVY2H K+EnQmaaWbV4aUG1TeFfjl56LcCg8J8RJkRV8TAya6y06IHRbdLnn3bji7COSc/97mP5 5SKUp/4FkLw/avqYB8X3QabyOlg0arrY0xnQusw7dVBNlwqClpZqbtURlGVdis+5DGSS j2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752114032; x=1752718832; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=La38bpNvym9P0SG4sHe+uHRcxOOSKpxAGmg4JaBHWlQ=; b=RlDImOqiD3AWZKlBRU5EgNlx7zDh9whn88YGqMwRb8NaZX9i+lGEVbQV5ZmcLhziKK +EraTfsvRTTg2avEXR7OErXWTBF2jLSpG6Sk8GN6aPAWNSy9fX5KwWPwpf/y7bmsTOqF f4IaI3qhV1cIlAKqgRZ8fisUFGL/N8hVevb++9bVTUEzAJrtiPSyOA7kjTLT/wuoqZCY z9X0v+bST8RAUc0AbtpHUYV/T2i+rDu8EpPNR12ki0Dh5PqmSgswmlbgWV0HLIn4ZkiR 2kRUB8TrEC0YpGBHQGuzPLsEEqgsKEep0c1aM8WzBdo7DX5MDzUbnn/TBsboPWjBiiL/ uiPw== X-Forwarded-Encrypted: i=1; AJvYcCXJ4PSMVLdCsqat/AkPvKkRVSa6T8RPEoxgI37L6UEDNg9vi5yvG78j4IBEH4s7f6+aXT2YN4Fg9LetYJY=@vger.kernel.org X-Gm-Message-State: AOJu0YwxH1dlhfTjeC0l6jZh08nhOfpwogIYe7MkeFqjg/y65nvOsvTi 7hSFQucBeum+auzaR5VkFsjDH+LEtor9/YoEgRJJtRBWx2oxD4MeUHBxXQ+Lo9ehks4= X-Gm-Gg: ASbGncvVgrf9EQVsXlvZ5AT0H+K32mBzDxFw2Bo+HaBbnQtWaSjalxQqocEjIWiyJqq eA+QZGh3J/o5PnV4D65RuG+R0HyW3ELLntQvw4eL9NrNd/o8knlTMHKp3VbNUnWdSQLrJbrCnBG CgGBoAMpOCJwXzDwlctFS3KSFXxczvQ1Cm9nRCtHhLhqgdIrxVkaik5huFEEwg98e5MMpwIvvad LiWApymn3fQb1+uszTHsVIU+wsREg4S8fzdmOjWgiz/UWY0P+X/0ycd76AY5YUZEoWB/CS8NTjJ LPYECob2aV7bjRV+7gEi+Ll3S3109ZcxymgHJS20Nsdhmekb/t4Xnx8RIZ56PjJirkzg X-Google-Smtp-Source: AGHT+IGED0OyDkTZlJZY6bL6UdAlzshsytNE4n6qwY8n7ay5Z6rl6ikJKtV7hvy1K4dtPURwN3dwtw== X-Received: by 2002:a05:6820:4b89:b0:613:c922:32c6 with SMTP id 006d021491bc7-613d6e13bf0mr1535420eaf.2.1752114031791; Wed, 09 Jul 2025 19:20:31 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:6f38:cf8f:abb1:34f7]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-613d9f00d46sm66972eaf.22.2025.07.09.19.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jul 2025 19:20:31 -0700 (PDT) From: David Lechner Date: Wed, 09 Jul 2025 21:20:00 -0500 Subject: [PATCH v2 1/2] iio: imu: bno055: fix OOB access of hw_xlate array Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250709-iio-const-data-19-v2-1-fb3fc9191251@baylibre.com> References: <20250709-iio-const-data-19-v2-0-fb3fc9191251@baylibre.com> In-Reply-To: <20250709-iio-const-data-19-v2-0-fb3fc9191251@baylibre.com> To: Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , David Lechner , Andrea Merello Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , kernel test robot X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2711; i=dlechner@baylibre.com; h=from:subject:message-id; bh=PrdYl6cL5ELmEcjkN1E1wVLyUoxLSD2mgLWQ/8TLt70=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBobyNdqlts8HOoSJGjEpUG0vkpz3w/6lOCHab6J x/NMV3xG/WJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaG8jXQAKCRDCzCAB/wGP wJZlB/9NBd9Xls/tWIsMyNt2QblowGb92oV81hUIFWXripSyeMN93WZ6cfo1basvQJg4g453W4H N9q9aeMYlFwXEBVhANdBQYP5pbMD7Z1PPgMFzP+ZKcCfArjMU+ofRaXgOcJIaEg3DxSmTPlHwXX WGobVVtPOBsUVwUjIlm4coJjwBPQ4NHECXtsce9sWUnbhW/bjqk0hA0gwP0jwcmRTe05WKVHetR NfBTkbVK2c/hsPqhQM/LSqto5WgpF+Df1+ERLe7FZ4uha6V0J2GtfV72uuQvAMdXi2MJOKT9WMe 92/yxsnyh5GOmn6SZH1AD+7Zy6ef6uaeAJ8dAY1FPRdBcEkd X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Fix a potential out-of-bounds array access of the hw_xlate array in bno055.c. In bno055_get_regmask(), hw_xlate was iterated over the length of the vals array instead of the length of the hw_xlate array. In the case of bno055_gyr_scale, the vals array is larger than the hw_xlate array, so this could result in an out-of-bounds access. In practice, this shouldn't happen though because a match should always be found which breaks out of the for loop before it iterates beyond the end of the hw_xlate array. By adding a new hw_xlate_len field to the bno055_sysfs_attr, we can be sure we are iterating over the correct length. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202507100510.rGt1YOOx-lkp@int= el.com/ Fixes: 4aefe1c2bd0c ("iio: imu: add Bosch Sensortec BNO055 core driver") Signed-off-by: David Lechner --- drivers/iio/imu/bno055/bno055.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno05= 5.c index 3f4c18dc3ee983fe3c5569406a2c6350b0cc756c..0eb5e1334e5564284c7f4bf5604= 24b5ec734903d 100644 --- a/drivers/iio/imu/bno055/bno055.c +++ b/drivers/iio/imu/bno055/bno055.c @@ -118,6 +118,7 @@ struct bno055_sysfs_attr { int len; int *fusion_vals; int *hw_xlate; + int hw_xlate_len; int type; }; =20 @@ -170,20 +171,24 @@ static int bno055_gyr_scale_vals[] =3D { 1000, 1877467, 2000, 1877467, }; =20 +static int bno055_gyr_scale_hw_xlate[] =3D {0, 1, 2, 3, 4}; static struct bno055_sysfs_attr bno055_gyr_scale =3D { .vals =3D bno055_gyr_scale_vals, .len =3D ARRAY_SIZE(bno055_gyr_scale_vals), .fusion_vals =3D (int[]){1, 900}, - .hw_xlate =3D (int[]){4, 3, 2, 1, 0}, + .hw_xlate =3D bno055_gyr_scale_hw_xlate, + .hw_xlate_len =3D ARRAY_SIZE(bno055_gyr_scale_hw_xlate), .type =3D IIO_VAL_FRACTIONAL, }; =20 static int bno055_gyr_lpf_vals[] =3D {12, 23, 32, 47, 64, 116, 230, 523}; +static int bno055_gyr_lpf_hw_xlate[] =3D {5, 4, 7, 3, 6, 2, 1, 0}; static struct bno055_sysfs_attr bno055_gyr_lpf =3D { .vals =3D bno055_gyr_lpf_vals, .len =3D ARRAY_SIZE(bno055_gyr_lpf_vals), .fusion_vals =3D (int[]){32}, - .hw_xlate =3D (int[]){5, 4, 7, 3, 6, 2, 1, 0}, + .hw_xlate =3D bno055_gyr_lpf_hw_xlate, + .hw_xlate_len =3D ARRAY_SIZE(bno055_gyr_lpf_hw_xlate), .type =3D IIO_VAL_INT, }; =20 @@ -561,7 +566,7 @@ static int bno055_get_regmask(struct bno055_priv *priv,= int *val, int *val2, =20 idx =3D (hwval & mask) >> shift; if (attr->hw_xlate) - for (i =3D 0; i < attr->len; i++) + for (i =3D 0; i < attr->hw_xlate_len; i++) if (attr->hw_xlate[i] =3D=3D idx) { idx =3D i; break; --=20 2.43.0 From nobody Tue Dec 16 21:12:00 2025 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79AA527FB02 for ; Thu, 10 Jul 2025 02:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752114038; cv=none; b=MpAEN9n8Pzl8gd0Q3DR/6yRhNdaTjXXZAEZglK31zEfJbSStCsBPWFesvRciNZRyeyjQMBFAs1s+5v+C7hz1vw3TW9GIZ66H0sO4awXwyWVVwDPTJD4h//KfjG73NUh9XwC7MCpaWnvQu2K7dwO7/7eiNTINSoibtegwJu+pYQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752114038; c=relaxed/simple; bh=Xl8o2DtSaigWESa1n7kRRDmN3sTUITSG1wrwo5ezoAU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=js5mx58azA22xfKXn7KNjFjVCay8sfhV/C5aRQ6SypDFO/yrqhOgYb8v4/Vbcz1vln76BhFRvE+St9TFT0O3epiTFUhh8eMtu1zNrm6d9+jtapbsuSfwzuiq9xr50NI9Lcro0U1EATdF9FRlKlK/uqw+pLzco1Gvc8olJLU9OyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=pGAHSaz/; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="pGAHSaz/" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-4067106dd56so302257b6e.3 for ; Wed, 09 Jul 2025 19:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1752114034; x=1752718834; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IImpk5jGtMH+w7dUqRTc1wLzrv2Bvf1SOOEFKZMUB0Y=; b=pGAHSaz/WYDUE+LBTGQKz8XKV78ByaCXn8WB/SBg+igS1axmL66v5Hd6UTv6tL9H5n ITC0qL1HpnVSHgREWByQg0aEP+FQ9EVuZpSDuLoze9bFVX+FgFlfmPqWCBglwdU9MJd3 o4e7yfk5CsaIsVh2khFtGA4adnpOi9Iofhm/Zf5Kp3Q6f8JRXMBnIuzswUkIkYeo02mD YHO5pJSWSH4Ckr1oMPCNZhDJG5xtlN+XGE2yiTiwtixlPGpNQCfscgTFeolSZVhogeNd lHScxtBaGVrlc9zUEiKP6cSBespGSPa6YlJ8ztPsRBd/zPJfu4SlOi7GpE+sT+Wirgfu l2PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752114034; x=1752718834; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IImpk5jGtMH+w7dUqRTc1wLzrv2Bvf1SOOEFKZMUB0Y=; b=v7W7gtEMah/LKL7vBoGBmmtq/WvLfj6Pw+/pJ1OBRgpWqTo1GltrIUEFFzeSkIcqfc WPDO7cJ/BnvUQyG6G9QiAzA01THV+bBdAx2OtQRUlCmBml9dlBerKRnMM6crO2+4RwWL fJeb5x66fPpPm91jQPaKhGnZl3IWzzWlRX2fShEeIGpKFZdPVQRJm16804yYrdZTonnh 9gWZ4BDx5XUgfZRURV/OhAWGZWYAUjoPn7Bn/7lZ6+SPG/aicC3YIgcQlnydgQeazBu3 mNnKW7sCt9xKK5jysx6MlT/grAUvLS/66alsbC3t+KPhYlYu63hcp4U3vroV0UzRaEYO qPoQ== X-Forwarded-Encrypted: i=1; AJvYcCWmPZGm51CVouIAEQT8z21b4bWrCyWztxbPy6RUF1/yZhzZX44Mrvho9d2jYVT93dPnUBLQGJzUpXu0PsE=@vger.kernel.org X-Gm-Message-State: AOJu0YwmxDHDhjG8HeQ9UB/WOEWopZdEvOWMu/JP62pD0MV2xfuPU2d7 7fnA+kfgzQQ5+j93dxpWFJeCF4unQ+PIzAQFQ1MhljcLuColU/exxzkhHBL6U3t+BNY= X-Gm-Gg: ASbGncsk2v4UosG7Jwzo8ooNHXC8RrNgvA8WzyEV19yj3GuHkUt5EKI6vxlJBvurYFH rhTg9kQwVjvVGcRHvtNVstZudPa7kvp766z1TW5o1dben6vfQ1mqaP4C1IgZZGdZLcWZOpu4sUY 6kS2kYduS87mZI+4pyto6oAKv7lK7Wd/a+sQsjMaSOGMN+f8snBytW23l5lkQ5a0hYjncccYogP SeYA5JmLsXfS0oWqeP11sHxC6z6+Z3aK+kxGq/2+NIVSLOQpoqxEMq5GxSKb+HdCwVVu8x89tSZ 3OPsJ758ixJdb6BTxgB7ZCg6dfKnumvDm3Wx7FOdBT5B0djz364695aIJ26YU2Olx/8n X-Google-Smtp-Source: AGHT+IEM0Ysmp21GGMggoZwDFO+qiHN33lKFW/Brnj2s4UMHLtA+QhysRcAWqjOcvP9MWblYhuy33g== X-Received: by 2002:a05:6808:16aa:b0:40a:b141:8f57 with SMTP id 5614622812f47-413abe70954mr1688660b6e.3.1752114034470; Wed, 09 Jul 2025 19:20:34 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:6f38:cf8f:abb1:34f7]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-613d9f00d46sm66972eaf.22.2025.07.09.19.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jul 2025 19:20:33 -0700 (PDT) From: David Lechner Date: Wed, 09 Jul 2025 21:20:01 -0500 Subject: [PATCH v2 2/2] iio: imu: bno055: make bno055_sysfs_attr const Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250709-iio-const-data-19-v2-2-fb3fc9191251@baylibre.com> References: <20250709-iio-const-data-19-v2-0-fb3fc9191251@baylibre.com> In-Reply-To: <20250709-iio-const-data-19-v2-0-fb3fc9191251@baylibre.com> To: Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , David Lechner , Andrea Merello Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4938; i=dlechner@baylibre.com; h=from:subject:message-id; bh=Xl8o2DtSaigWESa1n7kRRDmN3sTUITSG1wrwo5ezoAU=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBobyNlraRWW7K8uZDXgQLj+ENEEPzweXxt7C4vB NMNfZiH3fOJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaG8jZQAKCRDCzCAB/wGP wKpIB/4rRcQqwnTUqv458/jvmUABudUHoudfABuvizaJ6Oq3BD1ZnDUakM7vJe2JkPKFo50Gxhl algDuQApJ7dK8m8R99KMgBs0Mj/pBJtRD1SxkeYKLlIZ53bfd9oN6zThGGnnzENuhb+oQcY4mfD hS1k36K/k2P+TsCRb08OPApmb9VYKR9UIgpGxY3B29IrCnpQDE84ei8xQU2d0YDVocIa2NY3+4B cWzTI2GlRvOymIR1LbkbuwMpjUBCH2CC0/xB56CY8J/VD2bnYro8E102mhhmBPA93rBPzFFPdq1 5lM1zq5Jojv74x+aenkeozVXEvEQv+RPS4ne1J0DNI4G5HHU X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add const qualifier to struct bno055_sysfs_attr and its array fields. All of this is read-only data so it can be made const. Signed-off-by: David Lechner --- drivers/iio/imu/bno055/bno055.c | 49 ++++++++++++++++++++++---------------= ---- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno05= 5.c index 0eb5e1334e5564284c7f4bf560424b5ec734903d..a8e71679ec21dc2cfb0cbbce978= fc7cad9929d96 100644 --- a/drivers/iio/imu/bno055/bno055.c +++ b/drivers/iio/imu/bno055/bno055.c @@ -114,35 +114,35 @@ #define BNO055_UID_LEN 16 =20 struct bno055_sysfs_attr { - int *vals; + const int *vals; int len; - int *fusion_vals; - int *hw_xlate; + const int *fusion_vals; + const int *hw_xlate; int hw_xlate_len; int type; }; =20 -static int bno055_acc_lpf_vals[] =3D { +static const int bno055_acc_lpf_vals[] =3D { 7, 810000, 15, 630000, 31, 250000, 62, 500000, 125, 0, 250, 0, 500, 0, 1000, 0, }; =20 -static struct bno055_sysfs_attr bno055_acc_lpf =3D { +static const struct bno055_sysfs_attr bno055_acc_lpf =3D { .vals =3D bno055_acc_lpf_vals, .len =3D ARRAY_SIZE(bno055_acc_lpf_vals), - .fusion_vals =3D (int[]){62, 500000}, + .fusion_vals =3D (const int[]){62, 500000}, .type =3D IIO_VAL_INT_PLUS_MICRO, }; =20 -static int bno055_acc_range_vals[] =3D { +static const int bno055_acc_range_vals[] =3D { /* G: 2, 4, 8, 16 */ 1962, 3924, 7848, 15696 }; =20 -static struct bno055_sysfs_attr bno055_acc_range =3D { +static const struct bno055_sysfs_attr bno055_acc_range =3D { .vals =3D bno055_acc_range_vals, .len =3D ARRAY_SIZE(bno055_acc_range_vals), - .fusion_vals =3D (int[]){3924}, /* 4G */ + .fusion_vals =3D (const int[]){3924}, /* 4G */ .type =3D IIO_VAL_INT, }; =20 @@ -166,37 +166,37 @@ static struct bno055_sysfs_attr bno055_acc_range =3D { * =3D hwval * (dps_range/(2^15 * k)) * where k is rad-to-deg factor */ -static int bno055_gyr_scale_vals[] =3D { +static const int bno055_gyr_scale_vals[] =3D { 125, 1877467, 250, 1877467, 500, 1877467, 1000, 1877467, 2000, 1877467, }; =20 -static int bno055_gyr_scale_hw_xlate[] =3D {0, 1, 2, 3, 4}; -static struct bno055_sysfs_attr bno055_gyr_scale =3D { +static const int bno055_gyr_scale_hw_xlate[] =3D {0, 1, 2, 3, 4}; +static const struct bno055_sysfs_attr bno055_gyr_scale =3D { .vals =3D bno055_gyr_scale_vals, .len =3D ARRAY_SIZE(bno055_gyr_scale_vals), - .fusion_vals =3D (int[]){1, 900}, + .fusion_vals =3D (const int[]){1, 900}, .hw_xlate =3D bno055_gyr_scale_hw_xlate, .hw_xlate_len =3D ARRAY_SIZE(bno055_gyr_scale_hw_xlate), .type =3D IIO_VAL_FRACTIONAL, }; =20 -static int bno055_gyr_lpf_vals[] =3D {12, 23, 32, 47, 64, 116, 230, 523}; -static int bno055_gyr_lpf_hw_xlate[] =3D {5, 4, 7, 3, 6, 2, 1, 0}; -static struct bno055_sysfs_attr bno055_gyr_lpf =3D { +static const int bno055_gyr_lpf_vals[] =3D {12, 23, 32, 47, 64, 116, 230, = 523}; +static const int bno055_gyr_lpf_hw_xlate[] =3D {5, 4, 7, 3, 6, 2, 1, 0}; +static const struct bno055_sysfs_attr bno055_gyr_lpf =3D { .vals =3D bno055_gyr_lpf_vals, .len =3D ARRAY_SIZE(bno055_gyr_lpf_vals), - .fusion_vals =3D (int[]){32}, + .fusion_vals =3D (const int[]){32}, .hw_xlate =3D bno055_gyr_lpf_hw_xlate, .hw_xlate_len =3D ARRAY_SIZE(bno055_gyr_lpf_hw_xlate), .type =3D IIO_VAL_INT, }; =20 -static int bno055_mag_odr_vals[] =3D {2, 6, 8, 10, 15, 20, 25, 30}; -static struct bno055_sysfs_attr bno055_mag_odr =3D { +static const int bno055_mag_odr_vals[] =3D {2, 6, 8, 10, 15, 20, 25, 30}; +static const struct bno055_sysfs_attr bno055_mag_odr =3D { .vals =3D bno055_mag_odr_vals, .len =3D ARRAY_SIZE(bno055_mag_odr_vals), - .fusion_vals =3D (int[]){20}, + .fusion_vals =3D (const int[]){20}, .type =3D IIO_VAL_INT, }; =20 @@ -553,7 +553,8 @@ static const struct iio_chan_spec bno055_channels[] =3D= { }; =20 static int bno055_get_regmask(struct bno055_priv *priv, int *val, int *val= 2, - int reg, int mask, struct bno055_sysfs_attr *attr) + int reg, int mask, + const struct bno055_sysfs_attr *attr) { const int shift =3D __ffs(mask); int hwval, idx; @@ -582,7 +583,8 @@ static int bno055_get_regmask(struct bno055_priv *priv,= int *val, int *val2, } =20 static int bno055_set_regmask(struct bno055_priv *priv, int val, int val2, - int reg, int mask, struct bno055_sysfs_attr *attr) + int reg, int mask, + const struct bno055_sysfs_attr *attr) { const int shift =3D __ffs(mask); int best_delta; @@ -763,7 +765,8 @@ static int bno055_read_simple_chan(struct iio_dev *indi= o_dev, } } =20 -static int bno055_sysfs_attr_avail(struct bno055_priv *priv, struct bno055= _sysfs_attr *attr, +static int bno055_sysfs_attr_avail(struct bno055_priv *priv, + const struct bno055_sysfs_attr *attr, const int **vals, int *length) { if (priv->operation_mode !=3D BNO055_OPR_MODE_AMG) { --=20 2.43.0