From owner-svn-src-all@FreeBSD.ORG Sat May 9 10:45:56 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B19071A2; Sat, 9 May 2015 10:45:56 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87BA216E9; Sat, 9 May 2015 10:45:56 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3C697B93B; Sat, 9 May 2015 06:45:55 -0400 (EDT) From: John Baldwin To: Luiz Otavio O Souza Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r282674 - in head/sys/dev: iicbus ofw Date: Sat, 09 May 2015 06:45:13 -0400 Message-ID: <2165864.Vg8k3tllF7@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <201505090305.t4935jYk086983@svn.freebsd.org> References: <201505090305.t4935jYk086983@svn.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Sat, 09 May 2015 06:45:55 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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, 09 May 2015 10:45:56 -0000 On Saturday, May 09, 2015 03:05:45 AM Luiz Otavio O Souza wrote: > Author: loos > Date: Sat May 9 03:05:44 2015 > New Revision: 282674 > URL: https://svnweb.freebsd.org/changeset/base/282674 > > Log: > Handle IRQ resources on iicbus and ofw_iicbus. > > Based on a patch submitted by Michal Meloun . > > Modified: > head/sys/dev/iicbus/iicbus.c > head/sys/dev/iicbus/iicbus.h > head/sys/dev/ofw/ofw_iicbus.c > > Modified: head/sys/dev/iicbus/iicbus.c > ============================================================================== > --- head/sys/dev/iicbus/iicbus.c Sat May 9 00:48:44 2015 (r282673) > +++ head/sys/dev/iicbus/iicbus.c Sat May 9 03:05:44 2015 (r282674) > @@ -157,9 +159,9 @@ iicbus_probe_nomatch(device_t bus, devic > { > struct iicbus_ivar *devi = IICBUS_IVAR(child); > > - device_printf(bus, ""); > - printf(" at addr %#x\n", devi->addr); > - return; > + device_printf(bus, " at addr %#x", devi->addr); > + resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%ld"); > + printf("\n"); Other bus drivers do not print resources for nomatch devices (or at least PCI doesn't). Given that, I'm not sure it makes sense to do that here? > +static int > +iicbus_set_resource(device_t dev, device_t child, int type, int rid, > + u_long start, u_long count) > +{ > + struct iicbus_ivar *devi; > + struct resource_list_entry *rle; > + > + devi = IICBUS_IVAR(child); > + rle = resource_list_add(&devi->rl, type, rid, start, > + start + count - 1, count); > + if (rle == NULL) > + return (ENXIO); > + > + return (0); > +} Isn't this the same as bus_generic_rl_set_resource()? > + > +static struct resource * > +iicbus_alloc_resource(device_t bus, device_t child, int type, int *rid, > + u_long start, u_long end, u_long count, u_int flags) > +{ > + struct resource_list *rl; > + struct resource_list_entry *rle; > + > + /* Only IRQ resources are supported. */ > + if (type != SYS_RES_IRQ) > + return (NULL); > + > + /* > + * Request for the default allocation with a given rid: use resource > + * list stored in the local device info. > + */ > + if ((start == 0UL) && (end == ~0UL)) { > + rl = BUS_GET_RESOURCE_LIST(bus, child); > + if (rl == NULL) > + return (NULL); > + rle = resource_list_find(rl, type, *rid); > + if (rle == NULL) { > + if (bootverbose) > + device_printf(bus, "no default resources for " > + "rid = %d, type = %d\n", *rid, type); > + return (NULL); > + } > + start = rle->start; > + end = rle->end; > + count = rle->count; > + } > + > + return (bus_generic_alloc_resource(bus, child, type, rid, start, end, > + count, flags)); If you are using a resource list, you should be using resource_list_alloc(). However, I think you can replace this entire method with just bus_generic_rl_alloc_resource(). > @@ -297,6 +366,16 @@ static device_method_t iicbus_methods[] > DEVMETHOD(device_detach, iicbus_detach), > > /* bus interface */ > + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), > + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), > + DEVMETHOD(bus_release_resource, bus_generic_release_resource), After fixing alloc_resource to use resource_list_alloc() (either directly or via the generic method), this should be set to bus_generic_rl_release_resource(). > Modified: head/sys/dev/ofw/ofw_iicbus.c > ============================================================================== > --- head/sys/dev/ofw/ofw_iicbus.c Sat May 9 00:48:44 2015 (r282673) > +++ head/sys/dev/ofw/ofw_iicbus.c Sat May 9 03:05:44 2015 (r282674) > @@ -199,3 +205,12 @@ ofw_iicbus_get_devinfo(device_t bus, dev > dinfo = device_get_ivars(dev); > return (&dinfo->opd_obdinfo); > } > + > +static struct resource_list * > +ofw_iicbus_get_resource_list(device_t bus __unused, device_t child) > +{ > + struct ofw_iicbus_devinfo *devi; > + > + devi = device_get_ivars(child); > + return (&devi->opd_dinfo.rl); > +} I think you don't actually need this since the inherited method should already work. -- John Baldwin