Merge branch 'drm-init-cleanup' of git://people.freedesktop.org/~danvet/drm into...
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / drm_irq.c
index 589e865832cdd9081d31e7ce55dbe74fc717ed7b..7583767ec619aab7acda2702c2cc767a8dd9a7de 100644 (file)
@@ -233,11 +233,6 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state)
        }
 }
 
-static inline int drm_dev_to_irq(struct drm_device *dev)
-{
-       return dev->driver->bus->get_irq(dev);
-}
-
 /**
  * Install IRQ handler.
  *
@@ -247,16 +242,15 @@ static inline int drm_dev_to_irq(struct drm_device *dev)
  * \c irq_preinstall() and \c irq_postinstall() functions
  * before and after the installation.
  */
-int drm_irq_install(struct drm_device *dev)
+int drm_irq_install(struct drm_device *dev, int irq)
 {
        int ret;
        unsigned long sh_flags = 0;
-       char *irqname;
 
        if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
                return -EINVAL;
 
-       if (drm_dev_to_irq(dev) == 0)
+       if (irq == 0)
                return -EINVAL;
 
        /* Driver must have been initialized */
@@ -267,7 +261,7 @@ int drm_irq_install(struct drm_device *dev)
                return -EBUSY;
        dev->irq_enabled = true;
 
-       DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
+       DRM_DEBUG("irq=%d\n", irq);
 
        /* Before installing handler */
        if (dev->driver->irq_preinstall)
@@ -277,13 +271,8 @@ int drm_irq_install(struct drm_device *dev)
        if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
                sh_flags = IRQF_SHARED;
 
-       if (dev->devname)
-               irqname = dev->devname;
-       else
-               irqname = dev->driver->name;
-
-       ret = request_irq(drm_dev_to_irq(dev), dev->driver->irq_handler,
-                         sh_flags, irqname, dev);
+       ret = request_irq(irq, dev->driver->irq_handler,
+                         sh_flags, dev->driver->name, dev);
 
        if (ret < 0) {
                dev->irq_enabled = false;
@@ -301,7 +290,9 @@ int drm_irq_install(struct drm_device *dev)
                dev->irq_enabled = false;
                if (!drm_core_check_feature(dev, DRIVER_MODESET))
                        vga_client_register(dev->pdev, NULL, NULL, NULL);
-               free_irq(drm_dev_to_irq(dev), dev);
+               free_irq(irq, dev);
+       } else {
+               dev->irq = irq;
        }
 
        return ret;
@@ -344,7 +335,7 @@ int drm_irq_uninstall(struct drm_device *dev)
        if (!irq_enabled)
                return -EINVAL;
 
-       DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev));
+       DRM_DEBUG("irq=%d\n", dev->irq);
 
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                vga_client_register(dev->pdev, NULL, NULL, NULL);
@@ -352,7 +343,7 @@ int drm_irq_uninstall(struct drm_device *dev)
        if (dev->driver->irq_uninstall)
                dev->driver->irq_uninstall(dev);
 
-       free_irq(drm_dev_to_irq(dev), dev);
+       free_irq(dev->irq, dev);
 
        return 0;
 }
@@ -373,7 +364,7 @@ int drm_control(struct drm_device *dev, void *data,
                struct drm_file *file_priv)
 {
        struct drm_control *ctl = data;
-       int ret = 0;
+       int ret = 0, irq;
 
        /* if we haven't irq we fallback for compatibility reasons -
         * this used to be a separate function in drm_dma.h
@@ -389,11 +380,13 @@ int drm_control(struct drm_device *dev, void *data,
 
        switch (ctl->func) {
        case DRM_INST_HANDLER:
+               irq = dev->pdev->irq;
+
                if (dev->if_version < DRM_IF_VERSION(1, 2) &&
-                   ctl->irq != drm_dev_to_irq(dev))
+                   ctl->irq != irq)
                        return -EINVAL;
                mutex_lock(&dev->struct_mutex);
-               ret = drm_irq_install(dev);
+               ret = drm_irq_install(dev, irq);
                mutex_unlock(&dev->struct_mutex);
 
                return ret;