git: d7661890efd2 - main - gpiopower: Fix failure case for attach

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Wed, 16 Mar 2022 00:10:27 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=d7661890efd2d921f248724a1708d1e77bdb2625

commit d7661890efd2d921f248724a1708d1e77bdb2625
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-03-15 18:40:48 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2022-03-16 00:16:17 +0000

    gpiopower: Fix failure case for attach
    
    Summary:
    We really should be checking the return value of
    ofw_gpiobus_parse_gpios_impl, not the value of sc_pins, which isn't
    changed on failure.
    
    Reported by:    alfredo@
    
    Reviewers: #powerpc, alfredo
    
    Reviewed By: #powerpc, alfredo
    
    Subscribers: imp, loos
    
    Differential Revision: https://reviews.freebsd.org/D34571
---
 sys/dev/gpio/gpiopower.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/dev/gpio/gpiopower.c b/sys/dev/gpio/gpiopower.c
index 98b635e3fd2a..3dcd489ed2fb 100644
--- a/sys/dev/gpio/gpiopower.c
+++ b/sys/dev/gpio/gpiopower.c
@@ -74,8 +74,7 @@ gpiopower_attach(device_t dev)
 	if ((node = ofw_bus_get_node(dev)) == -1)
 		return (ENXIO);
 
-	ofw_gpiobus_parse_gpios(dev, "gpios", &sc->sc_pin);
-	if (sc->sc_pin == NULL) {
+	if (ofw_gpiobus_parse_gpios(dev, "gpios", &sc->sc_pin) != 0) {
 		device_printf(dev, "failed to map GPIO pin\n");
 		return (ENXIO);
 	}