]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: dac: max5821: fix return value check in powerdown sync
authorSalah Triki <salah.triki@gmail.com>
Mon, 27 Apr 2026 21:33:19 +0000 (22:33 +0100)
committerJonathan Cameron <jic23@kernel.org>
Fri, 15 May 2026 11:05:34 +0000 (12:05 +0100)
commitd0a228d903425e653f18a4341e60c0538afb6d41
treea41cf4e7ab2a45fd9eb602817e62b8849757c85c
parentf9bbd943c34a9ad60e593a4b99ce2394e4e2381b
iio: dac: max5821: fix return value check in powerdown sync

The function max5821_sync_powerdown_mode() returned the result of
i2c_master_send() directly. If a partial transfer occurred, it would
be incorrectly treated as a success by the caller.

While the caller currently handles the positive return value of 2 as
success, this patch refactors the function to return 0 on full success
and -EIO on short writes. This ensures robust error handling for
incomplete transfers and improves code maintainability by using
sizeof(outbuf).

Fixes: 472988972737 ("iio: add support of the max5821")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/dac/max5821.c