gma500: tidy up the opregion and lid code
authorAlan Cox <alan@linux.intel.com>
Tue, 5 Jul 2011 14:42:23 +0000 (15:42 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 5 Jul 2011 15:20:43 +0000 (08:20 -0700)
This is leaking an io mapping and also referencing stuff directly that
should not be directly accessed. Sort it out

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/gma500/cdv_device.c
drivers/staging/gma500/psb_device.c
drivers/staging/gma500/psb_drv.c
drivers/staging/gma500/psb_drv.h
drivers/staging/gma500/psb_intel_opregion.c
drivers/staging/gma500/psb_lid.c

index bb0b3f987d5da7884351d9b07d692f92b420509b..5131106eda995e9134c4844601e5ed15acb37e92 100644 (file)
@@ -321,7 +321,7 @@ static void cdv_get_core_freq(struct drm_device *dev)
 static int cdv_chip_setup(struct drm_device *dev)
 {
        cdv_get_core_freq(dev);
-       psb_intel_opregion_init(dev);
+       intel_opregion_init(dev);
        psb_intel_init_bios(dev);
        return 0;
 }
index 1be6434be73a16ef2d0ac342bc815c07c187cb8c..8ac9de74f76351a1586138b2407a8d6ef4d1dff9 100644 (file)
@@ -322,7 +322,7 @@ static void psb_get_core_freq(struct drm_device *dev)
 static int psb_chip_setup(struct drm_device *dev)
 {
        psb_get_core_freq(dev);
-       psb_intel_opregion_init(dev);
+       intel_opregion_init(dev);
        psb_intel_init_bios(dev);
        return 0;
 }
index 69ab61b192ca7cc6944b036289682d014966f12c..e9772abc1a63c24591ae81b2f57919e4c22bbd4a 100644 (file)
@@ -245,6 +245,7 @@ static int psb_driver_unload(struct drm_device *dev)
 
        if (dev_priv) {
                psb_lid_timer_takedown(dev_priv);
+               intel_opregion_exit(dev);
 
                psb_do_takedown(dev);
 
index 307ff9c86fda05f286ae8d13024dc46cd13fad66..ee782fa2533da730e9424322e55e5a083bde849e 100644 (file)
@@ -727,9 +727,10 @@ extern int mdfld_enable_te(struct drm_device *dev, int pipe);
 extern void mdfld_disable_te(struct drm_device *dev, int pipe);
 
 /*
- * psb_opregion.c
+ * intel_opregion.c
  */
-extern int psb_intel_opregion_init(struct drm_device *dev);
+extern int intel_opregion_init(struct drm_device *dev);
+extern int intel_opregion_exit(struct drm_device *dev);
 
 /*
  * framebuffer.c
index 97a8b00a7e362c3fb36f2556bed46c8021b531e3..a586f3de7658433624af938c3701e2746e021b94 100644 (file)
@@ -47,10 +47,9 @@ struct opregion_acpi {
        /*FIXME: add it later*/
 } __packed;
 
-int psb_intel_opregion_init(struct drm_device *dev)
+int intel_opregion_init(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
-       /*struct psb_intel_opregion * opregion = &dev_priv->opregion;*/
        u32 opregion_phy;
        void *base;
        u32 *lid_state;
@@ -68,6 +67,15 @@ int psb_intel_opregion_init(struct drm_device *dev)
        lid_state = base + 0x01ac;
 
        dev_priv->lid_state = lid_state;
-       dev_priv->lid_last_state = *lid_state;
+       dev_priv->lid_last_state = readl(lid_state);
        return 0;
 }
+
+int intel_opregion_exit(struct drm_device *dev)
+{
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       if (dev_priv->lid_state)
+               iounmap(dev_priv->lid_state);
+       return 0;
+}
+       
\ No newline at end of file
index 21fd202f29312e2baccb1cdc92bdba1831e45960..af328516561eef19893a8673c2512bab589f3a58 100644 (file)
@@ -32,10 +32,10 @@ static void psb_lid_timer_func(unsigned long data)
        u32 *lid_state = dev_priv->lid_state;
        u32 pp_status;
 
-       if (*lid_state == dev_priv->lid_last_state)
+       if (readl(lid_state) == dev_priv->lid_last_state)
                goto lid_timer_schedule;
 
-       if ((*lid_state) & 0x01) {
+       if ((readl(lid_state)) & 0x01) {
                /*lid state is open*/
                REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON);
                do {
@@ -54,7 +54,7 @@ static void psb_lid_timer_func(unsigned long data)
        }
                /* printk(KERN_INFO"%s: lid: closed\n", __FUNCTION__); */
 
-       dev_priv->lid_last_state =  *lid_state;
+       dev_priv->lid_last_state =  readl(lid_state);
 
 lid_timer_schedule:
        spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);