Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp426659ybl; Wed, 4 Dec 2019 05:11:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwcBCbWR8e0iDdBj8K3dKCrKXabOHUMUroiUfuYBNH19aDvXJA/I106HRhSItU4v8uqZqEo X-Received: by 2002:aca:37d7:: with SMTP id e206mr2457734oia.87.1575465089233; Wed, 04 Dec 2019 05:11:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575465089; cv=none; d=google.com; s=arc-20160816; b=GXYutATpp+AIsbIdQCR/noiUgJ5nCA2iUKmZXu7bB9LB0PHyBgmTnCinn1GLlhrZkJ hrrRAlFjsN5mICPLrKg3QhCsEqSIt1LL9PRSlZlis4ABuZbZ7tIQuuPrztX2k65/a4fY rcMpfQg5tnPzHqqam/pRwaVdnUVP9XU4dkuMVI7coQDv3rmwQ11bCrb7yV0Y25HZNB5d fOfv/EWsdFGBp1IWpMp8j5zpWVhSW8eqds7HwX+E4LJK1U1kMoWxxHeJLewnhbW5sQSI Ek05LE9ngK/OHbgg6X982rz/udEv/IDOYdaoNZx2uzm1cOpjFhtKVVh2rCMvRfWxw/1W NZVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=ya3ULspfRCxqb9BJ+lx6dOJ4biNd6N6uQMSWdH/X0D0=; b=xg80yR64FOEjCmDvIy+LQmim1Gic3z+OmQl7XrsyeeUMnGFePxN6G/QBT1W0oe8oJI kh1co1QquuRsreeTlALKfZn+Qpu2QWAOxfgSRANYeOAeEpfe6+z1UheK6t+UrciPZrzk v292PvXmw7qE+9ZIejc7yjsXHU+h7SHYeSGHvmI3efudwBdA6AHEvKwR5MTQ0aE7PTdm dsdV/xKUmGcn4+9Lckw76x+fx0VqX8ut+m63fJ/ZmnBYd0yhHKWQ96HTXS6KXTq+7r/l IdeePVwmSEFjxQkxNV1uqLWMX540BjCUgLx/PrriuVbGKSqtb8GbWMG28BZk+uwDkcUy 4Y0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=TLtiOByY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si3212760otq.55.2019.12.04.05.11.13; Wed, 04 Dec 2019 05:11:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=TLtiOByY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbfLDNKU (ORCPT + 99 others); Wed, 4 Dec 2019 08:10:20 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50741 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726215AbfLDNKU (ORCPT ); Wed, 4 Dec 2019 08:10:20 -0500 Received: by mail-wm1-f66.google.com with SMTP id p9so6962048wmg.0 for ; Wed, 04 Dec 2019 05:10:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ya3ULspfRCxqb9BJ+lx6dOJ4biNd6N6uQMSWdH/X0D0=; b=TLtiOByYiqqBKccq8pcm8/MxTUNlQqnIG0q25Qu4YEAvv/Q076tchnUAy4Oie3yuKF RgCMK4EKG+mz6y4jzNr+gdtAJk2ukGoyKei/9Tur8JBncaB/OyuUfWSkMrlLDM+gXx4H mOIPRcpVzdh/SJnkZ9UHQ4OlPtJdDtzoI1vnA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=ya3ULspfRCxqb9BJ+lx6dOJ4biNd6N6uQMSWdH/X0D0=; b=rP2wp0/HOQkGRoSaN6FeAlugLmVrr5eIeUFgmPwXUfTMUoTbxuP5RugL6DRU6Hm4Oz 7n4NH01Re4SXBxP0Y6OMfcpCt92HVb0wOs7rvP4wWVOn3kQD4oKvXo+AGMkKNzRC+pUN QWbSwkYrsHz5pdswjDf73ai66mejKH5Ixk7J7Z1YisBWOuJaJ10/TPkVwxMsGNQJ8jhp 1htWbMWfJRrRGOwtcITCz82M6jWcAqA5mtCVGfrnZdnRJ4u3TiFvHsj9T3tzwgIGtCSd sln1N/GDo5qHPz4V63v0Nop1qHVx/lQt4W5I9/fxeL2T3H0fnvk4v761Q93V+eo9HFRx dW+w== X-Gm-Message-State: APjAAAXaHfIbMdPpUHUyblSK3ybMcoaSKFGUFPUbQdKqJc0yv/wB40uP ibhpsxGujUXe8VzbV2UqaU4u2Q== X-Received: by 2002:a7b:cd82:: with SMTP id y2mr37626595wmj.58.1575465018010; Wed, 04 Dec 2019 05:10:18 -0800 (PST) Received: from phenom.ffwll.local (212-51-149-96.fiber7.init7.net. [212.51.149.96]) by smtp.gmail.com with ESMTPSA id e16sm8132348wrj.80.2019.12.04.05.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 05:10:17 -0800 (PST) Date: Wed, 4 Dec 2019 14:10:15 +0100 From: Daniel Vetter To: Mihail Atanassov Cc: "dri-devel@lists.freedesktop.org" , nd , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 01/28] drm: Introduce drm_bridge_init() Message-ID: <20191204131015.GM624164@phenom.ffwll.local> Mail-Followup-To: Mihail Atanassov , "dri-devel@lists.freedesktop.org" , nd , Maarten Lankhorst , Maxime Ripard , David Airlie , "linux-kernel@vger.kernel.org" References: <20191204114732.28514-1-mihail.atanassov@arm.com> <20191204114732.28514-2-mihail.atanassov@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191204114732.28514-2-mihail.atanassov@arm.com> X-Operating-System: Linux phenom 5.3.0-2-amd64 User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 04, 2019 at 11:48:02AM +0000, Mihail Atanassov wrote: > A simple convenience function to initialize the struct drm_bridge. The > goal is to standardize initialization for any bridge registered with > drm_bridge_add() so that we can later add device links for consumers of > those bridges. > > v2: > - s/WARN_ON(!funcs)/WARN_ON(!funcs || !dev)/ as suggested by Daniel > - expand on some kerneldoc comments as suggested by Daniel > - update commit message as suggested by Daniel > > Signed-off-by: Mihail Atanassov Reviewed-by: Daniel Vetter > --- > drivers/gpu/drm/drm_bridge.c | 34 +++++++++++++++++++++++++++++++++- > include/drm/drm_bridge.h | 15 ++++++++++++++- > 2 files changed, 47 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index cba537c99e43..50e1c1b46e20 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -64,7 +64,10 @@ static DEFINE_MUTEX(bridge_lock); > static LIST_HEAD(bridge_list); > > /** > - * drm_bridge_add - add the given bridge to the global bridge list > + * drm_bridge_add - add the given bridge to the global bridge list. > + * > + * Drivers should call drm_bridge_init() prior adding it to the list. > + * Drivers should call drm_bridge_remove() to clean up the bridge list. > * > * @bridge: bridge control structure > */ > @@ -89,6 +92,35 @@ void drm_bridge_remove(struct drm_bridge *bridge) > } > EXPORT_SYMBOL(drm_bridge_remove); > > +/** > + * drm_bridge_init - initialise a drm_bridge structure > + * > + * @bridge: bridge control structure > + * @funcs: control functions > + * @dev: device associated with this drm_bridge > + * @timings: timing specification for the bridge; optional (may be NULL) > + * @driver_private: pointer to the bridge driver internal context (may be NULL) > + */ > +void drm_bridge_init(struct drm_bridge *bridge, struct device *dev, > + const struct drm_bridge_funcs *funcs, > + const struct drm_bridge_timings *timings, > + void *driver_private) > +{ > + WARN_ON(!funcs || !dev); > + > + bridge->dev = NULL; > + bridge->encoder = NULL; > + bridge->next = NULL; > + > +#ifdef CONFIG_OF > + bridge->of_node = dev->of_node; > +#endif > + bridge->timings = timings; > + bridge->funcs = funcs; > + bridge->driver_private = driver_private; > +} > +EXPORT_SYMBOL(drm_bridge_init); > + > /** > * drm_bridge_attach - attach the bridge to an encoder's chain > * > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index c0a2286a81e9..949e4f401a53 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -373,7 +373,16 @@ struct drm_bridge_timings { > }; > > /** > - * struct drm_bridge - central DRM bridge control structure > + * struct drm_bridge - central DRM bridge control structure. > + * > + * Bridge drivers should call drm_bridge_init() to initialize a bridge > + * driver, and then register it with drm_bridge_add(). > + * > + * Users of bridges link a bridge driver into their overall display output > + * pipeline by calling drm_bridge_attach(). > + * > + * Modular drivers in OF systems can query the list of registered bridges > + * with of_drm_find_bridge(). > */ > struct drm_bridge { > /** @dev: DRM device this bridge belongs to */ > @@ -402,6 +411,10 @@ struct drm_bridge { > > void drm_bridge_add(struct drm_bridge *bridge); > void drm_bridge_remove(struct drm_bridge *bridge); > +void drm_bridge_init(struct drm_bridge *bridge, struct device *dev, > + const struct drm_bridge_funcs *funcs, > + const struct drm_bridge_timings *timings, > + void *driver_private); > struct drm_bridge *of_drm_find_bridge(struct device_node *np); > int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, > struct drm_bridge *previous); > -- > 2.23.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch