Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp331601rdb; Fri, 5 Jan 2024 11:12:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3WsXbOUSWsaG6AGs6Z52iLxM5jdVngq43nyEWEkXBqAZJEn2+ZBArTF8pEkXZdxuNXKY3 X-Received: by 2002:a05:6a00:1c87:b0:6d9:ac49:4e36 with SMTP id y7-20020a056a001c8700b006d9ac494e36mr2470389pfw.68.1704481975595; Fri, 05 Jan 2024 11:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704481975; cv=none; d=google.com; s=arc-20160816; b=KCwG3u3BXc5LRK5oLnjZ/bxIYqzzq8hzpPI2/kKhTIiDSyJR+JIh3jWSo1dOEPOUfm xPxvvAXw+wqArIKzOfZb8b2BbAiPmEZiQ4wxCr6j8yB2NoXF8t8QS8hPwIjF9+veSjMs /rbZfXNqhRr1ALJN6f84IxTtrhwCLuALXZQLtsAqM5A+aFtuf/sXWBHw20re0Vl+qkCT PNLaeFc8uVw3paxyZdDyvWyLMiO9wHONMQAFw0Ai8pLky+kPfwDcD75SP7SKZubxjdOS +U/jsqZg5zdqP7+DaFZ6N9r5ys9BlMPGga6RBs9imrAg+9pDZscE+iLJMJNuOetffRtE gBhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=ErPKmSYhNrbfnzyEAO2BQ7vXgNXlBRQQMiqSRXEACtk=; fh=5vf+uLzie1HRhfbrsNSTNabAbIF7C3Fqt/5w7JsYlGQ=; b=YYUzsjgs+LwOL5lVSUeT+PmocI1CBGuZOR3pH7LcernEcde55C22Nwoqzfp42STBxr TY98ssKiIrv/3ErwO55ONhGuSW7DR98ejupc5gVuwiBfOfpegUeU4Bglln5vEOKxKeeG Kr6wD8YaU4QD/4H0YA2noa/YDMWMY2KbNG6cZa/v3YlnTO3JBNsLw6IOM6C3DHnjnYK+ 90XKw1FCR50AUqcEaquuxajQ3gyVmWnZIf+/QV9lXyyANj3LVsfPkES2ZNXQUYHZcCYe mpwzeOvLZRB2gBEg4hWdkR0ChVk2mP1q9oTB9GFfi4+ZI2/d4lh+9Ejz9DasUczOcjrK iW1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18290-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18290-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r4-20020a62e404000000b006d9be379dc7si1658198pfh.237.2024.01.05.11.12.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 11:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18290-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18290-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18290-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4549D284A7F for ; Fri, 5 Jan 2024 19:12:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D98435EFB; Fri, 5 Jan 2024 19:12:48 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0C1335EF8 for ; Fri, 5 Jan 2024 19:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rLpbk-0005gn-FF; Fri, 05 Jan 2024 20:11:52 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rLpbi-000e8E-Ky; Fri, 05 Jan 2024 20:11:50 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rLpbi-003rVv-1k; Fri, 05 Jan 2024 20:11:50 +0100 Date: Fri, 5 Jan 2024 20:11:50 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Philipp Stanner Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Palcu , Lucas Stach , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Mark Brown , Takashi Iwai , David Gow , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH 1/2] platform_device: add devres function region-reqs Message-ID: <5k75ed3czl6rqzkykl7xc4dbyih2frunoor4ypfqxx7yzfs2vd@6ieg4dewtgxf> References: <20240105172218.42457-2-pstanner@redhat.com> <20240105172218.42457-3-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3o2nisona3kyspak" Content-Disposition: inline In-Reply-To: <20240105172218.42457-3-pstanner@redhat.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --3o2nisona3kyspak Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 05, 2024 at 06:22:18PM +0100, Philipp Stanner wrote: > Some drivers want to use (request) a region exclusively but nevertheless > create several mappings within that region. >=20 > Currently, there is no managed devres function to request a region > without mapping it. >=20 > Add the function devm_platform_get_resource() >=20 > Signed-off-by: Philipp Stanner > --- > drivers/base/platform.c | 37 +++++++++++++++++++++++++++++++++ > include/linux/platform_device.h | 2 ++ > 2 files changed, 39 insertions(+) >=20 > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index 10c577963418..243b9ec54d04 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -82,6 +82,43 @@ struct resource *platform_get_mem_or_io(struct platfor= m_device *dev, > } > EXPORT_SYMBOL_GPL(platform_get_mem_or_io); > =20 > +/** > + * devm_platform_get_and_resource - get and request a resource This function name is wrong. > + * > + * @pdev: the platform device to get the resource from > + * @type: resource type (either IORESOURCE_MEM or IORESOURCE_IO) > + * @num: resource index > + * @name: name to be associated with the request > + * > + * Return: a pointer to the resource on success, an ERR_PTR on failure. > + * > + * Gets a resource and requests it. Use this instead of > + * devm_platform_ioremap_resource() only if you have to create several s= ingle > + * mappings with devm_ioremap(). > + */ > +struct resource *devm_platform_get_resource(struct platform_device *pdev, > + unsigned int type, unsigned int num, const char *name) > +{ > + struct resource *res; > + > + res =3D platform_get_resource(pdev, type, num); > + if (!res) > + return ERR_PTR(-EINVAL); =46rom devm_platform_get_resource I'd expect that it only does platform_get_resource() + register a cleanup function to undo it. > + if (type & IORESOURCE_MEM) > + res =3D devm_request_mem_region(&pdev->dev, res->start, res->end, name= ); > + else if (type & IORESOURCE_IO) > + res =3D devm_request_region(&pdev->dev, res->start, res->end, name); > + else > + return ERR_PTR(-EINVAL); So this part is surprising. IMHO your function's name should include "request". > + if (!res) > + return ERR_PTR(-EBUSY); > + > + return res; > +} > +EXPORT_SYMBOL_GPL(devm_platform_get_resource); > + > #ifdef CONFIG_HAS_IOMEM > /** > * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource()= for a Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --3o2nisona3kyspak Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmWYVHUACgkQj4D7WH0S /k7XoQf/XQgujb3wJQ7wPs2niAnyXYWMuP6k5VtPrmtieV97iKmKJoovSFpNlN7z i1CC2tHW8sXkAROPQmqKUjaYNhA7EaIcR1I5uAaE657JeEAvST4cmrrgH/lBE6XG uov7/CgYQNxTRDbix2M47T2fj2BfQiQtPVVIkdYOhkJatWSq7FOx/2Fi74NzISHF 3GWVPlWVpT4U/hn78DsEmfxtWcw4cdoq3pVYZQyGHKzdEKu79IKgVjllgtBVNiMb x0yJ+ifcj7OC2zbfCHjdgd5+igXKmSQw6OJdG6VOOmICgvNwTczUl/QvMCfOt7FB sxivF8VqMGJ5VpFauMWtvBS/3oyKrw== =2FhD -----END PGP SIGNATURE----- --3o2nisona3kyspak--