Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6626015iob; Wed, 11 May 2022 01:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaMmLqFA80cKfSYfXXSvsT8MSqXlcWKwGdpNeQ+8i1UrYv/juzwDXizv42nOu4alYg8a7a X-Received: by 2002:a17:907:7da7:b0:6f4:f92b:3986 with SMTP id oz39-20020a1709077da700b006f4f92b3986mr22674828ejc.50.1652257995518; Wed, 11 May 2022 01:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652257995; cv=none; d=google.com; s=arc-20160816; b=j7rZEOEQJFyIqqjUW6ii4Xv6rP4DOgmbWYaP+PHdJAiY0hf4U8V/fUxyqwxdPKwPOm MeC7rhMT/n2VuHFgdBAUAqECiNP906FEOY9KfUG4MJ3LMyhK/wqwu705VOsUeP/itpOh sNMakbp7h8Uh9pP7FgvuQFB5ZIM5xULLjI7CX9pOIxRFL+zP5aoMhjhHujVqxRpoaMDm GE1L76p6dDXwzbRkSGBmxiTjOA83ILPMaQHcszXc/VQg8+nsK06MDKUTl6UKWmKxR/qj f3SFzfi+CGCNHaxktRzdXpQSVnDrD0w6E/effPkdbXBrPdCjW7QxXhEE1thPprIxYRaQ diZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DdS4LZ7mqGBxPaeGzqFu6xL7PLhOVbvjUXM7la61o/M=; b=M9f8jqFym8wLA+HmPqi6/ifevtaJ9oBNEifw25U+r00fsTQIKBCfJySs8ZKXOI/GuX wC+5mZQhITZ/obbWRMcHb+D8K3NTG682W5foBzJIE2BoBpbI0Tw8o61RBrAtC8bBWF9g 98FM3PzM2uoWexeSIJpUZ5OAlpAbXepHx+Za2QFoppcuCkajtWvPaw4UMtNs8YYqzEDG 0rIi8dIxaNNGQ5K8udiOKGrvDZMdLid5loeKPqHxqyzXRvxbq+EvutBXS7U8CuS2NFrl cZfwzXL7OvZmMO1yRP/tE2HOrJZxKvhnebggRGtSk4/OF/Xl4qaFtqoNGhflCk42PIO0 TjOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XgCUr/iO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id do11-20020a170906c10b00b006e7f47d22a9si1774874ejc.434.2022.05.11.01.32.49; Wed, 11 May 2022 01:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XgCUr/iO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237502AbiEKAWh (ORCPT + 99 others); Tue, 10 May 2022 20:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231645AbiEKAWc (ORCPT ); Tue, 10 May 2022 20:22:32 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5956F51589 for ; Tue, 10 May 2022 17:22:31 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id i11so909511ybq.9 for ; Tue, 10 May 2022 17:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DdS4LZ7mqGBxPaeGzqFu6xL7PLhOVbvjUXM7la61o/M=; b=XgCUr/iOevJS21fhdEkGGCivLNeOLhoAWYumXsPp88f8f/zg+5r5oQHJyI4Ie99jFI agkIVkxUbE8yXd6i6Us8qlSyT/Th3Y/mrwqi1qoVavNqEeWz0RweVhVtAqH3vjyRYzQ3 ItTBNXxi/bmOSBRTTNxUjknJVTUCg+RndVzGtDIYpws852Kh9mUQXEBSpuS563rOh/hE bfDND2E5hCJkaOpuX/tSNFmiHcrXBGanJACUQmkrx5DOn3b2P9kZmXBCR1m7VvrDkv6A jKVcgfEuIoysQ3aA0Mo3H3SGEIPWd/6Z/VCs8DchZjZGpV1XFn4R47tG4UWTYddAgCIb cA8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DdS4LZ7mqGBxPaeGzqFu6xL7PLhOVbvjUXM7la61o/M=; b=35r7BS9G88Ouppp/ZPP9fQR+7LB4hXL6vqYbm1e10Lmyt6j08giVSnJC6nKwjiO6ya iNz1pTXuffb4Dkbdgdg9wVfikQVjJ6hWZmQEJMkqG1hWrY1d7Af6XBotQ+22N6/3yIzo Hdc9SD9DtvrCIDgykTGwpGlpVxAbS6nM1d4VI/sZlf+FYETCgYFdTLEV1Bx9kTreDZHF AVfK4IrHXLhwy6CJL6vgeoQcPEfSdukbQdOCf0AUTtgovMFAP6NMWUdvBiADgPXAP+1i 9QIxcKAaGi4XNx6/AEwapMUgfCLNoeTBVOki0XkDZb9TLB6JFkw0ZdkwF2a5oRq9LQkY mMZg== X-Gm-Message-State: AOAM532iLEzbX5lACa9pdKqj8s4hGuWOWsVM3fzz5c89zmwz4JVmcEGN 6O6Ozhzv1B/0CXP46RphHmyB4dm8EH/guBHrjaeAUw== X-Received: by 2002:a25:fb10:0:b0:64a:d339:3f38 with SMTP id j16-20020a25fb10000000b0064ad3393f38mr11111060ybe.234.1652228550563; Tue, 10 May 2022 17:22:30 -0700 (PDT) MIME-Version: 1.0 References: <20220510192944.2408515-1-dianders@chromium.org> <20220510122726.v3.3.Iba4b9bf6c7a1ee5ea2835ad7bd5eaf84d7688520@changeid> In-Reply-To: <20220510122726.v3.3.Iba4b9bf6c7a1ee5ea2835ad7bd5eaf84d7688520@changeid> From: Dmitry Baryshkov Date: Wed, 11 May 2022 03:22:19 +0300 Message-ID: Subject: Re: [PATCH v3 3/4] drm/bridge: Add devm_drm_bridge_add() To: Douglas Anderson Cc: dri-devel@lists.freedesktop.org, Hsin-Yi Wang , Abhinav Kumar , Philip Chen , Sankeerth Billakanti , Robert Foss , freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Stephen Boyd , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 May 2022 at 22:30, Douglas Anderson wrote: > > This adds a devm managed version of drm_bridge_add(). Like other > "devm" function listed in drm_bridge.h, this function takes an > explicit "dev" to use for the lifetime management. A few notes: > * In general we have a "struct device" for bridges that makes a good > candidate for where the lifetime matches exactly what we want. > * The "bridge->dev->dev" device appears to be the encoder > device. That's not the right device to use for lifetime management. > > Suggested-by: Dmitry Baryshkov > Signed-off-by: Douglas Anderson Reviewed-by: Dmitry Baryshkov > --- > > Changes in v3: > - Patch ("drm/bridge: Add devm_drm_bridge_add()") new for v3. > > drivers/gpu/drm/drm_bridge.c | 23 +++++++++++++++++++++++ > include/drm/drm_bridge.h | 1 + > 2 files changed, 24 insertions(+) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index c96847fc0ebc..e275b4ca344b 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -170,6 +170,29 @@ void drm_bridge_add(struct drm_bridge *bridge) > } > EXPORT_SYMBOL(drm_bridge_add); > > +static void drm_bridge_remove_void(void *bridge) > +{ > + drm_bridge_remove(bridge); > +} > + > +/** > + * devm_drm_bridge_add - devm managed version of drm_bridge_add() > + * > + * @dev: device to tie the bridge lifetime to > + * @bridge: bridge control structure > + * > + * This is the managed version of drm_bridge_add() which automatically > + * calls drm_bridge_remove() when @dev is unbound. > + * > + * Return: 0 if no error or negative error code. > + */ > +int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge) > +{ > + drm_bridge_add(bridge); > + return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge); > +} > +EXPORT_SYMBOL(devm_drm_bridge_add); > + > /** > * drm_bridge_remove - remove the given bridge from the global bridge list > * > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index f27b4060faa2..42aec8612f37 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -796,6 +796,7 @@ drm_priv_to_bridge(struct drm_private_obj *priv) > } > > void drm_bridge_add(struct drm_bridge *bridge); > +int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge); > void drm_bridge_remove(struct drm_bridge *bridge); > int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, > struct drm_bridge *previous, > -- > 2.36.0.550.gb090851708-goog > -- With best wishes Dmitry