From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17CE124A074 for ; Mon, 6 Jul 2026 20:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783370592; cv=none; b=Fn8gc4lF5JXEfLaBXd+NB8bvQb+hTqf7D1HZzU5fQnrZclbcynHOm2rv6Rq4v5ftk+cRL85JpwlZ45h+FdRtLf+3UJvs2UzvS58ut8lGAQzxl+iqvC/sn3RJAlB11pF/w0DlSLROg8BHs32mzIN9bS6juNXkXhSqLsxs9Ci/P1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783370592; c=relaxed/simple; bh=rdHWKQtKnLg83grHgN5IAyACJE//06tR6Xap9IRwE2w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tMQNHXhBFNZxxK/8jhnNXgI/td9xNCAC5WBDhRMQ8gC+hDMQ4n/vA5T5XO1KxXv5W2Ei9AERk3R/oq3rRFzFXfV9j+9edMeIdaaibnXk4ErJfoLnGV84Qv9jHoLOoBqjozRG4qNYOj8ZybQno1aioFZObyczb+fGAfZ8PE86PJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FfkYQ49Y; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=CkpKR+UL; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FfkYQ49Y"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="CkpKR+UL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783370590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a0yT3cRB/ZfiLQ4mk1Xbwro2I/aUVBk2/yCRP+/Pzhg=; b=FfkYQ49YRDCrHT6hDF4LdhaTVFkAHeNerEUccyTT4UfY9TFDe1fGongQMrcK71r95VQTW3 2zofffZxE1Rx8U6mmE1NuRv85/aJ4lK19utWhThg0dQh/5CUq7stkl4K57AAAJJs64SMLk bxiBD79IpjcDmGJH8BlO1svg2YmgOEs= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-jHkdbyx_Pb-GsEAiB-Uueg-1; Mon, 06 Jul 2026 16:43:09 -0400 X-MC-Unique: jHkdbyx_Pb-GsEAiB-Uueg-1 X-Mimecast-MFC-AGG-ID: jHkdbyx_Pb-GsEAiB-Uueg_1783370588 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8ec235c7c66so44941446d6.0 for ; Mon, 06 Jul 2026 13:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783370588; x=1783975388; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=a0yT3cRB/ZfiLQ4mk1Xbwro2I/aUVBk2/yCRP+/Pzhg=; b=CkpKR+ULNyObLROQ8kW5wSukIH8hOtxDzeLxrjcMAZHlXKFQcFxnfMGVkRfm3Msjau 1LWcYUlxmItIMyb3BE++5J0FlTVnEF30xt5nz8jn7IYJ5a9i/5JRvWBd+Le1uRpteFnG jNAFry2OMwnOejfTty/+oi20tMCnlQoXslFZ3C1Q+HqOWxeHX75JvO1CB1L065K/PuOA JmeZ7bQUOPwx9MgQ/Yir7dqNSTUnVqKiAVudaGjs0iRBtwsMT2ZcowR5Rv2jlXcrsoap APSNaZXlIns6nkbyzhZHmzIAt38l+nTffsd02ENrF+w21w408Z0/IGSFk/F2X73qYQ1i bXuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783370588; x=1783975388; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=a0yT3cRB/ZfiLQ4mk1Xbwro2I/aUVBk2/yCRP+/Pzhg=; b=mUeW+RhRdCZ7W6OLFmEEHTG21VkKIBasCqgeL8aRGzR7KX4RvPnl1HkVUeqy2iAdcq UU3QWDbB3PjTr1d/FXPA23ohEtePOXOeOFPdWnxo+fqVppIan5MbGlI8umAyQW9NrzW4 5iPwIqInw5NbYMoBowBdk4KyEhdTeuqBbXvL4A/0jwKas8W1wVY2wqjmJiPEuv54RCBl L30f+NxqD7kjizNgKiSqFtxm1XJOTQQQBb98xsDMEjL1lkZSBS1n8v/n3DPf6DTPTLMT RpLA4s5eCFnDKQrpKdx0cNnQJw7Nq2x3YsTNwJWx2AkBgK+9Ql27odWaU3dYQxzUndRK DU6Q== X-Forwarded-Encrypted: i=1; AHgh+Rr8NRYgbX8WfFouH6ZTkd3kIp//B6NHETnB26AHKjyHkbfzHkk/HD/6WzVdDR6YIVUDQDShzK7EbB6LZa0=@vger.kernel.org X-Gm-Message-State: AOJu0YxbyEo4SLJywCzTHUtlPiThW0aakJihpR/Ngjbwqv8iikSmdd+m ewZxCzyWSo/Zr/is8u98HXKiwk/cyztOyfXV45z0SsR9hfuzIGBeMVwridF3dGV5TQ2Yqg8LYYh yNwMfxBkJR3Vd+byQZY7qXNjYdJ/OYCKtHOP+cw/mg5I3UGCUgou7iXeqiW4LtUQ6wg== X-Gm-Gg: AfdE7cklKW/T0VZcai1ke8FWPNq6Aad7n9NKmu/xf2lLdYt2N1POhhOMR+e7D6G0ISv KWRODKbMV6GHuo5shBk9Hw5AGWVsMIfvyr1aylHZCoFwAx47W25Z5zzeXupWB5j5SzdkIDVt4EH YLN/YLfaWJpJFx4/npzclYAgu4EkwXqHObBC6hUi2zzgaJdO/QgdBpecLFl5qbeK8HzqRN2+Xrt HOPA9JA5PqMDVYe+66qWMqtRSBL4LDEhPt7aicPyZQ89fsNKp6CaRodaBD8lur+vm+Wym2TQiRI V943F5aG5qiQsn4Ls3LcQCW7dKXKoXUnjQ80zGa6PxqE++DlDzBx1FeYSwJPWKagoFVeV0Dpguk URnVTzmR67UOeH2gMv+O0KmFRgj3GehaTgIH5Im3XIyYiRQ== X-Received: by 2002:a05:6214:1d01:b0:8f3:f17a:a3f with SMTP id 6a1803df08f44-8fcb25aa951mr31607456d6.3.1783370588053; Mon, 06 Jul 2026 13:43:08 -0700 (PDT) X-Received: by 2002:a05:6214:1d01:b0:8f3:f17a:a3f with SMTP id 6a1803df08f44-8fcb25aa951mr31607136d6.3.1783370587551; Mon, 06 Jul 2026 13:43:07 -0700 (PDT) Received: from redhat.com (c-73-183-53-213.hsd1.pa.comcast.net. [73.183.53.213]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8f472a9ad1fsm143039156d6.47.2026.07.06.13.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 13:43:06 -0700 (PDT) Date: Mon, 6 Jul 2026 16:43:05 -0400 From: Brian Masney To: Myeonghun Pak Cc: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Ijae Kim Subject: Re: [PATCH v2] clk: palmas: Balance external-control clock prepare Message-ID: References: <20260624070602.10328-1-mhun512@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260624070602.10328-1-mhun512@gmail.com> User-Agent: Mutt/2.3.2 (2026-04-26) Hi Myeonghun, On Wed, Jun 24, 2026 at 04:05:42PM +0900, Myeonghun Pak wrote: > palmas_clks_init_configure() prepares the clock when an external control > pin is configured. The current driver only drops that prepare reference > when external control configuration fails. > > If provider registration fails after that point, or if the driver is later > removed, the prepare reference remains held. > > Use devm_add_action_or_reset() to manage the prepare reference. Use > devm_of_clk_add_hw_provider() to manage provider registration. This > balances the prepare reference on probe failure and driver removal. > > Fixes: 942d1d674931 ("clk: Add driver for Palmas clk32kg and clk32kgaudio clocks") > Co-developed-by: Ijae Kim > Signed-off-by: Ijae Kim > Signed-off-by: Myeonghun Pak Please split these into two separate patches. Otherwise, it looks good to me. Brian > --- > Changes in v2: > - Use devm_of_clk_add_hw_provider() for provider cleanup. > - Manage the external-control clk_prepare() with devm_add_action_or_reset(). > - Remove the manual provider remove callback. > > drivers/clk/clk-palmas.c | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c > index 39049f62db..fdbf8445eb 100644 > --- a/drivers/clk/clk-palmas.c > +++ b/drivers/clk/clk-palmas.c > @@ -194,6 +194,13 @@ static void palmas_clks_get_clk_data(struct platform_device *pdev, > cinfo->ext_control_pin = prop; > } > > +static void palmas_clks_unprepare_ext_control(void *data) > +{ > + struct palmas_clock_info *cinfo = data; > + > + clk_unprepare(cinfo->hw.clk); > +} > + > static int palmas_clks_init_configure(struct palmas_clock_info *cinfo) > { > int ret; > @@ -214,13 +221,18 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo) > return ret; > } > > + ret = devm_add_action_or_reset(cinfo->dev, > + palmas_clks_unprepare_ext_control, > + cinfo); > + if (ret) > + return ret; > + > ret = palmas_ext_control_req_config(cinfo->palmas, > cinfo->clk_desc->sleep_reqstr_id, > cinfo->ext_control_pin, true); > if (ret < 0) { > dev_err(cinfo->dev, "Ext config for %s failed, %d\n", > cinfo->clk_desc->clk_name, ret); > - clk_unprepare(cinfo->hw.clk); > return ret; > } > } > @@ -230,7 +242,6 @@ static int palmas_clks_init_configure(struct palmas_clock_info *cinfo) > static int palmas_clks_probe(struct platform_device *pdev) > { > struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); > - struct device_node *node = pdev->dev.of_node; > const struct palmas_clks_of_match_data *match_data; > struct palmas_clock_info *cinfo; > int ret; > @@ -264,24 +275,19 @@ static int palmas_clks_probe(struct platform_device *pdev) > return ret; > } > > - ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, &cinfo->hw); > + ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_simple_get, > + &cinfo->hw); > if (ret < 0) > dev_err(&pdev->dev, "Fail to add clock driver, %d\n", ret); > return ret; > } > > -static void palmas_clks_remove(struct platform_device *pdev) > -{ > - of_clk_del_provider(pdev->dev.of_node); > -} > - > static struct platform_driver palmas_clks_driver = { > .driver = { > .name = "palmas-clk", > .of_match_table = palmas_clks_of_match, > }, > .probe = palmas_clks_probe, > - .remove = palmas_clks_remove, > }; > > module_platform_driver(palmas_clks_driver); > -- > 2.47.1