nvidia-oot: cdi: Update cdi package buf size check

The original checking for cdi_dev_package buffer size is wrong,
it should not check the max size against max I2C payload size.

If the cdi_dev_package buffer size is too big for i2c transfer,
it will be breaking down to smaller sizes and transferred using
multiple I2C messages.

Define a new MAX_CDI_DEV_PACKAGE_BUFFER_SIZE for checking the
cdi_dev_package buffer size.

Bug 5107765
Jira CAMERASW-333779

Change-Id: Ieec049d51af4911dfd31410f43aa4733b75d265d
Signed-off-by: Frank Chen <frankc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3365281
Reviewed-by: Kevin Xie (SW-TEGRA) <kevixie@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Ganesh Ram Savithri Sreenivas Murthy <ganeshrams@nvidia.com>
Reviewed-by: Samuel Hung <samuelh@nvidia.com>
This commit is contained in:
Frank Chen
2025-05-16 01:11:11 +00:00
committed by Jon Hunter
parent c71ca8521c
commit 48f3711947

View File

@@ -23,7 +23,8 @@
/* i2c payload size is only 12 bit */
#define MAX_MSG_SIZE (0xFFF - 1)
/* max buffer size for cdi_dev_package */
#define MAX_CDI_DEV_PACKAGE_BUFFER_SIZE (0xFFFF - 1)
/*#define DEBUG_I2C_TRAFFIC*/
/* CDI Dev Debugfs functions
@@ -377,7 +378,7 @@ static int cdi_dev_get_package(
return -EINVAL;
}
if (!info->rw_pkg.size || info->rw_pkg.size > MAX_MSG_SIZE) {
if (!info->rw_pkg.size || info->rw_pkg.size > MAX_CDI_DEV_PACKAGE_BUFFER_SIZE) {
dev_err(info->dev, "%s invalid package size %d\n",
__func__, info->rw_pkg.size);
return -EINVAL;