rivafb/nvidiafb: Various cleanups
authorJean Delvare <khali@linux-fr.org>
Tue, 8 May 2007 07:38:20 +0000 (00:38 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:28 +0000 (11:15 -0700)
Various cleanups to rivafb/nvidiafb's I2C code:
* Drop useless par->bus.
* Refactor I2C bus deletion code.
* Drop useless variable initialization.
* Remove unneeded include of <linux/i2c-id.h>.
* Simplify +1/-1.
* Add __devinit tags where possible.

[adaplas]
The varible initialization are not useless. However, rivafb must
check if i2c bus are created properly before reading the EDID
block.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/nvidia/nv_i2c.c
drivers/video/nvidia/nv_type.h
drivers/video/riva/fbdev.c
drivers/video/riva/rivafb-i2c.c
drivers/video/riva/rivafb.h

index badc1a6c43578a22ebf08c28950b36544304509f..4fc7118397fec90aeb13f94ba8abdbc84d0956e1 100644 (file)
@@ -127,8 +127,6 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name,
 
 void nvidia_create_i2c_busses(struct nvidia_par *par)
 {
-       par->bus = 3;
-
        par->chan[0].par = par;
        par->chan[1].par = par;
        par->chan[2].par = par;
@@ -145,18 +143,14 @@ void nvidia_create_i2c_busses(struct nvidia_par *par)
 
 void nvidia_delete_i2c_busses(struct nvidia_par *par)
 {
-       if (par->chan[0].par)
-               i2c_del_adapter(&par->chan[0].adapter);
-       par->chan[0].par = NULL;
-
-       if (par->chan[1].par)
-               i2c_del_adapter(&par->chan[1].adapter);
-       par->chan[1].par = NULL;
-
-       if (par->chan[2].par)
-               i2c_del_adapter(&par->chan[2].adapter);
-       par->chan[2].par = NULL;
+       int i;
 
+       for (i = 0; i < 3; i++) {
+               if (!par->chan[i].par)
+                       continue;
+               i2c_del_adapter(&par->chan[i].adapter);
+               par->chan[i].par = NULL;
+       }
 }
 
 int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
index 86e65dea60d3a9b2aebf2136d7a2a93526a0b6f5..ee430af89a0dc9ac498727a28eb01fd4796fddf6 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/fb.h>
 #include <linux/types.h>
 #include <linux/i2c.h>
-#include <linux/i2c-id.h>
 #include <linux/i2c-algo-bit.h>
 
 #define NV_ARCH_04  0x04
@@ -100,7 +99,6 @@ struct nvidia_par {
        u32 Architecture;
        u32 CursorStart;
        int Chipset;
-       int bus;
        unsigned long FbAddress;
        u8 __iomem *FbStart;
        u32 FbMapSize;
index b8d50f178ad5a3f12aa0c9ccbec1d7fc78009c0d..9e6ee1ffd9f321d2c83d09ef61500b56e20837a6 100644 (file)
@@ -1788,10 +1788,10 @@ static int __devinit riva_get_EDID_i2c(struct fb_info *info)
 
        NVTRACE_ENTER();
        riva_create_i2c_busses(par);
-       for (i = 0; i < par->bus; i++) {
+       for (i = 0; i < 3; i++) {
                if (!par->chan[i].par)
                        continue;
-               riva_probe_i2c_connector(par, i+1, &par->EDID);
+               riva_probe_i2c_connector(par, i, &par->EDID);
                if (par->EDID && !fb_parse_edid(par->EDID, &var)) {
                        printk(PFX "Found EDID Block from BUS %i\n", i);
                        break;
index ca9e7e81a9c5b9afc9be20acdc52d1e157ddfcad..bcb209670a182de4f448364ef1935df7e40a33cd 100644 (file)
@@ -88,8 +88,9 @@ static int riva_gpio_getsda(void* data)
        return val;
 }
 
-static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name,
-                             unsigned int i2c_class)
+static int __devinit riva_setup_i2c_bus(struct riva_i2c_chan *chan,
+                                       const char *name,
+                                       unsigned int i2c_class)
 {
        int rc;
 
@@ -126,10 +127,8 @@ static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name,
        return rc;
 }
 
-void riva_create_i2c_busses(struct riva_par *par)
+void __devinit riva_create_i2c_busses(struct riva_par *par)
 {
-       par->bus = 3;
-
        par->chan[0].par        = par;
        par->chan[1].par        = par;
        par->chan[2].par        = par;
@@ -144,24 +143,22 @@ void riva_create_i2c_busses(struct riva_par *par)
 
 void riva_delete_i2c_busses(struct riva_par *par)
 {
-       if (par->chan[0].par)
-               i2c_del_adapter(&par->chan[0].adapter);
-       par->chan[0].par = NULL;
-
-       if (par->chan[1].par)
-               i2c_del_adapter(&par->chan[1].adapter);
-       par->chan[1].par = NULL;
+       int i;
 
-       if (par->chan[2].par)
-               i2c_del_adapter(&par->chan[2].adapter);
-       par->chan[2].par = NULL;
+       for (i = 0; i < 3; i++) {
+               if (!par->chan[i].par)
+                       continue;
+               i2c_del_adapter(&par->chan[i].adapter);
+               par->chan[i].par = NULL;
+       }
 }
 
-int riva_probe_i2c_connector(struct riva_par *par, int conn, u8 **out_edid)
+int __devinit riva_probe_i2c_connector(struct riva_par *par, int conn, u8 **out_edid)
 {
        u8 *edid = NULL;
 
-       edid = fb_ddc_read(&par->chan[conn-1].adapter);
+       if (par->chan[conn].par)
+               edid = fb_ddc_read(&par->chan[conn].adapter);
 
        if (out_edid)
                *out_edid = edid;
index 48ead6d72f24e9906e2dd33937357cce9687aa89..d9f107b704c6296feb52ee2ea83aa2aa11a1b9a4 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/fb.h>
 #include <video/vga.h>
 #include <linux/i2c.h>
-#include <linux/i2c-id.h>
 #include <linux/i2c-algo-bit.h>
 
 #include "riva_hw.h"
@@ -61,7 +60,6 @@ struct riva_par {
        Bool SecondCRTC;
        int FlatPanel;
        struct pci_dev *pdev;
-       int bus;
        int cursor_reset;
 #ifdef CONFIG_MTRR
        struct { int vram; int vram_valid; } mtrr;