mgag200: Various cleanups
Subsystems (3)
Thomas Zimmermann
maintainercover mgag200: Various cleanups
Cleanup several nits in the driver's init code. Also move constant data into the RO data segment. No functional changes.
Tested on mgag200 HW.
Thomas Zimmermann (4):
drm/mgag200: Don't pass flags to drm_dev_register() drm/mgag200: Inline mgag200_device_init()
drm/mgag200: Extract device type and flags in mgag200_pci_probe() drm/mgag200: Constify LUT for programming bpp
drivers/gpu/drm/mgag200/mgag200_drv.c | 62 +++++++++++++------------- drivers/gpu/drm/mgag200/mgag200_drv.h | 14 ------ drivers/gpu/drm/mgag200/mgag200_mode.c | 16 +++---- 3 files changed, 36 insertions(+), 56 deletions(-)
base-commit: 67f5a18128770817e4218a9e496d2bf5047c51e8 --
2.32.0
Thomas Zimmermann
maintainerPATCH 1/4 drm/mgag200: Don't pass flags to drm_dev_register()
The flags argument is only relevant for UMS drivers. Pass 0.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +1 -1
@@ -355,7 +355,7 @@ mgag200_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return PTR_ERR (mdev); dev = &mdev->base; - ret =drm_dev_register (dev, ent->driver_data); + ret =drm_dev_register (dev,0 );if (ret)return ret;
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 2/4 drm/mgag200: Inline mgag200_device_init()
In reply to Thomas ZimmermannInline mgag200_device_init() into mgag200_device_create(), which is the only caller.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 41 +++++++++------------------ 1 file changed, 13 insertions(+), 28 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +13 -28
@@ -262,17 +262,26 @@ static void mgag200_g200se_init_unique_id(struct mga_device *mdev) mdev->model.g200se.unique_rev_id); } -static int mgag200_device_init (struct mga_device *mdev,unsigned long flags) +static struct mga_device * +mgag200_device_create (struct pci_dev *pdev,unsigned long flags) { -struct drm_device *dev = &mdev->base; +struct mga_device *mdev; +struct drm_device *dev;int ret; + mdev = devm_drm_dev_alloc(&pdev->dev, &mgag200_driver, struct mga_device, base); +if (IS_ERR (mdev)) +return mdev; + dev = &mdev->base; + +pci_set_drvdata (pdev, dev); + mdev->flags =mgag200_flags_from_driver_data (flags); mdev->type =mgag200_type_from_driver_data (flags); ret =mgag200_regs_init (mdev);if (ret) -return ret; +return ERR_PTR (ret);if (mdev->type ==G200_PCI || mdev->type ==G200_AGP )mgag200_g200_init_refclk (mdev);
@@ -281,33 +290,9 @@ static int mgag200_device_init(struct mga_device *mdev, unsigned long flags) ret =mgag200_mm_init (mdev);if (ret) -return ret; +return ERR_PTR (ret); ret =mgag200_modeset_init (mdev); -if (ret) { -drm_err (dev,"Fatal error during modeset init: %d\n" , ret); -return ret; - } - -return 0 ; -} - -static struct mga_device * -mgag200_device_create (struct pci_dev *pdev,unsigned long flags) -{ -struct drm_device *dev; -struct mga_device *mdev; -int ret; - - mdev =devm_drm_dev_alloc (&pdev->dev, &mgag200_driver, - struct mga_device, base); -if (IS_ERR (mdev)) -return mdev; - dev = &mdev->base; - -pci_set_drvdata (pdev, dev); - - ret =mgag200_device_init (mdev, flags);if (ret)return ERR_PTR (ret);
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 3/4 drm/mgag200: Extract device type and flags in mgag200_pci_probe()
In reply to Thomas ZimmermannThe type and flags values are stored in the PCI ID list. Extract them in the probe function. Makes the device initialization more readable.
--- drivers/gpu/drm/mgag200/mgag200_drv.c | 21 +++++++++++++++++---- drivers/gpu/drm/mgag200/mgag200_drv.h | 12 ------------ 2 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +17 -4
@@ -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;
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -12
@@ -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);
Signature · 1 line
2.32.0
Thomas Zimmermann
maintainerPATCH 4/4 drm/mgag200: Constify LUT for programming bpp
In reply to Thomas ZimmermannDeclare constant LUT for bpp programming as static const. Removes mutable data from device structure.
--- drivers/gpu/drm/mgag200/mgag200_drv.h | 2 -- drivers/gpu/drm/mgag200/mgag200_mode.c | 16 ++++++---------- 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -2
@@ -166,8 +166,6 @@ struct mga_device {enum mga_type type; -int bpp_shifts[4 ]; -int fb_mtrr;union {
drivers/gpu/drm/mgag200/mgag200_mode.c +6 -10
@@ -1137,10 +1137,11 @@ static void mgag200_set_mode_regs(struct mga_device *mdev,WREG8 (MGA_MISC_OUT , misc); } -static u8 mgag200_get_bpp_shift (struct mga_device *mdev, -const struct drm_format_info *format) +static u8 mgag200_get_bpp_shift (const struct drm_format_info *format) { -return mdev->bpp_shifts[format->cpp[0 ] -1 ]; +static const u8 bpp_shift[] = {0 ,1 ,0 ,2 }; + +return bpp_shift[format->cpp[0 ] -1 ]; }/*
@@ -1152,7 +1153,7 @@ static u32 mgag200_calculate_offset(struct mga_device *mdev, const struct drm_framebuffer *fb) {u32 offset = fb->pitches[0 ] / fb->format->cpp[0 ]; -u8 bppshift =mgag200_get_bpp_shift (mdev, fb->format); +u8 bppshift =mgag200_get_bpp_shift (fb->format);if (fb->format->cpp[0 ] *8 ==24 ) offset = (offset *3 ) >> (4 - bppshift);
@@ -1189,7 +1190,7 @@ static void mgag200_set_format_regs(struct mga_device *mdev, bpp = format->cpp[0 ] *8 ; - bppshift =mgag200_get_bpp_shift (mdev, format); + bppshift =mgag200_get_bpp_shift (format);switch (bpp) {case 24 : scale = ((1 << bppshift) *3 ) -1 ;
@@ -1699,11 +1700,6 @@ int mgag200_modeset_init(struct mga_device *mdev)size_t format_count =ARRAY_SIZE (mgag200_simple_display_pipe_formats);int ret; - mdev->bpp_shifts[0 ] =0 ; - mdev->bpp_shifts[1 ] =1 ; - mdev->bpp_shifts[2 ] =0 ; - mdev->bpp_shifts[3 ] =2 ; -mgag200_init_regs (mdev); ret =drmm_mode_config_init (dev);
Signature · 1 line
2.32.0
Hi Thomas,
Quoted 8 lines · Thomas Zimmermann
Cleanup several nits in the driver's init code. Also move constant data into the RO data segment. No functional changes.
Tested on mgag200 HW.
Thomas Zimmermann (4):
drm/mgag200: Don't pass flags todrm_dev_register()drm/mgag200: Inlinemgag200_device_init()
This patch drop a redundant error message too - it had helped me if the changelog had said so but whatever.
Quoted 2 lines
drm/mgag200: Extract device type and flags in
mgag200_pci_probe()drm/mgag200: Constify LUT for programming bpp
Full serie is:
Sam
Thomas Zimmermann
maintainerHi Sam
Am 01.07.21 um 19:58 schrieb Sam Ravnborg:
Quoted 6 lines
Hi Thomas,
Quoted 3 lines · Thomas Zimmermann
Cleanup several nits in the driver's init code. Also move constant data into the RO data segment. No functional changes.
Quoted 7 lines
Quoted 5 lines
Tested on mgag200 HW.
Thomas Zimmermann (4):
drm/mgag200: Don't pass flags todrm_dev_register()drm/mgag200: Inlinemgag200_device_init()This patch drop a redundant error message too - it had helped me if the changelog had said so but whatever.
Sure, I'll add it to the log.
Quoted 6 lines
Quoted 3 lines
drm/mgag200: Extract device type and flags in
mgag200_pci_probe()drm/mgag200: Constify LUT for programming bppFull serie is:
Acked-by Sam Ravnborg <[email protected]>
Thanks for the review.
Best regards
Thomas
Quoted 3 lines
Sam
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer