Commit 76a21cfa authored by Petr Vandrovec's avatar Petr Vandrovec

Use container_of instead of simple typecast when we convert pointers from

pointer to fb_info to pointers to matrox_fb_info.
parent d5f14f25
......@@ -238,7 +238,7 @@ static void matroxfb_remove(WPMINFO int dummy) {
static int matroxfb_open(struct fb_info *info, int user)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG_LOOP("matroxfb_open")
if (ACCESS_FBINFO(dead)) {
......@@ -251,7 +251,7 @@ static int matroxfb_open(struct fb_info *info, int user)
static int matroxfb_release(struct fb_info *info, int user)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG_LOOP("matroxfb_release")
if (!(--ACCESS_FBINFO(usecount)) && ACCESS_FBINFO(dead)) {
......@@ -263,7 +263,7 @@ static int matroxfb_release(struct fb_info *info, int user)
static int matroxfb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info* info) {
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_pan_display")
......@@ -289,7 +289,7 @@ static int matroxfb_pan_display(struct fb_var_screeninfo *var, int con,
static int matroxfb_updatevar(int con, struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_updatevar");
matrox_pan_var(PMINFO &fb_display[con].var);
......@@ -566,7 +566,7 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
{
struct display* p;
#ifdef CONFIG_FB_MATROX_MULTIHEAD
struct matrox_fb_info* minfo = (struct matrox_fb_info*)fb_info;
struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon);
#endif
DBG("matroxfb_setcolreg")
......@@ -650,7 +650,7 @@ static int matroxfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct display* p;
DBG("matroxfb_get_fix")
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
if (ACCESS_FBINFO(dead)) {
return -ENXIO;
......@@ -683,7 +683,7 @@ static int matroxfb_get_fix(struct fb_fix_screeninfo *fix, int con,
static int matroxfb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_get_var")
if(con < 0)
......@@ -697,7 +697,7 @@ static int matroxfb_get_var(struct fb_var_screeninfo *var, int con,
static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
int err;
int visual;
int cmap_len;
......@@ -864,7 +864,7 @@ static int matrox_getcolreg(unsigned regno, unsigned *red, unsigned *green,
DBG("matrox_getcolreg")
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
/*
* Read a single color register and split it into colors/transparent.
* Return != 0 for invalid regno.
......@@ -884,7 +884,7 @@ static int matrox_getcolreg(unsigned regno, unsigned *red, unsigned *green,
static int matroxfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
struct display* dsp = (con < 0) ? ACCESS_FBINFO(fbcon.disp)
: fb_display + con;
......@@ -910,7 +910,7 @@ static int matroxfb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
{
unsigned int cmap_len;
struct display* dsp = (con < 0) ? info->disp : (fb_display + con);
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_set_cmap")
......@@ -965,7 +965,7 @@ static int matroxfb_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg, int con,
struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_ioctl")
if (ACCESS_FBINFO(dead)) {
......@@ -1173,7 +1173,7 @@ static int matroxfb_ioctl(struct inode *inode, struct file *file,
static int matroxfb_blank(int blank, struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
int seq;
int crtc;
CRITFLAGS
......@@ -1220,7 +1220,7 @@ static struct fb_ops matroxfb_ops = {
int matroxfb_switch(int con, struct fb_info *info)
{
#define minfo ((struct matrox_fb_info*)info)
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
struct fb_cmap* cmap;
struct display *p;
......
......@@ -426,7 +426,6 @@ struct matroxfb_driver;
struct matroxfb_dh_fb_info;
struct matrox_fb_info {
/* fb_info must be first */
struct fb_info fbcon;
struct list_head next_fb;
......@@ -622,7 +621,7 @@ struct matrox_fb_info {
#define PMINFO PMINFO2 ,
static inline struct matrox_fb_info* mxinfo(const struct display* p) {
return (struct matrox_fb_info*)p->fb_info;
return container_of(p->fb_info, struct matrox_fb_info, fbcon);
}
#define PMXINFO(p) mxinfo(p),
......
......@@ -28,7 +28,7 @@ MODULE_PARM_DESC(mem, "Memory size reserved for dualhead (default=8MB)");
static int matroxfb_dh_getcolreg(unsigned regno, unsigned *red, unsigned *green,
unsigned *blue, unsigned *transp, struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
if (regno >= 16)
return 1;
*red = m2info->palette[regno].red;
......@@ -41,7 +41,7 @@ static int matroxfb_dh_getcolreg(unsigned regno, unsigned *red, unsigned *green,
static int matroxfb_dh_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp, struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* p;
if (regno >= 16)
......@@ -185,8 +185,8 @@ static void matroxfb_dh_pan_var(struct matroxfb_dh_fb_info* m2info,
unsigned int pos;
unsigned int linelen;
unsigned int pixelsize;
MINFO_FROM(m2info->primary_dev);
#define minfo (m2info->primary_dev)
pixelsize = var->bits_per_pixel >> 3;
linelen = var->xres_virtual * pixelsize;
pos = var->yoffset * linelen + var->xoffset * pixelsize;
......@@ -197,7 +197,6 @@ static void matroxfb_dh_pan_var(struct matroxfb_dh_fb_info* m2info,
} else {
mga_outl(0x3C28, pos);
}
#undef minfo
}
static int matroxfb_dh_decode_var(struct matroxfb_dh_fb_info* m2info,
......@@ -301,7 +300,7 @@ static void initMatroxDH(struct matroxfb_dh_fb_info* m2info, struct display* p)
}
static int matroxfb_dh_open(struct fb_info* info, int user) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
MINFO_FROM(m2info->primary_dev);
if (MINFO) {
......@@ -314,7 +313,7 @@ static int matroxfb_dh_open(struct fb_info* info, int user) {
}
static int matroxfb_dh_release(struct fb_info* info, int user) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
MINFO_FROM(m2info->primary_dev);
if (MINFO) {
......@@ -325,7 +324,7 @@ static int matroxfb_dh_release(struct fb_info* info, int user) {
static int matroxfb_dh_get_fix(struct fb_fix_screeninfo* fix, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* p;
if (con >= 0)
......@@ -354,7 +353,7 @@ static int matroxfb_dh_get_fix(struct fb_fix_screeninfo* fix, int con,
static int matroxfb_dh_get_var(struct fb_var_screeninfo* var, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
if (con < 0)
*var = m2info->fbcon.disp->var;
else
......@@ -365,7 +364,7 @@ static int matroxfb_dh_get_var(struct fb_var_screeninfo* var, int con,
static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* p;
int chgvar;
int visual;
......@@ -464,7 +463,7 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
static int matroxfb_dh_get_cmap(struct fb_cmap* cmap, int kspc, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* dsp;
if (con < 0)
......@@ -483,7 +482,7 @@ static int matroxfb_dh_get_cmap(struct fb_cmap* cmap, int kspc, int con,
static int matroxfb_dh_set_cmap(struct fb_cmap* cmap, int kspc, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* dsp;
if (con < 0)
......@@ -507,7 +506,7 @@ static int matroxfb_dh_set_cmap(struct fb_cmap* cmap, int kspc, int con,
static int matroxfb_dh_pan_display(struct fb_var_screeninfo* var, int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
if (var->xoffset + fb_display[con].var.xres > fb_display[con].var.xres_virtual ||
var->yoffset + fb_display[con].var.yres > fb_display[con].var.yres_virtual)
return -EINVAL;
......@@ -540,7 +539,7 @@ static int matroxfb_dh_ioctl(struct inode* inode,
unsigned long arg,
int con,
struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
MINFO_FROM(m2info->primary_dev);
DBG("matroxfb_crtc2_ioctl")
......@@ -655,7 +654,7 @@ static int matroxfb_dh_ioctl(struct inode* inode,
}
static int matroxfb_dh_blank(int blank, struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
switch (blank) {
case 1:
case 2:
......@@ -684,7 +683,7 @@ static struct fb_ops matroxfb_dh_ops = {
};
static int matroxfb_dh_switch(int con, struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct fb_cmap* cmap;
struct display* p;
......@@ -707,7 +706,7 @@ static int matroxfb_dh_switch(int con, struct fb_info* info) {
}
static int matroxfb_dh_updatevar(int con, struct fb_info* info) {
#define m2info ((struct matroxfb_dh_fb_info*)info)
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
matroxfb_dh_pan_var(m2info, &fb_display[con].var);
return 0;
#undef m2info
......
......@@ -903,7 +903,7 @@ static struct matrox_altout maven_altout = {
static int maven_init_client(struct i2c_client* clnt) {
struct i2c_adapter* a = clnt->adapter;
struct maven_data* md = clnt->data;
MINFO_FROM(((struct i2c_bit_adapter*)a)->minfo);
MINFO_FROM(container_of(a, struct i2c_bit_adapter, adapter)->minfo);
md->primary_head = MINFO;
md->client = clnt;
......
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