@@ -64,21 +64,21 @@ func List() ([]string, error) {
64
64
return disks , nil
65
65
}
66
66
67
- // Vpd83Seach searches local disks for vpd
68
- func Vpd83Seach (vpd string ) ([]string , error ) {
67
+ // Vpd83Search searches local disks for vpd
68
+ func Vpd83Search (vpd string ) ([]string , error ) {
69
69
70
70
cs := C .CString (vpd )
71
71
defer C .free (unsafe .Pointer (cs ))
72
72
73
73
var deviceList []string
74
74
75
- var slist * C.lsm_string_list
75
+ var str_list * C.lsm_string_list
76
76
var lsmError * C.lsm_error
77
77
78
- var err = C .lsm_local_disk_vpd83_search (cs , & slist , & lsmError )
78
+ var err = C .lsm_local_disk_vpd83_search (cs , & str_list , & lsmError )
79
79
80
80
if err == 0 {
81
- deviceList = getStrings (slist , true )
81
+ deviceList = getStrings (str_list , true )
82
82
} else {
83
83
return deviceList , processError (int (err ), lsmError )
84
84
}
@@ -236,16 +236,19 @@ func LinkSpeedGet(diskPath string) (uint32, error) {
236
236
return 0 , processError (int (rc ), lsmError )
237
237
}
238
238
239
- type LedSlots struct {
239
+ // Opaque type for LED Slots API
240
+ type LedSlotsHandle struct {
240
241
handle * C.lsm_led_handle
241
242
}
242
243
243
- func LedSlotsHandleGet () (* LedSlots , error ) {
244
+ // Retrieve the handle to use for interacting with LED Slots, make sure to call LedSlotsHandleFree
245
+ // when done
246
+ func LedSlotsHandleGet () (* LedSlotsHandle , error ) {
244
247
var l_handle * C.lsm_led_handle
245
248
var rc = C .lsm_led_handle_get (& l_handle , 0 )
246
249
247
250
if rc == 0 {
248
- return & LedSlots {handle : l_handle }, nil
251
+ return & LedSlotsHandle {handle : l_handle }, nil
249
252
}
250
253
251
254
return nil , & errors.LsmError {
@@ -254,16 +257,19 @@ func LedSlotsHandleGet() (*LedSlots, error) {
254
257
255
258
}
256
259
257
- func LedSlotsHandleFree (led_slots * LedSlots ) {
260
+ // Frees the resources used by the LED Slot API, calling this is required to prevent a memory leak
261
+ func LedSlotsHandleFree (led_slots * LedSlotsHandle ) {
258
262
C .lsm_led_handle_free (led_slots .handle )
259
263
}
260
264
265
+ // Information about a specific LED slot
261
266
type LedSlot struct {
262
- SlotId string
263
- Device string
267
+ SlotId string // The slot identifier
268
+ Device string // The slot device node, if it has one
264
269
}
265
270
266
- func (l * LedSlots ) Slots () ([]LedSlot , error ) {
271
+ // Retrieves all the LED slots
272
+ func (l * LedSlotsHandle ) SlotsGet () ([]LedSlot , error ) {
267
273
var slots []LedSlot
268
274
var itr * C.lsm_led_slot_itr
269
275
var lsmError * C.lsm_error
@@ -297,7 +303,8 @@ func (l *LedSlots) Slots() ([]LedSlot, error) {
297
303
return slots , processError (int (rc ), lsmError )
298
304
}
299
305
300
- func (l * LedSlots ) StatusGet (slot * LedSlot ) (lsm.DiskLedStatusBitField , error ) {
306
+ // Retrieves the current status of the LED slot
307
+ func (l * LedSlotsHandle ) StatusGet (slot * LedSlot ) (lsm.DiskLedStatusBitField , error ) {
301
308
var itr * C.lsm_led_slot_itr
302
309
var lsmError * C.lsm_error
303
310
@@ -326,7 +333,8 @@ func (l *LedSlots) StatusGet(slot *LedSlot) (lsm.DiskLedStatusBitField, error) {
326
333
return 0 , processError (int (rc ), lsmError )
327
334
}
328
335
329
- func (l * LedSlots ) StatusSet (slot * LedSlot , led_status lsm.DiskLedStatusBitField ) error {
336
+ // Sets the LED slot
337
+ func (l * LedSlotsHandle ) StatusSet (slot * LedSlot , led_status lsm.DiskLedStatusBitField ) error {
330
338
var itr * C.lsm_led_slot_itr
331
339
var lsmError * C.lsm_error
332
340
0 commit comments