Skip to contentSkip to conversation

vga_switcheroo: Constify vga_switcheroo_handler

PATCH New Lukas Wunner 4 participants 4 messages Oct 18, 2015 – Oct 20, 2015 1 message not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover vga_switcheroo: Constify vga_switcheroo_handler

Another vga_switcheroo cleanup. Maintainers, is it okay to include the one-line change of each driver in here or do you want that split into separate patches?

Thanks,

Lukas

Lukas Wunner (1):
vga_switcheroo: Constify vga_switcheroo_handler

 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_acpi.c           | 2 +-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 2 +-
 drivers/gpu/vga/vga_switcheroo.c                 | 4 ++--
 drivers/platform/x86/apple-gmux.c                | 2 +-
 include/linux/vga_switcheroo.h                   | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
Signature · 6 lines
2.1.0

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
reviewer
#1 lore raw

PATCH 1/1 vga_switcheroo: Constify vga_switcheroo_handler

vga_switcheroo_client_ops has always been declared const since its introduction with 26ec685ff9d9 ("vga_switcheroo: Introduce struct vga_switcheroo_client_ops").

Do so for vga_switcheroo_handler as well.

drivers/gpu/drm/amd/amdgpu/amdgpu.ko:

   6 .rodata       00009888
- 19 .data         00001f00
+ 19 .data         00001ee0
 drivers/gpu/drm/nouveau/nouveau.ko:
   6 .rodata       000460b8
  17 .data         00018fe0
 drivers/gpu/drm/radeon/radeon.ko:
-  7 .rodata       00030944
+  7 .rodata       00030964
- 21 .data         0000d6a0
+ 21 .data         0000d678
 drivers/platform/x86/apple-gmux.ko:
-  7 .rodata       00000140
+  7 .rodata       00000160
- 11 .data         000000e0
+ 11 .data         000000b8
Cc Ben Skeggs <[email protected]>
Cc Darren Hart <[email protected]>
Cc Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_acpi.c           | 2 +-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 2 +-
 drivers/gpu/vga/vga_switcheroo.c                 | 4 ++--
 drivers/platform/x86/apple-gmux.c                | 2 +-
 include/linux/vga_switcheroo.h                   | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +1 -1
index 3f7aaa4..dc565a4 100644
@@ -501,7 +501,7 @@ static int amdgpu_atpx_get_client_id(struct pci_dev *pdev)
 		return VGA_SWITCHEROO_DIS;
 }
 
-static struct vga_switcheroo_handler amdgpu_atpx_handler = {
+static const struct vga_switcheroo_handler amdgpu_atpx_handler = {
 	.switchto = amdgpu_atpx_switchto,
 	.power_state = amdgpu_atpx_power_state,
 	.init = amdgpu_atpx_init,
drivers/gpu/drm/nouveau/nouveau_acpi.c +1 -1
index df2d981..8b8332e 100644
@@ -206,7 +206,7 @@ static int nouveau_dsm_get_client_id(struct pci_dev *pdev)
 	return VGA_SWITCHEROO_DIS;
 }
 
-static struct vga_switcheroo_handler nouveau_dsm_handler = {
+static const struct vga_switcheroo_handler nouveau_dsm_handler = {
 	.switchto = nouveau_dsm_switchto,
 	.power_state = nouveau_dsm_power_state,
 	.get_client_id = nouveau_dsm_get_client_id,
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -1
index 8bc7d0b..714508a 100644
@@ -499,7 +499,7 @@ static int radeon_atpx_get_client_id(struct pci_dev *pdev)
 		return VGA_SWITCHEROO_DIS;
 }
 
-static struct vga_switcheroo_handler radeon_atpx_handler = {
+static const struct vga_switcheroo_handler radeon_atpx_handler = {
 	.switchto = radeon_atpx_switchto,
 	.power_state = radeon_atpx_power_state,
 	.init = radeon_atpx_init,
drivers/gpu/vga/vga_switcheroo.c +2 -2
index af0d372..56bbbd6 100644
@@ -140,7 +140,7 @@ struct vgasr_priv {
 	int registered_clients;
 	struct list_head clients;
 
-	struct vga_switcheroo_handler *handler;
+	const struct vga_switcheroo_handler *handler;
 };
 
 #define ID_BIT_AUDIO		0x100
@@ -195,7 +195,7 @@ static void vga_switcheroo_enable(void)
  *
  * Return: 0 on success, -EINVAL if a handler was already registered.
  */
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler)
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler)
 {
 	mutex_lock(&vgasr_mutex);
 	if (vgasr_priv.handler) {
drivers/platform/x86/apple-gmux.c +1 -1
index 0dec3f5..976efeb 100644
@@ -346,7 +346,7 @@ gmux_active_client(struct apple_gmux_data *gmux_data)
 	return VGA_SWITCHEROO_DIS;
 }
 
-static struct vga_switcheroo_handler gmux_handler = {
+static const struct vga_switcheroo_handler gmux_handler = {
 	.switchto = gmux_switchto,
 	.power_state = gmux_set_power_state,
 	.get_client_id = gmux_get_client_id,
include/linux/vga_switcheroo.h +2 -2
index c557511..786bc93 100644
@@ -137,7 +137,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
 				  struct fb_info *info);
 
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler);
 void vga_switcheroo_unregister_handler(void);
 
 int vga_switcheroo_process_delayed_switch(void);
@@ -155,7 +155,7 @@ static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
 static inline int vga_switcheroo_register_client(struct pci_dev *dev,
 		const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; }
 static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
-static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
+static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 	const struct vga_switcheroo_client_ops *ops,
 	enum vga_switcheroo_client_id id) { return 0; }
Signature · 6 lines
2.1.0

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 24 lines · Lukas Wunner

vga_switcheroo_client_ops has always been declared const since its introduction with 26ec685ff9d9 ("vga_switcheroo: Introduce struct vga_switcheroo_client_ops").

Do so for vga_switcheroo_handler as well.

drivers/gpu/drm/amd/amdgpu/amdgpu.ko:

    6 .rodata       00009888
- 19 .data         00001f00
+ 19 .data         00001ee0
  drivers/gpu/drm/nouveau/nouveau.ko:
    6 .rodata       000460b8

17 .data 00018fe0
drivers/gpu/drm/radeon/radeon.ko:

(quoted diff) +4 -4
-  7 .rodata       00030944
+  7 .rodata       00030964
- 21 .data         0000d6a0
+ 21 .data         0000d678
  drivers/platform/x86/apple-gmux.ko:
-  7 .rodata       00000140
+  7 .rodata       00000160
- 11 .data         000000e0
+ 11 .data         000000b8
Quoted 4 lines
Cc Ben Skeggs <[email protected]>
Cc Darren Hart <[email protected]>
Cc Alex Deucher <[email protected]>

Looks like it makes sense and at least I don't need this split up between drivers.

Patch is Reviewed-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 97 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 2 +-
  drivers/gpu/drm/nouveau/nouveau_acpi.c           | 2 +-
  drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 2 +-
  drivers/gpu/vga/vga_switcheroo.c                 | 4 ++--
  drivers/platform/x86/apple-gmux.c                | 2 +-
  include/linux/vga_switcheroo.h                   | 4 ++--
  6 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +1 -1
index 3f7aaa4..dc565a4 100644
@@ -501,7 +501,7 @@ static int amdgpu_atpx_get_client_id(struct pci_dev *pdev)
  		return VGA_SWITCHEROO_DIS;
  }
 
-static struct vga_switcheroo_handler amdgpu_atpx_handler = {
+static const struct vga_switcheroo_handler amdgpu_atpx_handler = {
  	.switchto = amdgpu_atpx_switchto,
  	.power_state = amdgpu_atpx_power_state,
  	.init = amdgpu_atpx_init,
drivers/gpu/drm/nouveau/nouveau_acpi.c +1 -1
index df2d981..8b8332e 100644
@@ -206,7 +206,7 @@ static int nouveau_dsm_get_client_id(struct pci_dev *pdev)
  	return VGA_SWITCHEROO_DIS;
  }
 
-static struct vga_switcheroo_handler nouveau_dsm_handler = {
+static const struct vga_switcheroo_handler nouveau_dsm_handler = {
  	.switchto = nouveau_dsm_switchto,
  	.power_state = nouveau_dsm_power_state,
  	.get_client_id = nouveau_dsm_get_client_id,
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -1
index 8bc7d0b..714508a 100644
@@ -499,7 +499,7 @@ static int radeon_atpx_get_client_id(struct pci_dev *pdev)
  		return VGA_SWITCHEROO_DIS;
  }
 
-static struct vga_switcheroo_handler radeon_atpx_handler = {
+static const struct vga_switcheroo_handler radeon_atpx_handler = {
  	.switchto = radeon_atpx_switchto,
  	.power_state = radeon_atpx_power_state,
  	.init = radeon_atpx_init,
drivers/gpu/vga/vga_switcheroo.c +2 -2
index af0d372..56bbbd6 100644
@@ -140,7 +140,7 @@ struct vgasr_priv {
  	int registered_clients;
  	struct list_head clients;
 
-	struct vga_switcheroo_handler *handler;
+	const struct vga_switcheroo_handler *handler;
  };
 
  #define ID_BIT_AUDIO		0x100
@@ -195,7 +195,7 @@ static void vga_switcheroo_enable(void)
   *
   * Return: 0 on success, -EINVAL if a handler was already registered.
   */
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler)
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler)
  {
  	mutex_lock(&vgasr_mutex);
  	if (vgasr_priv.handler) {
drivers/platform/x86/apple-gmux.c +1 -1
index 0dec3f5..976efeb 100644
@@ -346,7 +346,7 @@ gmux_active_client(struct apple_gmux_data *gmux_data)
  	return VGA_SWITCHEROO_DIS;
  }
 
-static struct vga_switcheroo_handler gmux_handler = {
+static const struct vga_switcheroo_handler gmux_handler = {
  	.switchto = gmux_switchto,
  	.power_state = gmux_set_power_state,
  	.get_client_id = gmux_get_client_id,
include/linux/vga_switcheroo.h +1 -1
index c557511..786bc93 100644
@@ -137,7 +137,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
  void vga_switcheroo_client_fb_set(struct pci_dev *dev,
  				  struct fb_info *info);
 
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler);
  void vga_switcheroo_unregister_handler(void);
 
  int vga_switcheroo_process_delayed_switch(void);

include/linux/vga_switcheroo.h static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} · line 161

Quoted 8 lines
include/linux/vga_switcheroo.h +1 -1
@@ -155,7 +155,7 @@ static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
  static inline int vga_switcheroo_register_client(struct pci_dev *dev,
  		const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; }
  static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
-static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
+static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler) { return 0; }
  static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
  	const struct vga_switcheroo_client_ops *ops,
  	enum vga_switcheroo_client_id id) { return 0; }

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 30 lines · Christian König
Quoted 24 lines · Lukas Wunner

vga_switcheroo_client_ops has always been declared const since its introduction with 26ec685ff9d9 ("vga_switcheroo: Introduce struct vga_switcheroo_client_ops").

Do so for vga_switcheroo_handler as well.

drivers/gpu/drm/amd/amdgpu/amdgpu.ko:

   6 .rodata       00009888
- 19 .data         00001f00
+ 19 .data         00001ee0
 drivers/gpu/drm/nouveau/nouveau.ko:
   6 .rodata       000460b8

17 .data 00018fe0
drivers/gpu/drm/radeon/radeon.ko:

(quoted diff) +4 -4
-  7 .rodata       00030944
+  7 .rodata       00030964
- 21 .data         0000d6a0
+ 21 .data         0000d678
 drivers/platform/x86/apple-gmux.ko:
-  7 .rodata       00000140
+  7 .rodata       00000160
- 11 .data         000000e0
+ 11 .data         000000b8
Quoted 4 lines
Cc Ben Skeggs <[email protected]>
Cc Darren Hart <[email protected]>
Cc Alex Deucher <[email protected]>
Quoted 4 lines

Looks like it makes sense and at least I don't need this split up between drivers.

Patch is Reviewed-by: Christian König <[email protected]>.

Applied to drm-misc, thanks.
-Daniel

Quoted 106 lines

Regards,
Christian.

Quoted 89 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_acpi.c           | 2 +-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c     | 2 +-
 drivers/gpu/vga/vga_switcheroo.c                 | 4 ++--
 drivers/platform/x86/apple-gmux.c                | 2 +-
 include/linux/vga_switcheroo.h                   | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c +1 -1
index 3f7aaa4..dc565a4 100644
@@ -501,7 +501,7 @@ static int amdgpu_atpx_get_client_id(struct pci_dev *pdev)
 		return VGA_SWITCHEROO_DIS;
 }
-static struct vga_switcheroo_handler amdgpu_atpx_handler = {
+static const struct vga_switcheroo_handler amdgpu_atpx_handler = {
 	.switchto = amdgpu_atpx_switchto,
 	.power_state = amdgpu_atpx_power_state,
 	.init = amdgpu_atpx_init,
drivers/gpu/drm/nouveau/nouveau_acpi.c +1 -1
index df2d981..8b8332e 100644
@@ -206,7 +206,7 @@ static int nouveau_dsm_get_client_id(struct pci_dev *pdev)
 	return VGA_SWITCHEROO_DIS;
 }
-static struct vga_switcheroo_handler nouveau_dsm_handler = {
+static const struct vga_switcheroo_handler nouveau_dsm_handler = {
 	.switchto = nouveau_dsm_switchto,
 	.power_state = nouveau_dsm_power_state,
 	.get_client_id = nouveau_dsm_get_client_id,
drivers/gpu/drm/radeon/radeon_atpx_handler.c +1 -1
index 8bc7d0b..714508a 100644
@@ -499,7 +499,7 @@ static int radeon_atpx_get_client_id(struct pci_dev *pdev)
 		return VGA_SWITCHEROO_DIS;
 }
-static struct vga_switcheroo_handler radeon_atpx_handler = {
+static const struct vga_switcheroo_handler radeon_atpx_handler = {
 	.switchto = radeon_atpx_switchto,
 	.power_state = radeon_atpx_power_state,
 	.init = radeon_atpx_init,
drivers/gpu/vga/vga_switcheroo.c +2 -2
index af0d372..56bbbd6 100644
@@ -140,7 +140,7 @@ struct vgasr_priv {
 	int registered_clients;
 	struct list_head clients;
-	struct vga_switcheroo_handler *handler;
+	const struct vga_switcheroo_handler *handler;
 };
 #define ID_BIT_AUDIO		0x100
@@ -195,7 +195,7 @@ static void vga_switcheroo_enable(void)
  *
  * Return: 0 on success, -EINVAL if a handler was already registered.
  */
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler)
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler)
 {
 	mutex_lock(&vgasr_mutex);
 	if (vgasr_priv.handler) {
drivers/platform/x86/apple-gmux.c +1 -1
index 0dec3f5..976efeb 100644
@@ -346,7 +346,7 @@ gmux_active_client(struct apple_gmux_data *gmux_data)
 	return VGA_SWITCHEROO_DIS;
 }
-static struct vga_switcheroo_handler gmux_handler = {
+static const struct vga_switcheroo_handler gmux_handler = {
 	.switchto = gmux_switchto,
 	.power_state = gmux_set_power_state,
 	.get_client_id = gmux_get_client_id,
include/linux/vga_switcheroo.h +1 -1
index c557511..786bc93 100644
@@ -137,7 +137,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
 				  struct fb_info *info);
-int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
+int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler);
 void vga_switcheroo_unregister_handler(void);
 int vga_switcheroo_process_delayed_switch(void);

include/linux/vga_switcheroo.h static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} · line 161

Quoted 8 lines
include/linux/vga_switcheroo.h +1 -1
@@ -155,7 +155,7 @@ static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
 static inline int vga_switcheroo_register_client(struct pci_dev *dev,
 		const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; }
 static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
-static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
+static inline int vga_switcheroo_register_handler(const struct vga_switcheroo_handler *handler) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 	const struct vga_switcheroo_client_ops *ops,
 	enum vga_switcheroo_client_id id) { return 0; }

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau