Skip to content

Commit aef43e0

Browse files
Niklas Söderlundrafaeljw
authored andcommitted
thermal/drivers/rcar_gen3_thermal: Create device local ops struct
The callback operations are modified on a driver global level. If one device tree description do not define interrupts, the set_trips() operation was disabled globally for all users of the driver. Fix this by creating a device local copy of the operations structure and modify the copy depending on what the device can do. Signed-off-by: Niklas Söderlund <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1c63f8c commit aef43e0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/thermal/rcar_gen3_thermal.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct rcar_gen3_thermal_tsc {
8787

8888
struct rcar_gen3_thermal_priv {
8989
struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
90+
struct thermal_zone_device_ops ops;
9091
unsigned int num_tscs;
9192
void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
9293
int ptat[3];
@@ -225,7 +226,7 @@ static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low,
225226
return 0;
226227
}
227228

228-
static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = {
229+
static const struct thermal_zone_device_ops rcar_gen3_tz_of_ops = {
229230
.get_temp = rcar_gen3_thermal_get_temp,
230231
.set_trips = rcar_gen3_thermal_set_trips,
231232
};
@@ -470,14 +471,15 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
470471
if (!priv)
471472
return -ENOMEM;
472473

474+
priv->ops = rcar_gen3_tz_of_ops;
473475
priv->thermal_init = rcar_gen3_thermal_init;
474476
if (soc_device_match(r8a7795es1))
475477
priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1;
476478

477479
platform_set_drvdata(pdev, priv);
478480

479481
if (rcar_gen3_thermal_request_irqs(priv, pdev))
480-
rcar_gen3_tz_of_ops.set_trips = NULL;
482+
priv->ops.set_trips = NULL;
481483

482484
pm_runtime_enable(dev);
483485
pm_runtime_get_sync(dev);
@@ -512,8 +514,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
512514
for (i = 0; i < priv->num_tscs; i++) {
513515
struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
514516

515-
zone = devm_thermal_of_zone_register(dev, i, tsc,
516-
&rcar_gen3_tz_of_ops);
517+
zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops);
517518
if (IS_ERR(zone)) {
518519
dev_err(dev, "Sensor %u: Can't register thermal zone\n", i);
519520
ret = PTR_ERR(zone);

0 commit comments

Comments
 (0)