[vbox-dev] [PATCH 5/7] Additions: linux/drm: Change vbox_irq.c to kernel coding style

Hans de Goede hdegoede at redhat.com
Thu Jun 8 19:08:12 GMT 2017


This is the result of running linux/scripts/Lindent + manual cleanups.
After this the file passes linux/scripts/checkpatch -f
except for the LINUX_VERSION_CODE checks.

This patch contains no functional changes, only coding style fixes,
including changing uintXX_t types to uXX.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/VBox/Additions/linux/drm/vbox_irq.c | 244 +++++++++++++++++---------------
 1 file changed, 133 insertions(+), 111 deletions(-)

diff --git a/src/VBox/Additions/linux/drm/vbox_irq.c b/src/VBox/Additions/linux/drm/vbox_irq.c
index 7fdf8660..c9b4079f 100644
--- a/src/VBox/Additions/linux/drm/vbox_irq.c
+++ b/src/VBox/Additions/linux/drm/vbox_irq.c
@@ -40,73 +40,87 @@
 
 static void vbox_clear_irq(void)
 {
-    outl((uint32_t)~0, VGA_PORT_HGSMI_HOST);
+	outl((u32)~0, VGA_PORT_HGSMI_HOST);
 }
 
-static uint32_t vbox_get_flags(struct vbox_private *vbox)
+static u32 vbox_get_flags(struct vbox_private *vbox)
 {
 	return readl(vbox->guest_heap + HOST_FLAGS_OFFSET);
 }
 
 void vbox_report_hotplug(struct vbox_private *vbox)
 {
-    schedule_work(&vbox->hotplug_work);
+	schedule_work(&vbox->hotplug_work);
 }
 
 irqreturn_t vbox_irq_handler(int irq, void *arg)
 {
-    struct drm_device *dev = (struct drm_device *) arg;
-    struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
-    uint32_t host_flags = vbox_get_flags(vbox);
-
-    if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
-        return IRQ_NONE;
-
-    /* Due to a bug in the initial host implementation of hot-plug interrupts,
-     * the hot-plug and cursor capability flags were never cleared.  Fortunately
-     * we can tell when they would have been set by checking that the VSYNC flag
-     * is not set. */
-    if (   host_flags & (HGSMIHOSTFLAGS_HOTPLUG | HGSMIHOSTFLAGS_CURSOR_CAPABILITIES)
-        && !(host_flags & HGSMIHOSTFLAGS_VSYNC))
-        vbox_report_hotplug(vbox);
-    vbox_clear_irq();
-    return IRQ_HANDLED;
+	struct drm_device *dev = (struct drm_device *)arg;
+	struct vbox_private *vbox = (struct vbox_private *)dev->dev_private;
+	u32 host_flags = vbox_get_flags(vbox);
+
+	if (!(host_flags & HGSMIHOSTFLAGS_IRQ))
+		return IRQ_NONE;
+
+	/*
+	 * Due to a bug in the initial host implementation of hot-plug irqs,
+	 * the hot-plug and cursor capability flags were never cleared.
+	 * Fortunately we can tell when they would have been set by checking
+	 * that the VSYNC flag is not set.
+	 */
+	if (host_flags &
+	    (HGSMIHOSTFLAGS_HOTPLUG | HGSMIHOSTFLAGS_CURSOR_CAPABILITIES) &&
+	    !(host_flags & HGSMIHOSTFLAGS_VSYNC))
+		vbox_report_hotplug(vbox);
+
+	vbox_clear_irq();
+
+	return IRQ_HANDLED;
 }
 
-/** Check that the position hints provided by the host are suitable for GNOME
+/**
+ * Check that the position hints provided by the host are suitable for GNOME
  * shell (i.e. all screens disjoint and hints for all enabled screens) and if
  * not replace them with default ones.  Providing valid hints improves the
- * chances that we will get a known screen layout for pointer mapping. */
+ * chances that we will get a known screen layout for pointer mapping.
+ */
 static void validate_or_set_position_hints(struct vbox_private *vbox)
 {
-    int i, j;
-    uint16_t currentx = 0;
-    bool valid = true;
-
-    for (i = 0; i < vbox->num_crtcs; ++i) {
-        for (j = 0; j < i; ++j) {
-            struct VBVAMODEHINT *hintsi = &vbox->last_mode_hints[i];
-            struct VBVAMODEHINT *hintsj = &vbox->last_mode_hints[j];
-
-            if (hintsi->fEnabled && hintsj->fEnabled) {
-                if ((hintsi->dx >= 0xffff || hintsi->dy >= 0xffff ||
-                     hintsj->dx >= 0xffff || hintsj->dy >= 0xffff) ||
-                    (hintsi->dx < hintsj->dx + (hintsj->cx & 0x8fff) &&
-                     hintsi->dx + (hintsi->cx & 0x8fff) > hintsj->dx) ||
-                    (hintsi->dy < hintsj->dy + (hintsj->cy & 0x8fff) &&
-                     hintsi->dy + (hintsi->cy & 0x8fff) > hintsj->dy))
-                    valid = false;
-            }
-        }
-    }
-    if (!valid)
-        for (i = 0; i < vbox->num_crtcs; ++i) {
-            if (vbox->last_mode_hints[i].fEnabled) {
-                vbox->last_mode_hints[i].dx = currentx;
-                vbox->last_mode_hints[i].dy = 0;
-                currentx += vbox->last_mode_hints[i].cx & 0x8fff;
-            }
-        }
+	int i, j;
+	u16 currentx = 0;
+	bool valid = true;
+
+	for (i = 0; i < vbox->num_crtcs; ++i) {
+		for (j = 0; j < i; ++j) {
+			struct VBVAMODEHINT *hintsi = &vbox->last_mode_hints[i];
+			struct VBVAMODEHINT *hintsj = &vbox->last_mode_hints[j];
+
+			if (hintsi->fEnabled && hintsj->fEnabled) {
+				if (hintsi->dx >= 0xffff ||
+				    hintsi->dy >= 0xffff ||
+				    hintsj->dx >= 0xffff ||
+				    hintsj->dy >= 0xffff ||
+				    (hintsi->dx <
+					hintsj->dx + (hintsj->cx & 0x8fff) &&
+				     hintsi->dx + (hintsi->cx & 0x8fff) >
+					hintsj->dx) ||
+				    (hintsi->dy <
+					hintsj->dy + (hintsj->cy & 0x8fff) &&
+				     hintsi->dy + (hintsi->cy & 0x8fff) >
+					hintsj->dy))
+					valid = false;
+			}
+		}
+	}
+	if (!valid)
+		for (i = 0; i < vbox->num_crtcs; ++i) {
+			if (vbox->last_mode_hints[i].fEnabled) {
+				vbox->last_mode_hints[i].dx = currentx;
+				vbox->last_mode_hints[i].dy = 0;
+				currentx +=
+				    vbox->last_mode_hints[i].cx & 0x8fff;
+			}
+		}
 }
 
 /**
@@ -114,89 +128,97 @@ static void validate_or_set_position_hints(struct vbox_private *vbox)
  */
 static void vbox_update_mode_hints(struct vbox_private *vbox)
 {
-    struct drm_device *dev = vbox->dev;
-    struct drm_connector *connector;
-    struct vbox_connector *vbox_connector;
-    struct VBVAMODEHINT *hints;
-    uint16_t flags;
-    bool disconnected;
-    unsigned crtc_id;
-    int rc;
-
-    rc = VBoxHGSMIGetModeHints(vbox->guest_pool, vbox->num_crtcs,
-                               vbox->last_mode_hints);
-    if (RT_FAILURE(rc)) {
-        printk("vboxvideo: VBoxHGSMIGetModeHints failed, rc=%i.\n", rc);
-        return;
-    }
-    validate_or_set_position_hints(vbox);
+	struct drm_device *dev = vbox->dev;
+	struct drm_connector *connector;
+	struct vbox_connector *vbox_connector;
+	struct VBVAMODEHINT *hints;
+	u16 flags;
+	bool disconnected;
+	unsigned int crtc_id;
+	int rc;
+
+	rc = VBoxHGSMIGetModeHints(vbox->guest_pool, vbox->num_crtcs,
+				   vbox->last_mode_hints);
+	if (RT_FAILURE(rc)) {
+		DRM_ERROR("vboxvideo: VBoxHGSMIGetModeHints failed, rc=%i.\n",
+			  rc);
+		return;
+	}
+	validate_or_set_position_hints(vbox);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-    drm_modeset_lock_all(dev);
+	drm_modeset_lock_all(dev);
 #else
-    mutex_lock(&dev->mode_config.mutex);
+	mutex_lock(&dev->mode_config.mutex);
 #endif
-    list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-        vbox_connector = to_vbox_connector(connector);
-        hints = &vbox->last_mode_hints[vbox_connector->vbox_crtc->crtc_id];
-        if (hints->magic == VBVAMODEHINT_MAGIC) {
-            disconnected = !(hints->fEnabled);
-            crtc_id = vbox_connector->vbox_crtc->crtc_id;
-            flags =   VBVA_SCREEN_F_ACTIVE
-                    | (disconnected ? VBVA_SCREEN_F_DISABLED : VBVA_SCREEN_F_BLANK);
-            vbox_connector->mode_hint.width = hints->cx & 0x8fff;
-            vbox_connector->mode_hint.height = hints->cy & 0x8fff;
-            vbox_connector->vbox_crtc->x_hint = hints->dx;
-            vbox_connector->vbox_crtc->y_hint = hints->dy;
-            vbox_connector->mode_hint.disconnected = disconnected;
-            if (vbox_connector->vbox_crtc->disconnected != disconnected) {
-                VBoxHGSMIProcessDisplayInfo(vbox->guest_pool, crtc_id,
-                                            0, 0, 0, hints->cx * 4, hints->cx,
-                                            hints->cy, 0, flags);
-                vbox_connector->vbox_crtc->disconnected = disconnected;
-            }
-        }
-    }
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		vbox_connector = to_vbox_connector(connector);
+		hints =
+		    &vbox->last_mode_hints[vbox_connector->vbox_crtc->crtc_id];
+		if (hints->magic == VBVAMODEHINT_MAGIC) {
+			disconnected = !(hints->fEnabled);
+			crtc_id = vbox_connector->vbox_crtc->crtc_id;
+			flags = VBVA_SCREEN_F_ACTIVE
+			    | (disconnected ? VBVA_SCREEN_F_DISABLED :
+			       VBVA_SCREEN_F_BLANK);
+			vbox_connector->mode_hint.width = hints->cx & 0x8fff;
+			vbox_connector->mode_hint.height = hints->cy & 0x8fff;
+			vbox_connector->vbox_crtc->x_hint = hints->dx;
+			vbox_connector->vbox_crtc->y_hint = hints->dy;
+			vbox_connector->mode_hint.disconnected = disconnected;
+			if (vbox_connector->vbox_crtc->disconnected !=
+			    disconnected) {
+				VBoxHGSMIProcessDisplayInfo(vbox->guest_pool,
+							    crtc_id, 0, 0, 0,
+							    hints->cx * 4,
+							    hints->cx,
+							    hints->cy, 0,
+							    flags);
+				vbox_connector->vbox_crtc->disconnected =
+				    disconnected;
+			}
+		}
+	}
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-    drm_modeset_unlock_all(dev);
+	drm_modeset_unlock_all(dev);
 #else
-    mutex_unlock(&dev->mode_config.mutex);
+	mutex_unlock(&dev->mode_config.mutex);
 #endif
 }
 
 static void vbox_hotplug_worker(struct work_struct *work)
 {
-    struct vbox_private *vbox = container_of(work, struct vbox_private,
-                                             hotplug_work);
+	struct vbox_private *vbox = container_of(work, struct vbox_private,
+						 hotplug_work);
 
-    vbox_update_mode_hints(vbox);
-    drm_kms_helper_hotplug_event(vbox->dev);
+	vbox_update_mode_hints(vbox);
+	drm_kms_helper_hotplug_event(vbox->dev);
 }
 
 int vbox_irq_init(struct vbox_private *vbox)
 {
-    int ret;
+	int ret;
 
-    vbox_update_mode_hints(vbox);
+	vbox_update_mode_hints(vbox);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
-    ret = drm_irq_install(vbox->dev, vbox->dev->pdev->irq);
+	ret = drm_irq_install(vbox->dev, vbox->dev->pdev->irq);
 #else
-    ret = drm_irq_install(vbox->dev);
+	ret = drm_irq_install(vbox->dev);
 #endif
-    if (unlikely(ret != 0)) {
-        vbox_irq_fini(vbox);
-        DRM_ERROR("Failed installing irq: %d\n", ret);
-        return 1;
-    }
-    INIT_WORK(&vbox->hotplug_work, vbox_hotplug_worker);
-    vbox->isr_installed = true;
-    return 0;
+	if (unlikely(ret != 0)) {
+		vbox_irq_fini(vbox);
+		DRM_ERROR("Failed installing irq: %d\n", ret);
+		return 1;
+	}
+	INIT_WORK(&vbox->hotplug_work, vbox_hotplug_worker);
+	vbox->isr_installed = true;
+	return 0;
 }
 
 void vbox_irq_fini(struct vbox_private *vbox)
 {
-    if (vbox->isr_installed) {
-        drm_irq_uninstall(vbox->dev);
-        flush_work(&vbox->hotplug_work);
-        vbox->isr_installed = false;
-    }
+	if (vbox->isr_installed) {
+		drm_irq_uninstall(vbox->dev);
+		flush_work(&vbox->hotplug_work);
+		vbox->isr_installed = false;
+	}
 }
-- 
2.13.0




More information about the vbox-dev mailing list