Message ID | 20231114150130.497915-5-sui.jingfeng@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp1987989rwb; Tue, 14 Nov 2023 07:11:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuZgpsJDyTj18exeJIrPLXbPiSiNPrH65CVWlHAZfIIubF7Y2aQdwxGHxCncQjW6fB2ako X-Received: by 2002:a05:6a20:8f29:b0:15e:707c:904 with SMTP id b41-20020a056a208f2900b0015e707c0904mr9250233pzk.24.1699974677085; Tue, 14 Nov 2023 07:11:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699974677; cv=none; d=google.com; s=arc-20160816; b=E0s2xsogSUrxuAtNT/WgfxM/i9extCJdzedr1Sdzkqe4dz8rggEnwujEIVcnGOGZ1f Ex8mwVXk/10dqQJ95eOq5pqbsuSwJ91rMKlT3DR1Hx4LQvaXv/tElPsgws8V0cBB1Oaf mj4C0XTktPKTmZku2jYNwkSVOTS7aoaGIDloSvepblF6iIC5a9soWQE/9hp4ulO2uv+l dQKRp5ATIYZclK1wjIKbop90cT1yYZjyxgrPEonDNviwb3R99C3hYiT+UWdN7lm1Wmvj tb9w5u3QWtNmRkmsCdU+dQg/Gvl4MSAUc2iaIADzS1tsVy6PuObQ7KlfT8Vn8Fzr8/20 iFnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m5kKprLLEL4tPCbX40jldFRROJifNOVhztsTzbLcjYw=; fh=AsQUxY17UP4I4ANjAjzQGhV+/8Tz+vG6DJFG+Cn0IYE=; b=Nlss0V/AQMuu56P664cnkyJpWSP6lJgu7g62cTNwwNoPbOotxiutpsRovXCm7vGv/i FqIOisLPfPeKNYcdiE13aUIo7h2VZgnJdAur/p1GBEjxwwyQa50E5n38vUH2i1sM7WbS dN0LRqEPBk4lQELIuv7XAxzF2nDwuHUQriOKGNZoU0fvtjkYFgtoX3dJuWBhOKdfH/T5 KDzXs7Vc4ErkcT/Ivzw7BpBAWQ0dXNmRUJgIMvy1lck2Z7kTyWrDQfzHkdO8fh2DaNz0 xqzlW6AAoC4VevuPlt9w3bAPhbYMF1GMc+9r7Cg2oJ7Hjalm6z3myWx1ysFnFXS5mhDH NZyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WyS6P1AX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z192-20020a6333c9000000b005b88dfa676esi7842642pgz.158.2023.11.14.07.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 07:11:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WyS6P1AX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6EEAD8026421; Tue, 14 Nov 2023 07:11:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbjKNPJx (ORCPT <rfc822;lhua1029@gmail.com> + 29 others); Tue, 14 Nov 2023 10:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233472AbjKNPJh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Nov 2023 10:09:37 -0500 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F4B1A1 for <linux-kernel@vger.kernel.org>; Tue, 14 Nov 2023 07:09:32 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1699974134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m5kKprLLEL4tPCbX40jldFRROJifNOVhztsTzbLcjYw=; b=WyS6P1AXayZo5bIYUZyFvxH6Pcx9HWuPhtPw37v8O/C66WjCM/UsZI7uLcPBQhHcgaFult iAcTH0nqI4aF7oSAFTboO7pyfc69AuLknUW9GM/uJkXUWSgMdgnBcNGGZ9brJwJvjYiGsZ OuC9XAyhhLHvBgL2h19yod6bgx6jhXg= From: Sui Jingfeng <sui.jingfeng@linux.dev> To: Phong LE <ple@baylibre.com>, Neil Armstrong <neil.armstrong@linaro.org> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sui Jingfeng <suijingfeng@loongson.cn> Subject: [PATCH 4/8] drm/bridge: it66121: Add a helper function to get the next bridge Date: Tue, 14 Nov 2023 23:01:26 +0800 Message-Id: <20231114150130.497915-5-sui.jingfeng@linux.dev> In-Reply-To: <20231114150130.497915-1-sui.jingfeng@linux.dev> References: <20231114150130.497915-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 14 Nov 2023 07:11:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782552647005644018 X-GMAIL-MSGID: 1782552647005644018 |
Series |
Allow link the it66121 display bridge driver as a lib
|
|
Commit Message
Sui Jingfeng
Nov. 14, 2023, 3:01 p.m. UTC
From: Sui Jingfeng <suijingfeng@loongson.cn> Group the code lines(which with the same functional) into one dedicated function, which reduce the weight of it66121_probe() function. Just trivial cleanuo, no functional change. Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn> --- drivers/gpu/drm/bridge/ite-it66121.c | 53 ++++++++++++++++++---------- 1 file changed, 34 insertions(+), 19 deletions(-)
Comments
On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@linux.dev> wrote: > > From: Sui Jingfeng <suijingfeng@loongson.cn> > > Group the code lines(which with the same functional) into one dedicated > function, which reduce the weight of it66121_probe() function. Just trivial > cleanuo, no functional change. > > Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn> > --- > drivers/gpu/drm/bridge/ite-it66121.c | 53 ++++++++++++++++++---------- > 1 file changed, 34 insertions(+), 19 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c > index 0f78737adc83..7e473beefc79 100644 > --- a/drivers/gpu/drm/bridge/ite-it66121.c > +++ b/drivers/gpu/drm/bridge/ite-it66121.c > @@ -340,6 +340,37 @@ static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width) > return 0; > } > > +static int it66121_of_get_next_bridge(struct device *dev, > + struct drm_bridge **next_bridge) it already exists and it is called drm_of_find_panel_or_bridge(), could you please use it instead? > +{ > + struct device_node *np; > + struct drm_bridge *bridge; > + > + np = of_graph_get_remote_node(dev->of_node, 1, -1); > + if (!np) { > + dev_err(dev, "The endpoint is unconnected\n"); > + return -EINVAL; > + } > + > + if (!of_device_is_available(np)) { > + of_node_put(np); > + dev_err(dev, "The remote device is disabled\n"); > + return -ENODEV; > + } > + > + bridge = of_drm_find_bridge(np); > + of_node_put(np); > + > + if (!bridge) { > + dev_dbg(dev, "Next bridge not found, deferring probe\n"); > + return -EPROBE_DEFER; > + } > + > + *next_bridge = bridge; > + > + return 0; > +} > + > static const struct regmap_range_cfg it66121_regmap_banks[] = { > { > .name = "it66121", > @@ -1531,7 +1562,6 @@ static const char * const it66121_supplies[] = { > static int it66121_probe(struct i2c_client *client) > { > u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; > - struct device_node *ep; > int ret; > struct it66121_ctx *ctx; > struct device *dev = &client->dev; > @@ -1553,24 +1583,9 @@ static int it66121_probe(struct i2c_client *client) > if (ret) > return ret; > > - ep = of_graph_get_remote_node(dev->of_node, 1, -1); > - if (!ep) { > - dev_err(dev, "The endpoint is unconnected\n"); > - return -EINVAL; > - } > - > - if (!of_device_is_available(ep)) { > - of_node_put(ep); > - dev_err(dev, "The remote device is disabled\n"); > - return -ENODEV; > - } > - > - ctx->next_bridge = of_drm_find_bridge(ep); > - of_node_put(ep); > - if (!ctx->next_bridge) { > - dev_dbg(dev, "Next bridge not found, deferring probe\n"); > - return -EPROBE_DEFER; > - } > + ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); > + if (ret) > + return ret; > > i2c_set_clientdata(client, ctx); > mutex_init(&ctx->lock); > -- > 2.34.1 >
Hi, On 2023/11/15 00:05, Dmitry Baryshkov wrote: > On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@linux.dev> wrote: >> From: Sui Jingfeng <suijingfeng@loongson.cn> >> >> Group the code lines(which with the same functional) into one dedicated >> function, which reduce the weight of it66121_probe() function. Just trivial >> cleanuo, no functional change. >> >> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn> >> --- >> drivers/gpu/drm/bridge/ite-it66121.c | 53 ++++++++++++++++++---------- >> 1 file changed, 34 insertions(+), 19 deletions(-) >> >> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c >> index 0f78737adc83..7e473beefc79 100644 >> --- a/drivers/gpu/drm/bridge/ite-it66121.c >> +++ b/drivers/gpu/drm/bridge/ite-it66121.c >> @@ -340,6 +340,37 @@ static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width) >> return 0; >> } >> >> +static int it66121_of_get_next_bridge(struct device *dev, >> + struct drm_bridge **next_bridge) > it already exists and it is called drm_of_find_panel_or_bridge(), > could you please use it instead? That function is too fat and tangled, and should be untangled. it66121 can not connect with a panel, this is a prior knowledge and is known at compile time. So this prior knowledge shouldn't be dropped. >> +{ >> + struct device_node *np; >> + struct drm_bridge *bridge; >> + >> + np = of_graph_get_remote_node(dev->of_node, 1, -1); >> + if (!np) { >> + dev_err(dev, "The endpoint is unconnected\n"); >> + return -EINVAL; >> + } >> + >> + if (!of_device_is_available(np)) { >> + of_node_put(np); >> + dev_err(dev, "The remote device is disabled\n"); >> + return -ENODEV; >> + } >> + >> + bridge = of_drm_find_bridge(np); >> + of_node_put(np); >> + >> + if (!bridge) { >> + dev_dbg(dev, "Next bridge not found, deferring probe\n"); >> + return -EPROBE_DEFER; >> + } >> + >> + *next_bridge = bridge; >> + >> + return 0; >> +} >> + >> static const struct regmap_range_cfg it66121_regmap_banks[] = { >> { >> .name = "it66121", >> @@ -1531,7 +1562,6 @@ static const char * const it66121_supplies[] = { >> static int it66121_probe(struct i2c_client *client) >> { >> u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; >> - struct device_node *ep; >> int ret; >> struct it66121_ctx *ctx; >> struct device *dev = &client->dev; >> @@ -1553,24 +1583,9 @@ static int it66121_probe(struct i2c_client *client) >> if (ret) >> return ret; >> >> - ep = of_graph_get_remote_node(dev->of_node, 1, -1); >> - if (!ep) { >> - dev_err(dev, "The endpoint is unconnected\n"); >> - return -EINVAL; >> - } >> - >> - if (!of_device_is_available(ep)) { >> - of_node_put(ep); >> - dev_err(dev, "The remote device is disabled\n"); >> - return -ENODEV; >> - } >> - >> - ctx->next_bridge = of_drm_find_bridge(ep); >> - of_node_put(ep); >> - if (!ctx->next_bridge) { >> - dev_dbg(dev, "Next bridge not found, deferring probe\n"); >> - return -EPROBE_DEFER; >> - } >> + ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); >> + if (ret) >> + return ret; >> >> i2c_set_clientdata(client, ctx); >> mutex_init(&ctx->lock); >> -- >> 2.34.1 >> >
On Thu, 23 Nov 2023 at 07:25, Sui Jingfeng <sui.jingfeng@linux.dev> wrote: > > Hi, > > > On 2023/11/15 00:05, Dmitry Baryshkov wrote: > > On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@linux.dev> wrote: > >> From: Sui Jingfeng <suijingfeng@loongson.cn> > >> > >> Group the code lines(which with the same functional) into one dedicated > >> function, which reduce the weight of it66121_probe() function. Just trivial > >> cleanuo, no functional change. > >> > >> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn> > >> --- > >> drivers/gpu/drm/bridge/ite-it66121.c | 53 ++++++++++++++++++---------- > >> 1 file changed, 34 insertions(+), 19 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c > >> index 0f78737adc83..7e473beefc79 100644 > >> --- a/drivers/gpu/drm/bridge/ite-it66121.c > >> +++ b/drivers/gpu/drm/bridge/ite-it66121.c > >> @@ -340,6 +340,37 @@ static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width) > >> return 0; > >> } > >> > >> +static int it66121_of_get_next_bridge(struct device *dev, > >> + struct drm_bridge **next_bridge) > > it already exists and it is called drm_of_find_panel_or_bridge(), > > could you please use it instead? > > That function is too fat and tangled, and should be untangled. > it66121 can not connect with a panel, this is a prior knowledge > and is known at compile time. So this prior knowledge shouldn't > be dropped. This prior knowledge is kept by passing NULL as a panel. We already have a helper. It covers your use case. There is no need to write your own boilerplate code for it. > > >> +{ > >> + struct device_node *np; > >> + struct drm_bridge *bridge; > >> + > >> + np = of_graph_get_remote_node(dev->of_node, 1, -1); > >> + if (!np) { > >> + dev_err(dev, "The endpoint is unconnected\n"); > >> + return -EINVAL; > >> + } > >> + > >> + if (!of_device_is_available(np)) { > >> + of_node_put(np); > >> + dev_err(dev, "The remote device is disabled\n"); > >> + return -ENODEV; > >> + } > >> + > >> + bridge = of_drm_find_bridge(np); > >> + of_node_put(np); > >> + > >> + if (!bridge) { > >> + dev_dbg(dev, "Next bridge not found, deferring probe\n"); > >> + return -EPROBE_DEFER; > >> + } > >> + > >> + *next_bridge = bridge; > >> + > >> + return 0; > >> +} > >> + > >> static const struct regmap_range_cfg it66121_regmap_banks[] = { > >> { > >> .name = "it66121", > >> @@ -1531,7 +1562,6 @@ static const char * const it66121_supplies[] = { > >> static int it66121_probe(struct i2c_client *client) > >> { > >> u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; > >> - struct device_node *ep; > >> int ret; > >> struct it66121_ctx *ctx; > >> struct device *dev = &client->dev; > >> @@ -1553,24 +1583,9 @@ static int it66121_probe(struct i2c_client *client) > >> if (ret) > >> return ret; > >> > >> - ep = of_graph_get_remote_node(dev->of_node, 1, -1); > >> - if (!ep) { > >> - dev_err(dev, "The endpoint is unconnected\n"); > >> - return -EINVAL; > >> - } > >> - > >> - if (!of_device_is_available(ep)) { > >> - of_node_put(ep); > >> - dev_err(dev, "The remote device is disabled\n"); > >> - return -ENODEV; > >> - } > >> - > >> - ctx->next_bridge = of_drm_find_bridge(ep); > >> - of_node_put(ep); > >> - if (!ctx->next_bridge) { > >> - dev_dbg(dev, "Next bridge not found, deferring probe\n"); > >> - return -EPROBE_DEFER; > >> - } > >> + ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); > >> + if (ret) > >> + return ret; > >> > >> i2c_set_clientdata(client, ctx); > >> mutex_init(&ctx->lock); > >> -- > >> 2.34.1 > >> > >
diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c index 0f78737adc83..7e473beefc79 100644 --- a/drivers/gpu/drm/bridge/ite-it66121.c +++ b/drivers/gpu/drm/bridge/ite-it66121.c @@ -340,6 +340,37 @@ static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width) return 0; } +static int it66121_of_get_next_bridge(struct device *dev, + struct drm_bridge **next_bridge) +{ + struct device_node *np; + struct drm_bridge *bridge; + + np = of_graph_get_remote_node(dev->of_node, 1, -1); + if (!np) { + dev_err(dev, "The endpoint is unconnected\n"); + return -EINVAL; + } + + if (!of_device_is_available(np)) { + of_node_put(np); + dev_err(dev, "The remote device is disabled\n"); + return -ENODEV; + } + + bridge = of_drm_find_bridge(np); + of_node_put(np); + + if (!bridge) { + dev_dbg(dev, "Next bridge not found, deferring probe\n"); + return -EPROBE_DEFER; + } + + *next_bridge = bridge; + + return 0; +} + static const struct regmap_range_cfg it66121_regmap_banks[] = { { .name = "it66121", @@ -1531,7 +1562,6 @@ static const char * const it66121_supplies[] = { static int it66121_probe(struct i2c_client *client) { u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 }; - struct device_node *ep; int ret; struct it66121_ctx *ctx; struct device *dev = &client->dev; @@ -1553,24 +1583,9 @@ static int it66121_probe(struct i2c_client *client) if (ret) return ret; - ep = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!ep) { - dev_err(dev, "The endpoint is unconnected\n"); - return -EINVAL; - } - - if (!of_device_is_available(ep)) { - of_node_put(ep); - dev_err(dev, "The remote device is disabled\n"); - return -ENODEV; - } - - ctx->next_bridge = of_drm_find_bridge(ep); - of_node_put(ep); - if (!ctx->next_bridge) { - dev_dbg(dev, "Next bridge not found, deferring probe\n"); - return -EPROBE_DEFER; - } + ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge); + if (ret) + return ret; i2c_set_clientdata(client, ctx); mutex_init(&ctx->lock);