Skip to contentSkip to conversation

drm/radeon: make array encoded_lanes static

PATCH Applied Colin King 2 participants 2 messages Sep 15, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/radeon: make array encoded_lanes static

From: Colin Ian King <[email protected]>

Don't populate the read-only array encoded_lanes on the stack but instead it static. Also makes the object code smaller by 97 bytes:

Before:
text data bss dec hex filename
38899 8064 0 46963 b773 ./drivers/gpu/drm/radeon/r600_dpm.o

After:
text data bss dec hex filename
38738 8128 0 46866 b712 ./drivers/gpu/drm/radeon/r600_dpm.o

(gcc version 11.2.0)

---
 drivers/gpu/drm/radeon/r600_dpm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/r600_dpm.c +3 -1
index fd4226b99862..9d2bcb9551e6 100644
@@ -1361,7 +1361,9 @@ u16 r600_get_pcie_lane_support(struct radeon_device *rdev,
 
 u8 r600_encode_pci_lane_width(u32 lanes)
 {
-	u8 encoded_lanes[] = { 0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6 };
+	static const u8 encoded_lanes[] = {
+		0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6
+	};
 
 	if (lanes > 16)
 		return 0;
Signature · 1 line
2.32.0
Applied
#1 lore raw
Quoted 10 lines · Colin King

From: Colin Ian King <[email protected]>

Don't populate the read-only array encoded_lanes on the stack but instead it static. Also makes the object code smaller by 97 bytes:

Before:
text data bss dec hex filename
38899 8064 0 46963 b773 ./drivers/gpu/drm/radeon/r600_dpm.o

Quoted 7 lines

After:
text data bss dec hex filename
38738 8128 0 46866 b712 ./drivers/gpu/drm/radeon/r600_dpm.o

(gcc version 11.2.0)

Applied. Thanks!

Alex

Quoted 22 lines
---
 drivers/gpu/drm/radeon/r600_dpm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/r600_dpm.c +3 -2
index fd4226b99862..9d2bcb9551e6 100644
@@ -1361,7 +1361,9 @@ u16 r600_get_pcie_lane_support(struct radeon_device *rdev,
 
 u8 r600_encode_pci_lane_width(u32 lanes)
 {
-       u8 encoded_lanes[] = { 0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6 };
+       static const u8 encoded_lanes[] = {
+               0, 1, 2, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6
+       };
 
        if (lanes > 16)
                return 0;
--

2.32.0