Skip to content

Commit 6185448

Browse files
jritterdiscordianfish
authored andcommitted
refactor: Rename symbol names according to golang conventions
Signed-off-by: Juerg Ritter <[email protected]>
1 parent 21839df commit 6185448

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

sysfs/class_drm_amdgpu_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The Prometheus Authors
1+
// Copyright 2024 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at

sysfs/class_drm_card.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Prometheus Authors
1+
// Copyright 2024 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -25,43 +25,43 @@ import (
2525

2626
const drmClassPath = "class/drm"
2727

28-
// DrmCard contains info from files in /sys/class/drm for a
28+
// DRMCard contains info from files in /sys/class/drm for a
2929
// single DRM Card device.
30-
type DrmCard struct {
30+
type DRMCard struct {
3131
Name string
3232
Driver string
33-
Ports map[string]DrmCardPort
33+
Ports map[string]DRMCardPort
3434
}
3535

36-
// DrmCardPort contains info from files in
36+
// DRMCardPort contains info from files in
3737
// /sys/class/drm/<Card>/<Card>-<Name>
38-
// for a single port of one DrmCard device.
39-
type DrmCardPort struct {
38+
// for a single port of one DRMCard device.
39+
type DRMCardPort struct {
4040
Name string
4141
Status string
42-
Dpms string
42+
DPMS string
4343
Enabled string
4444
}
4545

46-
// DrmCardClass is a collection of every Card device in
46+
// DRMCardClass is a collection of every Card device in
4747
// /sys/class/drm.
4848
//
4949
// The map keys are the names of the InfiniBand devices.
50-
type DrmCardClass map[string]DrmCard
50+
type DRMCardClass map[string]DRMCard
5151

52-
// DrmCardClass returns infos for all Drm devices read from
52+
// DRMCardClass returns infos for all DRM devices read from
5353
// /sys/class/drm.
54-
func (fs FS) DrmCardClass() (DrmCardClass, error) {
54+
func (fs FS) DRMCardClass() (DRMCardClass, error) {
5555

5656
cards, err := filepath.Glob(fs.sys.Path("class/drm/card[0-9]"))
5757

5858
if err != nil {
5959
return nil, fmt.Errorf("failed to list DRM card ports at %q: %w", cards, err)
6060
}
6161

62-
drmCardClass := make(DrmCardClass, len(cards))
62+
drmCardClass := make(DRMCardClass, len(cards))
6363
for _, c := range cards {
64-
card, err := fs.parseDrmCard(filepath.Base(c))
64+
card, err := fs.parseDRMCard(filepath.Base(c))
6565
if err != nil {
6666
return nil, err
6767
}
@@ -72,10 +72,10 @@ func (fs FS) DrmCardClass() (DrmCardClass, error) {
7272
return drmCardClass, nil
7373
}
7474

75-
// Parse one DrmCard.
76-
func (fs FS) parseDrmCard(name string) (*DrmCard, error) {
75+
// Parse one DRMCard.
76+
func (fs FS) parseDRMCard(name string) (*DRMCard, error) {
7777
path := fs.sys.Path(drmClassPath, name)
78-
card := DrmCard{Name: name}
78+
card := DRMCard{Name: name}
7979

8080
// Read the kernel module of the card
8181
cardDriverPath, err := filepath.EvalSymlinks(filepath.Join(path, "device/driver"))
@@ -90,9 +90,9 @@ func (fs FS) parseDrmCard(name string) (*DrmCard, error) {
9090
return nil, fmt.Errorf("failed to list DRM card ports at %q: %w", portsPath, err)
9191
}
9292

93-
card.Ports = make(map[string]DrmCardPort, len(portsPath))
93+
card.Ports = make(map[string]DRMCardPort, len(portsPath))
9494
for _, d := range portsPath {
95-
port, err := parseDrmCardPort(d)
95+
port, err := parseDRMCardPort(d)
9696
if err != nil {
9797
return nil, err
9898
}
@@ -103,20 +103,20 @@ func (fs FS) parseDrmCard(name string) (*DrmCard, error) {
103103
return &card, nil
104104
}
105105

106-
func parseDrmCardPort(port string) (*DrmCardPort, error) {
106+
func parseDRMCardPort(port string) (*DRMCardPort, error) {
107107
portStatus, err := util.SysReadFile(filepath.Join(port, "status"))
108108
if err != nil {
109109
return nil, err
110110
}
111111

112-
drmCardPort := DrmCardPort{Name: filepath.Base(port), Status: portStatus}
112+
drmCardPort := DRMCardPort{Name: filepath.Base(port), Status: portStatus}
113113

114-
portDpms, err := util.SysReadFile(filepath.Join(port, "dpms"))
114+
portDPMS, err := util.SysReadFile(filepath.Join(port, "dpms"))
115115
if err != nil {
116116
return nil, err
117117
}
118118

119-
drmCardPort.Dpms = portDpms
119+
drmCardPort.DPMS = portDPMS
120120

121121
portEnabled, err := util.SysReadFile(filepath.Join(port, "enabled"))
122122
if err != nil {

sysfs/class_drm_card_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The Prometheus Authors
1+
// Copyright 2024 The Prometheus Authors
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -28,30 +28,30 @@ func TestClassDRMCard(t *testing.T) {
2828
t.Fatal(err)
2929
}
3030

31-
got, err := fs.DrmCardClass()
31+
got, err := fs.DRMCardClass()
3232
if err != nil {
3333
t.Fatal(err)
3434
}
3535

36-
want := DrmCardClass{
37-
"card0": DrmCard{
36+
want := DRMCardClass{
37+
"card0": DRMCard{
3838
Name: "card0",
3939
Driver: "amdgpu",
40-
Ports: map[string]DrmCardPort{},
40+
Ports: map[string]DRMCardPort{},
4141
},
42-
"card1": DrmCard{
42+
"card1": DRMCard{
4343
Name: "card1",
4444
Driver: "i915",
45-
Ports: map[string]DrmCardPort{
45+
Ports: map[string]DRMCardPort{
4646
"card1-DP-1": {
4747
Name: "card1-DP-1",
48-
Dpms: "Off",
48+
DPMS: "Off",
4949
Enabled: "disabled",
5050
Status: "disconnected",
5151
},
5252
"card1-DP-5": {
5353
Name: "card1-DP-5",
54-
Dpms: "On",
54+
DPMS: "On",
5555
Enabled: "enabled",
5656
Status: "connected",
5757
},
@@ -60,6 +60,6 @@ func TestClassDRMCard(t *testing.T) {
6060
}
6161

6262
if diff := cmp.Diff(want, got); diff != "" {
63-
t.Fatalf("unexpected DrmCard class (-want +got):\n%s", diff)
63+
t.Fatalf("unexpected DRMCard class (-want +got):\n%s", diff)
6464
}
6565
}

0 commit comments

Comments
 (0)