From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 13A2B1CB13B; Thu, 22 Aug 2024 13:28:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333331; cv=none; b=WdzWxGJnBpRrfUVjAwH1yDplbegARM2trpDQGaAWX2y+k43hQHoF94iP9dKpPyYCKl2WFhb04A4bajy9gIayj2/crlanYQyv+N7aMRcH/FZ6IwBzoIU/c8ExRPOZajKOx37ZlkQtGgdjpHHpGNM4FTbs/xf5QWcc+uIZUYVyRic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333331; c=relaxed/simple; bh=nmOP7TigL4Lx6Rg75qYcaWJgEkGxlZtSC1NvnRpSduA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Bzs+yv2RIbyUYPqfU1pu21+5+7TDMBYOtUYHmuSEL4z2GeN0mewt9pjuXsUGtQTy3IgFdwj4yRloHGYKjnaZuN7ahM4ScVGnytpzaLjXhvr2WmMdxrYS3BrF3GXwI0fiDbw89j64YzYoJOeUbp1+PzlqviSusL0C2hHYLeQDQbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ByZNkwYy; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ByZNkwYy" Received: by mail.gandi.net (Postfix) with ESMTPSA id DE17160003; Thu, 22 Aug 2024 13:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724333326; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=23/UGc7HSdWd5XXoA2dH4m+DJsdQ98TBIyGL423yxJI=; b=ByZNkwYybdfVZ/peZeIpIbJiwwqti2s8SNgHbgXM3SfFoU2zBInDhtrTlr8bUtvte1Y1Ba JmJVHgL1bhDKuyIFJvsdz42Yp+lKuAlYiDUv4RAXFDqawxZ4q5vfQ+KtqA/852R9uDuwKx HXNkabi3i1/wtPrLVBPHe0XrY9M8DJYajGyDRsUsbmLV5Rpxg32QbUjeuLUfa5z2nePm40 OH2ArqJQBsTeMiKEVCnYmuznHH5g2u/ssq3Vyc2F04YX3Fluq4CyAcfrI0I8crF6wXGdAB pXKv6Q364h0BmDU4eG8d3+pnTkfF5Ro+6TnKHlW+m1egBVdjVchPgL42VTJs+w== Message-ID: Date: Thu, 22 Aug 2024 15:28:40 +0200 Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/8] tty: atmel_serial: Use devm_clk_get_enabled() helpers To: Lei Liu Cc: Paul Cercueil , Greg Kroah-Hartman , Jiri Slaby , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , =?UTF-8?Q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , Andy Shevchenko , Andi Shyti , Florian Fainelli , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , John Ogness , Thomas Gleixner , Jeff Johnson , Sebastian Andrzej Siewior , Valentin Caron , Lino Sanfilippo , Erwan Le Ray , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, opensource.kernel@vivo.com References: <20240822033924.32397-1-liulei.rjpt@vivo.com> <20240822033924.32397-5-liulei.rjpt@vivo.com> From: Richard GENOUD Content-Language: en-US, fr Organization: Bootlin In-Reply-To: <20240822033924.32397-5-liulei.rjpt@vivo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: richard.genoud@bootlin.com Le 22/08/2024 à 05:39, Lei Liu a écrit : > The devm_clk_get_enabled() helpers: > - call devm_clk_get() > - call clk_prepare_enable() and register what is needed in order to > call clk_disable_unprepare() when needed, as a managed resource. > > This simplifies the code and avoids calls to clk_disable_unprepare(). > > Signed-off-by: Lei Liu > --- > drivers/tty/serial/atmel_serial.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index 09b246c9e389..209f3d41a17c 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -2910,14 +2910,11 @@ static int atmel_serial_probe(struct platform_device *pdev) > atomic_set(&atmel_port->tasklet_shutdown, 0); > spin_lock_init(&atmel_port->lock_suspended); > > - atmel_port->clk = devm_clk_get(&pdev->dev, "usart"); > + atmel_port->clk = devm_clk_get_enabled(&pdev->dev, "usart"); > if (IS_ERR(atmel_port->clk)) { > ret = PTR_ERR(atmel_port->clk); > goto err; > } > - ret = clk_prepare_enable(atmel_port->clk); > - if (ret) > - goto err; > > atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk"); > if (IS_ERR(atmel_port->gclk)) { > @@ -2968,15 +2965,12 @@ static int atmel_serial_probe(struct platform_device *pdev) > * The peripheral clock can now safely be disabled till the port > * is used > */ > - clk_disable_unprepare(atmel_port->clk); > - Why removing this ? This is not an error path. > return 0; > > err_add_port: > kfree(atmel_port->rx_ring.buf); > atmel_port->rx_ring.buf = NULL; > err_clk_disable_unprepare: > - clk_disable_unprepare(atmel_port->clk); > clear_bit(atmel_port->uart.line, atmel_ports_in_use); > err: > return ret; Thanks, Richard.