From owner-svn-src-head@FreeBSD.ORG Sat Oct 26 18:25:56 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 992D391C; Sat, 26 Oct 2013 18:25:56 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6B8B62C19; Sat, 26 Oct 2013 18:25:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9QIPuto079817; Sat, 26 Oct 2013 18:25:56 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9QIPuhP079816; Sat, 26 Oct 2013 18:25:56 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310261825.r9QIPuhP079816@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 26 Oct 2013 18:25:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257183 - 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-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2013 18:25:56 -0000 Author: nwhitehorn Date: Sat Oct 26 18:25:55 2013 New Revision: 257183 URL: http://svnweb.freebsd.org/changeset/base/257183 Log: Be a bit more flexible in how we find the console from the properties on /chosen, following the list of allowed console properties in ePAPR. Also do not require that stdin be defined and equal to stdout: stdin is nonstandard (for ePAPR) and console in an unexpected place is after all better than no console. Modified: head/sys/dev/uart/uart_cpu_fdt.c Modified: head/sys/dev/uart/uart_cpu_fdt.c ============================================================================== --- head/sys/dev/uart/uart_cpu_fdt.c Sat Oct 26 18:23:43 2013 (r257182) +++ head/sys/dev/uart/uart_cpu_fdt.c Sat Oct 26 18:25:55 2013 (r257183) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -98,10 +99,25 @@ uart_cpu_eqres(struct uart_bas *b1, stru return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0); } +static int +phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node) +{ + char buf[64]; + + if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0) + return (ENXIO); + if ((*node = OF_finddevice(buf)) == -1) + return (ENXIO); + + return (0); +} + int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { - char buf[64]; + const char *propnames[] = {"stdout-path", "linux,stdout-path", "stdout", + "stdin-path", "stdin", NULL}; + const char **name; struct uart_class *class; phandle_t node, chosen; pcell_t shift, br, rclk; @@ -111,7 +127,7 @@ uart_cpu_getdev(int devtype, struct uart uart_bus_space_mem = fdtbus_bs_tag; uart_bus_space_io = NULL; - /* Allow overriding the FDT uning the environment. */ + /* Allow overriding the FDT using the environment. */ class = &uart_ns8250_class; err = uart_getenv(devtype, di, class); if (!err) @@ -125,14 +141,11 @@ uart_cpu_getdev(int devtype, struct uart */ if ((chosen = OF_finddevice("/chosen")) == -1) return (ENXIO); - if (OF_getprop(chosen, "stdin", buf, sizeof(buf)) <= 0) - return (ENXIO); - if ((node = OF_finddevice(buf)) == -1) - return (ENXIO); - if (OF_getprop(chosen, "stdout", buf, sizeof(buf)) <= 0) - return (ENXIO); - if (OF_finddevice(buf) != node) - /* Only stdin == stdout is supported. */ + for (name = propnames; *name != NULL; name++) { + if (phandle_chosen_propdev(chosen, *name, &node) == 0) + break; + } + if (*name == NULL) return (ENXIO); /* * Retrieve serial attributes.