Skip to content

Commit

Permalink
Simplifying code (google#129)
Browse files Browse the repository at this point in the history
* host: follow gosimple suggestions

* conn: follow gosimple suggestions

* devices: follow gosimple suggestions

* Update CONTRIBUTORS
  • Loading branch information
matiasinsaurralde authored and maruel committed Apr 20, 2017
1 parent d351d1b commit ebe840a
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 25 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
# Please keep the list sorted.

Marc-Antoine Ruel <[email protected]> <[email protected]>
Matias Insaurralde <[email protected]>
Stephan Sperber <[email protected]>
Thorsten von Eicken <[email protected]>
6 changes: 1 addition & 5 deletions conn/spi/spismoketest/spismoketest.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ func (s *SmokeTest) Run(args []string) error {
log.Printf("%s: random number seed %d", s, *seed)

// Run the tests.
if err := s.eeprom(spiDev, wpPin); err != nil {
return err
}

return nil
return s.eeprom(spiDev, wpPin)
}

// eeprom tests a 5080 8Kbit serial EEPROM attached to the SPI bus.
Expand Down
2 changes: 1 addition & 1 deletion devices/lepton/lepton.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (d *Dev) ReadImg() (*Frame, error) {
if err := d.readFrame(f); err != nil {
return nil, err
}
if f.Metadata.FFCDesired == true {
if f.Metadata.FFCDesired {
// TODO(maruel): Automatically trigger FFC when applicable, only do if
// the camera has a shutter.
//go d.RunFFC()
Expand Down
2 changes: 1 addition & 1 deletion host/bcm283x/gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ func (d *driverGPIO) Init() (bool, error) {
return false, errors.New("bcm283x CPU not detected")
}
model := distro.CPUInfo()["model name"]
if strings.Index(model, "ARMv6") != -1 {
if strings.Contains(model, "ARMv6") {
baseAddr = 0x20000000
dramBus = 0x40000000
} else {
Expand Down
6 changes: 1 addition & 5 deletions host/chip/chip.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,7 @@ func (d *driver) Init() (bool, error) {
{gpioreg.ByName("CSID6"), gpioreg.ByName("CSID7")},
{U14_39, U14_40},
}
if err := pinreg.Register("U14", U14); err != nil {
return true, err
}

return true, nil
return true, pinreg.Register("U14", U14)
}

func init() {
Expand Down
12 changes: 4 additions & 8 deletions host/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ func IsArmbian() bool {
func IsDebian() bool {
if isLinux {
// http://0pointer.de/public/systemd-man/os-release.html#ID_LIKE=
id, _ := OSRelease()["ID"]
if id == "debian" {
if OSRelease()["ID"] == "debian" {
return true
}
idLike, _ := OSRelease()["ID_LIKE"]
for _, part := range strings.Split(idLike, " ") {
for _, part := range strings.Split(OSRelease()["ID_LIKE"], " ") {
if part == "debian" {
return true
}
Expand All @@ -58,8 +56,7 @@ func IsDebian() bool {
// https://raspbian.org/
func IsRaspbian() bool {
if isArm && isLinux {
id, _ := OSRelease()["ID"]
return id == "raspbian"
return OSRelease()["ID"] == "raspbian"
}
return false
}
Expand All @@ -69,8 +66,7 @@ func IsRaspbian() bool {
// https://ubuntu.com/
func IsUbuntu() bool {
if isLinux {
id, _ := OSRelease()["ID"]
return id == "ubuntu"
return OSRelease()["ID"] == "ubuntu"
}
return false
}
Expand Down
2 changes: 1 addition & 1 deletion host/rpi/rpi.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (d *driver) Init() (bool, error) {
//
// This code is not futureproof, it will error out on a Raspberry Pi 4
// whenever it comes out.
rev, _ := distro.CPUInfo()["Revision"]
rev := distro.CPUInfo()["Revision"]
if i, err := strconv.ParseInt(rev, 16, 32); err == nil {
// Ignore the overclock bit.
i &= 0xFFFFFF
Expand Down
5 changes: 1 addition & 4 deletions host/sysfs/spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,7 @@ func (d *driverSPI) Init() (bool, error) {
}
// Update the global value.
spiBufSize, err = strconv.Atoi(strings.TrimSpace(string(b)))
if err != nil {
return true, err
}
return true, nil
return true, err
}

type openerSPI struct {
Expand Down

0 comments on commit ebe840a

Please sign in to comment.