From e1fd376a2e5711b8f9a9331915b7ccfe92981009 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Tue, 13 Jun 2017 10:48:28 +0200 Subject: [PATCH] more comment updates, rename "intf" parameter of Interface to "num" --- config.go | 28 ++++++++++++++-------------- constants.go | 2 +- interface.go | 6 +++--- misc.go | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/config.go b/config.go index c051e82..ee3a913 100644 --- a/config.go +++ b/config.go @@ -83,37 +83,37 @@ func (c *Config) String() string { } // Interface claims and returns an interface on a USB device. -// inft specifies the number of an interface to claim, and alt specifies the +// num specifies the number of an interface to claim, and alt specifies the // alternate setting number for that interface. -func (c *Config) Interface(intf, alt int) (*Interface, error) { +func (c *Config) Interface(num, alt int) (*Interface, error) { if c.dev == nil { - return nil, fmt.Errorf("Interface(%d, %d) called on %s after Close", intf, alt, c) + return nil, fmt.Errorf("Interface(%d, %d) called on %s after Close", num, alt, c) } - if intf < 0 || intf >= len(c.Desc.Interfaces) { - return nil, fmt.Errorf("interface %d not found in %s, available interfaces 0..%d", intf, c, len(c.Desc.Interfaces)-1) + if num < 0 || intNum >= len(c.Desc.Interfaces) { + return nil, fmt.Errorf("interface %d not found in %s, available interfaces 0..%d", num, c, len(c.Desc.Interfaces)-1) } - ifInfo := c.Desc.Interfaces[intf] + ifInfo := c.Desc.Interfaces[num] if alt < 0 || alt >= len(ifInfo.AltSettings) { return nil, fmt.Errorf("alternate setting %d not found for %s in %s, available alt settings 0..%d", alt, ifInfo, c, len(ifInfo.AltSettings)-1) } c.mu.Lock() defer c.mu.Unlock() - if c.claimed[intf] { - return nil, fmt.Errorf("interface %d on %s is already claimed", intf, c) + if c.claimed[num] { + return nil, fmt.Errorf("interface %d on %s is already claimed", num, c) } // Claim the interface - if err := libusb.claim(c.dev.handle, uint8(intf)); err != nil { - return nil, fmt.Errorf("failed to claim interface %d on %s: %v", intf, c, err) + if err := libusb.claim(c.dev.handle, uint8(num)); err != nil { + return nil, fmt.Errorf("failed to claim interface %d on %s: %v", num, c, err) } - if err := libusb.setAlt(c.dev.handle, uint8(intf), uint8(alt)); err != nil { - libusb.release(c.dev.handle, uint8(intf)) - return nil, fmt.Errorf("failed to set alternate config %d on interface %d of %s: %v", alt, intf, c, err) + if err := libusb.setAlt(c.dev.handle, uint8(num), uint8(alt)); err != nil { + libusb.release(c.dev.handle, uint8(num)) + return nil, fmt.Errorf("failed to set alternate config %d on interface %d of %s: %v", alt, num, c, err) } - c.claimed[intf] = true + c.claimed[num] = true return &Interface{ Setting: ifInfo.AltSettings[alt], config: c, diff --git a/constants.go b/constants.go index 7b16213..c2061c3 100644 --- a/constants.go +++ b/constants.go @@ -19,7 +19,7 @@ package gousb import "C" import "strconv" -// Class represents a USB-IF class or subclass code. +// Class represents a USB-IF (Implementers Forum) class or subclass code. type Class uint8 // Standard classes defined by USB spec. diff --git a/interface.go b/interface.go index 0165b5a..cc156a1 100644 --- a/interface.go +++ b/interface.go @@ -31,7 +31,7 @@ type InterfaceDesc struct { } // String returns a human-readable descripton of the interface descriptor and -// it's alternate settings. +// its alternate settings. func (i InterfaceDesc) String() string { return fmt.Sprintf("Interface %d (%d alternate settings)", i.Number, len(i.AltSettings)) } @@ -43,9 +43,9 @@ type InterfaceSetting struct { Number int // Alternate is the number of this alternate setting. Alternate int - // Class is the USB-IF class code, as defined by the USB spec. + // Class is the USB-IF (Implementers Forum) class code, as defined by the USB spec. Class Class - // SubClass is the USB-IF subclass code, as defined by the USB spec. + // SubClass is the USB-IF (Implementers Forum) subclass code, as defined by the USB spec. SubClass Class // Protocol is USB protocol code, as defined by the USB spe.c Protocol Protocol diff --git a/misc.go b/misc.go index 72cf997..66673bb 100644 --- a/misc.go +++ b/misc.go @@ -19,8 +19,8 @@ import ( "fmt" ) -// BCD is a binary-coded decimal version number, with first 8 bits representing -// the major version number, an latter 8 bits the minor version number. +// BCD is a binary-coded decimal version number. Its first 8 bits represent +// the major version number, its last 8 bits represent the minor version number. // Major and minor are composed of 4+4 bits, where each 4 bits represents // a decimal digit. // Example: BCD(0x1234) means major 12 (decimal) and minor 34 (decimal).