]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/nouveau/therm: fix various style issues, make more consistent
authorBen Skeggs <bskeggs@redhat.com>
Tue, 4 Dec 2012 01:35:40 +0000 (11:35 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 20 Feb 2013 06:00:16 +0000 (16:00 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Martin Peres <martin.peres@labri.fr>
drivers/gpu/drm/nouveau/Makefile
drivers/gpu/drm/nouveau/core/include/subdev/therm.h
drivers/gpu/drm/nouveau/core/subdev/therm/base.c
drivers/gpu/drm/nouveau/core/subdev/therm/nv40.c
drivers/gpu/drm/nouveau/core/subdev/therm/nv50.c
drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
drivers/gpu/drm/nouveau/core/subdev/therm/priv.h

index 4fc39ecb93dbd158f489cd134741a73fdf8cb778..26e0d56e45d9445a960c1f9de34f405c394b9358 100644 (file)
@@ -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
index 6cf9f931cc97a89bc57b0d3affec6a8d7bd6c7d3..2a48bff51837bfff80949eb2b29783c090fbb504 100644 (file)
@@ -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;
index 1674c74a76c8815789ec85b7dd340f7219e55975..6260eacb92bd6c92d6b2a7cf2e5d59930a5bb65a 100644 (file)
@@ -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;
+}
index fcf2cfe731d668cf64ec5a65ef63d50bdab877a7..f2092af62ce3bf8ff4736a4a68beea6e7449f7d0 100644 (file)
 
 #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
+};
index 9360ddd469e727cae0f053dd1a0cd7e96c894283..b7e1ecf93409929bbdb17a0e3ee80318efb04aa8 100644 (file)
 
 #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,
        },
 };
index a87338cecd45c2511043b655d6af36b2092ecf39..b001cd39b5a75a1bfa8b5a9af2cb28f2555ea1fe 100644 (file)
 
 #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,
        },
 };
index ac26ef5a354cce0cbae706a333d1216109bb04d8..64f4a4ab80eabd9dc46b63e435ab68f122b3de2d 100644 (file)
@@ -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,