From 0fb851e46fabc71048def13b722b57903087daff Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 29 Apr 2025 16:31:47 +0200 Subject: [PATCH] xfree86: sbus: use CloseScreen hook Wrapping ScreenRec's function pointers is problematic for many reasons, so use the new screen close notify hook instead. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86sbusBus.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c index 3beb17dfc..e5641ca1c 100644 --- a/hw/xfree86/common/xf86sbusBus.c +++ b/hw/xfree86/common/xf86sbusBus.c @@ -624,7 +624,6 @@ static DevPrivateKeyRec sbusPaletteKeyRec; typedef struct _sbusCmap { sbusDevicePtr psdp; - CloseScreenProcPtr CloseScreen; Bool origCmapValid; unsigned char origRed[16]; unsigned char origGreen[16]; @@ -668,13 +667,18 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, free(data); } -static Bool -xf86SbusCmapCloseScreen(ScreenPtr pScreen) +static void xf86SbusCmapCloseScreen(CallbackListPtr *pcbl, + ScreenPtr pScreen, void *unused) { sbusCmapPtr cmap; struct fbcmap fbcmap; + dixScreenUnhook(pScreen, xf86SbusCmapCloseScreen); + cmap = SBUSCMAPPTR(pScreen); + if (!cmap) + return; + if (cmap->origCmapValid) { fbcmap.index = 0; fbcmap.count = 16; @@ -683,9 +687,8 @@ xf86SbusCmapCloseScreen(ScreenPtr pScreen) fbcmap.blue = cmap->origBlue; ioctl(cmap->psdp->fd, FBIOPUTCMAP, &fbcmap); } - pScreen->CloseScreen = cmap->CloseScreen; free(cmap); - return (*pScreen->CloseScreen) (pScreen); + dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, NULL); } Bool @@ -722,8 +725,7 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) data[1] = 255; } ioctl(psdp->fd, FBIOPUTCMAP, &fbcmap); - cmap->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = xf86SbusCmapCloseScreen; + dixScreenHookClose(pScreen, xf86SbusCmapCloseScreen); return xf86HandleColormaps(pScreen, 256, 8, xf86SbusCmapLoadPalette, NULL, 0); }