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,
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to