Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/arm/hdlcd: Simplify IRQ install/uninstall

Since we no longer need to conform to the structure of the various DRM
IRQ callbacks, we can streamline the code by consolidating the piecemeal
functions and passing around our private data structure directly. We're
also a platform device so should never see IRQ_NOTCONNECTED either.

Furthermore we can also get rid of all the unnecesary read-modify-write
operations, since on install we know we cleared the whole interrupt mask
before enabling the debug IRQs, and thus on uninstall we're always
clearing everything as well.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/65cf7818b23c1a8629dc851f1d058ecb8a14849e.1655309413.git.robin.murphy@arm.com

authored by

Robin Murphy and committed by
Liviu Dudau
f818eac1 4b760f76

+16 -46
+16 -46
drivers/gpu/drm/arm/hdlcd_drv.c
··· 41 41 42 42 static irqreturn_t hdlcd_irq(int irq, void *arg) 43 43 { 44 - struct drm_device *drm = arg; 45 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 44 + struct hdlcd_drm_private *hdlcd = arg; 46 45 unsigned long irq_status; 47 46 48 47 irq_status = hdlcd_read(hdlcd, HDLCD_REG_INT_STATUS); ··· 69 70 return IRQ_HANDLED; 70 71 } 71 72 72 - static void hdlcd_irq_preinstall(struct drm_device *drm) 73 - { 74 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 75 - /* Ensure interrupts are disabled */ 76 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, 0); 77 - hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, ~0); 78 - } 79 - 80 - static void hdlcd_irq_postinstall(struct drm_device *drm) 81 - { 82 - #ifdef CONFIG_DEBUG_FS 83 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 84 - unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 85 - 86 - /* enable debug interrupts */ 87 - irq_mask |= HDLCD_DEBUG_INT_MASK; 88 - 89 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 90 - #endif 91 - } 92 - 93 - static int hdlcd_irq_install(struct drm_device *drm, int irq) 73 + static int hdlcd_irq_install(struct hdlcd_drm_private *hdlcd) 94 74 { 95 75 int ret; 96 76 97 - if (irq == IRQ_NOTCONNECTED) 98 - return -ENOTCONN; 77 + /* Ensure interrupts are disabled */ 78 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, 0); 79 + hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, ~0); 99 80 100 - hdlcd_irq_preinstall(drm); 101 - 102 - ret = request_irq(irq, hdlcd_irq, 0, drm->driver->name, drm); 81 + ret = request_irq(hdlcd->irq, hdlcd_irq, 0, "hdlcd", hdlcd); 103 82 if (ret) 104 83 return ret; 105 84 106 - hdlcd_irq_postinstall(drm); 85 + #ifdef CONFIG_DEBUG_FS 86 + /* enable debug interrupts */ 87 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, HDLCD_DEBUG_INT_MASK); 88 + #endif 107 89 108 90 return 0; 109 91 } 110 92 111 - static void hdlcd_irq_uninstall(struct drm_device *drm) 93 + static void hdlcd_irq_uninstall(struct hdlcd_drm_private *hdlcd) 112 94 { 113 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 114 95 /* disable all the interrupts that we might have enabled */ 115 - unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 96 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, 0); 116 97 117 - #ifdef CONFIG_DEBUG_FS 118 - /* disable debug interrupts */ 119 - irq_mask &= ~HDLCD_DEBUG_INT_MASK; 120 - #endif 121 - 122 - /* disable vsync interrupts */ 123 - irq_mask &= ~HDLCD_INTERRUPT_VSYNC; 124 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 125 - 126 - free_irq(hdlcd->irq, drm); 98 + free_irq(hdlcd->irq, hdlcd); 127 99 } 128 100 129 101 static int hdlcd_load(struct drm_device *drm, unsigned long flags) ··· 154 184 goto irq_fail; 155 185 hdlcd->irq = ret; 156 186 157 - ret = hdlcd_irq_install(drm, hdlcd->irq); 187 + ret = hdlcd_irq_install(hdlcd); 158 188 if (ret < 0) { 159 189 DRM_ERROR("failed to install IRQ handler\n"); 160 190 goto irq_fail; ··· 315 345 err_unload: 316 346 of_node_put(hdlcd->crtc.port); 317 347 hdlcd->crtc.port = NULL; 318 - hdlcd_irq_uninstall(drm); 348 + hdlcd_irq_uninstall(hdlcd); 319 349 of_reserved_mem_device_release(drm->dev); 320 350 err_free: 321 351 drm_mode_config_cleanup(drm); ··· 337 367 hdlcd->crtc.port = NULL; 338 368 pm_runtime_get_sync(dev); 339 369 drm_atomic_helper_shutdown(drm); 340 - hdlcd_irq_uninstall(drm); 370 + hdlcd_irq_uninstall(hdlcd); 341 371 pm_runtime_put(dev); 342 372 if (pm_runtime_enabled(dev)) 343 373 pm_runtime_disable(dev);