Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753494AbbKBKvA (ORCPT ); Mon, 2 Nov 2015 05:51:00 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:14910 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbbKBKuz (ORCPT ); Mon, 2 Nov 2015 05:50:55 -0500 X-AuditID: cbfec7f4-f79c56d0000012ee-bd-5637400dbcc1 Subject: Re: [RFC v2 5/5] drm/dsi: Get DSI host by DT device node To: Archit Taneja , dri-devel@lists.freedesktop.org References: <1435641851-27295-1-git-send-email-architt@codeaurora.org> <1444123482-25579-1-git-send-email-architt@codeaurora.org> <1444123482-25579-6-git-send-email-architt@codeaurora.org> Cc: linux-kernel@vger.kernel.org, airlied@linux.ie, daniel@ffwll.ch, treding@nvidia.com, l.stach@pengutronix.de, robh@kernel.org, linux-arm-msm@vger.kernel.org, jani.nikula@linux.intel.com From: Andrzej Hajda Message-id: <56374004.6040501@samsung.com> Date: Mon, 02 Nov 2015 11:50:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-version: 1.0 In-reply-to: <1444123482-25579-6-git-send-email-architt@codeaurora.org> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRmVeSWpSXmKPExsVy+t/xa7q8DuZhBueXc1r0njvJZNHU8ZbV 4v+2icwWV76+Z7NYfnk9o8WDuTeZLCbuP8tucXnXHDaL/3t2sFvc/s3nwOVxua+XyWPvtwUs HptWdbJ5bP/2gNVj3slAj/vdx5k8epvfsXn0/zXw+LxJLoAzissmJTUnsyy1SN8ugStj74qa ghcSFce3fmduYNwv0sXIySEhYCLxo+sTK4QtJnHh3no2EFtIYCmjRMt7oS5GLiD7OaPEo+c3 WUASwgKOEls7V4IViQh4S8xZ3ccIUXSAUaJ15RNmEIcZxOmfvooRpIpNQFPi7+abYB28AloS s6//YgexWQRUJWZsng9WIyoQITFxQgMrRI2gxI/J98C2cQq4S9xYfBzI5gAaqidx/6IWSJhZ QF5i85q3zBMYBWYh6ZiFUDULSdUCRuZVjKKppckFxUnpuYZ6xYm5xaV56XrJ+bmbGCEx8mUH 4+JjVocYBTgYlXh4M9zNwoRYE8uKK3MPMUpwMCuJ8IZomYcJ8aYkVlalFuXHF5XmpBYfYpTm YFES5527632IkEB6YklqdmpqQWoRTJaJg1OqgTG0d2nilrOr+zY0X7rpu9Gc6U1FtdnDotKA o5NNfa/v/XrHizdXvuP/50gvX79c+/RNJpb+2cmLdnJfYa5kVH52xyPuhOQejhsP6lOmhaUL tcybWbXof36e7+QJF7rfmS+4k3pqWa+C4SOtmRNEJ87+rdBgd3JqwywB4+4bbNf9Duu8fHvf kkuJpTgj0VCLuag4EQB2Hrh9jQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3322 Lines: 104 On 10/06/2015 11:24 AM, Archit Taneja wrote: > mipi_dsi_devices are inherently aware of their host because they > share a parent-child hierarchy in the device tree. > > Non-dsi drivers that create a dummy dsi device don't have this data. > In order to get this information, they require to a phandle to the dsi > host in the device tree. > > Maintain a list of all the hosts DSI that are currently registered. > > This list will be used to find the mipi_dsi_host corresponding to the > device_node passed in of_find_mipi_dsi_host_by_node. > > Signed-off-by: Archit Taneja Looks OK, beside lack of documentation, after fixing it you can add Reviewed-by: Andrzej Hajda Regards Andrzej > --- > drivers/gpu/drm/drm_mipi_dsi.c | 30 ++++++++++++++++++++++++++++++ > include/drm/drm_mipi_dsi.h | 2 ++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c > index cbb7373..c51d73e 100644 > --- a/drivers/gpu/drm/drm_mipi_dsi.c > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > @@ -216,6 +216,28 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) > return mipi_dsi_device_new(host, &info); > } > > +static DEFINE_MUTEX(host_lock); > +static LIST_HEAD(host_list); > + > +struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) > +{ > + struct mipi_dsi_host *host; > + > + mutex_lock(&host_lock); > + > + list_for_each_entry(host, &host_list, list) { > + if (host->dev->of_node == node) { > + mutex_unlock(&host_lock); > + return host; > + } > + } > + > + mutex_unlock(&host_lock); > + > + return NULL; > +} > +EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node); > + > int mipi_dsi_host_register(struct mipi_dsi_host *host) > { > struct device_node *node; > @@ -227,6 +249,10 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host) > of_mipi_dsi_device_add(host, node); > } > > + mutex_lock(&host_lock); > + list_add_tail(&host->list, &host_list); > + mutex_unlock(&host_lock); > + > return 0; > } > EXPORT_SYMBOL(mipi_dsi_host_register); > @@ -243,6 +269,10 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv) > void mipi_dsi_host_unregister(struct mipi_dsi_host *host) > { > device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn); > + > + mutex_lock(&host_lock); > + list_del_init(&host->list); > + mutex_unlock(&host_lock); > } > EXPORT_SYMBOL(mipi_dsi_host_unregister); > > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h > index 68f49f4..15d3068 100644 > --- a/include/drm/drm_mipi_dsi.h > +++ b/include/drm/drm_mipi_dsi.h > @@ -100,10 +100,12 @@ struct mipi_dsi_host_ops { > struct mipi_dsi_host { > struct device *dev; > const struct mipi_dsi_host_ops *ops; > + struct list_head list; > }; > > int mipi_dsi_host_register(struct mipi_dsi_host *host); > void mipi_dsi_host_unregister(struct mipi_dsi_host *host); > +struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); > > /* DSI mode flags */ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/