diff mbox series

[02/12] drm/pci: Hide legacy PCI functions from non-legacy code

Message ID 20191203100406.9674-3-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series [01/12] drm/pci: Only build drm_pci.c if CONFIG_PCI is set | expand

Commit Message

Thomas Zimmermann Dec. 3, 2019, 10:03 a.m. UTC
Declarations of drm_legacy_pci_{init,exit}() are being moved to
drm_legacy.h. CONFIG_DRM_LEGACY protects the implementation.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_pci.c |  4 ++++
 include/drm/drm_legacy.h  | 29 ++++++++++++++++++++++++++++-
 include/drm/drm_pci.h     | 15 ---------------
 3 files changed, 32 insertions(+), 16 deletions(-)

Comments

Emil Velikov Dec. 3, 2019, 11:06 a.m. UTC | #1
Hi Thomas,

On Tue, 3 Dec 2019 at 10:04, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Declarations of drm_legacy_pci_{init,exit}() are being moved to
> drm_legacy.h. CONFIG_DRM_LEGACY protects the implementation.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/gpu/drm/drm_pci.c |  4 ++++
>  include/drm/drm_legacy.h  | 29 ++++++++++++++++++++++++++++-
>  include/drm/drm_pci.h     | 15 ---------------
>  3 files changed, 32 insertions(+), 16 deletions(-)
>
How about we make this patch 01/12, this way we can avoid the current
case of - add code only to be moved in next patch.

As always - couple of ideas for follow-up cleanups.
 - drm_irq_by_busid() is legacy codebase (see the DRIVER_LEGACY check
at the top). How about we give it a _legacy_ name?
 - WE HAVE A FEW driver_features
Emil Velikov Dec. 3, 2019, 11:09 a.m. UTC | #2
On Tue, 3 Dec 2019 at 11:06, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>
> Hi Thomas,
>
> On Tue, 3 Dec 2019 at 10:04, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> >
> > Declarations of drm_legacy_pci_{init,exit}() are being moved to
> > drm_legacy.h. CONFIG_DRM_LEGACY protects the implementation.
> >
> > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> > ---
> >  drivers/gpu/drm/drm_pci.c |  4 ++++
> >  include/drm/drm_legacy.h  | 29 ++++++++++++++++++++++++++++-
> >  include/drm/drm_pci.h     | 15 ---------------
> >  3 files changed, 32 insertions(+), 16 deletions(-)
> >
> How about we make this patch 01/12, this way we can avoid the current
> case of - add code only to be moved in next patch.
>
> As always - couple of ideas for follow-up cleanups.
>  - drm_irq_by_busid() is legacy codebase (see the DRIVER_LEGACY check
> at the top). How about we give it a _legacy_ name?
>  - WE HAVE A FEW driver_features

Pardon there, the last one should read:
- We have a few instances that read driver_features directly, instead
of using the drm_core_check_feature() helper.
Might be a good idea to address those.

Just some nitpicks noticed while skimming through. It's not a
requirement by any means.

HTH
Emil
Thomas Zimmermann Dec. 3, 2019, 11:27 a.m. UTC | #3
Hi Emil

Am 03.12.19 um 12:09 schrieb Emil Velikov:
> On Tue, 3 Dec 2019 at 11:06, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>>
>> Hi Thomas,
>>
>> On Tue, 3 Dec 2019 at 10:04, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>>
>>> Declarations of drm_legacy_pci_{init,exit}() are being moved to
>>> drm_legacy.h. CONFIG_DRM_LEGACY protects the implementation.
>>>
>>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>>> ---
>>>  drivers/gpu/drm/drm_pci.c |  4 ++++
>>>  include/drm/drm_legacy.h  | 29 ++++++++++++++++++++++++++++-
>>>  include/drm/drm_pci.h     | 15 ---------------
>>>  3 files changed, 32 insertions(+), 16 deletions(-)
>>>
>> How about we make this patch 01/12, this way we can avoid the current
>> case of - add code only to be moved in next patch.

I tried. But before patch [01/12] drm_legacy_pci_init() in drm_pci.c is
protected by CONFIG_PCI, while drm_legacy_pci_exit() isn't. So moving
patch [02/12] first, makes things even more ugly.

>>
>> As always - couple of ideas for follow-up cleanups.
>>  - drm_irq_by_busid() is legacy codebase (see the DRIVER_LEGACY check
>> at the top). How about we give it a _legacy_ name?
>>  - WE HAVE A FEW driver_features
> 
> Pardon there, the last one should read:
> - We have a few instances that read driver_features directly, instead
> of using the drm_core_check_feature() helper.
> Might be a good idea to address those.

This specific patchset isn't about legacy, but PCI functions. But, yeah,
these things are good follow-up changes. If I need something quick and
simple to do before Christmas holidays... :)

Best regards
Thomas

> 
> Just some nitpicks noticed while skimming through. It's not a
> requirement by any means.
> 
> HTH
> Emil
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 40a2015abc77..f2e43d341980 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -282,6 +282,8 @@  int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 }
 EXPORT_SYMBOL(drm_get_pci_dev);
 
+#ifdef CONFIG_DRM_LEGACY
+
 /**
  * drm_legacy_pci_init - shadow-attach a legacy DRM PCI driver
  * @driver: DRM device driver
@@ -354,3 +356,5 @@  void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
 	DRM_INFO("Module unloaded\n");
 }
 EXPORT_SYMBOL(drm_legacy_pci_exit);
+
+#endif
diff --git a/include/drm/drm_legacy.h b/include/drm/drm_legacy.h
index 58dc0c04bf99..5745710453c8 100644
--- a/include/drm/drm_legacy.h
+++ b/include/drm/drm_legacy.h
@@ -38,7 +38,9 @@ 
 #include <drm/drm_hashtab.h>
 
 struct drm_device;
+struct drm_driver;
 struct file;
+struct pci_driver;
 
 /*
  * Legacy Support for palateontologic DRM drivers
@@ -188,8 +190,33 @@  do {										\
 void drm_legacy_idlelock_take(struct drm_lock_data *lock);
 void drm_legacy_idlelock_release(struct drm_lock_data *lock);
 
-/* drm_pci.c dma alloc wrappers */
+/* drm_pci.c */
+
+#ifdef CONFIG_PCI
+
 void __drm_legacy_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
+int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
+void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
+
+#else
+
+static inline void __drm_legacy_pci_free(struct drm_device *dev,
+					 drm_dma_handle_t *dmah)
+{
+}
+
+static inline int drm_legacy_pci_init(struct drm_driver *driver,
+				      struct pci_driver *pdriver)
+{
+	return -EINVAL;
+}
+
+static inline void drm_legacy_pci_exit(struct drm_driver *driver,
+				       struct pci_driver *pdriver)
+{
+}
+
+#endif
 
 /* drm_memory.c */
 void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev);
diff --git a/include/drm/drm_pci.h b/include/drm/drm_pci.h
index 029352f8c583..9031e217b506 100644
--- a/include/drm/drm_pci.h
+++ b/include/drm/drm_pci.h
@@ -38,7 +38,6 @@  struct drm_dma_handle;
 struct drm_device;
 struct drm_driver;
 struct drm_master;
-struct pci_device;
 
 #ifdef CONFIG_PCI
 
@@ -50,9 +49,6 @@  int drm_get_pci_dev(struct pci_dev *pdev,
 		    const struct pci_device_id *ent,
 		    struct drm_driver *driver);
 
-int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
-void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
-
 #else
 
 static inline struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev,
@@ -73,17 +69,6 @@  static inline int drm_get_pci_dev(struct pci_dev *pdev,
 	return -ENOSYS;
 }
 
-static inline int drm_legacy_pci_init(struct drm_driver *driver,
-				      struct pci_driver *pdriver)
-{
-	return -EINVAL;
-}
-
-static inline void drm_legacy_pci_exit(struct drm_driver *driver,
-				       struct pci_driver *pdriver)
-{
-}
-
 #endif
 
 #endif /* _DRM_PCI_H_ */