From owner-svn-src-all@FreeBSD.ORG Sat Jul 30 00:52:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C013106566B; Sat, 30 Jul 2011 00:52:13 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C7118FC13; Sat, 30 Jul 2011 00:52:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6U0qDnX073072; Sat, 30 Jul 2011 00:52:13 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6U0qDVU073070; Sat, 30 Jul 2011 00:52:13 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201107300052.p6U0qDVU073070@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 30 Jul 2011 00:52:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224505 - head/sys/powerpc/powermac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2011 00:52:13 -0000 Author: nwhitehorn Date: Sat Jul 30 00:52:13 2011 New Revision: 224505 URL: http://svn.freebsd.org/changeset/base/224505 Log: Fix an error that could cause sysctl -a to enter an infinite loop in the event of a broken or busy fan due to returning incorrect error codes from the FCU sysctl handler. Reported by: Path Mather 1 Approved by: re (kib) Modified: head/sys/powerpc/powermac/fcu.c Modified: head/sys/powerpc/powermac/fcu.c ============================================================================== --- head/sys/powerpc/powermac/fcu.c Sat Jul 30 00:51:36 2011 (r224504) +++ head/sys/powerpc/powermac/fcu.c Sat Jul 30 00:52:13 2011 (r224505) @@ -282,14 +282,14 @@ fcu_fan_set_rpm(struct fcu_fan *fan, int fan->setpoint = rpm; } else { device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); - return (-1); + return (ENXIO); } buf[0] = rpm >> (8 - fcu_rpm_shift); buf[1] = rpm << fcu_rpm_shift; if (fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 2) < 0) - return (-1); + return (EIO); return (0); } @@ -377,7 +377,7 @@ fcu_fan_set_pwm(struct fcu_fan *fan, int buf[0] = (pwm * 2550) / 1000; if (fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 1) < 0) - return (-1); + return (EIO); return (0); } @@ -536,12 +536,12 @@ fcu_fanrpm_sysctl(SYSCTL_HANDLER_ARGS) if (fan->type == FCU_FAN_RPM) { rpm = fcu_fan_get_rpm(fan); if (rpm < 0) - return (-1); + return (EIO); error = sysctl_handle_int(oidp, &rpm, 0, req); } else { error = fcu_fan_get_pwm(fcu, fan, &pwm, &rpm); if (error < 0) - return (-1); + return (EIO); switch (arg2 & 0xff00) { case FCU_PWM_SYSCTL_PWM: @@ -552,7 +552,7 @@ fcu_fanrpm_sysctl(SYSCTL_HANDLER_ARGS) break; default: /* This should never happen */ - error = -1; + return (EINVAL); }; }