Commit a65ff76a authored by Jean Delvare's avatar Jean Delvare Committed by Linus Torvalds

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: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarAntonino Daplas <adaplas@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5b358fe1
...@@ -127,8 +127,6 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name, ...@@ -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) void nvidia_create_i2c_busses(struct nvidia_par *par)
{ {
par->bus = 3;
par->chan[0].par = par; par->chan[0].par = par;
par->chan[1].par = par; par->chan[1].par = par;
par->chan[2].par = par; par->chan[2].par = par;
...@@ -145,18 +143,14 @@ void nvidia_create_i2c_busses(struct nvidia_par *par) ...@@ -145,18 +143,14 @@ void nvidia_create_i2c_busses(struct nvidia_par *par)
void nvidia_delete_i2c_busses(struct nvidia_par *par) void nvidia_delete_i2c_busses(struct nvidia_par *par)
{ {
if (par->chan[0].par) int i;
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;
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) int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-id.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#define NV_ARCH_04 0x04 #define NV_ARCH_04 0x04
...@@ -100,7 +99,6 @@ struct nvidia_par { ...@@ -100,7 +99,6 @@ struct nvidia_par {
u32 Architecture; u32 Architecture;
u32 CursorStart; u32 CursorStart;
int Chipset; int Chipset;
int bus;
unsigned long FbAddress; unsigned long FbAddress;
u8 __iomem *FbStart; u8 __iomem *FbStart;
u32 FbMapSize; u32 FbMapSize;
......
...@@ -1788,10 +1788,10 @@ static int __devinit riva_get_EDID_i2c(struct fb_info *info) ...@@ -1788,10 +1788,10 @@ static int __devinit riva_get_EDID_i2c(struct fb_info *info)
NVTRACE_ENTER(); NVTRACE_ENTER();
riva_create_i2c_busses(par); riva_create_i2c_busses(par);
for (i = 0; i < par->bus; i++) { for (i = 0; i < 3; i++) {
if (!par->chan[i].par) if (!par->chan[i].par)
continue; 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)) { if (par->EDID && !fb_parse_edid(par->EDID, &var)) {
printk(PFX "Found EDID Block from BUS %i\n", i); printk(PFX "Found EDID Block from BUS %i\n", i);
break; break;
......
...@@ -88,8 +88,9 @@ static int riva_gpio_getsda(void* data) ...@@ -88,8 +88,9 @@ static int riva_gpio_getsda(void* data)
return val; return val;
} }
static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name, static int __devinit riva_setup_i2c_bus(struct riva_i2c_chan *chan,
unsigned int i2c_class) const char *name,
unsigned int i2c_class)
{ {
int rc; int rc;
...@@ -126,10 +127,8 @@ static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name, ...@@ -126,10 +127,8 @@ static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name,
return rc; 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[0].par = par;
par->chan[1].par = par; par->chan[1].par = par;
par->chan[2].par = par; par->chan[2].par = par;
...@@ -144,24 +143,22 @@ void riva_create_i2c_busses(struct riva_par *par) ...@@ -144,24 +143,22 @@ void riva_create_i2c_busses(struct riva_par *par)
void riva_delete_i2c_busses(struct riva_par *par) void riva_delete_i2c_busses(struct riva_par *par)
{ {
if (par->chan[0].par) int i;
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) for (i = 0; i < 3; i++) {
i2c_del_adapter(&par->chan[2].adapter); if (!par->chan[i].par)
par->chan[2].par = NULL; 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; 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) if (out_edid)
*out_edid = edid; *out_edid = edid;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <linux/fb.h> #include <linux/fb.h>
#include <video/vga.h> #include <video/vga.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-id.h>
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include "riva_hw.h" #include "riva_hw.h"
...@@ -61,7 +60,6 @@ struct riva_par { ...@@ -61,7 +60,6 @@ struct riva_par {
Bool SecondCRTC; Bool SecondCRTC;
int FlatPanel; int FlatPanel;
struct pci_dev *pdev; struct pci_dev *pdev;
int bus;
int cursor_reset; int cursor_reset;
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
struct { int vram; int vram_valid; } mtrr; struct { int vram; int vram_valid; } mtrr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment