Skip to content

Commit

Permalink
staging: xgifb: inline XGIfb_query_VGA_config_space()
Browse files Browse the repository at this point in the history
XGIfb_query_VGA_config_space() is used only once during the init and
can be replaced with a single PCI configuration space read.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Aaro Koskinen authored and Greg Kroah-Hartman committed Oct 12, 2011
1 parent c62f2e4 commit 6048d76
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 54 deletions.
44 changes: 2 additions & 42 deletions drivers/staging/xgifb/XGI_main_26.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,44 +387,6 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)

}

/* ------------ Interface for init & mode switching code ------------- */

static unsigned char XGIfb_query_VGA_config_space(
struct xgi_hw_device_info *pXGIhw_ext, unsigned long offset,
unsigned long set, unsigned long *value)
{
static struct pci_dev *pdev;
static unsigned char init, valid_pdev;

if (!set)
DPRINTK("XGIfb: Get VGA offset 0x%lx\n", offset);
else
DPRINTK("XGIfb: Set offset 0x%lx to 0x%lx\n", offset, *value);

if (!init) {
init = 1;
pdev = pci_get_device(PCI_VENDOR_ID_XG, xgi_video_info.chip_id,
pdev);
if (pdev) {
valid_pdev = 1;
pci_dev_put(pdev);
}
}

if (!valid_pdev) {
printk(KERN_DEBUG "XGIfb: Can't find XGI %d VGA device.\n",
xgi_video_info.chip_id);
return 0;
}

if (set == 0)
pci_read_config_dword(pdev, offset, (u32 *) value);
else
pci_write_config_dword(pdev, offset, (u32)(*value));

return 1;
}

/* ------------------ Internal helper routines ----------------- */

static int XGIfb_GetXG21DefaultLVDSModeIdx(void)
Expand Down Expand Up @@ -2078,7 +2040,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
hw_info->pjVirtualRomBase = NULL;
printk(KERN_INFO "XGIfb: Video ROM usage disabled\n");
}
hw_info->pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space;

if (XGIfb_get_dram_size()) {
printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n");
Expand Down Expand Up @@ -2128,7 +2089,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
xgi_video_info.mmio_base, xgi_video_info.mmio_vbase,
xgi_video_info.mmio_size / 1024);
printk("XGIfb: XGIInitNew() ...");
if (XGIInitNew(hw_info))
pci_set_drvdata(pdev, &xgi_video_info);
if (XGIInitNew(pdev))
printk("OK\n");
else
printk("Fail\n");
Expand Down Expand Up @@ -2419,8 +2381,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
goto error_mtrr;
}

pci_set_drvdata(pdev, &xgi_video_info);

dumpVGAReg();

return 0;
Expand Down
15 changes: 8 additions & 7 deletions drivers/staging/xgifb/vb_init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <linux/types.h>
#include <linux/delay.h> /* udelay */
#include <linux/pci.h>

#include "vgatypes.h"
#include "XGIfb.h"

Expand Down Expand Up @@ -1427,8 +1429,10 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo)
return temp;
}

unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
unsigned char XGIInitNew(struct pci_dev *pdev)
{
struct video_info *xgifb_info = pci_get_drvdata(pdev);
struct xgi_hw_device_info *HwDeviceExtension = &xgifb_info->hw_info;
struct vb_device_info VBINF;
struct vb_device_info *pVBInfo = &VBINF;
unsigned char i, temp = 0, temp1;
Expand All @@ -1437,8 +1441,6 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)

/* unsigned long j, k; */

unsigned long Temp;

pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;

pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
Expand Down Expand Up @@ -1578,6 +1580,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
printk("12");

if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
u32 Temp;

/* Set AGP Rate */
/*
temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
Expand Down Expand Up @@ -1644,10 +1648,7 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
/* if (ChipsetID == 0x25308086) */
/* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */

HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension,
0x50,
0,
&Temp); /* Get */
pci_read_config_dword(pdev, 0x50, &Temp);
Temp >>= 20;
Temp &= 0xF;

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/xgifb/vb_init.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _VBINIT_
#define _VBINIT_
extern unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension);
extern unsigned char XGIInitNew(struct pci_dev *pdev);
extern struct XGI21_LVDSCapStruct XGI21_LCDCapList[13];
#endif

4 changes: 0 additions & 4 deletions drivers/staging/xgifb/vgatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ struct xgi_hw_device_info {
/* "XGI_VB_CHIP_TYPE" */

unsigned long ulCRT2LCDType; /* defined in the data structure type */

unsigned char(*pQueryVGAConfigSpace)(struct xgi_hw_device_info *,
unsigned long, unsigned long,
unsigned long *);
};

/* Additional IOCTL for communication xgifb <> X driver */
Expand Down

0 comments on commit 6048d76

Please sign in to comment.