Module Name: src
Committed By: jdc
Date: Thu Oct 29 06:50:53 UTC 2020
Modified Files:
src/sys/dev/i2c: pcagpio.c
Log Message:
Handle the change in the sparc64 OFW patching, where we now encode the
GPIO pin type in the pin name (only LED types are currently handled).
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/i2c/pcagpio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/pcagpio.c
diff -u src/sys/dev/i2c/pcagpio.c:1.4 src/sys/dev/i2c/pcagpio.c:1.5
--- src/sys/dev/i2c/pcagpio.c:1.4 Tue Oct 27 20:13:21 2020
+++ src/sys/dev/i2c/pcagpio.c Thu Oct 29 06:50:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $ */
+/* $NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $ */
/*-
* Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.4 2020/10/27 20:13:21 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -184,7 +184,7 @@ pcagpio_attach(device_t parent, device_t
if (pins != NULL) {
int i, num, def;
char name[32];
- const char *nptr;
+ const char *spptr, *nptr;
bool ok = TRUE, act;
for (i = 0; i < prop_array_count(pins); i++) {
@@ -192,16 +192,22 @@ pcagpio_attach(device_t parent, device_t
pin = prop_array_get(pins, i);
ok &= prop_dictionary_get_cstring_nocopy(pin, "name",
&nptr);
- strncpy(name, nptr, 31);
ok &= prop_dictionary_get_uint32(pin, "pin", &num);
- ok &= prop_dictionary_get_bool(
- pin, "active_high", &act);
+ ok &= prop_dictionary_get_bool( pin, "active_high",
+ &act);
/* optional default state */
def = -1;
prop_dictionary_get_int32(pin, "default_state", &def);
- if (ok) {
+ if (!ok)
+ continue;
+ /* Extract pin type from the name */
+ spptr = strstr(nptr, " ");
+ if (spptr == NULL)
+ continue;
+ spptr += 1;
+ strncpy(name, spptr, 31);
+ if (!strncmp(nptr, "LED ", 4))
pcagpio_attach_led(sc, name, num, act, def);
- }
}
}
}