aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-05-08 03:38:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:28 -0400
commita65ff76ac8b24df49bbf4acc38918fb52d1033b0 (patch)
tree4bd323a77da9e709267d1712e4424a2db155aab9
parent5b358fe12f03a7822db6f376b608f996c664a952 (diff)
rivafb/nvidiafb: Various cleanups
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>
-rw-r--r--drivers/video/nvidia/nv_i2c.c20
-rw-r--r--drivers/video/nvidia/nv_type.h2
-rw-r--r--drivers/video/riva/fbdev.c4
-rw-r--r--drivers/video/riva/rivafb-i2c.c31
-rw-r--r--drivers/video/riva/rivafb.h2
5 files changed, 23 insertions, 36 deletions
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index badc1a6c4357..4fc7118397fe 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -127,8 +127,6 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name,
127 127
128void nvidia_create_i2c_busses(struct nvidia_par *par) 128void nvidia_create_i2c_busses(struct nvidia_par *par)
129{ 129{
130 par->bus = 3;
131
132 par->chan[0].par = par; 130 par->chan[0].par = par;
133 par->chan[1].par = par; 131 par->chan[1].par = par;
134 par->chan[2].par = par; 132 par->chan[2].par = par;
@@ -145,18 +143,14 @@ void nvidia_create_i2c_busses(struct nvidia_par *par)
145 143
146void nvidia_delete_i2c_busses(struct nvidia_par *par) 144void nvidia_delete_i2c_busses(struct nvidia_par *par)
147{ 145{
148 if (par->chan[0].par) 146 int i;
149 i2c_del_adapter(&par->chan[0].adapter);
150 par->chan[0].par = NULL;
151
152 if (par->chan[1].par)
153 i2c_del_adapter(&par->chan[1].adapter);
154 par->chan[1].par = NULL;
155
156 if (par->chan[2].par)
157 i2c_del_adapter(&par->chan[2].adapter);
158 par->chan[2].par = NULL;
159 147
148 for (i = 0; i < 3; i++) {
149 if (!par->chan[i].par)
150 continue;
151 i2c_del_adapter(&par->chan[i].adapter);
152 par->chan[i].par = NULL;
153 }
160} 154}
161 155
162int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) 156int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
diff --git a/drivers/video/nvidia/nv_type.h b/drivers/video/nvidia/nv_type.h
index 86e65dea60d3..ee430af89a0d 100644
--- a/drivers/video/nvidia/nv_type.h
+++ b/drivers/video/nvidia/nv_type.h
@@ -4,7 +4,6 @@
4#include <linux/fb.h> 4#include <linux/fb.h>
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/i2c.h> 6#include <linux/i2c.h>
7#include <linux/i2c-id.h>
8#include <linux/i2c-algo-bit.h> 7#include <linux/i2c-algo-bit.h>
9 8
10#define NV_ARCH_04 0x04 9#define NV_ARCH_04 0x04
@@ -100,7 +99,6 @@ struct nvidia_par {
100 u32 Architecture; 99 u32 Architecture;
101 u32 CursorStart; 100 u32 CursorStart;
102 int Chipset; 101 int Chipset;
103 int bus;
104 unsigned long FbAddress; 102 unsigned long FbAddress;
105 u8 __iomem *FbStart; 103 u8 __iomem *FbStart;
106 u32 FbMapSize; 104 u32 FbMapSize;
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index b8d50f178ad5..9e6ee1ffd9f3 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -1788,10 +1788,10 @@ static int __devinit riva_get_EDID_i2c(struct fb_info *info)
1788 1788
1789 NVTRACE_ENTER(); 1789 NVTRACE_ENTER();
1790 riva_create_i2c_busses(par); 1790 riva_create_i2c_busses(par);
1791 for (i = 0; i < par->bus; i++) { 1791 for (i = 0; i < 3; i++) {
1792 if (!par->chan[i].par) 1792 if (!par->chan[i].par)
1793 continue; 1793 continue;
1794 riva_probe_i2c_connector(par, i+1, &par->EDID); 1794 riva_probe_i2c_connector(par, i, &par->EDID);
1795 if (par->EDID && !fb_parse_edid(par->EDID, &var)) { 1795 if (par->EDID && !fb_parse_edid(par->EDID, &var)) {
1796 printk(PFX "Found EDID Block from BUS %i\n", i); 1796 printk(PFX "Found EDID Block from BUS %i\n", i);
1797 break; 1797 break;
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c
index ca9e7e81a9c5..bcb209670a18 100644
--- a/drivers/video/riva/rivafb-i2c.c
+++ b/drivers/video/riva/rivafb-i2c.c
@@ -88,8 +88,9 @@ static int riva_gpio_getsda(void* data)
88 return val; 88 return val;
89} 89}
90 90
91static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name, 91static int __devinit riva_setup_i2c_bus(struct riva_i2c_chan *chan,
92 unsigned int i2c_class) 92 const char *name,
93 unsigned int i2c_class)
93{ 94{
94 int rc; 95 int rc;
95 96
@@ -126,10 +127,8 @@ static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name,
126 return rc; 127 return rc;
127} 128}
128 129
129void riva_create_i2c_busses(struct riva_par *par) 130void __devinit riva_create_i2c_busses(struct riva_par *par)
130{ 131{
131 par->bus = 3;
132
133 par->chan[0].par = par; 132 par->chan[0].par = par;
134 par->chan[1].par = par; 133 par->chan[1].par = par;
135 par->chan[2].par = par; 134 par->chan[2].par = par;
@@ -144,24 +143,22 @@ void riva_create_i2c_busses(struct riva_par *par)
144 143
145void riva_delete_i2c_busses(struct riva_par *par) 144void riva_delete_i2c_busses(struct riva_par *par)
146{ 145{
147 if (par->chan[0].par) 146 int i;
148 i2c_del_adapter(&par->chan[0].adapter);
149 par->chan[0].par = NULL;
150
151 if (par->chan[1].par)
152 i2c_del_adapter(&par->chan[1].adapter);
153 par->chan[1].par = NULL;
154 147
155 if (par->chan[2].par) 148 for (i = 0; i < 3; i++) {
156 i2c_del_adapter(&par->chan[2].adapter); 149 if (!par->chan[i].par)
157 par->chan[2].par = NULL; 150 continue;
151 i2c_del_adapter(&par->chan[i].adapter);
152 par->chan[i].par = NULL;
153 }
158} 154}
159 155
160int riva_probe_i2c_connector(struct riva_par *par, int conn, u8 **out_edid) 156int __devinit riva_probe_i2c_connector(struct riva_par *par, int conn, u8 **out_edid)
161{ 157{
162 u8 *edid = NULL; 158 u8 *edid = NULL;
163 159
164 edid = fb_ddc_read(&par->chan[conn-1].adapter); 160 if (par->chan[conn].par)
161 edid = fb_ddc_read(&par->chan[conn].adapter);
165 162
166 if (out_edid) 163 if (out_edid)
167 *out_edid = edid; 164 *out_edid = edid;
diff --git a/drivers/video/riva/rivafb.h b/drivers/video/riva/rivafb.h
index 48ead6d72f24..d9f107b704c6 100644
--- a/drivers/video/riva/rivafb.h
+++ b/drivers/video/riva/rivafb.h
@@ -4,7 +4,6 @@
4#include <linux/fb.h> 4#include <linux/fb.h>
5#include <video/vga.h> 5#include <video/vga.h>
6#include <linux/i2c.h> 6#include <linux/i2c.h>
7#include <linux/i2c-id.h>
8#include <linux/i2c-algo-bit.h> 7#include <linux/i2c-algo-bit.h>
9 8
10#include "riva_hw.h" 9#include "riva_hw.h"
@@ -61,7 +60,6 @@ struct riva_par {
61 Bool SecondCRTC; 60 Bool SecondCRTC;
62 int FlatPanel; 61 int FlatPanel;
63 struct pci_dev *pdev; 62 struct pci_dev *pdev;
64 int bus;
65 int cursor_reset; 63 int cursor_reset;
66#ifdef CONFIG_MTRR 64#ifdef CONFIG_MTRR
67 struct { int vram; int vram_valid; } mtrr; 65 struct { int vram; int vram_valid; } mtrr;