aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Smirl <jonsmirl@yahoo.com>2005-06-22 05:49:56 +0000
committerJon Smirl <jonsmirl@yahoo.com>2005-06-22 05:49:56 +0000
commit4152605ea174291f469c0c8a6fc433fd90194e71 (patch)
treeadcd867e68194af22a12a49cb72675495a9386ff
parent9fb77e869f530f3c9679dd63db07514e2f45efc7 (diff)
Get the power management hooks into the right place so that everything gets
freed correctly.
-rw-r--r--linux-core/drmP.h2
-rw-r--r--linux-core/drm_drv.c11
-rw-r--r--linux-core/drm_pm.c53
-rw-r--r--linux-core/drm_stub.c7
4 files changed, 39 insertions, 34 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 410a3e2c..9f836773 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -892,7 +892,7 @@ extern unsigned long drm_get_resource_len(drm_device_t *dev,
extern int drm_pm_setup(drm_device_t *dev);
extern void drm_pm_takedown(drm_device_t *dev);
extern int drm_pm_init(void);
-extern void drm_pm_cleanup(void);
+extern void drm_pm_exit(void);
/* DMA support (drm_dma.h) */
extern int drm_dma_setup(drm_device_t * dev);
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 39c893ce..6c1e5feb 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -310,7 +310,7 @@ int drm_init(struct drm_driver *driver,
{
struct pci_dev *pdev;
struct pci_device_id *pid;
- int i;
+ int rc, i;
DRM_DEBUG("\n");
@@ -351,7 +351,10 @@ int drm_init(struct drm_driver *driver,
pdev))) {
/* stealth mode requires a manual probe */
pci_dev_get(pdev);
- drm_get_dev(pdev, &pciidlist[i], driver);
+ if ((rc = drm_get_dev(pdev, &pciidlist[i], driver))) {
+ pci_dev_put(pdev);
+ return rc;
+ }
}
}
DRM_INFO("Used old pci detect: framebuffer loaded\n");
@@ -438,9 +441,6 @@ static void __exit drm_cleanup(drm_device_t * dev)
DRM_DEBUG("mtrr_del=%d\n", retval);
}
- if (drm_fb_loaded)
- drm_pm_cleanup();
-
if (drm_core_has_AGP(dev) && dev->agp) {
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
dev->agp = NULL;
@@ -539,6 +539,7 @@ static void __exit drm_core_exit(void)
unregister_chrdev(DRM_MAJOR, "drm");
drm_free(drm_heads, sizeof(*drm_heads) * cards_limit, DRM_MEM_STUB);
+ drm_pm_exit();
}
module_init(drm_core_init);
diff --git a/linux-core/drm_pm.c b/linux-core/drm_pm.c
index ea801bda..68c9d0a9 100644
--- a/linux-core/drm_pm.c
+++ b/linux-core/drm_pm.c
@@ -32,16 +32,16 @@
#define __NO_VERSION__
#include "drmP.h"
-
#include <linux/device.h>
#include <linux/sysdev.h>
+
static int drm_suspend(struct sys_device *sysdev, u32 state)
{
drm_device_t *dev = (drm_device_t *)sysdev;
-
- DRM_DEBUG("%s state=%d\n", __FUNCTION__, state);
-
+
+ DRM_DEBUG("state=%d\n", state);
+
if (dev->driver->power)
return dev->driver->power(dev, state);
else
@@ -51,15 +51,16 @@ static int drm_suspend(struct sys_device *sysdev, u32 state)
static int drm_resume(struct sys_device *sysdev)
{
drm_device_t *dev = (drm_device_t *)sysdev;
-
- DRM_DEBUG("%s\n", __FUNCTION__);
-
+
+ DRM_DEBUG("\n");
+
if (dev->driver->power)
return dev->driver->power(dev, 0);
else
return 0;
}
+static int drm_sysdev_class_registered = 0;
static struct sysdev_class drm_sysdev_class = {
set_kset_name("drm"),
.resume = drm_resume,
@@ -75,21 +76,21 @@ static struct sysdev_class drm_sysdev_class = {
*/
int drm_pm_setup(drm_device_t *dev)
{
- int error;
-
- DRM_DEBUG("%s\n", __FUNCTION__);
-
+ int rc;
+
+ DRM_DEBUG("\n");
+
dev->sysdev.id = dev->primary.minor;
dev->sysdev.cls = &drm_sysdev_class;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
- error = sys_device_register(&dev->sysdev);
+ rc = sys_device_register(&dev->sysdev);
#else
- error = sysdev_register(&dev->sysdev);
+ rc = sysdev_register(&dev->sysdev);
#endif
- if(!error)
+ if (!rc)
dev->sysdev_registered = 1;
- return error;
+ return rc;
}
/**
@@ -99,28 +100,30 @@ int drm_pm_setup(drm_device_t *dev)
*/
void drm_pm_takedown(drm_device_t *dev)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
+ DRM_DEBUG("\n");
+
if(dev->sysdev_registered) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
sys_device_unregister(&dev->sysdev);
#else
sysdev_unregister(&dev->sysdev);
#endif
- dev->sysdev_registered = 0;
}
}
int drm_pm_init(void)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- return sysdev_class_register(&drm_sysdev_class);
+ int rc;
+ DRM_DEBUG("\n");
+ rc = sysdev_class_register(&drm_sysdev_class);
+ if (!rc)
+ drm_sysdev_class_registered = 1;
+ return rc;
}
-void drm_pm_cleanup(void)
+void drm_pm_exit(void)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- sysdev_class_unregister(&drm_sysdev_class);
+ DRM_DEBUG("\n");
+ if (drm_sysdev_class_registered)
+ sysdev_class_unregister(&drm_sysdev_class);
}
diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c
index cb6d6c69..2f9a2c32 100644
--- a/linux-core/drm_stub.c
+++ b/linux-core/drm_stub.c
@@ -67,9 +67,6 @@ static int fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
dev->pdev = pdev;
- if (drm_fb_loaded)
- drm_pm_setup( dev );
-
#ifdef __alpha__
dev->hose = pdev->sysdata;
dev->pci_domain = dev->hose->bus->number;
@@ -97,6 +94,10 @@ static int fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
dev->driver = driver;
+ if (drm_fb_loaded)
+ if ((retcode = drm_pm_setup( dev )))
+ goto error_out_unreg;
+
if (dev->driver->preinit)
if ((retcode = dev->driver->preinit(dev, ent->driver_data)))
goto error_out_unreg;