Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp82411pxu; Tue, 5 Jan 2021 05:51:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEMEs6Z8m/P6JlVDCtZ7vMyh4e7E1KR+JXj7VIxxqGFtQb83ThE8ptgq/s8tfaufEhrWIZ X-Received: by 2002:a17:906:adce:: with SMTP id lb14mr70502926ejb.502.1609854668553; Tue, 05 Jan 2021 05:51:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609854668; cv=none; d=google.com; s=arc-20160816; b=GZ4Q17+DK5laMxABz3jB5/9HI+YsKcYiTXVpSWOqPspLgcuEep4dXaJ6vCMI0D8rS+ pCB5Bsk1ehZnYdS+3vFNN/TYbGAKZWNR/tlo9vW2iljN1a9g60+YrfqOZr2tjJzP4PnY 8QSdw1PRp/Pnx3CH0jJKYQ5Xujgak+KXyqlzX7hyk0D8UKCijKmQV3jf+qrTD2lOL6Nk y2cevOqidANVOiMRSHBDB843d80HHqs4OQrCo9Yz7h5DZR+IatfB6RkaZlX8yIzyiGcB Zlh8uxvWwg+Ed7uDP6teeyI13BvdYI8m87ICEzJ5rw7OlAxOz7a6YqRWC4XiTfjEilHX tx+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oNfG3Ik9nEEMpnfLsv2AXptqujCvj/oXOGtgFRPW1VU=; b=bHhD0CnCiS7osqQoH07pnhPSxE/iqmCej7K+xpet6Ki61rYZA1s+VZR3Ze6YscXlY7 7bbyTLbnHc+fR07yd/QGrS71EN7CBE6+lSjhM6XpUrvSB/zxl3ssIIt1CZXrqznFIbZQ Y4sH4qyWQhc6oc6Ozu10rswwz1XoAKyhyw+cNKLpChcPYIyzDjjdI7vx4P3YQSio5GSI eQx1OYHOh4NMiMtJYtsf34O36EKQkpJ58Nzsitj+aShG+64ebyGvkp35fO6NKagumL8y F/au/wTazo5B2vCQYhABGcW/DAMGvcBAZ61PStAuPY1FerGKEqdPCzRGVPbLEdSIJlGM OiXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tvWKEFip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co12si31925222edb.534.2021.01.05.05.50.45; Tue, 05 Jan 2021 05:51:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tvWKEFip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730012AbhAENoF (ORCPT + 99 others); Tue, 5 Jan 2021 08:44:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:38358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbhAENoF (ORCPT ); Tue, 5 Jan 2021 08:44:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A267229C4; Tue, 5 Jan 2021 13:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609854204; bh=wIlnL1VAyIouVMBSrzUu5JMg84xwPJWp1BYOBKzgZ/Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tvWKEFipHEDorOQU8OnU/LqjLJCoa7lP+Aafx3JLPVskDJ6tt1NXyYlWBraWFGGE1 V5ubiRc0+jpUzSNkExV72LsTkIHQ6jgbyqrzjK1RJCAdBXhRDXyzDDDBu0Py+Rplk8 F42hBCxBHvQCr3QQ0GnK+AVF+qqgPWfHhdZDiW+iGYmlQSknYpK3eFfIDFxGMyTnHY GCuDY+xIS7eufA7abSYllLvAWIL9/nnhtHcGBNl4EAowOLTn+/7sLamfdjkFldiVRe ezBjwTWAL9uzIDeYfPRtA9m4mACI05DbSqb8kAacFag/mj2ESMZsLxuW7t61XSuGbI WsDiprh/w/5og== Date: Tue, 5 Jan 2021 13:42:56 +0000 From: Mark Brown To: Jason Gunthorpe Cc: Greg KH , Alexandre Belloni , Dan Williams , Pierre-Louis Bossart , alsa-devel@alsa-project.org, Kiran Patil , linux-rdma , Shiraz Saleem , Martin Habets , Liam Girdwood , Ranjani Sridharan , Fred Oh , Dave Ertman , Jakub Kicinski , Netdev , Leon Romanovsky , David Miller , Linux Kernel Mailing List , Parav Pandit , lee.jones@linaro.org Subject: Re: [resend/standalone PATCH v4] Add auxiliary bus support Message-ID: <20210105134256.GA4487@sirena.org.uk> References: <20201218155204.GC5333@sirena.org.uk> <20201218162817.GX552508@nvidia.com> <20201218180310.GD5333@sirena.org.uk> <20201218184150.GY552508@nvidia.com> <20201218203211.GE5333@sirena.org.uk> <20201218205856.GZ552508@nvidia.com> <20201221185140.GD4521@sirena.org.uk> <20210104180831.GD552508@nvidia.com> <20210104211930.GI5645@sirena.org.uk> <20210105001341.GL552508@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5vNYLRcllDrimb99" Content-Disposition: inline In-Reply-To: <20210105001341.GL552508@nvidia.com> X-Cookie: I'm ANN LANDERS!! I can SHOPLIFT!! User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 04, 2021 at 08:13:41PM -0400, Jason Gunthorpe wrote: > On Mon, Jan 04, 2021 at 09:19:30PM +0000, Mark Brown wrote: > > Like I keep saying the same thing applies to all non-enumerable buses - > > exactly the same considerations exist for all the other buses like I2C > > (including the ACPI naming issue you mention below), and for that matter > > with enumerable buses which can have firmware info. > And most busses do already have their own bus type. ACPI, I2C, PCI, > etc. It is just a few that have been squished into platform, notably > OF. You're missing the point there. I2C is enumerated by firmware in exactly the same way as the platform bus is, it's not discoverable from the hardware (and similarly for a bunch of other buses). If we were to say that we need separate device types for platform devices enumerated using firmware then by analogy we should do the same for devices on these other buses that happen to be enumerated by firmware. I'm not convinced this is actually the design that's being pushed by Greg here, to the extent anything is being actively pushed. > But now it begs the question, why not push harder to make 'struct > device' the generic universal access point and add some resource_get() > API along these lines so even a platform_device * isn't needed? We still need a struct device of some kind so the discussions about exactly which bus type one is supposed to use in which circumstances remain given that you're not supposed to have raw struct devices. > Then the path seems much clearer, add a multi-bus-type device_driver > that has a probe(struct device *) and uses the 'universal api_get()' > style interface to find the generic 'resources'. That's exactly how things like mixed I2C/SPI devices work at present, given that they can usually use regmap to hide register I/O. > int gpiod_count(struct device *dev, const char *con_id) > { > int count =3D -ENOENT; > if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) > count =3D of_gpio_get_count(dev, con_id); > else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) > count =3D acpi_gpio_count(dev, con_id); >=20 > if (count < 0) > count =3D platform_gpio_count(dev, con_id); > With an actual bus specific virtual function: > return dev->bus->gpio_count(dev); That won't work, you might have a mix of enumeration types for a given bus type in a single system so you'd need to do this per device. It's also not clear to me that it is useful to spread things out like this, it makes it more hassle to add new APIs since you have to change core code. --5vNYLRcllDrimb99 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl/0bOAACgkQJNaLcl1U h9ASGQf+PqdAMqCv0v40Pazm4IUU5EhqpiFSYI0ApyvEeiC+ax6gxyaqepjUv9Iy QVScfPevt2Q95DSeFBBbTl0tNmGp6xVJedt1bb3f7O8tT6Og47jvopRj9Ng6Eua3 WBAXS1FsNefwO1XYB7lZbIPoGtZ3e93zDC3Lhfk8OMSzobu6Oc62xkHOV70E+TAK WWk2LX/abBhoGcP71eh6HmH/iSoSrjZFIamO3KNmZ46oq7aDLbIM658cy0/vku0j Ed6tn2HjxxT+UaQ4Fh6Egs8MldDGQWwBdvjo6+i8+zTKy+TDbq+ftf0YOjfHPNn/ BLq3yUaioOz3/qxoY/b+oWE2kwZ2Tg== =DXq7 -----END PGP SIGNATURE----- --5vNYLRcllDrimb99--