Commit 5f066c32 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/therm: fix various style issues, make more consistent

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarMartin Peres <martin.peres@labri.fr>
parent bc79202f
......@@ -107,10 +107,10 @@ nouveau-y += core/subdev/mxm/nv50.o
nouveau-y += core/subdev/therm/base.o
nouveau-y += core/subdev/therm/fan.o
nouveau-y += core/subdev/therm/ic.o
nouveau-y += core/subdev/therm/temp.o
nouveau-y += core/subdev/therm/nv40.o
nouveau-y += core/subdev/therm/nv50.o
nouveau-y += core/subdev/therm/nvd0.o
nouveau-y += core/subdev/therm/temp.o
nouveau-y += core/subdev/timer/base.o
nouveau-y += core/subdev/timer/nv04.o
nouveau-y += core/subdev/vm/base.o
......
......@@ -46,11 +46,24 @@ nouveau_therm(void *obj)
}
#define nouveau_therm_create(p,e,o,d) \
nouveau_subdev_create((p), (e), (o), 0, "THERM", "therm", d)
nouveau_therm_create_((p), (e), (o), sizeof(**d), (void **)d)
#define nouveau_therm_destroy(p) \
nouveau_subdev_destroy(&(p)->base)
#define nouveau_therm_init(p) ({ \
struct nouveau_therm *therm = (p); \
_nouveau_therm_init(nv_object(therm)); \
})
#define nouveau_therm_fini(p,s) ({ \
struct nouveau_therm *therm = (p); \
_nouveau_therm_init(nv_object(therm), (s)); \
})
int nouveau_therm_create_(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, int, void **);
#define _nouveau_therm_dtor _nouveau_subdev_dtor
int _nouveau_therm_init(struct nouveau_object *);
int _nouveau_therm_fini(struct nouveau_object *, bool);
extern struct nouveau_oclass nv40_therm_oclass;
extern struct nouveau_oclass nv50_therm_oclass;
......
......@@ -116,7 +116,7 @@ nouveau_therm_attr_set(struct nouveau_therm *therm,
}
int
nouveau_therm_init(struct nouveau_object *object)
_nouveau_therm_init(struct nouveau_object *object)
{
struct nouveau_therm *therm = (void *)object;
struct nouveau_therm_priv *priv = (void *)therm;
......@@ -133,7 +133,7 @@ nouveau_therm_init(struct nouveau_object *object)
}
int
nouveau_therm_fini(struct nouveau_object *object, bool suspend)
_nouveau_therm_fini(struct nouveau_object *object, bool suspend)
{
struct nouveau_therm *therm = (void *)object;
struct nouveau_therm_priv *priv = (void *)therm;
......@@ -142,3 +142,30 @@ nouveau_therm_fini(struct nouveau_object *object, bool suspend)
return nouveau_subdev_fini(&therm->base, suspend);
}
int
nouveau_therm_create_(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass,
int length, void **pobject)
{
struct nouveau_therm_priv *priv;
int ret;
ret = nouveau_subdev_create_(parent, engine, oclass, 0, "PTHERM",
"therm", length, pobject);
priv = *pobject;
if (ret)
return ret;
nouveau_therm_ic_ctor(&priv->base);
nouveau_therm_sensor_ctor(&priv->base);
nouveau_therm_fan_ctor(&priv->base);
priv->base.fan_get = nouveau_therm_fan_user_get;
priv->base.fan_set = nouveau_therm_fan_user_set;
priv->base.fan_sense = nouveau_therm_fan_sense;
priv->base.attr_get = nouveau_therm_attr_get;
priv->base.attr_set = nouveau_therm_attr_set;
return 0;
}
......@@ -25,6 +25,10 @@
#include "priv.h"
struct nv40_therm_priv {
struct nouveau_therm_priv base;
};
static int
nv40_sensor_setup(struct nouveau_therm *therm)
{
......@@ -120,34 +124,21 @@ nv40_fan_pwm_set(struct nouveau_therm *therm, int line, u32 divs, u32 duty)
static int
nv40_therm_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nouveau_therm_priv *priv;
struct nouveau_therm *therm;
struct nv40_therm_priv *priv;
int ret;
ret = nouveau_therm_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
therm = (void *) priv;
if (ret)
return ret;
nouveau_therm_ic_ctor(therm);
nouveau_therm_sensor_ctor(therm);
nouveau_therm_fan_ctor(therm);
priv->fan.pwm_get = nv40_fan_pwm_get;
priv->fan.pwm_set = nv40_fan_pwm_set;
therm->temp_get = nv40_temp_get;
therm->fan_get = nouveau_therm_fan_user_get;
therm->fan_set = nouveau_therm_fan_user_set;
therm->fan_sense = nouveau_therm_fan_sense;
therm->attr_get = nouveau_therm_attr_get;
therm->attr_set = nouveau_therm_attr_set;
priv->base.fan.pwm_get = nv40_fan_pwm_get;
priv->base.fan.pwm_set = nv40_fan_pwm_set;
priv->base.base.temp_get = nv40_temp_get;
return 0;
}
......@@ -157,7 +148,7 @@ nv40_therm_oclass = {
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv40_therm_ctor,
.dtor = _nouveau_therm_dtor,
.init = nouveau_therm_init,
.fini = nouveau_therm_fini,
.init = _nouveau_therm_init,
.fini = _nouveau_therm_fini,
},
};
\ No newline at end of file
};
......@@ -25,6 +25,10 @@
#include "priv.h"
struct nv50_therm_priv {
struct nouveau_therm_priv base;
};
static int
pwm_info(struct nouveau_therm *therm, int *line, int *ctrl, int *indx)
{
......@@ -113,35 +117,22 @@ nv50_temp_get(struct nouveau_therm *therm)
static int
nv50_therm_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nouveau_therm_priv *priv;
struct nouveau_therm *therm;
struct nv50_therm_priv *priv;
int ret;
ret = nouveau_therm_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
therm = (void *) priv;
if (ret)
return ret;
nouveau_therm_ic_ctor(therm);
nouveau_therm_sensor_ctor(therm);
nouveau_therm_fan_ctor(therm);
priv->fan.pwm_get = nv50_fan_pwm_get;
priv->fan.pwm_set = nv50_fan_pwm_set;
priv->fan.pwm_clock = nv50_fan_pwm_clock;
therm->temp_get = nv50_temp_get;
therm->fan_get = nouveau_therm_fan_user_get;
therm->fan_set = nouveau_therm_fan_user_set;
therm->fan_sense = nouveau_therm_fan_sense;
therm->attr_get = nouveau_therm_attr_get;
therm->attr_set = nouveau_therm_attr_set;
priv->base.fan.pwm_get = nv50_fan_pwm_get;
priv->base.fan.pwm_set = nv50_fan_pwm_set;
priv->base.fan.pwm_clock = nv50_fan_pwm_clock;
priv->base.base.temp_get = nv50_temp_get;
return 0;
}
......@@ -151,7 +142,7 @@ nv50_therm_oclass = {
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv50_therm_ctor,
.dtor = _nouveau_therm_dtor,
.init = nouveau_therm_init,
.fini = nouveau_therm_fini,
.init = _nouveau_therm_init,
.fini = _nouveau_therm_fini,
},
};
......@@ -24,6 +24,10 @@
#include "priv.h"
struct nvd0_therm_priv {
struct nouveau_therm_priv base;
};
static int
pwm_info(struct nouveau_therm *therm, int line)
{
......@@ -73,34 +77,22 @@ nvd0_fan_pwm_clock(struct nouveau_therm *therm)
static int
nvd0_therm_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nouveau_therm_priv *priv;
struct nouveau_therm *therm;
struct nvd0_therm_priv *priv;
int ret;
ret = nouveau_therm_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
therm = (void *) priv;
if (ret)
return ret;
nouveau_therm_ic_ctor(therm);
nouveau_therm_sensor_ctor(therm);
nouveau_therm_fan_ctor(therm);
priv->fan.pwm_get = nvd0_fan_pwm_get;
priv->fan.pwm_set = nvd0_fan_pwm_set;
priv->fan.pwm_clock = nvd0_fan_pwm_clock;
therm->temp_get = nv50_temp_get;
therm->fan_get = nouveau_therm_fan_user_get;
therm->fan_set = nouveau_therm_fan_user_set;
therm->fan_sense = nouveau_therm_fan_sense;
therm->attr_get = nouveau_therm_attr_get;
therm->attr_set = nouveau_therm_attr_set;
priv->base.fan.pwm_get = nvd0_fan_pwm_get;
priv->base.fan.pwm_set = nvd0_fan_pwm_set;
priv->base.fan.pwm_clock = nvd0_fan_pwm_clock;
priv->base.base.temp_get = nv50_temp_get;
return 0;
}
......@@ -110,7 +102,7 @@ nvd0_therm_oclass = {
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nvd0_therm_ctor,
.dtor = _nouveau_therm_dtor,
.init = nouveau_therm_init,
.fini = nouveau_therm_fini,
.init = _nouveau_therm_init,
.fini = _nouveau_therm_fini,
},
};
......@@ -53,8 +53,6 @@ struct nouveau_therm_priv {
struct i2c_client *ic;
};
int nouveau_therm_init(struct nouveau_object *object);
int nouveau_therm_fini(struct nouveau_object *object, bool suspend);
int nouveau_therm_attr_get(struct nouveau_therm *therm,
enum nouveau_therm_attr_type type);
int nouveau_therm_attr_set(struct nouveau_therm *therm,
......
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