Commit 6048d761 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: xgifb: inline XGIfb_query_VGA_config_space()

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: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c62f2e46
...@@ -387,44 +387,6 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) ...@@ -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 ----------------- */ /* ------------------ Internal helper routines ----------------- */
static int XGIfb_GetXG21DefaultLVDSModeIdx(void) static int XGIfb_GetXG21DefaultLVDSModeIdx(void)
...@@ -2078,7 +2040,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -2078,7 +2040,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
hw_info->pjVirtualRomBase = NULL; hw_info->pjVirtualRomBase = NULL;
printk(KERN_INFO "XGIfb: Video ROM usage disabled\n"); printk(KERN_INFO "XGIfb: Video ROM usage disabled\n");
} }
hw_info->pQueryVGAConfigSpace = &XGIfb_query_VGA_config_space;
if (XGIfb_get_dram_size()) { if (XGIfb_get_dram_size()) {
printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n"); printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n");
...@@ -2128,7 +2089,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -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_base, xgi_video_info.mmio_vbase,
xgi_video_info.mmio_size / 1024); xgi_video_info.mmio_size / 1024);
printk("XGIfb: XGIInitNew() ..."); printk("XGIfb: XGIInitNew() ...");
if (XGIInitNew(hw_info)) pci_set_drvdata(pdev, &xgi_video_info);
if (XGIInitNew(pdev))
printk("OK\n"); printk("OK\n");
else else
printk("Fail\n"); printk("Fail\n");
...@@ -2419,8 +2381,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -2419,8 +2381,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
goto error_mtrr; goto error_mtrr;
} }
pci_set_drvdata(pdev, &xgi_video_info);
dumpVGAReg(); dumpVGAReg();
return 0; return 0;
......
#include <linux/types.h> #include <linux/types.h>
#include <linux/delay.h> /* udelay */ #include <linux/delay.h> /* udelay */
#include <linux/pci.h>
#include "vgatypes.h" #include "vgatypes.h"
#include "XGIfb.h" #include "XGIfb.h"
...@@ -1427,8 +1429,10 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo) ...@@ -1427,8 +1429,10 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo)
return temp; 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 VBINF;
struct vb_device_info *pVBInfo = &VBINF; struct vb_device_info *pVBInfo = &VBINF;
unsigned char i, temp = 0, temp1; unsigned char i, temp = 0, temp1;
...@@ -1437,8 +1441,6 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) ...@@ -1437,8 +1441,6 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
/* unsigned long j, k; */ /* unsigned long j, k; */
unsigned long Temp;
pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
...@@ -1578,6 +1580,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) ...@@ -1578,6 +1580,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
printk("12"); printk("12");
if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
u32 Temp;
/* Set AGP Rate */ /* Set AGP Rate */
/* /*
temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B); temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
...@@ -1644,10 +1648,7 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) ...@@ -1644,10 +1648,7 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
/* if (ChipsetID == 0x25308086) */ /* if (ChipsetID == 0x25308086) */
/* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */ /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */
HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension, pci_read_config_dword(pdev, 0x50, &Temp);
0x50,
0,
&Temp); /* Get */
Temp >>= 20; Temp >>= 20;
Temp &= 0xF; Temp &= 0xF;
......
#ifndef _VBINIT_ #ifndef _VBINIT_
#define _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]; extern struct XGI21_LVDSCapStruct XGI21_LCDCapList[13];
#endif #endif
...@@ -73,10 +73,6 @@ struct xgi_hw_device_info { ...@@ -73,10 +73,6 @@ struct xgi_hw_device_info {
/* "XGI_VB_CHIP_TYPE" */ /* "XGI_VB_CHIP_TYPE" */
unsigned long ulCRT2LCDType; /* defined in the data structure 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 */ /* Additional IOCTL for communication xgifb <> X driver */
......
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