[PATCH] fbdev: sstfb: Driver cleanups

- remove unneeded casts
- make setcolreg return success if regno > 15, but don't do anything
- use framebuffer_alloc/framebuffer_release to allocate/free memory

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Antonino A. Daplas 2006-01-09 20:53:14 -08:00 committed by Linus Torvalds
parent cb639258f9
commit 7227576f4b
2 changed files with 28 additions and 33 deletions

View File

@ -382,7 +382,7 @@ static void sstfb_clear_screen(struct fb_info *info)
static int sstfb_check_var(struct fb_var_screeninfo *var, static int sstfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info) struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
int hSyncOff = var->xres + var->right_margin + var->left_margin; int hSyncOff = var->xres + var->right_margin + var->left_margin;
int vSyncOff = var->yres + var->lower_margin + var->upper_margin; int vSyncOff = var->yres + var->lower_margin + var->upper_margin;
int vBackPorch = var->left_margin, yDim = var->yres; int vBackPorch = var->left_margin, yDim = var->yres;
@ -542,7 +542,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
*/ */
static int sstfb_set_par(struct fb_info *info) static int sstfb_set_par(struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u32 lfbmode, fbiinit1, fbiinit2, fbiinit3, fbiinit5, fbiinit6=0; u32 lfbmode, fbiinit1, fbiinit2, fbiinit3, fbiinit5, fbiinit6=0;
struct pci_dev *sst_dev = par->dev; struct pci_dev *sst_dev = par->dev;
unsigned int freq; unsigned int freq;
@ -748,13 +748,14 @@ static int sstfb_set_par(struct fb_info *info)
static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info) u_int transp, struct fb_info *info)
{ {
struct sstfb_par *par = info->par;
u32 col; u32 col;
f_dddprintk("sstfb_setcolreg\n"); f_dddprintk("sstfb_setcolreg\n");
f_dddprintk("%-2d rgbt: %#x, %#x, %#x, %#x\n", f_dddprintk("%-2d rgbt: %#x, %#x, %#x, %#x\n",
regno, red, green, blue, transp); regno, red, green, blue, transp);
if (regno >= 16) if (regno > 15)
return -EINVAL; return 0;
red >>= (16 - info->var.red.length); red >>= (16 - info->var.red.length);
green >>= (16 - info->var.green.length); green >>= (16 - info->var.green.length);
@ -765,7 +766,7 @@ static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
| (blue << info->var.blue.offset) | (blue << info->var.blue.offset)
| (transp << info->var.transp.offset); | (transp << info->var.transp.offset);
((u32 *)info->pseudo_palette)[regno] = col; par->palette[regno] = col;
return 0; return 0;
} }
@ -773,7 +774,7 @@ static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
static int sstfb_ioctl(struct inode *inode, struct file *file, static int sstfb_ioctl(struct inode *inode, struct file *file,
u_int cmd, u_long arg, struct fb_info *info ) u_int cmd, u_long arg, struct fb_info *info )
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
struct pci_dev *sst_dev = par->dev; struct pci_dev *sst_dev = par->dev;
u32 fbiinit0, tmp, val; u32 fbiinit0, tmp, val;
u_long p; u_long p;
@ -830,7 +831,7 @@ static int sstfb_ioctl(struct inode *inode, struct file *file,
#if 0 #if 0
static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u32 stride = info->fix.line_length; u32 stride = info->fix.line_length;
if (!IS_VOODOO2(par)) if (!IS_VOODOO2(par))
@ -855,7 +856,7 @@ static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
*/ */
static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u32 stride = info->fix.line_length; u32 stride = info->fix.line_length;
if (!IS_VOODOO2(par)) if (!IS_VOODOO2(par))
@ -925,7 +926,7 @@ static int __devinit sst_get_memsize(struct fb_info *info, __u32 *memsize)
static int __devinit sst_detect_att(struct fb_info *info) static int __devinit sst_detect_att(struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
int i, mir, dir; int i, mir, dir;
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
@ -950,7 +951,7 @@ static int __devinit sst_detect_att(struct fb_info *info)
static int __devinit sst_detect_ti(struct fb_info *info) static int __devinit sst_detect_ti(struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
int i, mir, dir; int i, mir, dir;
for (i = 0; i<3; i++) { for (i = 0; i<3; i++) {
@ -986,7 +987,7 @@ static int __devinit sst_detect_ti(struct fb_info *info)
*/ */
static int __devinit sst_detect_ics(struct fb_info *info) static int __devinit sst_detect_ics(struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
int m_clk0_1, m_clk0_7, m_clk1_b; int m_clk0_1, m_clk0_7, m_clk1_b;
int n_clk0_1, n_clk0_7, n_clk1_b; int n_clk0_1, n_clk0_7, n_clk1_b;
int i; int i;
@ -1023,7 +1024,7 @@ static int __devinit sst_detect_ics(struct fb_info *info)
static int sst_set_pll_att_ti(struct fb_info *info, static int sst_set_pll_att_ti(struct fb_info *info,
const struct pll_timing *t, const int clock) const struct pll_timing *t, const int clock)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u8 cr0, cc; u8 cr0, cc;
/* enable indexed mode */ /* enable indexed mode */
@ -1077,7 +1078,7 @@ static int sst_set_pll_att_ti(struct fb_info *info,
static int sst_set_pll_ics(struct fb_info *info, static int sst_set_pll_ics(struct fb_info *info,
const struct pll_timing *t, const int clock) const struct pll_timing *t, const int clock)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u8 pll_ctrl; u8 pll_ctrl;
sst_dac_write(DACREG_ICS_PLLRMA, DACREG_ICS_PLL_CTRL); sst_dac_write(DACREG_ICS_PLLRMA, DACREG_ICS_PLL_CTRL);
@ -1114,7 +1115,7 @@ static int sst_set_pll_ics(struct fb_info *info,
static void sst_set_vidmod_att_ti(struct fb_info *info, const int bpp) static void sst_set_vidmod_att_ti(struct fb_info *info, const int bpp)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
u8 cr0; u8 cr0;
sst_dac_write(DACREG_WMA, 0); /* backdoor */ sst_dac_write(DACREG_WMA, 0); /* backdoor */
@ -1149,7 +1150,7 @@ static void sst_set_vidmod_att_ti(struct fb_info *info, const int bpp)
static void sst_set_vidmod_ics(struct fb_info *info, const int bpp) static void sst_set_vidmod_ics(struct fb_info *info, const int bpp)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
switch(bpp) { switch(bpp) {
case 16: case 16:
@ -1308,7 +1309,7 @@ static int __devinit sst_init(struct fb_info *info, struct sstfb_par *par)
static void __devexit sst_shutdown(struct fb_info *info) static void __devexit sst_shutdown(struct fb_info *info)
{ {
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
struct pci_dev *dev = par->dev; struct pci_dev *dev = par->dev;
struct pll_timing gfx_timings; struct pll_timing gfx_timings;
int Fout; int Fout;
@ -1394,12 +1395,6 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
struct sst_spec *spec; struct sst_spec *spec;
int err; int err;
struct all_info {
struct fb_info info;
struct sstfb_par par;
u32 pseudo_palette[16];
} *all;
/* Enable device in PCI config. */ /* Enable device in PCI config. */
if ((err=pci_enable_device(pdev))) { if ((err=pci_enable_device(pdev))) {
eprintk("cannot enable device\n"); eprintk("cannot enable device\n");
@ -1407,14 +1402,13 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
} }
/* Allocate the fb and par structures. */ /* Allocate the fb and par structures. */
all = kmalloc(sizeof(*all), GFP_KERNEL); info = framebuffer_alloc(sizeof(struct sstfb_par), &pdev->dev);
if (!all) if (!info)
return -ENOMEM; return -ENOMEM;
memset(all, 0, sizeof(*all));
pci_set_drvdata(pdev, all);
info = &all->info; pci_set_drvdata(pdev, info);
par = info->par = &all->par;
par = info->par;
fix = &info->fix; fix = &info->fix;
par->type = id->driver_data; par->type = id->driver_data;
@ -1471,7 +1465,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
info->flags = FBINFO_DEFAULT; info->flags = FBINFO_DEFAULT;
info->fbops = &sstfb_ops; info->fbops = &sstfb_ops;
info->pseudo_palette = &all->pseudo_palette; info->pseudo_palette = par->palette;
fix->type = FB_TYPE_PACKED_PIXELS; fix->type = FB_TYPE_PACKED_PIXELS;
fix->visual = FB_VISUAL_TRUECOLOR; fix->visual = FB_VISUAL_TRUECOLOR;
@ -1527,7 +1521,7 @@ fail_mmio_remap:
fail_fb_mem: fail_fb_mem:
release_mem_region(fix->mmio_start, info->fix.mmio_len); release_mem_region(fix->mmio_start, info->fix.mmio_len);
fail_mmio_mem: fail_mmio_mem:
kfree(info); framebuffer_release(info);
return -ENXIO; /* no voodoo detected */ return -ENXIO; /* no voodoo detected */
} }
@ -1537,7 +1531,7 @@ static void __devexit sstfb_remove(struct pci_dev *pdev)
struct fb_info *info; struct fb_info *info;
info = pci_get_drvdata(pdev); info = pci_get_drvdata(pdev);
par = (struct sstfb_par *) info->par; par = info->par;
sst_shutdown(info); sst_shutdown(info);
unregister_framebuffer(info); unregister_framebuffer(info);
@ -1545,7 +1539,7 @@ static void __devexit sstfb_remove(struct pci_dev *pdev)
iounmap(par->mmio_vbase); iounmap(par->mmio_vbase);
release_mem_region(info->fix.smem_start, 0x400000); release_mem_region(info->fix.smem_start, 0x400000);
release_mem_region(info->fix.mmio_start, info->fix.mmio_len); release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
kfree(info); framebuffer_release(info);
} }
@ -1613,7 +1607,7 @@ static int sstfb_dump_regs(struct fb_info *info)
const int pci_s = sizeof(pci_regs)/sizeof(pci_regs[0]); const int pci_s = sizeof(pci_regs)/sizeof(pci_regs[0]);
const int sst_s = sizeof(sst_regs)/sizeof(sst_regs[0]); const int sst_s = sizeof(sst_regs)/sizeof(sst_regs[0]);
struct sstfb_par *par = (struct sstfb_par *) info->par; struct sstfb_par *par = info->par;
struct pci_dev *dev = par->dev; struct pci_dev *dev = par->dev;
u32 pci_res[pci_s]; u32 pci_res[pci_s];
u32 sst_res[sst_s]; u32 sst_res[sst_s];

View File

@ -334,6 +334,7 @@ struct sst_spec {
}; };
struct sstfb_par { struct sstfb_par {
u32 palette[16];
unsigned int yDim; unsigned int yDim;
unsigned int hSyncOn; /* hsync_len */ unsigned int hSyncOn; /* hsync_len */
unsigned int hSyncOff; /* left_margin + xres + right_margin */ unsigned int hSyncOff; /* left_margin + xres + right_margin */