Commit 9dbbcd6c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge tag 'thermal-v6.10-rc1-2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Merge thermal driver fixes for 6.10-rc1 from Daniel Lezcano:

"- Check for a NULL pointer before using it in the probe routine of the
   Mediatek LVTS driver (Julien Panis)

 - Remove the num_lvts_sensor and cal_offset fields of the
   lvts_ctrl_data as they are not used. These are not functional fixes
   but slight memory usage fix of the Mediatek LVTS driver (Julien
   Panis)

 - Fix wrong lvts_ctrl index leading to a NULL pointer dereference in
   the Mediatek LVTS driver (Julien Panis)"

* tag 'thermal-v6.10-rc1-2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal/drivers/mediatek/lvts_thermal: Fix wrong lvts_ctrl index
  thermal/drivers/mediatek/lvts_thermal: Remove unused members from struct lvts_ctrl_data
  thermal/drivers/mediatek/lvts_thermal: Check NULL ptr on lvts_data
parents f952b6c8 b66c079a
...@@ -105,8 +105,6 @@ struct lvts_sensor_data { ...@@ -105,8 +105,6 @@ struct lvts_sensor_data {
struct lvts_ctrl_data { struct lvts_ctrl_data {
struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX]; struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
int cal_offset[LVTS_SENSOR_MAX];
int num_lvts_sensor;
u8 valid_sensor_mask; u8 valid_sensor_mask;
int offset; int offset;
int mode; int mode;
...@@ -118,9 +116,9 @@ struct lvts_ctrl_data { ...@@ -118,9 +116,9 @@ struct lvts_ctrl_data {
((s2) ? BIT(2) : 0) | \ ((s2) ? BIT(2) : 0) | \
((s3) ? BIT(3) : 0)) ((s3) ? BIT(3) : 0))
#define lvts_for_each_valid_sensor(i, lvts_ctrl_data) \ #define lvts_for_each_valid_sensor(i, lvts_ctrl) \
for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \ for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \
if (!((lvts_ctrl_data)->valid_sensor_mask & BIT(i))) \ if (!((lvts_ctrl)->valid_sensor_mask & BIT(i))) \
continue; \ continue; \
else else
...@@ -147,6 +145,7 @@ struct lvts_ctrl { ...@@ -147,6 +145,7 @@ struct lvts_ctrl {
const struct lvts_data *lvts_data; const struct lvts_data *lvts_data;
u32 calibration[LVTS_SENSOR_MAX]; u32 calibration[LVTS_SENSOR_MAX];
u32 hw_tshut_raw_temp; u32 hw_tshut_raw_temp;
u8 valid_sensor_mask;
int mode; int mode;
void __iomem *base; void __iomem *base;
int low_thresh; int low_thresh;
...@@ -358,7 +357,7 @@ static bool lvts_should_update_thresh(struct lvts_ctrl *lvts_ctrl, int high) ...@@ -358,7 +357,7 @@ static bool lvts_should_update_thresh(struct lvts_ctrl *lvts_ctrl, int high)
if (high > lvts_ctrl->high_thresh) if (high > lvts_ctrl->high_thresh)
return true; return true;
lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl) lvts_for_each_valid_sensor(i, lvts_ctrl)
if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
&& lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh) && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
return false; return false;
...@@ -619,6 +618,8 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, ...@@ -619,6 +618,8 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
lvts_sensor[i].high_thresh = INT_MIN; lvts_sensor[i].high_thresh = INT_MIN;
}; };
lvts_ctrl->valid_sensor_mask = lvts_ctrl_data->valid_sensor_mask;
return 0; return 0;
} }
...@@ -1114,7 +1115,7 @@ static int lvts_ctrl_start(struct device *dev, struct lvts_ctrl *lvts_ctrl) ...@@ -1114,7 +1115,7 @@ static int lvts_ctrl_start(struct device *dev, struct lvts_ctrl *lvts_ctrl)
u32 *sensor_bitmap = lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE ? u32 *sensor_bitmap = lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE ?
sensor_imm_bitmap : sensor_filt_bitmap; sensor_imm_bitmap : sensor_filt_bitmap;
lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl) { lvts_for_each_valid_sensor(i, lvts_ctrl) {
int dt_id = lvts_sensors[i].dt_id; int dt_id = lvts_sensors[i].dt_id;
...@@ -1271,6 +1272,8 @@ static int lvts_probe(struct platform_device *pdev) ...@@ -1271,6 +1272,8 @@ static int lvts_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
lvts_data = of_device_get_match_data(dev); lvts_data = of_device_get_match_data(dev);
if (!lvts_data)
return -ENODEV;
lvts_td->clk = devm_clk_get_enabled(dev, NULL); lvts_td->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(lvts_td->clk)) if (IS_ERR(lvts_td->clk))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment