From e58cd453d58b20c6a6f34d3591640aa19aa14d25 Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Fri, 4 Feb 2022 15:57:50 +0200 Subject: at91: add kernel support for sama7g5 soc Add kernel support for SAMA7G5 by back-porting mainline kernel patches. Among SAMA7G5 features could be remembered: - ARM Cortex-A7 - double data rate multi-port dynamic RAM controller supporting DDR2, DDR3, DDR3L, LPDDR2, LPDDR3 up to 533MHz - peripherals for audio, video processing - 1 gigabit + 1 megabit Ethernet controllers - 6 CAN controllers - trust zone support - DVFS for CPU - criptography IPs Signed-off-by: Claudiu Beznea --- ...ore-validate-selector-against-linear_min_.patch | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch (limited to 'target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch') diff --git a/target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch b/target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch new file mode 100644 index 0000000000..88302fda04 --- /dev/null +++ b/target/linux/at91/patches-5.10/127-regulator-core-validate-selector-against-linear_min_.patch @@ -0,0 +1,71 @@ +From 3aee4f22ed0a22d3d6d22fc49812c03d876c7637 Mon Sep 17 00:00:00 2001 +From: Claudiu Beznea +Date: Fri, 13 Nov 2020 17:21:05 +0200 +Subject: [PATCH 127/247] regulator: core: validate selector against + linear_min_sel + +There are regulators who's min selector is not zero. Selectors loops +(looping b/w zero and regulator::desc::n_voltages) might throw errors +because invalid selectors are used (lower than +regulator::desc::linear_min_sel). For this situations validate selectors +against regulator::desc::linear_min_sel. + +Signed-off-by: Claudiu Beznea +Link: https://lore.kernel.org/r/1605280870-32432-2-git-send-email-claudiu.beznea@microchip.com +Signed-off-by: Mark Brown +--- + drivers/regulator/core.c | 9 +++++++-- + drivers/regulator/helpers.c | 3 ++- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c +index 043b5f63b94a..dfdd42b9d773 100644 +--- a/drivers/regulator/core.c ++++ b/drivers/regulator/core.c +@@ -2984,7 +2984,8 @@ static int _regulator_list_voltage(struct regulator_dev *rdev, + return rdev->desc->fixed_uV; + + if (ops->list_voltage) { +- if (selector >= rdev->desc->n_voltages) ++ if (selector >= rdev->desc->n_voltages || ++ selector < rdev->desc->linear_min_sel) + return -EINVAL; + if (lock) + regulator_lock(rdev); +@@ -3135,7 +3136,8 @@ int regulator_list_hardware_vsel(struct regulator *regulator, + struct regulator_dev *rdev = regulator->rdev; + const struct regulator_ops *ops = rdev->desc->ops; + +- if (selector >= rdev->desc->n_voltages) ++ if (selector >= rdev->desc->n_voltages || ++ selector < rdev->desc->linear_min_sel) + return -EINVAL; + if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap) + return -EOPNOTSUPP; +@@ -4058,6 +4060,9 @@ int regulator_set_voltage_time(struct regulator *regulator, + + for (i = 0; i < rdev->desc->n_voltages; i++) { + /* We only look for exact voltage matches here */ ++ if (i < rdev->desc->linear_min_sel) ++ continue; ++ + voltage = regulator_list_voltage(regulator, i); + if (voltage < 0) + return -EINVAL; +diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c +index e4bb09bbd3fa..974f1a63993d 100644 +--- a/drivers/regulator/helpers.c ++++ b/drivers/regulator/helpers.c +@@ -647,7 +647,8 @@ int regulator_list_voltage_table(struct regulator_dev *rdev, + return -EINVAL; + } + +- if (selector >= rdev->desc->n_voltages) ++ if (selector >= rdev->desc->n_voltages || ++ selector < rdev->desc->linear_min_sel) + return -EINVAL; + + return rdev->desc->volt_table[selector]; +-- +2.32.0 + -- cgit v1.2.3