Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1495286rdb; Mon, 8 Jan 2024 00:25:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWeoHLB7CUNA1l+huFmI86g5WbgNUrMhNR8JlGz6+BAkrOZlH2qXXkmgvwf8pFhc0zKGHY X-Received: by 2002:a05:6a20:4290:b0:199:ab8a:7a50 with SMTP id o16-20020a056a20429000b00199ab8a7a50mr2032972pzj.32.1704702348177; Mon, 08 Jan 2024 00:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704702348; cv=none; d=google.com; s=arc-20160816; b=o7vfURVEhxF4N+g0Z4e8+EBVmYEwFKeafKTotFd9T+cXnOgi75mv/Zw8wAJ+8TUEcG TbvopHAWjQ7LggnaKiOEUR/PNiPw+XGnF6RxurL2PaaPtMVXOXqTyZ1/Ujc6pE0gBbIm /pa2o3qSVckS8n7svcoLlC2TOEEl1H9Lv1f/cVqmW43VNwBXh3FvKjYbRp1bDwWwJZaa 9ZU/kxWl/ONo8jnWePSV/InxTTX5epiUe9kNA9qGcXyUrJycQTolruZ7plg6Pcj1B+Da Dkjf+xn1+rY6rn4eunq+VONDEniiNUp0WaYDIzhkByXXF6w4JCLgM2YdCwC10jefhalV Y1Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=KZTv9nbes+UUv6ydUaDBh+0jRRVdETkIFavswDy7m5g=; fh=QDcpXezgEITB/QSLy8iJDVYP9ihNcngEVYTchkt5Ye8=; b=h5bCPOpFNHYoR/EJz8X43E3CGYgjc8qb3Yi1E6pGGWL9LyFQxxTROt3lVR1Ca4uLqK 0e6IARgBEBNth9CGPc6jhe3kmsW5v+M4+vSifZcbv5RWGbeQH07lO0sjXxI9kGrdOSns eyc4yP83a6UXrPtC6of/nRG37uykyx0N6C8BFPfYQTlWHYu3KQb/gPuaqBu9dUQi1KdF YS8rZD7WTidV+3zFfHtzqFk38J98p3ClIVEm9111M3OuqpPj3hY6DotoU9cP90FRPUyj ElMeLktubUvBslUsLq50S4Dfv8udvjr5ADYTqEcHfNmr0lnEi2+S5RnVthZteWZ+iseP eeew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gESezSnz; spf=pass (google.com: domain of linux-kernel+bounces-19182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j13-20020a056a00234d00b006dab3629a78si5824926pfj.373.2024.01.08.00.25.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 00:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gESezSnz; spf=pass (google.com: domain of linux-kernel+bounces-19182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 007C9B2121F for ; Mon, 8 Jan 2024 08:25:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15D88BA26; Mon, 8 Jan 2024 08:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gESezSnz" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 D0E6FB665 for ; Mon, 8 Jan 2024 08:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704702332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KZTv9nbes+UUv6ydUaDBh+0jRRVdETkIFavswDy7m5g=; b=gESezSnzLQ++EcmmORs8Xw7RVyySirLfgYj9kGu+9QJMT2PKoPZnZnR5tdFVr8PWQbsWxd dguMmYyMFNqoD98BmOnB2h1v76uqgO5IA+SjY+aZ7oeZre5DYmOBfjy6AHjvBWfjCVq5EU 9djF4HbotoJ8QQqI9d7r8INvDVWoD4I= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-0CaYMRCVOrmpV6T-XdDqtg-1; Mon, 08 Jan 2024 03:25:26 -0500 X-MC-Unique: 0CaYMRCVOrmpV6T-XdDqtg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-78130939196so50381485a.1 for ; Mon, 08 Jan 2024 00:25:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704702325; x=1705307125; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KZTv9nbes+UUv6ydUaDBh+0jRRVdETkIFavswDy7m5g=; b=dwPCvDRwyQP5ZFh+a9pVnrWjE28gBBE9aC6GXJtLJnh1A1tgGsAfyd9S+yLHFMtcYV WS9C1DOWQNTIqUV3KYlYs9Vj3pLcJr394R+KjoK6IEpfbRHQkFbNxLYu2gv68jsY0vrH o9H44WRvMnGZfr+i2zDuz8N3db+6/LroxH3IELBSML2zh1oBeCD4Wwkmu2+JE6Lob6s6 hexAKUhtV83vU9A102ivkbaKebgYv12ah4/yy9WfeQDzE7uuPw53ZY5Q5muhU4Wc1LFf WjJ1r9gWrbG7OiZKfKWX1Ug1YPdB1q7G5ii+MijPlDa6uZh8CEdtBDEhdKVw9w/E0Z7L u2rg== X-Gm-Message-State: AOJu0YxZKquhad6Tbf535jJTR4j7RIOIUDjVmBi0GAR5JGmyTHpuEalk +3mALzdnePdUgaQH6bNRK0ygP1wtVAcLn0+JENzyQU6FhyxkMZJntb23rdSelt/XIb3Eg29tZ+p wBMHt/cru/6nqOtBP0nL1fj5zB+AXJu9/LdXoLYnS X-Received: by 2002:a05:620a:288e:b0:783:c16:7a16 with SMTP id j14-20020a05620a288e00b007830c167a16mr6043900qkp.1.1704702325676; Mon, 08 Jan 2024 00:25:25 -0800 (PST) X-Received: by 2002:a05:620a:288e:b0:783:c16:7a16 with SMTP id j14-20020a05620a288e00b007830c167a16mr6043890qkp.1.1704702325367; Mon, 08 Jan 2024 00:25:25 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id c28-20020a05620a135c00b007831a3aaa0bsm1087803qkl.110.2024.01.08.00.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 00:25:25 -0800 (PST) Message-ID: <3d0e251f0d58f1f8266074973644160d831fa462.camel@redhat.com> Subject: Re: [PATCH 1/2] platform_device: add devres function region-reqs From: Philipp Stanner To: Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= Cc: dri-devel@lists.freedesktop.org, Fabio Estevam , "Rafael J. Wysocki" , Greg Kroah-Hartman , Sascha Hauer , linux-kernel@vger.kernel.org, Maxime Ripard , Mark Brown , NXP Linux Team , Thomas Zimmermann , Laurentiu Palcu , David Gow , Shawn Guo , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org Date: Mon, 08 Jan 2024 09:25:22 +0100 In-Reply-To: <5k75ed3czl6rqzkykl7xc4dbyih2frunoor4ypfqxx7yzfs2vd@6ieg4dewtgxf> References: <20240105172218.42457-2-pstanner@redhat.com> <20240105172218.42457-3-pstanner@redhat.com> <5k75ed3czl6rqzkykl7xc4dbyih2frunoor4ypfqxx7yzfs2vd@6ieg4dewtgxf> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi On Fri, 2024-01-05 at 20:11 +0100, Uwe Kleine-K=C3=B6nig wrote: > 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 > > --- > > =C2=A0drivers/base/platform.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 | 37 > > +++++++++++++++++++++++++++++++++ > > =C2=A0include/linux/platform_device.h |=C2=A0 2 ++ > > =C2=A02 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 > > platform_device *dev, > > =C2=A0} > > =C2=A0EXPORT_SYMBOL_GPL(platform_get_mem_or_io); > > =C2=A0 > > +/** > > + * devm_platform_get_and_resource - get and request a resource >=20 > This function name is wrong. >=20 > > + * > > + * @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 single > > + * mappings with devm_ioremap(). > > + */ > > +struct resource *devm_platform_get_resource(struct platform_device > > *pdev, > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0unsigned int type, unsigned int num, const char > > *name) > > +{ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct resource *res; > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0res =3D platform_get_resourc= e(pdev, type, num); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!res) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ERR_PTR(-EINVAL); >=20 > From devm_platform_get_resource I'd expect that it only does > platform_get_resource() + register a cleanup function to undo it. >=20 > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (type & IORESOURCE_MEM) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0res =3D devm_request_mem_region(&pdev->dev, res- > > >start, res->end, name); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else if (type & IORESOURCE_I= O) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0res =3D devm_request_region(&pdev->dev, res->start, > > res->end, name); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ERR_PTR(-EINVAL); >=20 > So this part is surprising. IMHO your function's name should include > "request". Yes, that sounds very correct to me. I'll address that in v2 Thx for the feedback, P. >=20 > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!res) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0return ERR_PTR(-EBUSY); > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return res; > > +} > > +EXPORT_SYMBOL_GPL(devm_platform_get_resource); > > + > > =C2=A0#ifdef CONFIG_HAS_IOMEM > > =C2=A0/** > > =C2=A0 * devm_platform_get_and_ioremap_resource - call > > devm_ioremap_resource() for a >=20 > Best regards > Uwe >=20