diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2021-07-02 10:56:41 +0300 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2021-07-05 09:55:39 +0300 |
commit | 02d4b387cb5600fedb1c2fbe3b336d32b41f4664 (patch) | |
tree | 698b32cb12be9cf550a0cad92a4f82837794e004 /drivers | |
parent | 382d019d1022bc7e3b45c664a5545f21f6b85dc0 (diff) | |
download | linux-02d4b387cb5600fedb1c2fbe3b336d32b41f4664.tar.xz |
drm/mgag200: Extract device type and flags in mgag200_pci_probe()
The type and flags values are stored in the PCI ID list. Extract them
in the probe function. Makes the device initialization more readable.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210702075642.27834-4-tzimmermann@suse.de
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/mgag200/mgag200_drv.c | 21 | ||||
-rw-r--r-- | drivers/gpu/drm/mgag200/mgag200_drv.h | 12 |
2 files changed, 17 insertions, 16 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 2bbbf7d537a9..6b9243713b3c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -263,7 +263,7 @@ static void mgag200_g200se_init_unique_id(struct mga_device *mdev) } static struct mga_device * -mgag200_device_create(struct pci_dev *pdev, unsigned long flags) +mgag200_device_create(struct pci_dev *pdev, enum mga_type type, unsigned long flags) { struct mga_device *mdev; struct drm_device *dev; @@ -276,8 +276,8 @@ mgag200_device_create(struct pci_dev *pdev, unsigned long flags) pci_set_drvdata(pdev, dev); - mdev->flags = mgag200_flags_from_driver_data(flags); - mdev->type = mgag200_type_from_driver_data(flags); + mdev->flags = flags; + mdev->type = type; ret = mgag200_regs_init(mdev); if (ret) @@ -320,9 +320,22 @@ static const struct pci_device_id mgag200_pciidlist[] = { MODULE_DEVICE_TABLE(pci, mgag200_pciidlist); +static enum mga_type mgag200_type_from_driver_data(kernel_ulong_t driver_data) +{ + return (enum mga_type)(driver_data & MGAG200_TYPE_MASK); +} + +static unsigned long mgag200_flags_from_driver_data(kernel_ulong_t driver_data) +{ + return driver_data & MGAG200_FLAG_MASK; +} + static int mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { + kernel_ulong_t driver_data = ent->driver_data; + enum mga_type type = mgag200_type_from_driver_data(driver_data); + unsigned long flags = mgag200_flags_from_driver_data(driver_data); struct mga_device *mdev; struct drm_device *dev; int ret; @@ -335,7 +348,7 @@ mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) return ret; - mdev = mgag200_device_create(pdev, ent->driver_data); + mdev = mgag200_device_create(pdev, type, flags); if (IS_ERR(mdev)) return PTR_ERR(mdev); dev = &mdev->base; diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 749a075fe9e4..75ae1809fb5a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -192,18 +192,6 @@ static inline struct mga_device *to_mga_device(struct drm_device *dev) return container_of(dev, struct mga_device, base); } -static inline enum mga_type -mgag200_type_from_driver_data(kernel_ulong_t driver_data) -{ - return (enum mga_type)(driver_data & MGAG200_TYPE_MASK); -} - -static inline unsigned long -mgag200_flags_from_driver_data(kernel_ulong_t driver_data) -{ - return driver_data & MGAG200_FLAG_MASK; -} - /* mgag200_mode.c */ int mgag200_modeset_init(struct mga_device *mdev); |