regulator: cros-ec: use devm_kmemdup_array()

Convert to use devm_kmemdup_array() and while at it, make the size robust
against type changes.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Link: https://patch.msgid.link/20250228072057.151436-3-raag.jadav@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
pull/1184/head
Raag Jadav 2025-02-28 12:50:57 +05:30 committed by Mark Brown
parent 6ddd115982
commit c5c4ce6612
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 2 additions and 2 deletions

View File

@ -138,8 +138,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->num_voltages = data->num_voltages =
min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages); min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages);
data->voltages_mV = data->voltages_mV =
devm_kmemdup(dev, resp.voltages_mv, devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
sizeof(u16) * data->num_voltages, GFP_KERNEL); sizeof(resp.voltages_mv[0]), GFP_KERNEL);
if (!data->voltages_mV) if (!data->voltages_mV)
return -ENOMEM; return -ENOMEM;