Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753386AbdGSI6z (ORCPT ); Wed, 19 Jul 2017 04:58:55 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40843 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753096AbdGSI6w (ORCPT ); Wed, 19 Jul 2017 04:58:52 -0400 From: Philippe CORNU To: Eric Anholt , "dri-devel@lists.freedesktop.org" , Archit Taneja , Andrzej Hajda , Laurent Pinchart , Thierry Reding CC: "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Thread-Topic: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Thread-Index: AQHTAAmUJjiD3Al3SkechKGeeoJfxKJauLaA Date: Wed, 19 Jul 2017 08:58:16 +0000 Message-ID: <8aee8855-7089-49b9-f43b-5f03f44c1c76@st.com> References: <20170718210510.12229-1-eric@anholt.net> <20170718210510.12229-2-eric@anholt.net> In-Reply-To: <20170718210510.12229-2-eric@anholt.net> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.45] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-19_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v6J8x2t2013015 Content-Length: 2272 Lines: 72 On 07/18/2017 11:05 PM, Eric Anholt wrote: > This will let drivers reduce the error cleanup they need, in > particular the "is_panel_bridge" flag. > > v2: Slight cleanup of remove function by Andrzej > > Signed-off-by: Eric Anholt > Reviewed-by: Andrzej Hajda Reviewed-by: Philippe Cornu Tested-by: Philippe Cornu > --- > drivers/gpu/drm/bridge/panel.c | 30 ++++++++++++++++++++++++++++++ > include/drm/drm_bridge.h | 3 +++ > 2 files changed, 33 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c > index 685c1a480201..292ee92a9c97 100644 > --- a/drivers/gpu/drm/bridge/panel.c > +++ b/drivers/gpu/drm/bridge/panel.c > @@ -195,3 +195,33 @@ void drm_panel_bridge_remove(struct drm_bridge *bridge) > devm_kfree(panel_bridge->panel->dev, bridge); > } > EXPORT_SYMBOL(drm_panel_bridge_remove); > + > +static void devm_drm_panel_bridge_release(struct device *dev, void *res) > +{ > + struct drm_bridge **bridge = res; > + > + drm_panel_bridge_remove(*bridge); > +} > + > +struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, > + struct drm_panel *panel, > + u32 connector_type) > +{ > + struct drm_bridge **ptr, *bridge; > + > + ptr = devres_alloc(devm_drm_panel_bridge_release, sizeof(*ptr), > + GFP_KERNEL); > + if (!ptr) > + return ERR_PTR(-ENOMEM); > + > + bridge = drm_panel_bridge_add(panel, connector_type); > + if (!IS_ERR(bridge)) { > + *ptr = bridge; > + devres_add(dev, ptr); > + } else { > + devres_free(ptr); > + } > + > + return bridge; > +} > +EXPORT_SYMBOL(devm_drm_panel_bridge_add); > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index 1dc94d5392e2..6522d4cbc9d9 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -268,6 +268,9 @@ void drm_bridge_enable(struct drm_bridge *bridge); > struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel, > u32 connector_type); > void drm_panel_bridge_remove(struct drm_bridge *bridge); > +struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, > + struct drm_panel *panel, > + u32 connector_type); > #endif > > #endif >