Commit aef43e04 authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Rafael J. Wysocki
Browse files

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: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20230208190333.3159879-3-niklas.soderlund+renesas@ragnatech.se


Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1c63f8cd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ struct rcar_gen3_thermal_tsc {

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

static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = {
static const struct thermal_zone_device_ops rcar_gen3_tz_of_ops = {
	.get_temp	= rcar_gen3_thermal_get_temp,
	.set_trips	= rcar_gen3_thermal_set_trips,
};
@@ -470,6 +471,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
	if (!priv)
		return -ENOMEM;

	priv->ops = rcar_gen3_tz_of_ops;
	priv->thermal_init = rcar_gen3_thermal_init;
	if (soc_device_match(r8a7795es1))
		priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1;
@@ -477,7 +479,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
	platform_set_drvdata(pdev, priv);

	if (rcar_gen3_thermal_request_irqs(priv, pdev))
		rcar_gen3_tz_of_ops.set_trips = NULL;
		priv->ops.set_trips = NULL;

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

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