]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/matrox/matroxfb_maven.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6-omap-h63xx.git] / drivers / video / matrox / matroxfb_maven.c
index 6019710dc298513c819c1fc419a24a29d5427118..49cd53e46c0acacee1e588ed77e192ad841139a3 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/i2c.h>
 #include <linux/matroxfb.h>
 #include <asm/div64.h>
-#include <asm/uaccess.h>
 
 #define MAVEN_I2CID    (0x1B)
 
@@ -89,12 +88,12 @@ static const struct mctl maven_controls[] =
        }, offsetof(struct matrox_fb_info, altout.tvo_params.hue) },
        { { V4L2_CID_GAMMA, V4L2_CTRL_TYPE_INTEGER,
          "gamma",
-         0, sizeof(maven_gamma)/sizeof(maven_gamma[0])-1, 1, 3,
+         0, ARRAY_SIZE(maven_gamma) - 1, 1, 3,
          0,
        }, offsetof(struct matrox_fb_info, altout.tvo_params.gamma) },
        { { MATROXFB_CID_TESTOUT, V4L2_CTRL_TYPE_BOOLEAN,
          "test output",
-         0, 1, 1, 0, 
+         0, 1, 1, 0,
          0,
        }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) },
        { { MATROXFB_CID_DEFLICKER, V4L2_CTRL_TYPE_INTEGER,
@@ -105,7 +104,7 @@ static const struct mctl maven_controls[] =
 
 };
 
-#define MAVCTRLS (sizeof(maven_controls)/sizeof(maven_controls[0]))
+#define MAVCTRLS ARRAY_SIZE(maven_controls)
 
 /* Return: positive number: id found
            -EINVAL:         id not found, return failure
@@ -129,7 +128,7 @@ static int get_ctrl_id(__u32 v4l2_id) {
 
 struct maven_data {
        struct matrox_fb_info*          primary_head;
-       struct i2c_client*              client;
+       struct i2c_client               client;
        int                             version;
 };
 
@@ -273,8 +272,11 @@ static int matroxfb_PLL_mavenclock(const struct matrox_pll_features2* pll,
                        }
                }
        }
+
+       /* if h2/post/in/feed have not been assigned, return zero (error) */
        if (besth2 < 2)
                return 0;
+
        dprintk(KERN_ERR "clk: %02X %02X %02X %d %d\n", *in, *feed, *post, fxtal, fwant);
        return fxtal * (*feed) / (*in) * ctl->den;
 }
@@ -284,7 +286,7 @@ static unsigned int matroxfb_mavenclock(const struct matrox_pll_ctl* ctl,
                unsigned int* in, unsigned int* feed, unsigned int* post,
                unsigned int* htotal2) {
        unsigned int fvco;
-       unsigned int p;
+       unsigned int uninitialized_var(p);
 
        fvco = matroxfb_PLL_mavenclock(&maven1000_pll, ctl, htotal, vtotal, in, feed, &p, htotal2);
        if (!fvco)
@@ -715,7 +717,9 @@ static int maven_find_exact_clocks(unsigned int ht, unsigned int vt,
        m->regs[0x82] = 0x81;
 
        for (x = 0; x < 8; x++) {
-               unsigned int a, b, c, h2;
+               unsigned int c;
+               unsigned int uninitialized_var(a), uninitialized_var(b),
+                            uninitialized_var(h2);
                unsigned int h = ht + 2 + x;
 
                if (!matroxfb_mavenclock((m->mode == MATROXFB_OUTPUT_MODE_PAL) ? &maven_PAL : &maven_NTSC, h, vt, &a, &b, &c, &h2)) {
@@ -970,7 +974,7 @@ static inline int maven_compute_timming(struct maven_data* md,
 
 static int maven_program_timming(struct maven_data* md,
                const struct mavenregs* m) {
-       struct i2c_client* c = md->client;
+       struct i2c_client* c = &md->client;
 
        if (m->mode == MATROXFB_OUTPUT_MODE_MONITOR) {
                LR(0x80);
@@ -1007,7 +1011,7 @@ static int maven_program_timming(struct maven_data* md,
 }
 
 static inline int maven_resync(struct maven_data* md) {
-       struct i2c_client* c = md->client;
+       struct i2c_client* c = &md->client;
        maven_set_reg(c, 0x95, 0x20);   /* start whole thing */
        return 0;
 }
@@ -1065,48 +1069,48 @@ static int maven_set_control (struct maven_data* md,
                  maven_compute_bwlevel(md, &blacklevel, &whitelevel);
                  blacklevel = (blacklevel >> 2) | ((blacklevel & 3) << 8);
                  whitelevel = (whitelevel >> 2) | ((whitelevel & 3) << 8);
-                 maven_set_reg_pair(md->client, 0x0e, blacklevel);
-                 maven_set_reg_pair(md->client, 0x1e, whitelevel);
+                 maven_set_reg_pair(&md->client, 0x0e, blacklevel);
+                 maven_set_reg_pair(&md->client, 0x1e, whitelevel);
                }
                break;
                case V4L2_CID_SATURATION:
                {
-                 maven_set_reg(md->client, 0x20, p->value);
-                 maven_set_reg(md->client, 0x22, p->value);
+                 maven_set_reg(&md->client, 0x20, p->value);
+                 maven_set_reg(&md->client, 0x22, p->value);
                }
                break;
                case V4L2_CID_HUE:
                {
-                 maven_set_reg(md->client, 0x25, p->value);
+                 maven_set_reg(&md->client, 0x25, p->value);
                }
                break;
                case V4L2_CID_GAMMA:
                {
                  const struct maven_gamma* g;
                  g = maven_compute_gamma(md);
-                 maven_set_reg(md->client, 0x83, g->reg83);
-                 maven_set_reg(md->client, 0x84, g->reg84);
-                 maven_set_reg(md->client, 0x85, g->reg85);
-                 maven_set_reg(md->client, 0x86, g->reg86);
-                 maven_set_reg(md->client, 0x87, g->reg87);
-                 maven_set_reg(md->client, 0x88, g->reg88);
-                 maven_set_reg(md->client, 0x89, g->reg89);
-                 maven_set_reg(md->client, 0x8a, g->reg8a);
-                 maven_set_reg(md->client, 0x8b, g->reg8b);
+                 maven_set_reg(&md->client, 0x83, g->reg83);
+                 maven_set_reg(&md->client, 0x84, g->reg84);
+                 maven_set_reg(&md->client, 0x85, g->reg85);
+                 maven_set_reg(&md->client, 0x86, g->reg86);
+                 maven_set_reg(&md->client, 0x87, g->reg87);
+                 maven_set_reg(&md->client, 0x88, g->reg88);
+                 maven_set_reg(&md->client, 0x89, g->reg89);
+                 maven_set_reg(&md->client, 0x8a, g->reg8a);
+                 maven_set_reg(&md->client, 0x8b, g->reg8b);
                }
                break;
                case MATROXFB_CID_TESTOUT:
                {
                        unsigned char val 
-                         = maven_get_reg (md->client,0x8d);
+                         = maven_get_reg(&md->client,0x8d);
                        if (p->value) val |= 0x10;
                        else          val &= ~0x10;
-                       maven_set_reg (md->client, 0x8d, val);
+                       maven_set_reg(&md->client, 0x8d, val);
                }
                break;
                case MATROXFB_CID_DEFLICKER:
                {
-                 maven_set_reg(md->client, 0x93, maven_compute_deflicker(md));
+                 maven_set_reg(&md->client, 0x93, maven_compute_deflicker(md));
                }
                break;
        }
@@ -1185,7 +1189,6 @@ static int maven_init_client(struct i2c_client* clnt) {
        MINFO_FROM(container_of(clnt->adapter, struct i2c_bit_adapter, adapter)->minfo);
 
        md->primary_head = MINFO;
-       md->client = clnt;
        down_write(&ACCESS_FBINFO(altout.lock));
        ACCESS_FBINFO(outputs[1]).output = &maven_altout;
        ACCESS_FBINFO(outputs[1]).src = ACCESS_FBINFO(outputs[1]).default_src;
@@ -1243,19 +1246,17 @@ static int maven_detect_client(struct i2c_adapter* adapter, int address, int kin
                                              I2C_FUNC_SMBUS_BYTE_DATA |
                                              I2C_FUNC_PROTOCOL_MANGLING))
                goto ERROR0;
-       if (!(new_client = (struct i2c_client*)kmalloc(sizeof(*new_client) + sizeof(*data),
-                       GFP_KERNEL))) {
+       if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {
                err = -ENOMEM;
                goto ERROR0;
        }
-       memset(new_client, 0, sizeof(*new_client) + sizeof(*data));
-       data = (struct maven_data*)(new_client + 1);
+       new_client = &data->client;
        i2c_set_clientdata(new_client, data);
        new_client->addr = address;
        new_client->adapter = adapter;
        new_client->driver = &maven_driver;
        new_client->flags = 0;
-       strcpy(new_client->name, "maven client");
+       strlcpy(new_client->name, "maven", I2C_NAME_SIZE);
        if ((err = i2c_attach_client(new_client)))
                goto ERROR3;
        err = maven_init_client(new_client);
@@ -1279,12 +1280,10 @@ static int maven_attach_adapter(struct i2c_adapter* adapter) {
 static int maven_detach_client(struct i2c_client* client) {
        int err;
 
-       if ((err = i2c_detach_client(client))) {
-               printk(KERN_ERR "maven: Cannot deregister client\n");
+       if ((err = i2c_detach_client(client)))
                return err;
-       }
        maven_shutdown_client(client);
-       kfree(client);
+       kfree(i2c_get_clientdata(client));
        return 0;
 }
 
@@ -1297,20 +1296,13 @@ static struct i2c_driver maven_driver={
        .detach_client  = maven_detach_client,
 };
 
-/* ************************** */
-
-static int matroxfb_maven_init(void) {
-       int err;
-
-       err = i2c_add_driver(&maven_driver);
-       if (err) {
-               printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err);
-               return err;
-       }
-       return 0;
+static int __init matroxfb_maven_init(void)
+{
+       return i2c_add_driver(&maven_driver);
 }
 
-static void matroxfb_maven_exit(void) {
+static void __exit matroxfb_maven_exit(void)
+{
        i2c_del_driver(&maven_driver);
 }