From owner-svn-src-all@FreeBSD.ORG Sat Apr 4 09:21:58 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7299EC18; Sat, 4 Apr 2015 09:21:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DA72E55; Sat, 4 Apr 2015 09:21:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t349Lv5G035722; Sat, 4 Apr 2015 09:21:57 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t349LvBG035719; Sat, 4 Apr 2015 09:21:57 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201504040921.t349LvBG035719@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sat, 4 Apr 2015 09:21:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281073 - head/sys/dev/uart X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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, 04 Apr 2015 09:21:58 -0000 Author: andrew Date: Sat Apr 4 09:21:56 2015 New Revision: 281073 URL: https://svnweb.freebsd.org/changeset/base/281073 Log: Use OF_getencprop over OF_getprop and fdt32_to_cpu. The latter may give us the wrong data in the failure case if shift was not zero. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/uart/uart_bus_fdt.c head/sys/dev/uart/uart_cpu_fdt.c Modified: head/sys/dev/uart/uart_bus_fdt.c ============================================================================== --- head/sys/dev/uart/uart_bus_fdt.c Sat Apr 4 09:07:31 2015 (r281072) +++ head/sys/dev/uart/uart_bus_fdt.c Sat Apr 4 09:21:56 2015 (r281073) @@ -89,11 +89,9 @@ uart_fdt_get_clock(phandle_t node, pcell static int uart_fdt_get_shift(phandle_t node, pcell_t *cell) { - pcell_t shift; - if ((OF_getprop(node, "reg-shift", &shift, sizeof(shift))) <= 0) - shift = 0; - *cell = fdt32_to_cpu(shift); + if ((OF_getencprop(node, "reg-shift", cell, sizeof(*cell))) <= 0) + *cell = 0; return (0); } Modified: head/sys/dev/uart/uart_cpu_fdt.c ============================================================================== --- head/sys/dev/uart/uart_cpu_fdt.c Sat Apr 4 09:07:31 2015 (r281072) +++ head/sys/dev/uart/uart_cpu_fdt.c Sat Apr 4 09:21:56 2015 (r281073) @@ -82,11 +82,9 @@ uart_fdt_get_clock(phandle_t node, pcell static int uart_fdt_get_shift(phandle_t node, pcell_t *cell) { - pcell_t shift; - if ((OF_getprop(node, "reg-shift", &shift, sizeof(shift))) <= 0) - shift = 0; - *cell = fdt32_to_cpu(shift); + if ((OF_getencprop(node, "reg-shift", cell, sizeof(*cell))) <= 0) + *cell = 0; return (0); }