Date: Tue, 18 Jan 2011 21:47:30 +0000 (UTC) From: Andreas Tobler <andreast@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r217560 - head/sys/dev/iicbus Message-ID: <201101182147.p0ILlUcU053092@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andreast Date: Tue Jan 18 21:47:30 2011 New Revision: 217560 URL: http://svn.freebsd.org/changeset/base/217560 Log: There are PowerMacs which do not have a hwsensor-location property for this sensor. Instead of leaving this location empty we use here the default name 'sensor'. Submitted by: Justin Hibbits <chmeeedalf at gmail dot com> Approved by: nwhitehorn (mentor) Modified: head/sys/dev/iicbus/ds1775.c Modified: head/sys/dev/iicbus/ds1775.c ============================================================================== --- head/sys/dev/iicbus/ds1775.c Tue Jan 18 21:36:51 2011 (r217559) +++ head/sys/dev/iicbus/ds1775.c Tue Jan 18 21:47:30 2011 (r217560) @@ -172,6 +172,7 @@ ds1775_start(void *xdev) struct ds1775_sensor *sens; struct sysctl_oid *sensroot_oid; struct sysctl_ctx_list *ctx; + ssize_t plen; int i; char sysctl_name[40], sysctl_desc[40]; const char *units; @@ -190,16 +191,20 @@ ds1775_start(void *xdev) ctx = device_get_sysctl_ctx(dev); sensroot_oid = device_get_sysctl_tree(dev); - OF_getprop(child, "hwsensor-location", sens->location, - sizeof(sens->location)); + plen = OF_getprop(child, "hwsensor-location", sens->location, + sizeof(sens->location)); units = "C"; - for (i = 0; i < strlen(sens->location); i++) { - sysctl_name[i] = tolower(sens->location[i]); - if (isspace(sysctl_name[i])) - sysctl_name[i] = '_'; + if (plen == -1) { + strcpy(sysctl_name, "sensor"); + } else { + for (i = 0; i < strlen(sens->location); i++) { + sysctl_name[i] = tolower(sens->location[i]); + if (isspace(sysctl_name[i])) + sysctl_name[i] = '_'; + } + sysctl_name[i] = 0; } - sysctl_name[i] = 0; sprintf(sysctl_desc,"%s (%s)", sens->location, units); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(sensroot_oid), OID_AUTO,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101182147.p0ILlUcU053092>