drm/nouveau/fuse: remove object accessor functions
authorBen Skeggs <bskeggs@redhat.com>
Thu, 20 Aug 2015 04:54:13 +0000 (14:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:40:26 +0000 (12:40 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/fuse.h
drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gf100.c
drivers/gpu/drm/nouveau/nvkm/subdev/fuse/gm107.c
drivers/gpu/drm/nouveau/nvkm/subdev/fuse/nv50.c
drivers/gpu/drm/nouveau/nvkm/subdev/therm/g84.c

index ebfb6aa2a855901ed6cb7139f8b8aa388de663b6..570a35356ff589f770ffee4abfef1df7983af0f0 100644 (file)
@@ -5,6 +5,11 @@
 
 struct nvkm_fuse {
        struct nvkm_subdev subdev;
+       const struct nvkm_fuse_func *func;
+};
+
+struct nvkm_fuse_func {
+       u32 (*read)(struct nvkm_fuse *, u32 addr);
 };
 
 static inline struct nvkm_fuse *
index e9d432424071317700bad53c636f181833a267e9..4e94cb94430c6b225e4e8b8a4393057d44dbf04d 100644 (file)
@@ -30,9 +30,9 @@ struct gf100_fuse {
 };
 
 static u32
-gf100_fuse_rd32(struct nvkm_object *object, u64 addr)
+gf100_fuse_read(struct nvkm_fuse *obj, u32 addr)
 {
-       struct gf100_fuse *fuse = (void *)object;
+       struct gf100_fuse *fuse = container_of(obj, typeof(*fuse), base);
        struct nvkm_device *device = fuse->base.subdev.device;
        unsigned long flags;
        u32 fuse_enable, unk, val;
@@ -48,6 +48,10 @@ gf100_fuse_rd32(struct nvkm_object *object, u64 addr)
        return val;
 }
 
+static const struct nvkm_fuse_func
+gf100_fuse_func = {
+       .read = gf100_fuse_read,
+};
 
 static int
 gf100_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
@@ -63,6 +67,7 @@ gf100_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
                return ret;
 
        spin_lock_init(&fuse->fuse_enable_lock);
+       fuse->base.func = &gf100_fuse_func;
        return 0;
 }
 
@@ -74,6 +79,5 @@ gf100_fuse_oclass = {
                .dtor = _nvkm_fuse_dtor,
                .init = _nvkm_fuse_init,
                .fini = _nvkm_fuse_fini,
-               .rd32 = gf100_fuse_rd32,
        },
 };
index 94594ac9990b70bd488302903b8147adc1cf61af..bb1101e121488f01b207ccc531aafaa8dbe22167 100644 (file)
 #include "priv.h"
 
 static u32
-gm107_fuse_rd32(struct nvkm_object *object, u64 addr)
+gm107_fuse_read(struct nvkm_fuse *fuse, u32 addr)
 {
-       struct nvkm_fuse *fuse = (void *)object;
        struct nvkm_device *device = fuse->subdev.device;
        return nvkm_rd32(device, 0x21100 + addr);
 }
 
+static const struct nvkm_fuse_func
+gm107_fuse_func = {
+       .read = gm107_fuse_read,
+};
 
 static int
 gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
@@ -43,6 +46,7 @@ gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
        ret = nvkm_fuse_create(parent, engine, oclass, &fuse);
        *pobject = nv_object(fuse);
 
+       fuse->func = &gm107_fuse_func;
        return ret;
 }
 
@@ -54,6 +58,5 @@ gm107_fuse_oclass = {
                .dtor = _nvkm_fuse_dtor,
                .init = _nvkm_fuse_init,
                .fini = _nvkm_fuse_fini,
-               .rd32 = gm107_fuse_rd32,
        },
 };
index c47abfa98809ea6f525a1057ed9486ca8dce8086..ee76268ae702668cebf31291f2441ba32272b74e 100644 (file)
@@ -30,9 +30,9 @@ struct nv50_fuse {
 };
 
 static u32
-nv50_fuse_rd32(struct nvkm_object *object, u64 addr)
+nv50_fuse_read(struct nvkm_fuse *obj, u32 addr)
 {
-       struct nv50_fuse *fuse = (void *)object;
+       struct nv50_fuse *fuse = container_of(obj, typeof(*fuse), base);
        struct nvkm_device *device = fuse->base.subdev.device;
        unsigned long flags;
        u32 fuse_enable, val;
@@ -46,6 +46,10 @@ nv50_fuse_rd32(struct nvkm_object *object, u64 addr)
        return val;
 }
 
+static const struct nvkm_fuse_func
+nv50_fuse_func = {
+       .read = &nv50_fuse_read,
+};
 
 static int
 nv50_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
@@ -61,6 +65,7 @@ nv50_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
                return ret;
 
        spin_lock_init(&fuse->fuse_enable_lock);
+       fuse->base.func = &nv50_fuse_func;
        return 0;
 }
 
@@ -72,6 +77,5 @@ nv50_fuse_oclass = {
                .dtor = _nvkm_fuse_dtor,
                .init = _nvkm_fuse_init,
                .fini = _nvkm_fuse_fini,
-               .rd32 = nv50_fuse_rd32,
        },
 };
index a1da856d5103e46610c53116d11344c23d7b3007..aea79d7201bdaebda6964b8baf0ba37ebbfdfbdf 100644 (file)
@@ -32,7 +32,7 @@ g84_temp_get(struct nvkm_therm *therm)
        struct nvkm_device *device = therm->subdev.device;
        struct nvkm_fuse *fuse = nvkm_fuse(therm);
 
-       if (nv_ro32(fuse, 0x1a8) == 1)
+       if (fuse->func->read(fuse, 0x1a8) == 1)
                return nvkm_rd32(device, 0x20400);
        else
                return -ENODEV;
@@ -45,7 +45,7 @@ g84_sensor_setup(struct nvkm_therm *therm)
        struct nvkm_fuse *fuse = nvkm_fuse(therm);
 
        /* enable temperature reading for cards with insane defaults */
-       if (nv_ro32(fuse, 0x1a8) == 1) {
+       if (fuse->func->read(fuse, 0x1a8) == 1) {
                nvkm_mask(device, 0x20008, 0x80008000, 0x80000000);
                nvkm_mask(device, 0x2000c, 0x80000003, 0x00000000);
                mdelay(20); /* wait for the temperature to stabilize */