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
2626const 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 {
0 commit comments