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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 EE380C54FD0 for ; Mon, 27 Apr 2020 11:24:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCDFE205C9 for ; Mon, 27 Apr 2020 11:24:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbgD0LYT (ORCPT ); Mon, 27 Apr 2020 07:24:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:39090 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgD0LYS (ORCPT ); Mon, 27 Apr 2020 07:24:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BADA4ABC2; Mon, 27 Apr 2020 11:24:15 +0000 (UTC) Message-ID: <4842d1b72192bb7c461a2d50c8798f178da964e0.camel@suse.de> Subject: Re: [PATCH v2 04/91] firmware: rpi: Only create clocks device if we don't have a node for it From: Nicolas Saenz Julienne To: Maxime Ripard , Eric Anholt Cc: dri-devel@lists.freedesktop.org, linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Tim Gover , Phil Elwell Date: Mon, 27 Apr 2020 13:24:14 +0200 In-Reply-To: References: Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-t2CrNR4eS4OpaMihaaXw" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-t2CrNR4eS4OpaMihaaXw Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Maxime, On Fri, 2020-04-24 at 17:33 +0200, Maxime Ripard wrote: > The firmware clocks driver was previously probed through a platform_devic= e > created by the firmware driver. >=20 > Since we will now have a node for that clocks driver, we need to create t= he > device only in the case where there's no node for it already. >=20 > Signed-off-by: Maxime Ripard > --- > drivers/firmware/raspberrypi.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberryp= i.c > index da26a584dca0..1874f41b007c 100644 > --- a/drivers/firmware/raspberrypi.c > +++ b/drivers/firmware/raspberrypi.c > @@ -210,6 +210,15 @@ rpi_register_hwmon_driver(struct device *dev, struct > rpi_firmware *fw) > =20 > static void rpi_register_clk_driver(struct device *dev) > { > + /* > + * Earlier DTs don't have a node for the firmware clocks but > + * rely on us creating a platform device by hand. If we do > + * have a node for the firmware clocks, just bail out here. > + */ > + if (of_get_compatible_child(dev->of_node, > + "raspberrypi,firmware-clocks")) > + return; > + > rpi_clk =3D platform_device_register_data(dev, "raspberrypi-clk", > -1, NULL, 0); > } > @@ -262,8 +271,12 @@ static int rpi_firmware_remove(struct platform_devic= e > *pdev) > =20 > platform_device_unregister(rpi_hwmon); > rpi_hwmon =3D NULL; > - platform_device_unregister(rpi_clk); > - rpi_clk =3D NULL; > + > + if (rpi_clk) { rpi_clk, being a static global variable, will be zeroed by default. So, if = you don't register the platform device, rpi_clk is going to be NULL, which you'= re allowed to feed platform_device_unregister(), so no need to be extra carefu= l. Regards, Nicolas > + platform_device_unregister(rpi_clk); > + rpi_clk =3D NULL; > + } > + > mbox_free_channel(fw->chan); > =20 > return 0; --=-t2CrNR4eS4OpaMihaaXw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl6mwN4ACgkQlfZmHno8 x/5xXAf+Ng2E3SKjoUMbR1+VP/yWSENtjk2GqBEMGPPIZYYmsbkt9al9HYQZJ5C3 nwOXe0b3145xT5Von1/JrpzL3sPIp29cbA9zYKU+7x+WpZtSctau+dkeM5VpTPdw hHu01BPVOX2KJERjvB8u4y25U2Xpm1LzosEf9CFGDxng3LDaBrgP4j779Oq9sbq3 0pfATYlX1KFsMwbN3twlsShGwuokSb6kdcrKj53kBP2alNxL2dGpre4COea33YAx Ro1hGda3eGhqBndalntUHQ0MsSiKIwdkQP4H287W+D7UPb46ee0GdRcoVohqQadY W9mJfQMFIP2MiJ/tYqxOUPFqBrJi7A== =fYAz -----END PGP SIGNATURE----- --=-t2CrNR4eS4OpaMihaaXw-- 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 874CDC54FD0 for ; Mon, 27 Apr 2020 11:24:28 +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 3BF41205C9 for ; Mon, 27 Apr 2020 11:24:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="utVZf/CC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BF41205C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de 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: MIME-Version:References:In-Reply-To:Date:To:From:Subject:Message-ID: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=dbsPYStOWIgCnMLZERcrEFFD9QeIVOAgzbGKa2l5MgQ=; b=utVZf/CCJFJoFqFEDVdWwZPQk XrT+HFQ5uaV3KnYCMzmYkWA8idokkv30Tt0oJ4Og9rXHbLZWmqvC3aFKm0ERysrFT/k/pDNRxxl1y zy+cwE8zoOqt79pfIuOdbyoKjl4iKCiX1N+w5Lt60twXizakBo+kfHtiAyGKF0CLN2hV2z2uaLroq Tq8+FrqUjBeUT44d0rrGLfWRZ5x3H3olgx0mGxU6mmTcvDHsXXL/R4umhn5/NCW0e0q7LwaYu7Ima jzPHg34VZjgqIeMKRqZMcsgl/Xl1ZrUbrwPtDodKt4EvnFqxDcJuMbRZD7Uf5AsYhfrl85wmKZ7Bg oKGjxUCtw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jT1sA-00084o-P8; Mon, 27 Apr 2020 11:24:26 +0000 Received: from mx2.suse.de ([195.135.220.15]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jT1s5-00083W-MT; Mon, 27 Apr 2020 11:24:23 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BADA4ABC2; Mon, 27 Apr 2020 11:24:15 +0000 (UTC) Message-ID: <4842d1b72192bb7c461a2d50c8798f178da964e0.camel@suse.de> Subject: Re: [PATCH v2 04/91] firmware: rpi: Only create clocks device if we don't have a node for it From: Nicolas Saenz Julienne To: Maxime Ripard , Eric Anholt Date: Mon, 27 Apr 2020 13:24:14 +0200 In-Reply-To: References: User-Agent: Evolution 3.34.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200427_042422_040848_7E4A1EA2 X-CRM114-Status: GOOD ( 21.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Gover , Dave Stevenson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Phil Elwell , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============5628699131984865013==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============5628699131984865013== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-t2CrNR4eS4OpaMihaaXw" --=-t2CrNR4eS4OpaMihaaXw Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Maxime, On Fri, 2020-04-24 at 17:33 +0200, Maxime Ripard wrote: > The firmware clocks driver was previously probed through a platform_devic= e > created by the firmware driver. >=20 > Since we will now have a node for that clocks driver, we need to create t= he > device only in the case where there's no node for it already. >=20 > Signed-off-by: Maxime Ripard > --- > drivers/firmware/raspberrypi.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberryp= i.c > index da26a584dca0..1874f41b007c 100644 > --- a/drivers/firmware/raspberrypi.c > +++ b/drivers/firmware/raspberrypi.c > @@ -210,6 +210,15 @@ rpi_register_hwmon_driver(struct device *dev, struct > rpi_firmware *fw) > =20 > static void rpi_register_clk_driver(struct device *dev) > { > + /* > + * Earlier DTs don't have a node for the firmware clocks but > + * rely on us creating a platform device by hand. If we do > + * have a node for the firmware clocks, just bail out here. > + */ > + if (of_get_compatible_child(dev->of_node, > + "raspberrypi,firmware-clocks")) > + return; > + > rpi_clk =3D platform_device_register_data(dev, "raspberrypi-clk", > -1, NULL, 0); > } > @@ -262,8 +271,12 @@ static int rpi_firmware_remove(struct platform_devic= e > *pdev) > =20 > platform_device_unregister(rpi_hwmon); > rpi_hwmon =3D NULL; > - platform_device_unregister(rpi_clk); > - rpi_clk =3D NULL; > + > + if (rpi_clk) { rpi_clk, being a static global variable, will be zeroed by default. So, if = you don't register the platform device, rpi_clk is going to be NULL, which you'= re allowed to feed platform_device_unregister(), so no need to be extra carefu= l. Regards, Nicolas > + platform_device_unregister(rpi_clk); > + rpi_clk =3D NULL; > + } > + > mbox_free_channel(fw->chan); > =20 > return 0; --=-t2CrNR4eS4OpaMihaaXw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl6mwN4ACgkQlfZmHno8 x/5xXAf+Ng2E3SKjoUMbR1+VP/yWSENtjk2GqBEMGPPIZYYmsbkt9al9HYQZJ5C3 nwOXe0b3145xT5Von1/JrpzL3sPIp29cbA9zYKU+7x+WpZtSctau+dkeM5VpTPdw hHu01BPVOX2KJERjvB8u4y25U2Xpm1LzosEf9CFGDxng3LDaBrgP4j779Oq9sbq3 0pfATYlX1KFsMwbN3twlsShGwuokSb6kdcrKj53kBP2alNxL2dGpre4COea33YAx Ro1hGda3eGhqBndalntUHQ0MsSiKIwdkQP4H287W+D7UPb46ee0GdRcoVohqQadY W9mJfQMFIP2MiJ/tYqxOUPFqBrJi7A== =fYAz -----END PGP SIGNATURE----- --=-t2CrNR4eS4OpaMihaaXw-- --===============5628699131984865013== 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 --===============5628699131984865013==-- 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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 51111C83006 for ; Tue, 28 Apr 2020 12:47:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 305EF206D6 for ; Tue, 28 Apr 2020 12:47:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 305EF206D6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FBF86E3EB; Tue, 28 Apr 2020 12:46:29 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 505816E109 for ; Mon, 27 Apr 2020 11:24:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BADA4ABC2; Mon, 27 Apr 2020 11:24:15 +0000 (UTC) Message-ID: <4842d1b72192bb7c461a2d50c8798f178da964e0.camel@suse.de> Subject: Re: [PATCH v2 04/91] firmware: rpi: Only create clocks device if we don't have a node for it From: Nicolas Saenz Julienne To: Maxime Ripard , Eric Anholt Date: Mon, 27 Apr 2020 13:24:14 +0200 In-Reply-To: References: User-Agent: Evolution 3.34.4 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 28 Apr 2020 12:46:22 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim Gover , Dave Stevenson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Phil Elwell , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============0065676404==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============0065676404== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-t2CrNR4eS4OpaMihaaXw" --=-t2CrNR4eS4OpaMihaaXw Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Maxime, On Fri, 2020-04-24 at 17:33 +0200, Maxime Ripard wrote: > The firmware clocks driver was previously probed through a platform_devic= e > created by the firmware driver. >=20 > Since we will now have a node for that clocks driver, we need to create t= he > device only in the case where there's no node for it already. >=20 > Signed-off-by: Maxime Ripard > --- > drivers/firmware/raspberrypi.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberryp= i.c > index da26a584dca0..1874f41b007c 100644 > --- a/drivers/firmware/raspberrypi.c > +++ b/drivers/firmware/raspberrypi.c > @@ -210,6 +210,15 @@ rpi_register_hwmon_driver(struct device *dev, struct > rpi_firmware *fw) > =20 > static void rpi_register_clk_driver(struct device *dev) > { > + /* > + * Earlier DTs don't have a node for the firmware clocks but > + * rely on us creating a platform device by hand. If we do > + * have a node for the firmware clocks, just bail out here. > + */ > + if (of_get_compatible_child(dev->of_node, > + "raspberrypi,firmware-clocks")) > + return; > + > rpi_clk =3D platform_device_register_data(dev, "raspberrypi-clk", > -1, NULL, 0); > } > @@ -262,8 +271,12 @@ static int rpi_firmware_remove(struct platform_devic= e > *pdev) > =20 > platform_device_unregister(rpi_hwmon); > rpi_hwmon =3D NULL; > - platform_device_unregister(rpi_clk); > - rpi_clk =3D NULL; > + > + if (rpi_clk) { rpi_clk, being a static global variable, will be zeroed by default. So, if = you don't register the platform device, rpi_clk is going to be NULL, which you'= re allowed to feed platform_device_unregister(), so no need to be extra carefu= l. Regards, Nicolas > + platform_device_unregister(rpi_clk); > + rpi_clk =3D NULL; > + } > + > mbox_free_channel(fw->chan); > =20 > return 0; --=-t2CrNR4eS4OpaMihaaXw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEErOkkGDHCg2EbPcGjlfZmHno8x/4FAl6mwN4ACgkQlfZmHno8 x/5xXAf+Ng2E3SKjoUMbR1+VP/yWSENtjk2GqBEMGPPIZYYmsbkt9al9HYQZJ5C3 nwOXe0b3145xT5Von1/JrpzL3sPIp29cbA9zYKU+7x+WpZtSctau+dkeM5VpTPdw hHu01BPVOX2KJERjvB8u4y25U2Xpm1LzosEf9CFGDxng3LDaBrgP4j779Oq9sbq3 0pfATYlX1KFsMwbN3twlsShGwuokSb6kdcrKj53kBP2alNxL2dGpre4COea33YAx Ro1hGda3eGhqBndalntUHQ0MsSiKIwdkQP4H287W+D7UPb46ee0GdRcoVohqQadY W9mJfQMFIP2MiJ/tYqxOUPFqBrJi7A== =fYAz -----END PGP SIGNATURE----- --=-t2CrNR4eS4OpaMihaaXw-- --===============0065676404== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0065676404==--