]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/gma500: Embed struct drm_device in struct drm_psb_private
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 20 Sep 2021 14:10:49 +0000 (16:10 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Thu, 23 Sep 2021 07:40:39 +0000 (09:40 +0200)
Embed struct drm_device in struct drm_psb_private. Replace the use
of dev_private by an upcast operation. Switch to managed release of
struct drm_psb_private.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210920141051.30988-4-tzimmermann@suse.de
drivers/gpu/drm/gma500/cdv_device.c
drivers/gpu/drm/gma500/intel_bios.c
drivers/gpu/drm/gma500/intel_gmbus.c
drivers/gpu/drm/gma500/mid_bios.c
drivers/gpu/drm/gma500/opregion.c
drivers/gpu/drm/gma500/psb_drv.c
drivers/gpu/drm/gma500/psb_drv.h
drivers/gpu/drm/gma500/psb_irq.c
drivers/gpu/drm/gma500/psb_lid.c

index ce8215e0b1c1d59cafab63821673139629c46bac..d7c6cca23e943c304397d89a73e742d9bd4921b6 100644 (file)
@@ -429,7 +429,7 @@ static void cdv_hotplug_work_func(struct work_struct *work)
 {
         struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private,
                                                        hotplug_work);
-        struct drm_device *dev = dev_priv->dev;
+       struct drm_device *dev = &dev_priv->dev;
 
         /* Just fire off a uevent and let userspace tell us what to do */
         drm_helper_hpd_irq_event(dev);
index ebc7dd82830222a2111ae7ab56d3614dccfceefd..d5ca5f2419740dcb07fac58864b3f0d5603e07aa 100644 (file)
@@ -207,7 +207,7 @@ static void parse_backlight_data(struct drm_psb_private *dev_priv,
 
        lvds_bl = kmemdup(vbt_lvds_bl, sizeof(*vbt_lvds_bl), GFP_KERNEL);
        if (!lvds_bl) {
-               dev_err(dev_priv->dev->dev, "out of memory for backlight data\n");
+               dev_err(dev_priv->dev.dev, "out of memory for backlight data\n");
                return;
        }
        dev_priv->lvds_bl = lvds_bl;
@@ -248,7 +248,7 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
        panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode),
                                      GFP_KERNEL);
        if (panel_fixed_mode == NULL) {
-               dev_err(dev_priv->dev->dev, "out of memory for fixed panel mode\n");
+               dev_err(dev_priv->dev.dev, "out of memory for fixed panel mode\n");
                return;
        }
 
@@ -259,7 +259,7 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
                dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
                drm_mode_debug_printmodeline(panel_fixed_mode);
        } else {
-               dev_dbg(dev_priv->dev->dev, "ignoring invalid LVDS VBT\n");
+               dev_dbg(dev_priv->dev.dev, "ignoring invalid LVDS VBT\n");
                dev_priv->lvds_vbt = 0;
                kfree(panel_fixed_mode);
        }
index 413a18cdd6d6b3e88815e34b206db1d40a8f941d..09cedabf4776dffb065a74157a8a04a857b77047 100644 (file)
@@ -196,7 +196,7 @@ intel_gpio_create(struct drm_psb_private *dev_priv, u32 pin)
                 "gma500 GPIO%c", "?BACDE?F"[pin]);
        gpio->adapter.owner = THIS_MODULE;
        gpio->adapter.algo_data = &gpio->algo;
-       gpio->adapter.dev.parent = dev_priv->dev->dev;
+       gpio->adapter.dev.parent = dev_priv->dev.dev;
        gpio->algo.setsda = set_data;
        gpio->algo.setscl = set_clock;
        gpio->algo.getsda = get_data;
@@ -226,7 +226,7 @@ intel_i2c_quirk_xfer(struct drm_psb_private *dev_priv,
                                               adapter);
        int ret;
 
-       gma_intel_i2c_reset(dev_priv->dev);
+       gma_intel_i2c_reset(&dev_priv->dev);
 
        intel_i2c_quirk_set(dev_priv, true);
        set_data(gpio, 1);
@@ -432,7 +432,7 @@ int gma_intel_setup_gmbus(struct drm_device *dev)
                bus->force_bit = intel_gpio_create(dev_priv, i);
        }
 
-       gma_intel_i2c_reset(dev_priv->dev);
+       gma_intel_i2c_reset(&dev_priv->dev);
 
        return 0;
 
index bdc57b9070ec00b9e238da142634d60fb50a2fa9..7e76790c6a81fac1f95c9d09811bdceb03490f8c 100644 (file)
@@ -94,7 +94,7 @@ static void mid_get_fuse_settings(struct drm_device *dev)
 static void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 {
        uint32_t platform_rev_id = 0;
-       struct pci_dev *pdev = to_pci_dev(dev_priv->dev->dev);
+       struct pci_dev *pdev = to_pci_dev(dev_priv->dev.dev);
        int domain = pci_domain_nr(pdev->bus);
        struct pci_dev *pci_gfx_root =
                pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(2, 0));
@@ -106,8 +106,7 @@ static void mid_get_pci_revID(struct drm_psb_private *dev_priv)
        pci_read_config_dword(pci_gfx_root, 0x08, &platform_rev_id);
        dev_priv->platform_rev_id = (uint8_t) platform_rev_id;
        pci_dev_put(pci_gfx_root);
-       dev_dbg(dev_priv->dev->dev, "platform_rev_id is %x\n",
-                                       dev_priv->platform_rev_id);
+       dev_dbg(dev_priv->dev.dev, "platform_rev_id is %x\n", dev_priv->platform_rev_id);
 }
 
 struct mid_vbt_header {
@@ -270,7 +269,7 @@ out:
 
 static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 {
-       struct drm_device *dev = dev_priv->dev;
+       struct drm_device *dev = &dev_priv->dev;
        struct pci_dev *pdev = to_pci_dev(dev->dev);
        u32 addr;
        u8 __iomem *vbt_virtual;
index c81927c6b2eb6c1b3bb6b0a10eb45d1596d00deb..fef04ff8c3a9bb1f0b04c9bb802b9f7996494898 100644 (file)
@@ -190,7 +190,7 @@ static void psb_intel_opregion_asle_work(struct work_struct *work)
        }
 
        if (asle_req & ASLE_SET_BACKLIGHT)
-               asle_stat |= asle_set_backlight(dev_priv->dev, asle->bclp);
+               asle_stat |= asle_set_backlight(&dev_priv->dev, asle->bclp);
 
        asle->aslc = asle_stat;
 
index 80ef2f0562c375bc866452b95abf3d326b11d75d..48967bbc45016391cb5edd7faad9dff87e98512e 100644 (file)
@@ -217,9 +217,6 @@ static void psb_driver_unload(struct drm_device *dev)
 
                /* Destroy VBT data */
                psb_intel_destroy_bios(dev);
-
-               kfree(dev_priv);
-               dev->dev_private = NULL;
        }
        gma_power_uninit(dev);
 }
@@ -227,7 +224,7 @@ static void psb_driver_unload(struct drm_device *dev)
 static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 {
        struct pci_dev *pdev = to_pci_dev(dev->dev);
-       struct drm_psb_private *dev_priv;
+       struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
        unsigned long resource_start, resource_len;
        unsigned long irqflags;
        int ret = -ENOMEM;
@@ -235,14 +232,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
        struct gma_encoder *gma_encoder;
        struct psb_gtt *pg;
 
-       /* allocating and initializing driver private data */
-       dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
-       if (dev_priv == NULL)
-               return -ENOMEM;
+       /* initializing driver private data */
 
        dev_priv->ops = (struct psb_ops *)flags;
-       dev_priv->dev = dev;
-       dev->dev_private = (void *) dev_priv;
 
        pg = &dev_priv->gtt;
 
@@ -445,6 +437,7 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
 
 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
+       struct drm_psb_private *dev_priv;
        struct drm_device *dev;
        int ret;
 
@@ -452,15 +445,16 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (ret)
                return ret;
 
-       dev = drm_dev_alloc(&driver, &pdev->dev);
-       if (IS_ERR(dev))
+       dev_priv = devm_drm_dev_alloc(&pdev->dev, &driver, struct drm_psb_private, dev);
+       if (IS_ERR(dev_priv))
                return PTR_ERR(dev);
+       dev = &dev_priv->dev;
 
        pci_set_drvdata(pdev, dev);
 
        ret = psb_driver_load(dev, ent->driver_data);
        if (ret)
-               goto err_drm_dev_put;
+               return ret;
 
        ret = drm_dev_register(dev, ent->driver_data);
        if (ret)
@@ -470,8 +464,6 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 err_psb_driver_unload:
        psb_driver_unload(dev);
-err_drm_dev_put:
-       drm_dev_put(dev);
        return ret;
 }
 
@@ -481,7 +473,6 @@ static void psb_pci_remove(struct pci_dev *pdev)
 
        drm_dev_unregister(dev);
        psb_driver_unload(dev);
-       drm_dev_put(dev);
 }
 
 static const struct dev_pm_ops psb_pm_ops = {
index 469f277de4d52f1f90e67eba1f7a1f4b03bbb1ea..0439b10d3db5429cf422b7554c73b782b380970b 100644 (file)
@@ -389,7 +389,8 @@ struct psb_ops;
 struct intel_scu_ipc_dev;
 
 struct drm_psb_private {
-       struct drm_device *dev;
+       struct drm_device dev;
+
        struct pci_dev *aux_pdev; /* Currently only used by mrst */
        struct pci_dev *lpc_pdev; /* Currently only used by mrst */
        const struct psb_ops *ops;
@@ -569,7 +570,7 @@ struct drm_psb_private {
 
 static inline struct drm_psb_private *to_drm_psb_private(struct drm_device *dev)
 {
-       return dev->dev_private;
+       return container_of(dev, struct drm_psb_private, dev);
 }
 
 /* Operations for each board type */
index 32ec0a42daa70fd588d7410a9c7d292dc0af2341..ccf402007beb295ad13a05c48f5828530b91e2bf 100644 (file)
@@ -76,12 +76,12 @@ psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
                u32 reg = psb_pipestat(pipe);
                dev_priv->pipestat[pipe] |= mask;
                /* Enable the interrupt, clear any pending status */
-               if (gma_power_begin(dev_priv->dev, false)) {
+               if (gma_power_begin(&dev_priv->dev, false)) {
                        u32 writeVal = PSB_RVDC32(reg);
                        writeVal |= (mask | (mask >> 16));
                        PSB_WVDC32(writeVal, reg);
                        (void) PSB_RVDC32(reg);
-                       gma_power_end(dev_priv->dev);
+                       gma_power_end(&dev_priv->dev);
                }
        }
 }
@@ -92,12 +92,12 @@ psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
        if ((dev_priv->pipestat[pipe] & mask) != 0) {
                u32 reg = psb_pipestat(pipe);
                dev_priv->pipestat[pipe] &= ~mask;
-               if (gma_power_begin(dev_priv->dev, false)) {
+               if (gma_power_begin(&dev_priv->dev, false)) {
                        u32 writeVal = PSB_RVDC32(reg);
                        writeVal &= ~mask;
                        PSB_WVDC32(writeVal, reg);
                        (void) PSB_RVDC32(reg);
-                       gma_power_end(dev_priv->dev);
+                       gma_power_end(&dev_priv->dev);
                }
        }
 }
index 97b0c52bfd8a84e2f9a6ed6f7e7a9317f989c838..58a7fe39263601bbf052e1029ebf68099cd819cf 100644 (file)
@@ -14,7 +14,7 @@
 static void psb_lid_timer_func(struct timer_list *t)
 {
        struct drm_psb_private *dev_priv = from_timer(dev_priv, t, lid_timer);
-       struct drm_device *dev = (struct drm_device *)dev_priv->dev;
+       struct drm_device *dev = (struct drm_device *)&dev_priv->dev;
        struct timer_list *lid_timer = &dev_priv->lid_timer;
        unsigned long irq_flags;
        u32 __iomem *lid_state = dev_priv->opregion.lid_state;