@@ -63,9 +63,9 @@ type Hub struct {
63
63
stateLock sync.RWMutex // Protects the internals of the hub from racey access
64
64
65
65
// TODO(karalabe): remove if hotplug lands on Windows
66
- commsPend int // Number of operations blocking enumeration
67
- commsLock sync.Mutex // Lock protecting the pending counter and enumeration
68
- enumFails uint32 // Number of times enumeration has failed
66
+ commsPend int // Number of operations blocking enumeration
67
+ commsLock sync.Mutex // Lock protecting the pending counter and enumeration
68
+ enumFails atomic. Uint32 // Number of times enumeration has failed
69
69
}
70
70
71
71
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
@@ -151,7 +151,7 @@ func (hub *Hub) refreshWallets() {
151
151
return
152
152
}
153
153
// If USB enumeration is continually failing, don't keep trying indefinitely
154
- if atomic . LoadUint32 ( & hub .enumFails ) > 2 {
154
+ if hub .enumFails . Load ( ) > 2 {
155
155
return
156
156
}
157
157
// Retrieve the current list of USB wallet devices
@@ -172,7 +172,7 @@ func (hub *Hub) refreshWallets() {
172
172
}
173
173
infos , err := usb .Enumerate (hub .vendorID , 0 )
174
174
if err != nil {
175
- failcount := atomic . AddUint32 ( & hub .enumFails , 1 )
175
+ failcount := hub .enumFails . Add ( 1 )
176
176
if runtime .GOOS == "linux" {
177
177
// See rationale before the enumeration why this is needed and only on Linux.
178
178
hub .commsLock .Unlock ()
@@ -181,7 +181,7 @@ func (hub *Hub) refreshWallets() {
181
181
"vendor" , hub .vendorID , "failcount" , failcount , "err" , err )
182
182
return
183
183
}
184
- atomic . StoreUint32 ( & hub .enumFails , 0 )
184
+ hub .enumFails . Store ( 0 )
185
185
186
186
for _ , info := range infos {
187
187
for _ , id := range hub .productIDs {
0 commit comments