Re: searching for pci busses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/30/06, Matthew Wilcox <[email protected]> wrote:
On Tue, May 30, 2006 at 12:52:31PM -0400, Jon Smirl wrote:
> This is how DRM does it...

>        for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
>                pid = (struct pci_device_id *)&driver->pci_driver.id_table[i];

Why do you cast away the const warning?  Why not just make pid a pointer
to const?  drm_get_dev already has the const qualifier, so somebody
realised what the right thing to do was.

Nobody pointed that out before (That code has been around for a while,
I suspect one of the routines being called wasn't always marked as
taking a const parameter). I made a patch and attached it. You can
send it to DaveA, they reject everything from me.

But looking at this code just reinforces the basic problem -- that DRM
does everything wrong and it needs shooting in the head.

DRM has to do that loop because the fbdev drivers are already bound to
the device. There is a more complex version in DRM CVS that looks for
the fbdev drivers, if they are not present DRM will bind to the
device, otherwise it falls back in stealth mode. It also adds code to
manually mark PCI memory regions in use. Confusion over who can bind
has impacts on attaching to the suspend/resume hooks.

But binding is only a minor problem. The true problem is who controls
the state loaded inside of the device.

--
Jon Smirl
[email protected]
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 3c0b882..3af48be 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -253,7 +253,7 @@ int drm_lastclose(drm_device_t * dev)
 int drm_init(struct drm_driver *driver)
 {
 	struct pci_dev *pdev = NULL;
-	struct pci_device_id *pid;
+	const struct pci_device_id *pid;
 	int i;
 
 	DRM_DEBUG("\n");
@@ -261,7 +261,7 @@ int drm_init(struct drm_driver *driver)
 	drm_mem_init();
 
 	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
-		pid = (struct pci_device_id *)&driver->pci_driver.id_table[i];
+		pid = &driver->pci_driver.id_table[i];
 
 		pdev = NULL;
 		/* pass back in pdev to account for multiple identical cards */

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux