From owner-svn-src-head@FreeBSD.ORG Sat Jun 20 04:48:53 2015 Return-Path: Delivered-To: svn-src-head@hub.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 E65E2F46; Sat, 20 Jun 2015 04:48:53 +0000 (UTC) (envelope-from imp@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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D49B0789; Sat, 20 Jun 2015 04:48:53 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5K4mrLD088606; Sat, 20 Jun 2015 04:48:53 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5K4mrFT088605; Sat, 20 Jun 2015 04:48:53 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201506200448.t5K4mrFT088605@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 20 Jun 2015 04:48:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284625 - head/sys/dev/gpio 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.20 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, 20 Jun 2015 04:48:54 -0000 Author: imp Date: Sat Jun 20 04:48:53 2015 New Revision: 284625 URL: https://svnweb.freebsd.org/changeset/base/284625 Log: Use ofw_bus_find_child_device_by_phandle to see if the child we're adding already exists and if so just return that. The typical use case is from identify routines, which shouldn't be adding multiple copies of the same phandle_t to the gpiobus. Only one per phandle_t is needed (or expected by the current code). Differential Revision: https://reviews.freebsd.org/D2871 Modified: head/sys/dev/gpio/ofw_gpiobus.c Modified: head/sys/dev/gpio/ofw_gpiobus.c ============================================================================== --- head/sys/dev/gpio/ofw_gpiobus.c Sat Jun 20 04:48:48 2015 (r284624) +++ head/sys/dev/gpio/ofw_gpiobus.c Sat Jun 20 04:48:53 2015 (r284625) @@ -56,6 +56,14 @@ ofw_gpiobus_add_fdt_child(device_t bus, struct ofw_gpiobus_devinfo *dinfo; /* + * Check to see if we already have a child for @p child, and if so + * return it. + */ + childdev = ofw_bus_find_child_device_by_phandle(bus, child); + if (childdev != NULL) + return (childdev); + + /* * Set up the GPIO child and OFW bus layer devinfo and add it to bus. */ childdev = device_add_child(bus, drvname, -1);