Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F8EDC4332F for ; Wed, 24 Nov 2021 21:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343633AbhKXVcS (ORCPT ); Wed, 24 Nov 2021 16:32:18 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.83]:36243 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232874AbhKXVcR (ORCPT ); Wed, 24 Nov 2021 16:32:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1637789325; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Cc:Date:In-Reply-To:From:Subject:Cc:Date: From:Subject:Sender; bh=xop8XlZAoTl1OV6De+uWk96yVRTl49IvEavBZ+QQ5D8=; b=Uwz7zEyjAeqLxi9rLNp+UFq4MsyxKzi7QkPnpc2pGHFiO8JhKtRdo8wp2o13YFoKBq 37cJ53heBEu6lWTok97mTx4G+cBK+wHHGw3hS+PPlLrVO3bhsdz/optzLemsZ/xE83PL RzKZpdRE8vk+pLu38IQmJnMSq91MI0SPjo7nYUF1R/j8IFzFYyP888YYfszhH1l3RvRk hlxOx+fKSDd0SNhm9hVh0oz7OaniTAEvrGV2nHXPcnenkd9F+S9U6eRy1Ug93Y0c/J4z 1bPDa4+oO/3jLqTDVIsIy+pFwodt/Q7ob47mCdqYN1NC+Ew9J4+EoZ7TdIoqRy5F5+t6 6Euw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj7gpw91N5y2S3jsN+" X-RZG-CLASS-ID: mo00 Received: from imac.fritz.box by smtp.strato.de (RZmta 47.34.10 DYNA|AUTH) with ESMTPSA id e05ed8xAOLSi5Al (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Wed, 24 Nov 2021 22:28:44 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [PATCH v8 4/8] drm/ingenic: Add dw-hdmi driver for jz4780 From: "H. Nikolaus Schaller" In-Reply-To: Date: Wed, 24 Nov 2021 22:28:43 +0100 Cc: Rob Herring , Mark Rutland , Thomas Bogendoerfer , Geert Uytterhoeven , Kees Cook , "Eric W. Biederman" , Miquel Raynal , David Airlie , Daniel Vetter , Neil Armstrong , Robert Foss , Laurent Pinchart , Jernej Skrabec , Ezequiel Garcia , Harry Wentland , Sam Ravnborg , Maxime Ripard , Hans Verkuil , Liam Girdwood , Mark Brown , Paul Boddie , devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, Jonas Karlman , dri-devel@lists.freedesktop.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <64c6ab288d4d7159f633c860f1b23b3395491ae1.1637691240.git.hns@goldelico.com> <016973B0-B7F0-4E63-BF4F-2643611A6351@goldelico.com> To: Paul Cercueil X-Mailer: Apple Mail (2.3445.104.21) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, >>> You probably should disable the regulator (if not NULL) here. >> Indeed. Would it be ok to make struct regulator *regulator static >> or do we need dynamically allocated memory? >=20 > static non-const is almost always a bad idea, so avoid it. Well some years ago it was a perfectly simple solution that still = works... But I asked because I had a lot of doubt. >=20 > You can either: >=20 > - create a "ingenic_dw_hdmi" struct that will contain a pointer to = dw_hdmi and a pointer to the regulator. Instanciate it in the probe with = devm_kzalloc() and set the pointers, then set it as the driver data = (platform_set_drvdata). In the remove function you can then obtain the = pointer to your ingenic_dw_hdmi struct with platform_get_drvdata(), and = you can remove the dw_hdmi and unregister the regulator. >=20 > - register cleanup functions, using devm_add_action_or_reset(dev, f, = priv). When it's time to cleanup, the kernel core will call f(priv) = automatically. So you can add a small wrapper around dw_hdmi_remove() = and another one around regulator_disable(), and those will be called = automatically if your probe function fails, or when the driver is = removed. Then you can completely remove the ".remove" callback. There = are a few examples of these in the ingenic-drm-drv.c if you want to take = a look. The second one turned out to be cleaner to handle special cases like if = there is no regulator. We just register the disabler only if there is a = regulator and enable succeeds. So v9 is coming now. BR and thanks, Nikolaus