diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2015-08-20 07:54:07 +0300 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2015-08-28 05:40:09 +0300 |
commit | da06b46b720687117178d3ee85a601762f1c36b5 (patch) | |
tree | da40c22819f17b63324333d0849e4ce555f8d3fd /drivers/gpu | |
parent | 5a7d1e22feedd3cfab5a94bba5f26ab61610bc62 (diff) | |
download | linux-da06b46b720687117178d3ee85a601762f1c36b5.tar.xz |
drm/nouveau/therm: cosmetic changes
This is purely preparation for upcoming commits, there should be no
code changes here.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c | 232 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c | 122 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/fannil.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c | 65 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/fantog.c | 84 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c | 67 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/ic.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c | 32 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c | 32 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c | 112 |
15 files changed, 440 insertions, 466 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h index 6662829b6db1..6e60f9bceaba 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h @@ -24,7 +24,7 @@ enum nvkm_therm_attr_type { }; struct nvkm_therm { - struct nvkm_subdev base; + struct nvkm_subdev subdev; int (*pwm_ctrl)(struct nvkm_therm *, int line, bool); int (*pwm_get)(struct nvkm_therm *, int line, u32 *, u32 *); @@ -50,16 +50,16 @@ nvkm_therm(void *obj) #define nvkm_therm_create(p,e,o,d) \ nvkm_therm_create_((p), (e), (o), sizeof(**d), (void **)d) #define nvkm_therm_destroy(p) ({ \ - struct nvkm_therm *therm = (p); \ - _nvkm_therm_dtor(nv_object(therm)); \ + struct nvkm_therm *_therm = (p); \ + _nvkm_therm_dtor(nv_object(_therm)); \ }) #define nvkm_therm_init(p) ({ \ - struct nvkm_therm *therm = (p); \ - _nvkm_therm_init(nv_object(therm)); \ + struct nvkm_therm *_therm = (p); \ + _nvkm_therm_init(nv_object(_therm)); \ }) #define nvkm_therm_fini(p,s) ({ \ - struct nvkm_therm *therm = (p); \ - _nvkm_therm_init(nv_object(therm), (s)); \ + struct nvkm_therm *_therm = (p); \ + _nvkm_therm_init(nv_object(_therm), (s)); \ }) int nvkm_therm_create_(struct nvkm_object *, struct nvkm_object *, diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c index a624e9eb0c3b..d54d84aaf763 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c @@ -76,7 +76,7 @@ nvkm_clk_adjust(struct nvkm_clk *clk, bool adjust, static int nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) { - struct nvkm_therm *ptherm = nvkm_therm(clk); + struct nvkm_therm *therm = nvkm_therm(clk); struct nvkm_volt *volt = nvkm_volt(clk); struct nvkm_cstate *cstate; int ret; @@ -87,8 +87,8 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) cstate = &pstate->base; } - if (ptherm) { - ret = nvkm_therm_cstate(ptherm, pstate->fanspeed, +1); + if (therm) { + ret = nvkm_therm_cstate(therm, pstate->fanspeed, +1); if (ret && ret != -ENODEV) { nv_error(clk, "failed to raise fan speed: %d\n", ret); return ret; @@ -115,8 +115,8 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) nv_error(clk, "failed to lower voltage: %d\n", ret); } - if (ptherm) { - ret = nvkm_therm_cstate(ptherm, pstate->fanspeed, -1); + if (therm) { + ret = nvkm_therm_cstate(therm, pstate->fanspeed, -1); if (ret && ret != -ENODEV) nv_error(clk, "failed to lower fan speed: %d\n", ret); } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c index eb86c3ed5f56..abb3fdc18910 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c @@ -24,18 +24,18 @@ #include "priv.h" static int -nvkm_therm_update_trip(struct nvkm_therm *therm) +nvkm_therm_update_trip(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_trip_point *trip = priv->fan->bios.trip, + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip = NULL, - *last_trip = priv->last_trip; - u8 temp = therm->temp_get(therm); + *last_trip = therm->last_trip; + u8 temp = therm->base.temp_get(&therm->base); u16 duty, i; /* look for the trip point corresponding to the current temperature */ cur_trip = NULL; - for (i = 0; i < priv->fan->bios.nr_fan_trip; i++) { + for (i = 0; i < therm->fan->bios.nr_fan_trip; i++) { if (temp >= trip[i].temp) cur_trip = &trip[i]; } @@ -47,72 +47,72 @@ nvkm_therm_update_trip(struct nvkm_therm *therm) if (cur_trip) { duty = cur_trip->fan_duty; - priv->last_trip = cur_trip; + therm->last_trip = cur_trip; } else { duty = 0; - priv->last_trip = NULL; + therm->last_trip = NULL; } return duty; } static int -nvkm_therm_update_linear(struct nvkm_therm *therm) +nvkm_therm_update_linear(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - u8 linear_min_temp = priv->fan->bios.linear_min_temp; - u8 linear_max_temp = priv->fan->bios.linear_max_temp; - u8 temp = therm->temp_get(therm); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + u8 linear_min_temp = therm->fan->bios.linear_min_temp; + u8 linear_max_temp = therm->fan->bios.linear_max_temp; + u8 temp = therm->base.temp_get(&therm->base); u16 duty; /* handle the non-linear part first */ if (temp < linear_min_temp) - return priv->fan->bios.min_duty; + return therm->fan->bios.min_duty; else if (temp > linear_max_temp) - return priv->fan->bios.max_duty; + return therm->fan->bios.max_duty; /* we are in the linear zone */ duty = (temp - linear_min_temp); - duty *= (priv->fan->bios.max_duty - priv->fan->bios.min_duty); + duty *= (therm->fan->bios.max_duty - therm->fan->bios.min_duty); duty /= (linear_max_temp - linear_min_temp); - duty += priv->fan->bios.min_duty; + duty += therm->fan->bios.min_duty; return duty; } static void -nvkm_therm_update(struct nvkm_therm *therm, int mode) +nvkm_therm_update(struct nvkm_therm *obj, int mode) { + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_timer *ptimer = nvkm_timer(therm); - struct nvkm_therm_priv *priv = (void *)therm; unsigned long flags; bool immd = true; bool poll = true; int duty = -1; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&therm->lock, flags); if (mode < 0) - mode = priv->mode; - priv->mode = mode; + mode = therm->mode; + therm->mode = mode; switch (mode) { case NVKM_THERM_CTRL_MANUAL: - ptimer->alarm_cancel(ptimer, &priv->alarm); - duty = nvkm_therm_fan_get(therm); + ptimer->alarm_cancel(ptimer, &therm->alarm); + duty = nvkm_therm_fan_get(&therm->base); if (duty < 0) duty = 100; poll = false; break; case NVKM_THERM_CTRL_AUTO: - switch(priv->fan->bios.fan_mode) { + switch(therm->fan->bios.fan_mode) { case NVBIOS_THERM_FAN_TRIP: - duty = nvkm_therm_update_trip(therm); + duty = nvkm_therm_update_trip(&therm->base); break; case NVBIOS_THERM_FAN_LINEAR: - duty = nvkm_therm_update_linear(therm); + duty = nvkm_therm_update_linear(&therm->base); break; case NVBIOS_THERM_FAN_OTHER: - if (priv->cstate) - duty = priv->cstate; + if (therm->cstate) + duty = therm->cstate; poll = false; break; } @@ -120,29 +120,29 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode) break; case NVKM_THERM_CTRL_NONE: default: - ptimer->alarm_cancel(ptimer, &priv->alarm); + ptimer->alarm_cancel(ptimer, &therm->alarm); poll = false; } - if (list_empty(&priv->alarm.head) && poll) - ptimer->alarm(ptimer, 1000000000ULL, &priv->alarm); - spin_unlock_irqrestore(&priv->lock, flags); + if (list_empty(&therm->alarm.head) && poll) + ptimer->alarm(ptimer, 1000000000ULL, &therm->alarm); + spin_unlock_irqrestore(&therm->lock, flags); if (duty >= 0) { nv_debug(therm, "FAN target request: %d%%\n", duty); - nvkm_therm_fan_set(therm, immd, duty); + nvkm_therm_fan_set(&therm->base, immd, duty); } } int -nvkm_therm_cstate(struct nvkm_therm *ptherm, int fan, int dir) +nvkm_therm_cstate(struct nvkm_therm *obj, int fan, int dir) { - struct nvkm_therm_priv *priv = (void *)ptherm; - if (!dir || (dir < 0 && fan < priv->cstate) || - (dir > 0 && fan > priv->cstate)) { - nv_debug(ptherm, "default fan speed -> %d%%\n", fan); - priv->cstate = fan; - nvkm_therm_update(ptherm, -1); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + if (!dir || (dir < 0 && fan < therm->cstate) || + (dir > 0 && fan > therm->cstate)) { + nv_debug(therm, "default fan speed -> %d%%\n", fan); + therm->cstate = fan; + nvkm_therm_update(&therm->base, -1); } return 0; } @@ -150,15 +150,15 @@ nvkm_therm_cstate(struct nvkm_therm *ptherm, int fan, int dir) static void nvkm_therm_alarm(struct nvkm_alarm *alarm) { - struct nvkm_therm_priv *priv = + struct nvkm_therm_priv *therm = container_of(alarm, struct nvkm_therm_priv, alarm); - nvkm_therm_update(&priv->base, -1); + nvkm_therm_update(&therm->base, -1); } int -nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) +nvkm_therm_fan_mode(struct nvkm_therm *obj, int mode) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_device *device = nv_device(therm); static const char *name[] = { "disabled", @@ -174,105 +174,105 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) /* do not allow automatic fan management if the thermal sensor is * not available */ - if (mode == NVKM_THERM_CTRL_AUTO && therm->temp_get(therm) < 0) + if (mode == NVKM_THERM_CTRL_AUTO && + therm->base.temp_get(&therm->base) < 0) return -EINVAL; - if (priv->mode == mode) + if (therm->mode == mode) return 0; nv_info(therm, "fan management: %s\n", name[mode]); - nvkm_therm_update(therm, mode); + nvkm_therm_update(&therm->base, mode); return 0; } int -nvkm_therm_attr_get(struct nvkm_therm *therm, - enum nvkm_therm_attr_type type) +nvkm_therm_attr_get(struct nvkm_therm *obj, enum nvkm_therm_attr_type type) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); switch (type) { case NVKM_THERM_ATTR_FAN_MIN_DUTY: - return priv->fan->bios.min_duty; + return therm->fan->bios.min_duty; case NVKM_THERM_ATTR_FAN_MAX_DUTY: - return priv->fan->bios.max_duty; + return therm->fan->bios.max_duty; case NVKM_THERM_ATTR_FAN_MODE: - return priv->mode; + return therm->mode; case NVKM_THERM_ATTR_THRS_FAN_BOOST: - return priv->bios_sensor.thrs_fan_boost.temp; + return therm->bios_sensor.thrs_fan_boost.temp; case NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST: - return priv->bios_sensor.thrs_fan_boost.hysteresis; + return therm->bios_sensor.thrs_fan_boost.hysteresis; case NVKM_THERM_ATTR_THRS_DOWN_CLK: - return priv->bios_sensor.thrs_down_clock.temp; + return therm->bios_sensor.thrs_down_clock.temp; case NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST: - return priv->bios_sensor.thrs_down_clock.hysteresis; + return therm->bios_sensor.thrs_down_clock.hysteresis; case NVKM_THERM_ATTR_THRS_CRITICAL: - return priv->bios_sensor.thrs_critical.temp; + return therm->bios_sensor.thrs_critical.temp; case NVKM_THERM_ATTR_THRS_CRITICAL_HYST: - return priv->bios_sensor.thrs_critical.hysteresis; + return therm->bios_sensor.thrs_critical.hysteresis; case NVKM_THERM_ATTR_THRS_SHUTDOWN: - return priv->bios_sensor.thrs_shutdown.temp; + return therm->bios_sensor.thrs_shutdown.temp; case NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST: - return priv->bios_sensor.thrs_shutdown.hysteresis; + return therm->bios_sensor.thrs_shutdown.hysteresis; } return -EINVAL; } int -nvkm_therm_attr_set(struct nvkm_therm *therm, +nvkm_therm_attr_set(struct nvkm_therm *obj, enum nvkm_therm_attr_type type, int value) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); switch (type) { case NVKM_THERM_ATTR_FAN_MIN_DUTY: if (value < 0) value = 0; - if (value > priv->fan->bios.max_duty) - value = priv->fan->bios.max_duty; - priv->fan->bios.min_duty = value; + if (value > therm->fan->bios.max_duty) + value = therm->fan->bios.max_duty; + therm->fan->bios.min_duty = value; return 0; case NVKM_THERM_ATTR_FAN_MAX_DUTY: if (value < 0) value = 0; - if (value < priv->fan->bios.min_duty) - value = priv->fan->bios.min_duty; - priv->fan->bios.max_duty = value; + if (value < therm->fan->bios.min_duty) + value = therm->fan->bios.min_duty; + therm->fan->bios.max_duty = value; return 0; case NVKM_THERM_ATTR_FAN_MODE: - return nvkm_therm_fan_mode(therm, value); + return nvkm_therm_fan_mode(&therm->base, value); case NVKM_THERM_ATTR_THRS_FAN_BOOST: - priv->bios_sensor.thrs_fan_boost.temp = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_fan_boost.temp = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST: - priv->bios_sensor.thrs_fan_boost.hysteresis = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_fan_boost.hysteresis = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_DOWN_CLK: - priv->bios_sensor.thrs_down_clock.temp = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_down_clock.temp = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST: - priv->bios_sensor.thrs_down_clock.hysteresis = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_down_clock.hysteresis = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_CRITICAL: - priv->bios_sensor.thrs_critical.temp = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_critical.temp = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_CRITICAL_HYST: - priv->bios_sensor.thrs_critical.hysteresis = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_critical.hysteresis = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_SHUTDOWN: - priv->bios_sensor.thrs_shutdown.temp = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_shutdown.temp = value; + therm->sensor.program_alarms(&therm->base); return 0; case NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST: - priv->bios_sensor.thrs_shutdown.hysteresis = value; - priv->sensor.program_alarms(therm); + therm->bios_sensor.thrs_shutdown.hysteresis = value; + therm->sensor.program_alarms(&therm->base); return 0; } @@ -282,65 +282,63 @@ nvkm_therm_attr_set(struct nvkm_therm *therm, int _nvkm_therm_init(struct nvkm_object *object) { - struct nvkm_therm *therm = (void *)object; - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = (void *)object; int ret; - ret = nvkm_subdev_init(&therm->base); + ret = nvkm_subdev_init(&therm->base.subdev); if (ret) return ret; - if (priv->suspend >= 0) { + if (therm->suspend >= 0) { /* restore the pwm value only when on manual or auto mode */ - if (priv->suspend > 0) - nvkm_therm_fan_set(therm, true, priv->fan->percent); + if (therm->suspend > 0) + nvkm_therm_fan_set(&therm->base, true, therm->fan->percent); - nvkm_therm_fan_mode(therm, priv->suspend); + nvkm_therm_fan_mode(&therm->base, therm->suspend); } - nvkm_therm_sensor_init(therm); - nvkm_therm_fan_init(therm); + nvkm_therm_sensor_init(&therm->base); + nvkm_therm_fan_init(&therm->base); return 0; } int _nvkm_therm_fini(struct nvkm_object *object, bool suspend) { - struct nvkm_therm *therm = (void *)object; - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = (void *)object; - nvkm_therm_fan_fini(therm, suspend); - nvkm_therm_sensor_fini(therm, suspend); + nvkm_therm_fan_fini(&therm->base, suspend); + nvkm_therm_sensor_fini(&therm->base, suspend); if (suspend) { - priv->suspend = priv->mode; - priv->mode = NVKM_THERM_CTRL_NONE; + therm->suspend = therm->mode; + therm->mode = NVKM_THERM_CTRL_NONE; } - return nvkm_subdev_fini(&therm->base, suspend); + return nvkm_subdev_fini(&therm->base.subdev, suspend); } int nvkm_therm_create_(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, int length, void **pobject) { - struct nvkm_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; ret = nvkm_subdev_create_(parent, engine, oclass, 0, "PTHERM", "therm", length, pobject); - priv = *pobject; + therm = *pobject; if (ret) return ret; - nvkm_alarm_init(&priv->alarm, nvkm_therm_alarm); - spin_lock_init(&priv->lock); - spin_lock_init(&priv->sensor.alarm_program_lock); + nvkm_alarm_init(&therm->alarm, nvkm_therm_alarm); + spin_lock_init(&therm->lock); + spin_lock_init(&therm->sensor.alarm_program_lock); - priv->base.fan_get = nvkm_therm_fan_user_get; - priv->base.fan_set = nvkm_therm_fan_user_set; - priv->base.fan_sense = nvkm_therm_fan_sense; - priv->base.attr_get = nvkm_therm_attr_get; - priv->base.attr_set = nvkm_therm_attr_set; - priv->mode = priv->suspend = -1; /* undefined */ + therm->base.fan_get = nvkm_therm_fan_user_get; + therm->base.fan_set = nvkm_therm_fan_user_set; + therm->base.fan_sense = nvkm_therm_fan_sense; + therm->base.attr_get = nvkm_therm_attr_get; + therm->base.attr_set = nvkm_therm_attr_set; + therm->mode = therm->suspend = -1; /* undefined */ return 0; } @@ -359,7 +357,7 @@ nvkm_therm_preinit(struct nvkm_therm *therm) void _nvkm_therm_dtor(struct nvkm_object *object) { - struct nvkm_therm_priv *priv = (void *)object; - kfree(priv->fan); - nvkm_subdev_destroy(&priv->base.base); + struct nvkm_therm_priv *therm = (void *)object; + kfree(therm->fan); + nvkm_subdev_destroy(&therm->base.subdev); } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c index 434fa745ca40..37b9f47f663c 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c @@ -31,9 +31,8 @@ static int nvkm_fan_update(struct nvkm_fan *fan, bool immediate, int target) { - struct nvkm_therm *therm = fan->parent; - struct nvkm_therm_priv *priv = (void *)therm; - struct nvkm_timer *ptimer = nvkm_timer(priv); + struct nvkm_therm_priv *therm = (void *)fan->parent; + struct nvkm_timer *ptimer = nvkm_timer(therm); unsigned long flags; int ret = 0; int duty; @@ -50,7 +49,7 @@ nvkm_fan_update(struct nvkm_fan *fan, bool immediate, int target) } /* check that we're not already at the target duty cycle */ - duty = fan->get(therm); + duty = fan->get(&therm->base); if (duty == target) { spin_unlock_irqrestore(&fan->lock, flags); return 0; @@ -71,7 +70,7 @@ nvkm_fan_update(struct nvkm_fan *fan, bool immediate, int target) } nv_debug(therm, "FAN update: %d\n", duty); - ret = fan->set(therm, duty); + ret = fan->set(&therm->base, duty); if (ret) { spin_unlock_irqrestore(&fan->lock, flags); return ret; @@ -109,29 +108,29 @@ nvkm_fan_alarm(struct nvkm_alarm *alarm) } int -nvkm_therm_fan_get(struct nvkm_therm *therm) +nvkm_therm_fan_get(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - return priv->fan->get(therm); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + return therm->fan->get(&therm->base); } int -nvkm_therm_fan_set(struct nvkm_therm *therm, bool immediate, int percent) +nvkm_therm_fan_set(struct nvkm_therm *obj, bool immediate, int percent) { - struct nvkm_therm_priv *priv = (void *)therm; - return nvkm_fan_update(priv->fan, immediate, percent); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + return nvkm_fan_update(therm->fan, immediate, percent); } int -nvkm_therm_fan_sense(struct nvkm_therm *therm) +nvkm_therm_fan_sense(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_timer *ptimer = nvkm_timer(therm); struct nvkm_gpio *gpio = nvkm_gpio(therm); u32 cycles, cur, prev; u64 start, end, tach; - if (priv->fan->tach.func == DCB_GPIO_UNUSED) + if (therm->fan->tach.func == DCB_GPIO_UNUSED) return -ENODEV; /* Time a complete rotation and extrapolate to RPM: @@ -139,12 +138,12 @@ nvkm_therm_fan_sense(struct nvkm_therm *therm) * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. */ start = ptimer->read(ptimer); - prev = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); + prev = gpio->get(gpio, 0, therm->fan->tach.func, therm->fan->tach.line); cycles = 0; do { usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ - cur = gpio->get(gpio, 0, priv->fan->tach.func, priv->fan->tach.line); + cur = gpio->get(gpio, 0, therm->fan->tach.func, therm->fan->tach.line); if (prev != cur) { if (!start) start = ptimer->read(ptimer); @@ -163,71 +162,72 @@ nvkm_therm_fan_sense(struct nvkm_therm *therm) } int -nvkm_therm_fan_user_get(struct nvkm_therm *therm) +nvkm_therm_fan_user_get(struct nvkm_therm *obj) { - return nvkm_therm_fan_get(therm); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + return nvkm_therm_fan_get(&therm->base); } int -nvkm_therm_fan_user_set(struct nvkm_therm *therm, int percent) +nvkm_therm_fan_user_set(struct nvkm_therm *obj, int percent) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); - if (priv->mode != NVKM_THERM_CTRL_MANUAL) + if (therm->mode != NVKM_THERM_CTRL_MANUAL) return -EINVAL; - return nvkm_therm_fan_set(therm, true, percent); + return nvkm_therm_fan_set(&therm->base, true, percent); } static void -nvkm_therm_fan_set_defaults(struct nvkm_therm *therm) +nvkm_therm_fan_set_defaults(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - - priv->fan->bios.pwm_freq = 0; - priv->fan->bios.min_duty = 0; - priv->fan->bios.max_duty = 100; - priv->fan->bios.bump_period = 500; - priv->fan->bios.slow_down_period = 2000; - priv->fan->bios.linear_min_temp = 40; - priv->fan->bios.linear_max_temp = 85; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + + therm->fan->bios.pwm_freq = 0; + therm->fan->bios.min_duty = 0; + therm->fan->bios.max_duty = 100; + therm->fan->bios.bump_period = 500; + therm->fan->bios.slow_down_period = 2000; + therm->fan->bios.linear_min_temp = 40; + therm->fan->bios.linear_max_temp = 85; } static void -nvkm_therm_fan_safety_checks(struct nvkm_therm *therm) +nvkm_therm_fan_safety_checks(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); - if (priv->fan->bios.min_duty > 100) - priv->fan->bios.min_duty = 100; - if (priv->fan->bios.max_duty > 100) - priv->fan->bios.max_duty = 100; + if (therm->fan->bios.min_duty > 100) + therm->fan->bios.min_duty = 100; + if (therm->fan->bios.max_duty > 100) + therm->fan->bios.max_duty = 100; - if (priv->fan->bios.min_duty > priv->fan->bios.max_duty) - priv->fan->bios.min_duty = priv->fan->bios.max_duty; + if (therm->fan->bios.min_duty > therm->fan->bios.max_duty) + therm->fan->bios.min_duty = therm->fan->bios.max_duty; } int -nvkm_therm_fan_init(struct nvkm_therm *therm) +nvkm_therm_fan_init(struct nvkm_therm *obj) { return 0; } int -nvkm_therm_fan_fini(struct nvkm_therm *therm, bool suspend) +nvkm_therm_fan_fini(struct nvkm_therm *obj, bool suspend) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_timer *ptimer = nvkm_timer(therm); if (suspend) - ptimer->alarm_cancel(ptimer, &priv->fan->alarm); + ptimer->alarm_cancel(ptimer, &therm->fan->alarm); return 0; } int -nvkm_therm_fan_ctor(struct nvkm_therm *therm) +nvkm_therm_fan_ctor(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_gpio *gpio = nvkm_gpio(therm); struct nvkm_bios *bios = nvkm_bios(therm); struct dcb_gpio_func func; @@ -241,42 +241,42 @@ nvkm_therm_fan_ctor(struct nvkm_therm *therm) nv_debug(therm, "GPIO_FAN is in input mode\n"); ret = -EINVAL; } else { - ret = nvkm_fanpwm_create(therm, &func); + ret = nvkm_fanpwm_create(&therm->base, &func); if (ret != 0) - ret = nvkm_fantog_create(therm, &func); + ret = nvkm_fantog_create(&therm->base, &func); } } /* no controllable fan found, create a dummy fan module */ if (ret != 0) { - ret = nvkm_fannil_create(therm); + ret = nvkm_fannil_create(&therm->base); if (ret) return ret; } - nv_info(therm, "FAN control: %s\n", priv->fan->type); + nv_info(therm, "FAN control: %s\n", therm->fan->type); /* read the current speed, it is useful when resuming */ - priv->fan->percent = nvkm_therm_fan_get(therm); + therm->fan->percent = nvkm_therm_fan_get(&therm->base); /* attempt to detect a tachometer connection */ - ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &priv->fan->tach); + ret = gpio->find(gpio, 0, DCB_GPIO_FAN_SENSE, 0xff, &therm->fan->tach); if (ret) - priv->fan->tach.func = DCB_GPIO_UNUSED; + therm->fan->tach.func = DCB_GPIO_UNUSED; /* initialise fan bump/slow update handling */ - priv->fan->parent = therm; - nvkm_alarm_init(&priv->fan->alarm, nvkm_fan_alarm); - spin_lock_init(&priv->fan->lock); + therm->fan->parent = &therm->base; + nvkm_alarm_init(&therm->fan->alarm, nvkm_fan_alarm); + spin_lock_init(&therm->fan->lock); /* other random init... */ - nvkm_therm_fan_set_defaults(therm); - nvbios_perf_fan_parse(bios, &priv->fan->perf); - if (!nvbios_fan_parse(bios, &priv->fan->bios)) { + nvkm_therm_fan_set_defaults(&therm->base); + nvbios_perf_fan_parse(bios, &therm->fan->perf); + if (!nvbios_fan_parse(bios, &therm->fan->bios)) { nv_debug(therm, "parsing the fan table failed\n"); - if (nvbios_therm_fan_parse(bios, &priv->fan->bios)) + if (nvbios_therm_fan_parse(bios, &therm->fan->bios)) nv_error(therm, "parsing both fan tables failed\n"); } - nvkm_therm_fan_safety_checks(therm); + nvkm_therm_fan_safety_checks(&therm->base); return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fannil.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fannil.c index 534e5970ec9c..693b4efd1841 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fannil.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fannil.c @@ -36,13 +36,13 @@ nvkm_fannil_set(struct nvkm_therm *therm, int percent) } int -nvkm_fannil_create(struct nvkm_therm *therm) +nvkm_fannil_create(struct nvkm_therm *obj) { - struct nvkm_therm_priv *tpriv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_fan *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); - tpriv->fan = priv; + therm->fan = priv; if (!priv) return -ENOMEM; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c index 3cf4192a33af..97917c532e14 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c @@ -29,84 +29,85 @@ #include <subdev/bios/fan.h> #include <subdev/gpio.h> -struct nvkm_fanpwm_priv { +struct nvkm_fanpwm { struct nvkm_fan base; struct dcb_gpio_func func; }; static int -nvkm_fanpwm_get(struct nvkm_therm *therm) +nvkm_fanpwm_get(struct nvkm_therm *obj) { - struct nvkm_therm_priv *tpriv = (void *)therm; - struct nvkm_fanpwm_priv *priv = (void *)tpriv->fan; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvkm_fanpwm *fan = (void *)therm->fan; struct nvkm_gpio *gpio = nvkm_gpio(therm); int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; - ret = therm->pwm_get(therm, priv->func.line, &divs, &duty); + ret = therm->base.pwm_get(&therm->base, fan->func.line, &divs, &duty); if (ret == 0 && divs) { divs = max(divs, duty); - if (card_type <= NV_40 || (priv->func.log[0] & 1)) + if (card_type <= NV_40 || (fan->func.log[0] & 1)) duty = divs - duty; return (duty * 100) / divs; } - return gpio->get(gpio, 0, priv->func.func, priv->func.line) * 100; + return gpio->get(gpio, 0, fan->func.func, fan->func.line) * 100; } static int -nvkm_fanpwm_set(struct nvkm_therm *therm, int percent) +nvkm_fanpwm_set(struct nvkm_therm *obj, int percent) { - struct nvkm_therm_priv *tpriv = (void *)therm; - struct nvkm_fanpwm_priv *priv = (void *)tpriv->fan; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvkm_fanpwm *fan = (void *)therm->fan; int card_type = nv_device(therm)->card_type; u32 divs, duty; int ret; - divs = priv->base.perf.pwm_divisor; - if (priv->base.bios.pwm_freq) { + divs = fan->base.perf.pwm_divisor; + if (fan->base.bios.pwm_freq) { divs = 1; - if (therm->pwm_clock) - divs = therm->pwm_clock(therm, priv->func.line); - divs /= priv->base.bios.pwm_freq; + if (therm->base.pwm_clock) + divs = therm->base.pwm_clock(&therm->base, + fan->func.line); + divs /= fan->base.bios.pwm_freq; } duty = ((divs * percent) + 99) / 100; - if (card_type <= NV_40 || (priv->func.log[0] & 1)) + if (card_type <= NV_40 || (fan->func.log[0] & 1)) duty = divs - duty; - ret = therm->pwm_set(therm, priv->func.line, divs, duty); + ret = therm->base.pwm_set(&therm->base, fan->func.line, divs, duty); if (ret == 0) - ret = therm->pwm_ctrl(therm, priv->func.line, true); + ret = therm->base.pwm_ctrl(&therm->base, fan->func.line, true); return ret; } int -nvkm_fanpwm_create(struct nvkm_therm *therm, struct dcb_gpio_func *func) +nvkm_fanpwm_create(struct nvkm_therm *obj, struct dcb_gpio_func *func) { + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_device *device = nv_device(therm); - struct nvkm_therm_priv *tpriv = (void *)therm; struct nvkm_bios *bios = nvkm_bios(therm); - struct nvkm_fanpwm_priv *priv; - struct nvbios_therm_fan fan; + struct nvkm_fanpwm *fan; + struct nvbios_therm_fan info; u32 divs, duty; - nvbios_fan_parse(bios, &fan); + nvbios_fan_parse(bios, &info); if (!nvkm_boolopt(device->cfgopt, "NvFanPWM", func->param) || - !therm->pwm_ctrl || fan.type == NVBIOS_THERM_FAN_TOGGLE || - therm->pwm_get(therm, func->line, &divs, &duty) == -ENODEV) + !therm->base.pwm_ctrl || info.type == NVBIOS_THERM_FAN_TOGGLE || + therm->base.pwm_get(&therm->base, func->line, &divs, &duty) == -ENODEV) return -ENODEV; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - tpriv->fan = &priv->base; - if (!priv) + fan = kzalloc(sizeof(*fan), GFP_KERNEL); + therm->fan = &fan->base; + if (!fan) return -ENOMEM; - priv->base.type = "PWM"; - priv->base.get = nvkm_fanpwm_get; - priv->base.set = nvkm_fanpwm_set; - priv->func = *func; + fan->base.type = "PWM"; + fan->base.get = nvkm_fanpwm_get; + fan->base.set = nvkm_fanpwm_set; + fan->func = *func; return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fantog.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fantog.c index 4ce041e81371..138ee99ec0ea 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fantog.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fantog.c @@ -26,7 +26,7 @@ #include <subdev/gpio.h> #include <subdev/timer.h> -struct nvkm_fantog_priv { +struct nvkm_fantog { struct nvkm_fan base; struct nvkm_alarm alarm; spinlock_t lock; @@ -36,83 +36,83 @@ struct nvkm_fantog_priv { }; static void -nvkm_fantog_update(struct nvkm_fantog_priv *priv, int percent) +nvkm_fantog_update(struct nvkm_fantog *fan, int percent) { - struct nvkm_therm_priv *tpriv = (void *)priv->base.parent; - struct nvkm_timer *ptimer = nvkm_timer(tpriv); - struct nvkm_gpio *gpio = nvkm_gpio(tpriv); + struct nvkm_therm_priv *therm = (void *)fan->base.parent; + struct nvkm_timer *ptimer = nvkm_timer(therm); + struct nvkm_gpio *gpio = nvkm_gpio(therm); unsigned long flags; int duty; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&fan->lock, flags); if (percent < 0) - percent = priv->percent; - priv->percent = percent; + percent = fan->percent; + fan->percent = percent; duty = !gpio->get(gpio, 0, DCB_GPIO_FAN, 0xff); gpio->set(gpio, 0, DCB_GPIO_FAN, 0xff, duty); - if (list_empty(&priv->alarm.head) && percent != (duty * 100)) { - u64 next_change = (percent * priv->period_us) / 100; + if (list_empty(&fan->alarm.head) && percent != (duty * 100)) { + u64 next_change = (percent * fan->period_us) / 100; if (!duty) - next_change = priv->period_us - next_change; - ptimer->alarm(ptimer, next_change * 1000, &priv->alarm); + next_change = fan->period_us - next_change; + ptimer->alarm(ptimer, next_change * 1000, &fan->alarm); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&fan->lock, flags); } static void nvkm_fantog_alarm(struct nvkm_alarm *alarm) { - struct nvkm_fantog_priv *priv = - container_of(alarm, struct nvkm_fantog_priv, alarm); - nvkm_fantog_update(priv, -1); + struct nvkm_fantog *fan = + container_of(alarm, struct nvkm_fantog, alarm); + nvkm_fantog_update(fan, -1); } static int -nvkm_fantog_get(struct nvkm_therm *therm) +nvkm_fantog_get(struct nvkm_therm *obj) { - struct nvkm_therm_priv *tpriv = (void *)therm; - struct nvkm_fantog_priv *priv = (void *)tpriv->fan; - return priv->percent; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvkm_fantog *fan = (void *)therm->fan; + return fan->percent; } static int -nvkm_fantog_set(struct nvkm_therm *therm, int percent) +nvkm_fantog_set(struct nvkm_therm *obj, int percent) { - struct nvkm_therm_priv *tpriv = (void *)therm; - struct nvkm_fantog_priv *priv = (void *)tpriv->fan; - if (therm->pwm_ctrl) - therm->pwm_ctrl(therm, priv->func.line, false); - nvkm_fantog_update(priv, percent); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvkm_fantog *fan = (void *)therm->fan; + if (therm->base.pwm_ctrl) + therm->base.pwm_ctrl(&therm->base, fan->func.line, false); + nvkm_fantog_update(fan, percent); return 0; } int -nvkm_fantog_create(struct nvkm_therm *therm, struct dcb_gpio_func *func) +nvkm_fantog_create(struct nvkm_therm *obj, struct dcb_gpio_func *func) { - struct nvkm_therm_priv *tpriv = (void *)therm; - struct nvkm_fantog_priv *priv; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvkm_fantog *fan; int ret; - if (therm->pwm_ctrl) { - ret = therm->pwm_ctrl(therm, func->line, false); + if (therm->base.pwm_ctrl) { + ret = therm->base.pwm_ctrl(&therm->base, func->line, false); if (ret) return ret; } - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - tpriv->fan = &priv->base; - if (!priv) + fan = kzalloc(sizeof(*fan), GFP_KERNEL); + therm->fan = &fan->base; + if (!fan) return -ENOMEM; - priv->base.type = "toggle"; - priv->base.get = nvkm_fantog_get; - priv->base.set = nvkm_fantog_set; - nvkm_alarm_init(&priv->alarm, nvkm_fantog_alarm); - priv->period_us = 100000; /* 10Hz */ - priv->percent = 100; - priv->func = *func; - spin_lock_init(&priv->lock); + fan->base.type = "toggle"; + fan->base.get = nvkm_fantog_get; + fan->base.set = nvkm_fantog_set; + nvkm_alarm_init(&fan->alarm, nvkm_fantog_alarm); + fan->period_us = 100000; /* 10Hz */ + fan->percent = 100; + fan->func = *func; + spin_lock_init(&fan->lock); return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c index 85b5d0c18c0b..555722900bb3 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c @@ -26,10 +26,6 @@ #include <subdev/fuse.h> -struct g84_therm_priv { - struct nvkm_therm_priv base; -}; - int g84_temp_get(struct nvkm_therm *therm) { @@ -55,13 +51,13 @@ g84_sensor_setup(struct nvkm_therm *therm) } static void -g84_therm_program_alarms(struct nvkm_therm *therm) +g84_therm_program_alarms(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; unsigned long flags; - spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags); + spin_lock_irqsave(&therm->sensor.alarm_program_lock, flags); /* enable RISING and FALLING IRQs for shutdown, THRS 0, 1, 2 and 4 */ nv_wr32(therm, 0x20000, 0x000003ff); @@ -78,7 +74,7 @@ g84_therm_program_alarms(struct nvkm_therm *therm) /* THRS_4 : down clock */ nv_wr32(therm, 0x20414, sensor->thrs_down_clock.temp); - spin_unlock_irqrestore(&priv->sensor.alarm_program_lock, flags); + spin_unlock_irqrestore(&therm->sensor.alarm_program_lock, flags); nv_debug(therm, "Programmed thresholds [ %d(%d), %d(%d), %d(%d), %d(%d) ]\n", @@ -137,19 +133,18 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, static void g84_therm_intr(struct nvkm_subdev *subdev) { - struct nvkm_therm *therm = nvkm_therm(subdev); - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + struct nvkm_therm_priv *therm = (void *)subdev; + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; unsigned long flags; uint32_t intr; - spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags); + spin_lock_irqsave(&therm->sensor.alarm_program_lock, flags); intr = nv_rd32(therm, 0x20100) & 0x3ff; /* THRS_4: downclock */ if (intr & 0x002) { - g84_therm_threshold_hyst_emulation(therm, 0x20414, 24, + g84_therm_threshold_hyst_emulation(&therm->base, 0x20414, 24, &sensor->thrs_down_clock, NVKM_THERM_THRS_DOWNCLOCK); intr &= ~0x002; @@ -157,7 +152,7 @@ g84_therm_intr(struct nvkm_subdev *subdev) /* shutdown */ if (intr & 0x004) { - g84_therm_threshold_hyst_emulation(therm, 0x20480, 20, + g84_therm_threshold_hyst_emulation(&therm->base, 0x20480, 20, &sensor->thrs_shutdown, NVKM_THERM_THRS_SHUTDOWN); intr &= ~0x004; @@ -165,7 +160,7 @@ g84_therm_intr(struct nvkm_subdev *subdev) /* THRS_1 : fan boost */ if (intr & 0x008) { - g84_therm_threshold_hyst_emulation(therm, 0x204c4, 21, + g84_therm_threshold_hyst_emulation(&therm->base, 0x204c4, 21, &sensor->thrs_fan_boost, NVKM_THERM_THRS_FANBOOST); intr &= ~0x008; @@ -173,7 +168,7 @@ g84_therm_intr(struct nvkm_subdev *subdev) /* THRS_2 : critical */ if (intr & 0x010) { - g84_therm_threshold_hyst_emulation(therm, 0x204c0, 22, + g84_therm_threshold_hyst_emulation(&therm->base, 0x204c0, 22, &sensor->thrs_critical, NVKM_THERM_THRS_CRITICAL); intr &= ~0x010; @@ -186,20 +181,20 @@ g84_therm_intr(struct nvkm_subdev *subdev) nv_wr32(therm, 0x20100, 0xffffffff); nv_wr32(therm, 0x1100, 0x10000); /* PBUS */ - spin_unlock_irqrestore(&priv->sensor.alarm_program_lock, flags); + spin_unlock_irqrestore(&therm->sensor.alarm_program_lock, flags); } static int g84_therm_init(struct nvkm_object *object) { - struct g84_therm_priv *priv = (void *)object; + struct nvkm_therm_priv *therm = (void *)object; int ret; - ret = nvkm_therm_init(&priv->base.base); + ret = nvkm_therm_init(&therm->base); if (ret) return ret; - g84_sensor_setup(&priv->base.base); + g84_sensor_setup(&therm->base); return 0; } @@ -208,37 +203,37 @@ g84_therm_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct g84_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - priv->base.base.pwm_ctrl = nv50_fan_pwm_ctrl; - priv->base.base.pwm_get = nv50_fan_pwm_get; - priv->base.base.pwm_set = nv50_fan_pwm_set; - priv->base.base.pwm_clock = nv50_fan_pwm_clock; - priv->base.base.temp_get = g84_temp_get; - priv->base.sensor.program_alarms = g84_therm_program_alarms; - nv_subdev(priv)->intr = g84_therm_intr; + therm->base.pwm_ctrl = nv50_fan_pwm_ctrl; + therm->base.pwm_get = nv50_fan_pwm_get; + therm->base.pwm_set = nv50_fan_pwm_set; + therm->base.pwm_clock = nv50_fan_pwm_clock; + therm->base.temp_get = g84_temp_get; + therm->sensor.program_alarms = g84_therm_program_alarms; + nv_subdev(therm)->intr = g84_therm_intr; /* init the thresholds */ - nvkm_therm_sensor_set_threshold_state(&priv->base.base, + nvkm_therm_sensor_set_threshold_state(&therm->base, NVKM_THERM_THRS_SHUTDOWN, NVKM_THERM_THRS_LOWER); - nvkm_therm_sensor_set_threshold_state(&priv->base.base, + nvkm_therm_sensor_set_threshold_state(&therm->base, NVKM_THERM_THRS_FANBOOST, NVKM_THERM_THRS_LOWER); - nvkm_therm_sensor_set_threshold_state(&priv->base.base, + nvkm_therm_sensor_set_threshold_state(&therm->base, NVKM_THERM_THRS_CRITICAL, NVKM_THERM_THRS_LOWER); - nvkm_therm_sensor_set_threshold_state(&priv->base.base, + nvkm_therm_sensor_set_threshold_state(&therm->base, NVKM_THERM_THRS_DOWNCLOCK, NVKM_THERM_THRS_LOWER); - return nvkm_therm_preinit(&priv->base.base); + return nvkm_therm_preinit(&therm->base); } int diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c index 0540e6886d7d..4a2a2de9ef0b 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gf110.c @@ -23,10 +23,6 @@ */ #include "priv.h" -struct gf110_therm_priv { - struct nvkm_therm_priv base; -}; - static int pwm_info(struct nvkm_therm *therm, int line) { @@ -116,21 +112,21 @@ gf110_fan_pwm_clock(struct nvkm_therm *therm, int line) int gf110_therm_init(struct nvkm_object *object) { - struct gf110_therm_priv *priv = (void *)object; + struct nvkm_therm_priv *therm = (void *)object; int ret; - ret = nvkm_therm_init(&priv->base.base); + ret = nvkm_therm_init(&therm->base); if (ret) return ret; /* enable fan tach, count revolutions per-second */ - nv_mask(priv, 0x00e720, 0x00000003, 0x00000002); - if (priv->base.fan->tach.func != DCB_GPIO_UNUSED) { - nv_mask(priv, 0x00d79c, 0x000000ff, priv->base.fan->tach.line); - nv_wr32(priv, 0x00e724, nv_device(priv)->crystal * 1000); - nv_mask(priv, 0x00e720, 0x00000001, 0x00000001); + nv_mask(therm, 0x00e720, 0x00000003, 0x00000002); + if (therm->fan->tach.func != DCB_GPIO_UNUSED) { + nv_mask(therm, 0x00d79c, 0x000000ff, therm->fan->tach.line); + nv_wr32(therm, 0x00e724, nv_device(therm)->crystal * 1000); + nv_mask(therm, 0x00e720, 0x00000001, 0x00000001); } - nv_mask(priv, 0x00e720, 0x00000002, 0x00000000); + nv_mask(therm, 0x00e720, 0x00000002, 0x00000000); return 0; } @@ -140,24 +136,24 @@ gf110_therm_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct gf110_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - g84_sensor_setup(&priv->base.base); + g84_sensor_setup(&therm->base); - priv->base.base.pwm_ctrl = gf110_fan_pwm_ctrl; - priv->base.base.pwm_get = gf110_fan_pwm_get; - priv->base.base.pwm_set = gf110_fan_pwm_set; - priv->base.base.pwm_clock = gf110_fan_pwm_clock; - priv->base.base.temp_get = g84_temp_get; - priv->base.base.fan_sense = gt215_therm_fan_sense; - priv->base.sensor.program_alarms = nvkm_therm_program_alarms_polling; - return nvkm_therm_preinit(&priv->base.base); + therm->base.pwm_ctrl = gf110_fan_pwm_ctrl; + therm->base.pwm_get = gf110_fan_pwm_get; + therm->base.pwm_set = gf110_fan_pwm_set; + therm->base.pwm_clock = gf110_fan_pwm_clock; + therm->base.temp_get = g84_temp_get; + therm->base.fan_sense = gt215_therm_fan_sense; + therm->sensor.program_alarms = nvkm_therm_program_alarms_polling; + return nvkm_therm_preinit(&therm->base); } struct nvkm_oclass diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c index c1f3cf361837..f2271f3e5990 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c @@ -23,10 +23,6 @@ */ #include "priv.h" -struct gm107_therm_priv { - struct nvkm_therm_priv base; -}; - static int gm107_fan_pwm_ctrl(struct nvkm_therm *therm, int line, bool enable) { @@ -61,22 +57,22 @@ gm107_therm_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct gm107_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - priv->base.base.pwm_ctrl = gm107_fan_pwm_ctrl; - priv->base.base.pwm_get = gm107_fan_pwm_get; - priv->base.base.pwm_set = gm107_fan_pwm_set; - priv->base.base.pwm_clock = gm107_fan_pwm_clock; - priv->base.base.temp_get = g84_temp_get; - priv->base.base.fan_sense = gt215_therm_fan_sense; - priv->base.sensor.program_alarms = nvkm_therm_program_alarms_polling; - return nvkm_therm_preinit(&priv->base.base); + therm->base.pwm_ctrl = gm107_fan_pwm_ctrl; + therm->base.pwm_get = gm107_fan_pwm_get; + therm->base.pwm_set = gm107_fan_pwm_set; + therm->base.pwm_clock = gm107_fan_pwm_clock; + therm->base.temp_get = g84_temp_get; + therm->base.fan_sense = gt215_therm_fan_sense; + therm->sensor.program_alarms = nvkm_therm_program_alarms_polling; + return nvkm_therm_preinit(&therm->base); } struct nvkm_oclass diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c index b7fa4716ca9f..e6ba6e26da79 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gt215.c @@ -25,10 +25,6 @@ #include <subdev/gpio.h> -struct gt215_therm_priv { - struct nvkm_therm_priv base; -}; - int gt215_therm_fan_sense(struct nvkm_therm *therm) { @@ -42,24 +38,24 @@ gt215_therm_fan_sense(struct nvkm_therm *therm) static int gt215_therm_init(struct nvkm_object *object) { - struct gt215_therm_priv *priv = (void *)object; - struct dcb_gpio_func *tach = &priv->base.fan->tach; + struct nvkm_therm_priv *therm = (void *)object; + struct dcb_gpio_func *tach = &therm->fan->tach; int ret; - ret = nvkm_therm_init(&priv->base.base); + ret = nvkm_therm_init(&therm->base); if (ret) return ret; - g84_sensor_setup(&priv->base.base); + g84_sensor_setup(&therm->base); /* enable fan tach, count revolutions per-second */ - nv_mask(priv, 0x00e720, 0x00000003, 0x00000002); + nv_mask(therm, 0x00e720, 0x00000003, 0x00000002); if (tach->func != DCB_GPIO_UNUSED) { - nv_wr32(priv, 0x00e724, nv_device(priv)->crystal * 1000); - nv_mask(priv, 0x00e720, 0x001f0000, tach->line << 16); - nv_mask(priv, 0x00e720, 0x00000001, 0x00000001); + nv_wr32(therm, 0x00e724, nv_device(therm)->crystal * 1000); + nv_mask(therm, 0x00e720, 0x001f0000, tach->line << 16); + nv_mask(therm, 0x00e720, 0x00000001, 0x00000001); } - nv_mask(priv, 0x00e720, 0x00000002, 0x00000000); + nv_mask(therm, 0x00e720, 0x00000002, 0x00000000); return 0; } @@ -69,22 +65,22 @@ gt215_therm_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct gt215_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - priv->base.base.pwm_ctrl = nv50_fan_pwm_ctrl; - priv->base.base.pwm_get = nv50_fan_pwm_get; - priv->base.base.pwm_set = nv50_fan_pwm_set; - priv->base.base.pwm_clock = nv50_fan_pwm_clock; - priv->base.base.temp_get = g84_temp_get; - priv->base.base.fan_sense = gt215_therm_fan_sense; - priv->base.sensor.program_alarms = nvkm_therm_program_alarms_polling; - return nvkm_therm_preinit(&priv->base.base); + therm->base.pwm_ctrl = nv50_fan_pwm_ctrl; + therm->base.pwm_get = nv50_fan_pwm_get; + therm->base.pwm_set = nv50_fan_pwm_set; + therm->base.pwm_clock = nv50_fan_pwm_clock; + therm->base.temp_get = g84_temp_get; + therm->base.fan_sense = gt215_therm_fan_sense; + therm->sensor.program_alarms = nvkm_therm_program_alarms_polling; + return nvkm_therm_preinit(&therm->base); } struct nvkm_oclass diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/ic.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/ic.c index 09fc4605e853..f62198aa2969 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/ic.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/ic.c @@ -30,8 +30,8 @@ static bool probe_monitoring_device(struct nvkm_i2c_port *i2c, struct i2c_board_info *info, void *data) { - struct nvkm_therm_priv *priv = data; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + struct nvkm_therm_priv *therm = data; + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; struct i2c_client *client; request_module("%s%s", I2C_MODULE_PREFIX, info->type); @@ -46,11 +46,11 @@ probe_monitoring_device(struct nvkm_i2c_port *i2c, return false; } - nv_info(priv, + nv_info(therm, "Found an %s at address 0x%x (controlled by lm_sensors, " "temp offset %+i C)\n", info->type, info->addr, sensor->offset_constant); - priv->ic = client; + therm->ic = client; return true; } @@ -80,9 +80,9 @@ nv_board_infos[] = { }; void -nvkm_therm_ic_ctor(struct nvkm_therm *therm) +nvkm_therm_ic_ctor(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_bios *bios = nvkm_bios(therm); struct nvkm_i2c *i2c = nvkm_i2c(therm); struct nvbios_extdev_func extdev_entry; @@ -95,7 +95,7 @@ nvkm_therm_ic_ctor(struct nvkm_therm *therm) i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device", board, probe_monitoring_device, therm); - if (priv->ic) + if (therm->ic) return; } @@ -107,7 +107,7 @@ nvkm_therm_ic_ctor(struct nvkm_therm *therm) i2c->identify(i2c, NV_I2C_DEFAULT(0), "monitoring device", board, probe_monitoring_device, therm); - if (priv->ic) + if (therm->ic) return; } diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c index 20f65fd7679a..e66672dce7ca 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv40.c @@ -24,10 +24,6 @@ */ #include "priv.h" -struct nv40_therm_priv { - struct nvkm_therm_priv base; -}; - enum nv40_sensor_style { INVALID_STYLE = -1, OLD_STYLE = 0, NEW_STYLE = 1 }; static enum nv40_sensor_style @@ -76,11 +72,11 @@ nv40_sensor_setup(struct nvkm_therm *therm) } static int -nv40_temp_get(struct nvkm_therm *therm) +nv40_temp_get(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; - enum nv40_sensor_style style = nv40_sensor_style(therm); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; + enum nv40_sensor_style style = nv40_sensor_style(&therm->base); int core_temp; if (style == NEW_STYLE) { @@ -184,21 +180,21 @@ nv40_therm_ctor(struct nvkm_object *parent, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct nv40_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - priv->base.base.pwm_ctrl = nv40_fan_pwm_ctrl; - priv->base.base.pwm_get = nv40_fan_pwm_get; - priv->base.base.pwm_set = nv40_fan_pwm_set; - priv->base.base.temp_get = nv40_temp_get; - priv->base.sensor.program_alarms = nvkm_therm_program_alarms_polling; - nv_subdev(priv)->intr = nv40_therm_intr; - return nvkm_therm_preinit(&priv->base.base); + therm->base.pwm_ctrl = nv40_fan_pwm_ctrl; + therm->base.pwm_get = nv40_fan_pwm_get; + therm->base.pwm_set = nv40_fan_pwm_set; + therm->base.temp_get = nv40_temp_get; + therm->sensor.program_alarms = nvkm_therm_program_alarms_polling; + nv_subdev(therm)->intr = nv40_therm_intr; + return nvkm_therm_preinit(&therm->base); } static int diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c index 489dcf355d34..f57bac115628 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/nv50.c @@ -24,10 +24,6 @@ */ #include "priv.h" -struct nv50_therm_priv { - struct nvkm_therm_priv base; -}; - static int pwm_info(struct nvkm_therm *therm, int *line, int *ctrl, int *indx) { @@ -125,10 +121,10 @@ nv50_sensor_setup(struct nvkm_therm *therm) } static int -nv50_temp_get(struct nvkm_therm *therm) +nv50_temp_get(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; int core_temp; core_temp = nv_rd32(therm, 0x20014) & 0x3fff; @@ -155,23 +151,23 @@ nv50_therm_ctor(struct nvkm_object *parent, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { - struct nv50_therm_priv *priv; + struct nvkm_therm_priv *therm; int ret; - ret = nvkm_therm_create(parent, engine, oclass, &priv); - *pobject = nv_object(priv); + ret = nvkm_therm_create(parent, engine, oclass, &therm); + *pobject = nv_object(therm); if (ret) return ret; - priv->base.base.pwm_ctrl = nv50_fan_pwm_ctrl; - priv->base.base.pwm_get = nv50_fan_pwm_get; - priv->base.base.pwm_set = nv50_fan_pwm_set; - priv->base.base.pwm_clock = nv50_fan_pwm_clock; - priv->base.base.temp_get = nv50_temp_get; - priv->base.sensor.program_alarms = nvkm_therm_program_alarms_polling; - nv_subdev(priv)->intr = nv40_therm_intr; + therm->base.pwm_ctrl = nv50_fan_pwm_ctrl; + therm->base.pwm_get = nv50_fan_pwm_get; + therm->base.pwm_set = nv50_fan_pwm_set; + therm->base.pwm_clock = nv50_fan_pwm_clock; + therm->base.temp_get = nv50_temp_get; + therm->sensor.program_alarms = nvkm_therm_program_alarms_polling; + nv_subdev(therm)->intr = nv40_therm_intr; - return nvkm_therm_preinit(&priv->base.base); + return nvkm_therm_preinit(&therm->base); } static int diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c index aa13744f3854..a6f46ed0e2ae 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c @@ -24,31 +24,31 @@ #include "priv.h" static void -nvkm_therm_temp_set_defaults(struct nvkm_therm *therm) +nvkm_therm_temp_set_defaults(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); - priv->bios_sensor.offset_constant = 0; + therm->bios_sensor.offset_constant = 0; - priv->bios_sensor.thrs_fan_boost.temp = 90; - priv->bios_sensor.thrs_fan_boost.hysteresis = 3; + therm->bios_sensor.thrs_fan_boost.temp = 90; + therm->bios_sensor.thrs_fan_boost.hysteresis = 3; - priv->bios_sensor.thrs_down_clock.temp = 95; - priv->bios_sensor.thrs_down_clock.hysteresis = 3; + therm->bios_sensor.thrs_down_clock.temp = 95; + therm->bios_sensor.thrs_down_clock.hysteresis = 3; - priv->bios_sensor.thrs_critical.temp = 105; - priv->bios_sensor.thrs_critical.hysteresis = 5; + therm->bios_sensor.thrs_critical.temp = 105; + therm->bios_sensor.thrs_critical.hysteresis = 5; - priv->bios_sensor.thrs_shutdown.temp = 135; - priv->bios_sensor.thrs_shutdown.hysteresis = 5; /*not that it matters */ + therm->bios_sensor.thrs_shutdown.temp = 135; + therm->bios_sensor.thrs_shutdown.hysteresis = 5; /*not that it matters */ } static void -nvkm_therm_temp_safety_checks(struct nvkm_therm *therm) +nvkm_therm_temp_safety_checks(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *s = &priv->bios_sensor; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_sensor *s = &therm->bios_sensor; /* enforce a minimum hysteresis on thresholds */ s->thrs_fan_boost.hysteresis = max_t(u8, s->thrs_fan_boost.hysteresis, 2); @@ -59,21 +59,21 @@ nvkm_therm_temp_safety_checks(struct nvkm_therm *therm) /* must be called with alarm_program_lock taken ! */ void -nvkm_therm_sensor_set_threshold_state(struct nvkm_therm *therm, +nvkm_therm_sensor_set_threshold_state(struct nvkm_therm *obj, enum nvkm_therm_thrs thrs, enum nvkm_therm_thrs_state st) { - struct nvkm_therm_priv *priv = (void *)therm; - priv->sensor.alarm_state[thrs] = st; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + therm->sensor.alarm_state[thrs] = st; } /* must be called with alarm_program_lock taken ! */ enum nvkm_therm_thrs_state -nvkm_therm_sensor_get_threshold_state(struct nvkm_therm *therm, +nvkm_therm_sensor_get_threshold_state(struct nvkm_therm *obj, enum nvkm_therm_thrs thrs) { - struct nvkm_therm_priv *priv = (void *)therm; - return priv->sensor.alarm_state[thrs]; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + return therm->sensor.alarm_state[thrs]; } static void @@ -84,15 +84,15 @@ nv_poweroff_work(struct work_struct *work) } void -nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs, +nvkm_therm_sensor_event(struct nvkm_therm *obj, enum nvkm_therm_thrs thrs, enum nvkm_therm_thrs_direction dir) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); bool active; const char *thresolds[] = { "fanboost", "downclock", "critical", "shutdown" }; - int temperature = therm->temp_get(therm); + int temperature = therm->base.temp_get(&therm->base); if (thrs < 0 || thrs > 3) return; @@ -108,17 +108,17 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs, switch (thrs) { case NVKM_THERM_THRS_FANBOOST: if (active) { - nvkm_therm_fan_set(therm, true, 100); - nvkm_therm_fan_mode(therm, NVKM_THERM_CTRL_AUTO); + nvkm_therm_fan_set(&therm->base, true, 100); + nvkm_therm_fan_mode(&therm->base, NVKM_THERM_CTRL_AUTO); } break; case NVKM_THERM_THRS_DOWNCLOCK: - if (priv->emergency.downclock) - priv->emergency.downclock(therm, active); + if (therm->emergency.downclock) + therm->emergency.downclock(&therm->base, active); break; case NVKM_THERM_THRS_CRITICAL: - if (priv->emergency.pause) - priv->emergency.pause(therm, active); + if (therm->emergency.pause) + therm->emergency.pause(&therm->base, active); break; case NVKM_THERM_THRS_SHUTDOWN: if (active) { @@ -166,39 +166,39 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, static void alarm_timer_callback(struct nvkm_alarm *alarm) { - struct nvkm_therm_priv *priv = + struct nvkm_therm_priv *therm = container_of(alarm, struct nvkm_therm_priv, sensor.therm_poll_alarm); - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; - struct nvkm_timer *ptimer = nvkm_timer(priv); - struct nvkm_therm *therm = &priv->base; + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; + struct nvkm_timer *ptimer = nvkm_timer(therm); unsigned long flags; - spin_lock_irqsave(&priv->sensor.alarm_program_lock, flags); + spin_lock_irqsave(&therm->sensor.alarm_program_lock, flags); - nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_fan_boost, + nvkm_therm_threshold_hyst_polling(&therm->base, &sensor->thrs_fan_boost, NVKM_THERM_THRS_FANBOOST); - nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_down_clock, + nvkm_therm_threshold_hyst_polling(&therm->base, + &sensor->thrs_down_clock, NVKM_THERM_THRS_DOWNCLOCK); - nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_critical, + nvkm_therm_threshold_hyst_polling(&therm->base, &sensor->thrs_critical, NVKM_THERM_THRS_CRITICAL); - nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_shutdown, + nvkm_therm_threshold_hyst_polling(&therm->base, &sensor->thrs_shutdown, NVKM_THERM_THRS_SHUTDOWN); - spin_unlock_irqrestore(&priv->sensor.alarm_program_lock, flags); + spin_unlock_irqrestore(&therm->sensor.alarm_program_lock, flags); /* schedule the next poll in one second */ - if (therm->temp_get(therm) >= 0 && list_empty(&alarm->head)) + if (therm->base.temp_get(&therm->base) >= 0 && list_empty(&alarm->head)) ptimer->alarm(ptimer, 1000000000ULL, alarm); } void -nvkm_therm_program_alarms_polling(struct nvkm_therm *therm) +nvkm_therm_program_alarms_polling(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - struct nvbios_therm_sensor *sensor = &priv->bios_sensor; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + struct nvbios_therm_sensor *sensor = &therm->bios_sensor; nv_debug(therm, "programmed thresholds [ %d(%d), %d(%d), %d(%d), %d(%d) ]\n", @@ -208,25 +208,25 @@ nvkm_therm_program_alarms_polling(struct nvkm_therm *therm) sensor->thrs_critical.temp, sensor->thrs_critical.hysteresis, sensor->thrs_shutdown.temp, sensor->thrs_shutdown.hysteresis); - alarm_timer_callback(&priv->sensor.therm_poll_alarm); + alarm_timer_callback(&therm->sensor.therm_poll_alarm); } int -nvkm_therm_sensor_init(struct nvkm_therm *therm) +nvkm_therm_sensor_init(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; - priv->sensor.program_alarms(therm); + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); + therm->sensor.program_alarms(&therm->base); return 0; } int -nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend) +nvkm_therm_sensor_fini(struct nvkm_therm *obj, bool suspend) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_timer *ptimer = nvkm_timer(therm); if (suspend) - ptimer->alarm_cancel(ptimer, &priv->sensor.therm_poll_alarm); + ptimer->alarm_cancel(ptimer, &therm->sensor.therm_poll_alarm); return 0; } @@ -242,18 +242,18 @@ nvkm_therm_sensor_preinit(struct nvkm_therm *therm) } int -nvkm_therm_sensor_ctor(struct nvkm_therm *therm) +nvkm_therm_sensor_ctor(struct nvkm_therm *obj) { - struct nvkm_therm_priv *priv = (void *)therm; + struct nvkm_therm_priv *therm = container_of(obj, typeof(*therm), base); struct nvkm_bios *bios = nvkm_bios(therm); - nvkm_alarm_init(&priv->sensor.therm_poll_alarm, alarm_timer_callback); + nvkm_alarm_init(&therm->sensor.therm_poll_alarm, alarm_timer_callback); - nvkm_therm_temp_set_defaults(therm); + nvkm_therm_temp_set_defaults(&therm->base); if (nvbios_therm_sensor_parse(bios, NVBIOS_THERM_DOMAIN_CORE, - &priv->bios_sensor)) + &therm->bios_sensor)) nv_error(therm, "nvbios_therm_sensor_parse failed\n"); - nvkm_therm_temp_safety_checks(therm); + nvkm_therm_temp_safety_checks(&therm->base); return 0; } |