From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8903C43381 for ; Mon, 11 Mar 2019 15:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B239020657 for ; Mon, 11 Mar 2019 15:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727651AbfCKPrG (ORCPT ); Mon, 11 Mar 2019 11:47:06 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:46533 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbfCKPrG (ORCPT ); Mon, 11 Mar 2019 11:47:06 -0400 X-Originating-IP: 90.88.150.179 Received: from localhost (aaubervilliers-681-1-31-179.w90-88.abo.wanadoo.fr [90.88.150.179]) (Authenticated sender: maxime.ripard@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C8C2D1BF216; Mon, 11 Mar 2019 15:47:02 +0000 (UTC) Date: Mon, 11 Mar 2019 16:47:02 +0100 From: Maxime Ripard To: Mans Rullgard Cc: David Airlie , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/sun4i: hdmi: add support for ddc-i2c-bus property Message-ID: <20190311154702.eslw5ccol44vxcmy@flea> References: <20190311134713.25876-1-mans@mansr.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hoxjklpx767uqidw" Content-Disposition: inline In-Reply-To: <20190311134713.25876-1-mans@mansr.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hoxjklpx767uqidw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! On Mon, Mar 11, 2019 at 01:47:13PM +0000, Mans Rullgard wrote: > Sometimes it is desirabled to use a separate i2c controller for ddc > access. This adds support for the ddc-i2c-bus property of the > hdmi-connector node, using the specified controller if provided. >=20 > Signed-off-by: Mans Rullgard > --- > drivers/gpu/drm/sun4i/sun4i_hdmi.h | 1 + > drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 37 +++++++++++++++++++++++--- > 2 files changed, 35 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/s= un4i_hdmi.h > index b685ee11623d..b08c4453d47c 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h > @@ -269,6 +269,7 @@ struct sun4i_hdmi { > struct clk *tmds_clk; > =20 > struct i2c_adapter *i2c; > + struct i2c_adapter *ddc_i2c; > =20 > /* Regmap fields for I2C adapter */ > struct regmap_field *field_ddc_en; > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun= 4i/sun4i_hdmi_enc.c > index 061d2e0d9011..5b2fac79f5d6 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > @@ -212,7 +212,7 @@ static int sun4i_hdmi_get_modes(struct drm_connector = *connector) > struct edid *edid; > int ret; > =20 > - edid =3D drm_get_edid(connector, hdmi->i2c); > + edid =3D drm_get_edid(connector, hdmi->ddc_i2c ?: hdmi->i2c); You can't test whether ddc_i2c is NULL or not... > if (!edid) > return 0; > =20 > @@ -228,6 +228,28 @@ static int sun4i_hdmi_get_modes(struct drm_connector= *connector) > return ret; > } > =20 > +static struct i2c_adapter *sun4i_hdmi_get_ddc(struct device *dev) > +{ > + struct device_node *phandle, *remote; > + struct i2c_adapter *ddc; > + > + remote =3D of_graph_get_remote_node(dev->of_node, 1, -1); > + if (!remote) > + return ERR_PTR(-EINVAL); > + > + phandle =3D of_parse_phandle(remote, "ddc-i2c-bus", 0); > + of_node_put(remote); > + if (!phandle) > + return NULL; > + > + ddc =3D of_get_i2c_adapter_by_node(phandle); > + of_node_put(phandle); > + if (!ddc) > + return ERR_PTR(-EPROBE_DEFER); > + > + return ddc; =2E.. Since even in (most) error cases you're returning a !NULL pointer. > +} > + > static const struct drm_connector_helper_funcs sun4i_hdmi_connector_help= er_funcs =3D { > .get_modes =3D sun4i_hdmi_get_modes, > }; > @@ -575,6 +597,12 @@ static int sun4i_hdmi_bind(struct device *dev, struc= t device *master, > goto err_disable_mod_clk; > } > =20 > + hdmi->ddc_i2c =3D sun4i_hdmi_get_ddc(dev); > + if (IS_ERR(hdmi->ddc_i2c)) { > + ret =3D PTR_ERR(hdmi->ddc_i2c); > + goto err_del_i2c_adapter; > + } > + > drm_encoder_helper_add(&hdmi->encoder, > &sun4i_hdmi_helper_funcs); > ret =3D drm_encoder_init(drm, > @@ -584,14 +612,14 @@ static int sun4i_hdmi_bind(struct device *dev, stru= ct device *master, > NULL); > if (ret) { > dev_err(dev, "Couldn't initialise the HDMI encoder\n"); > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > hdmi->encoder.possible_crtcs =3D drm_of_find_possible_crtcs(drm, > dev->of_node); > if (!hdmi->encoder.possible_crtcs) { > ret =3D -EPROBE_DEFER; > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > #ifdef CONFIG_DRM_SUN4I_HDMI_CEC > @@ -630,6 +658,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct= device *master, > err_cleanup_connector: > cec_delete_adapter(hdmi->cec_adap); > drm_encoder_cleanup(&hdmi->encoder); > +err_put_ddc_i2c: > + i2c_put_adapter(hdmi->ddc_i2c); > err_del_i2c_adapter: > i2c_del_adapter(hdmi->i2c); > err_disable_mod_clk: > @@ -650,6 +680,7 @@ static void sun4i_hdmi_unbind(struct device *dev, str= uct device *master, > drm_connector_cleanup(&hdmi->connector); > drm_encoder_cleanup(&hdmi->encoder); > i2c_del_adapter(hdmi->i2c); > + i2c_put_adapter(hdmi->ddc_i2c); > clk_disable_unprepare(hdmi->mod_clk); > clk_disable_unprepare(hdmi->bus_clk); > } > --=20 > 2.21.0 > It looks good otherwise, thanks! Maxime --=20 Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --hoxjklpx767uqidw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXIaC9gAKCRDj7w1vZxhR xQn+AQCqjOQQ1+h6XtoxiXvWkZ+C6Dtx3z5MoVg1ce9F19/8XgD/dCBV6PkSIYv0 FOFmmO2muAVB/UcZbyI9EvPCvn3/gwM= =e+q0 -----END PGP SIGNATURE----- --hoxjklpx767uqidw-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 479E9C43381 for ; Mon, 11 Mar 2019 15:47:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1763D20657 for ; Mon, 11 Mar 2019 15:47:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bZS50iU8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1763D20657 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Xtfe4i81LnD8ZJgGUXhvsmOYGZDUDbbPMPofVY55DK4=; b=bZS50iU8uoKU2pHjU1yR77+0E G7J2ORZl1VEmbVb9aEHGI+gkaHs4tWkf2zsI5F6srHfEK9gWyu6k6T9pNcbc6fcpSXxn4XoVlNbYp EctIP7HAqkJtUmnEUUtLPJ80szJ0YNB5q7ZsezCkATiRjmMGcK1U9Fk9kAFboTH8YsSQ1f7cMyGsS 12AtwATXVaOaHZaLWdcey6i7DtI+12OSH3QPeMa31zaS3xGZyNUTHJxPZvFcv6qMZZzrTWwYso1wY AMFY5KlgDUdcRPzgLzAdnrMB1luvWPN8zKBswk1MyjNIBzxbm6Xeixe10o6QXqE0HGuIwGyxrGi4G SbR2p1tQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3N90-0002k5-KR; Mon, 11 Mar 2019 15:47:14 +0000 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3N8v-0002jM-MX for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2019 15:47:11 +0000 X-Originating-IP: 90.88.150.179 Received: from localhost (aaubervilliers-681-1-31-179.w90-88.abo.wanadoo.fr [90.88.150.179]) (Authenticated sender: maxime.ripard@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C8C2D1BF216; Mon, 11 Mar 2019 15:47:02 +0000 (UTC) Date: Mon, 11 Mar 2019 16:47:02 +0100 From: Maxime Ripard To: Mans Rullgard Subject: Re: [PATCH] drm/sun4i: hdmi: add support for ddc-i2c-bus property Message-ID: <20190311154702.eslw5ccol44vxcmy@flea> References: <20190311134713.25876-1-mans@mansr.com> MIME-Version: 1.0 In-Reply-To: <20190311134713.25876-1-mans@mansr.com> User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190311_084710_039592_2B1D020F X-CRM114-Status: GOOD ( 22.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="===============3596312535049843483==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============3596312535049843483== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hoxjklpx767uqidw" Content-Disposition: inline --hoxjklpx767uqidw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! On Mon, Mar 11, 2019 at 01:47:13PM +0000, Mans Rullgard wrote: > Sometimes it is desirabled to use a separate i2c controller for ddc > access. This adds support for the ddc-i2c-bus property of the > hdmi-connector node, using the specified controller if provided. >=20 > Signed-off-by: Mans Rullgard > --- > drivers/gpu/drm/sun4i/sun4i_hdmi.h | 1 + > drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 37 +++++++++++++++++++++++--- > 2 files changed, 35 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/s= un4i_hdmi.h > index b685ee11623d..b08c4453d47c 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h > @@ -269,6 +269,7 @@ struct sun4i_hdmi { > struct clk *tmds_clk; > =20 > struct i2c_adapter *i2c; > + struct i2c_adapter *ddc_i2c; > =20 > /* Regmap fields for I2C adapter */ > struct regmap_field *field_ddc_en; > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun= 4i/sun4i_hdmi_enc.c > index 061d2e0d9011..5b2fac79f5d6 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > @@ -212,7 +212,7 @@ static int sun4i_hdmi_get_modes(struct drm_connector = *connector) > struct edid *edid; > int ret; > =20 > - edid =3D drm_get_edid(connector, hdmi->i2c); > + edid =3D drm_get_edid(connector, hdmi->ddc_i2c ?: hdmi->i2c); You can't test whether ddc_i2c is NULL or not... > if (!edid) > return 0; > =20 > @@ -228,6 +228,28 @@ static int sun4i_hdmi_get_modes(struct drm_connector= *connector) > return ret; > } > =20 > +static struct i2c_adapter *sun4i_hdmi_get_ddc(struct device *dev) > +{ > + struct device_node *phandle, *remote; > + struct i2c_adapter *ddc; > + > + remote =3D of_graph_get_remote_node(dev->of_node, 1, -1); > + if (!remote) > + return ERR_PTR(-EINVAL); > + > + phandle =3D of_parse_phandle(remote, "ddc-i2c-bus", 0); > + of_node_put(remote); > + if (!phandle) > + return NULL; > + > + ddc =3D of_get_i2c_adapter_by_node(phandle); > + of_node_put(phandle); > + if (!ddc) > + return ERR_PTR(-EPROBE_DEFER); > + > + return ddc; =2E.. Since even in (most) error cases you're returning a !NULL pointer. > +} > + > static const struct drm_connector_helper_funcs sun4i_hdmi_connector_help= er_funcs =3D { > .get_modes =3D sun4i_hdmi_get_modes, > }; > @@ -575,6 +597,12 @@ static int sun4i_hdmi_bind(struct device *dev, struc= t device *master, > goto err_disable_mod_clk; > } > =20 > + hdmi->ddc_i2c =3D sun4i_hdmi_get_ddc(dev); > + if (IS_ERR(hdmi->ddc_i2c)) { > + ret =3D PTR_ERR(hdmi->ddc_i2c); > + goto err_del_i2c_adapter; > + } > + > drm_encoder_helper_add(&hdmi->encoder, > &sun4i_hdmi_helper_funcs); > ret =3D drm_encoder_init(drm, > @@ -584,14 +612,14 @@ static int sun4i_hdmi_bind(struct device *dev, stru= ct device *master, > NULL); > if (ret) { > dev_err(dev, "Couldn't initialise the HDMI encoder\n"); > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > hdmi->encoder.possible_crtcs =3D drm_of_find_possible_crtcs(drm, > dev->of_node); > if (!hdmi->encoder.possible_crtcs) { > ret =3D -EPROBE_DEFER; > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > #ifdef CONFIG_DRM_SUN4I_HDMI_CEC > @@ -630,6 +658,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct= device *master, > err_cleanup_connector: > cec_delete_adapter(hdmi->cec_adap); > drm_encoder_cleanup(&hdmi->encoder); > +err_put_ddc_i2c: > + i2c_put_adapter(hdmi->ddc_i2c); > err_del_i2c_adapter: > i2c_del_adapter(hdmi->i2c); > err_disable_mod_clk: > @@ -650,6 +680,7 @@ static void sun4i_hdmi_unbind(struct device *dev, str= uct device *master, > drm_connector_cleanup(&hdmi->connector); > drm_encoder_cleanup(&hdmi->encoder); > i2c_del_adapter(hdmi->i2c); > + i2c_put_adapter(hdmi->ddc_i2c); > clk_disable_unprepare(hdmi->mod_clk); > clk_disable_unprepare(hdmi->bus_clk); > } > --=20 > 2.21.0 > It looks good otherwise, thanks! Maxime --=20 Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --hoxjklpx767uqidw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXIaC9gAKCRDj7w1vZxhR xQn+AQCqjOQQ1+h6XtoxiXvWkZ+C6Dtx3z5MoVg1ce9F19/8XgD/dCBV6PkSIYv0 FOFmmO2muAVB/UcZbyI9EvPCvn3/gwM= =e+q0 -----END PGP SIGNATURE----- --hoxjklpx767uqidw-- --===============3596312535049843483== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============3596312535049843483==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Ripard Subject: Re: [PATCH] drm/sun4i: hdmi: add support for ddc-i2c-bus property Date: Mon, 11 Mar 2019 16:47:02 +0100 Message-ID: <20190311154702.eslw5ccol44vxcmy@flea> References: <20190311134713.25876-1-mans@mansr.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1689497944==" Return-path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by gabe.freedesktop.org (Postfix) with ESMTPS id E0B1189308 for ; Mon, 11 Mar 2019 15:47:05 +0000 (UTC) In-Reply-To: <20190311134713.25876-1-mans@mansr.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Mans Rullgard Cc: David Airlie , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org --===============1689497944== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hoxjklpx767uqidw" Content-Disposition: inline --hoxjklpx767uqidw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! On Mon, Mar 11, 2019 at 01:47:13PM +0000, Mans Rullgard wrote: > Sometimes it is desirabled to use a separate i2c controller for ddc > access. This adds support for the ddc-i2c-bus property of the > hdmi-connector node, using the specified controller if provided. >=20 > Signed-off-by: Mans Rullgard > --- > drivers/gpu/drm/sun4i/sun4i_hdmi.h | 1 + > drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 37 +++++++++++++++++++++++--- > 2 files changed, 35 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/s= un4i_hdmi.h > index b685ee11623d..b08c4453d47c 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h > @@ -269,6 +269,7 @@ struct sun4i_hdmi { > struct clk *tmds_clk; > =20 > struct i2c_adapter *i2c; > + struct i2c_adapter *ddc_i2c; > =20 > /* Regmap fields for I2C adapter */ > struct regmap_field *field_ddc_en; > diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun= 4i/sun4i_hdmi_enc.c > index 061d2e0d9011..5b2fac79f5d6 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c > @@ -212,7 +212,7 @@ static int sun4i_hdmi_get_modes(struct drm_connector = *connector) > struct edid *edid; > int ret; > =20 > - edid =3D drm_get_edid(connector, hdmi->i2c); > + edid =3D drm_get_edid(connector, hdmi->ddc_i2c ?: hdmi->i2c); You can't test whether ddc_i2c is NULL or not... > if (!edid) > return 0; > =20 > @@ -228,6 +228,28 @@ static int sun4i_hdmi_get_modes(struct drm_connector= *connector) > return ret; > } > =20 > +static struct i2c_adapter *sun4i_hdmi_get_ddc(struct device *dev) > +{ > + struct device_node *phandle, *remote; > + struct i2c_adapter *ddc; > + > + remote =3D of_graph_get_remote_node(dev->of_node, 1, -1); > + if (!remote) > + return ERR_PTR(-EINVAL); > + > + phandle =3D of_parse_phandle(remote, "ddc-i2c-bus", 0); > + of_node_put(remote); > + if (!phandle) > + return NULL; > + > + ddc =3D of_get_i2c_adapter_by_node(phandle); > + of_node_put(phandle); > + if (!ddc) > + return ERR_PTR(-EPROBE_DEFER); > + > + return ddc; =2E.. Since even in (most) error cases you're returning a !NULL pointer. > +} > + > static const struct drm_connector_helper_funcs sun4i_hdmi_connector_help= er_funcs =3D { > .get_modes =3D sun4i_hdmi_get_modes, > }; > @@ -575,6 +597,12 @@ static int sun4i_hdmi_bind(struct device *dev, struc= t device *master, > goto err_disable_mod_clk; > } > =20 > + hdmi->ddc_i2c =3D sun4i_hdmi_get_ddc(dev); > + if (IS_ERR(hdmi->ddc_i2c)) { > + ret =3D PTR_ERR(hdmi->ddc_i2c); > + goto err_del_i2c_adapter; > + } > + > drm_encoder_helper_add(&hdmi->encoder, > &sun4i_hdmi_helper_funcs); > ret =3D drm_encoder_init(drm, > @@ -584,14 +612,14 @@ static int sun4i_hdmi_bind(struct device *dev, stru= ct device *master, > NULL); > if (ret) { > dev_err(dev, "Couldn't initialise the HDMI encoder\n"); > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > hdmi->encoder.possible_crtcs =3D drm_of_find_possible_crtcs(drm, > dev->of_node); > if (!hdmi->encoder.possible_crtcs) { > ret =3D -EPROBE_DEFER; > - goto err_del_i2c_adapter; > + goto err_put_ddc_i2c; > } > =20 > #ifdef CONFIG_DRM_SUN4I_HDMI_CEC > @@ -630,6 +658,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct= device *master, > err_cleanup_connector: > cec_delete_adapter(hdmi->cec_adap); > drm_encoder_cleanup(&hdmi->encoder); > +err_put_ddc_i2c: > + i2c_put_adapter(hdmi->ddc_i2c); > err_del_i2c_adapter: > i2c_del_adapter(hdmi->i2c); > err_disable_mod_clk: > @@ -650,6 +680,7 @@ static void sun4i_hdmi_unbind(struct device *dev, str= uct device *master, > drm_connector_cleanup(&hdmi->connector); > drm_encoder_cleanup(&hdmi->encoder); > i2c_del_adapter(hdmi->i2c); > + i2c_put_adapter(hdmi->ddc_i2c); > clk_disable_unprepare(hdmi->mod_clk); > clk_disable_unprepare(hdmi->bus_clk); > } > --=20 > 2.21.0 > It looks good otherwise, thanks! Maxime --=20 Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --hoxjklpx767uqidw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXIaC9gAKCRDj7w1vZxhR xQn+AQCqjOQQ1+h6XtoxiXvWkZ+C6Dtx3z5MoVg1ce9F19/8XgD/dCBV6PkSIYv0 FOFmmO2muAVB/UcZbyI9EvPCvn3/gwM= =e+q0 -----END PGP SIGNATURE----- --hoxjklpx767uqidw-- --===============1689497944== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVs --===============1689497944==--