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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BCE1C4332F for ; Wed, 4 Jan 2023 08:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjADI2z (ORCPT ); Wed, 4 Jan 2023 03:28:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbjADI2y (ORCPT ); Wed, 4 Jan 2023 03:28:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0244D1869B; Wed, 4 Jan 2023 00:28:54 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 91F4F615B3; Wed, 4 Jan 2023 08:28:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81F1AC433EF; Wed, 4 Jan 2023 08:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672820933; bh=ar58y5os2YGCAH8RwgQby1IB5feNCexZ70wETyJ4bsI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OuC2NROcRWzws+vDOMTnmXLtUpumjs6aEgJvqZVed3L4FCLNjg7iFFvdotMv/HFbS deug4P+0xscrQpTGM6RvF/g3sMX5GBp9Tn+y3yK1BpTjaUzFuwxq+PLXwb8K5G4xzE 7O3PzrwbNw9PJ2oEXLip6A0ourIhlFFdXdYjrU4Y= Date: Wed, 4 Jan 2023 09:28:50 +0100 From: Greg Kroah-Hartman To: Deepak R Varma Cc: Jiri Slaby , "Maciej W. Rozycki" , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Saurabh Singh Sengar , Praveen Kumar Subject: Re: [PATCH v4 2/2] tty: serial: dz: convert atomic_* to refcount_* APIs for irq_guard Message-ID: References: <51ef854f77779c82010379420139993e12c38776.1671898144.git.drv@mailo.com> <3c4e744f-c313-e195-af93-a22382c81bb6@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org On Tue, Jan 03, 2023 at 03:39:17PM +0530, Deepak R Varma wrote: > On Tue, Jan 03, 2023 at 10:00:48AM +0100, Jiri Slaby wrote: > > On 26. 12. 22, 7:21, Deepak R Varma wrote: > > > The refcount_* APIs are designed to address known issues with the > > > atomic_t APIs for reference counting. They provide following distinct > > > advantages: > > > - protect the reference counters from overflow/underflow > > > - avoid use-after-free errors > > > - provide improved memory ordering guarantee schemes > > > - neater and safer. > > > Hence, replace the atomic_* APIs by their equivalent refcount_t > > > API functions. > > > > > > This patch proposal address the following warnings generated by > > > the atomic_as_refcounter.cocci coccinelle script > > > atomic_add_return(-1, ...) > > ... > > > --- a/drivers/tty/serial/dz.c > > > +++ b/drivers/tty/serial/dz.c > > ... > > > @@ -400,18 +399,16 @@ static int dz_startup(struct uart_port *uport) > > > struct dz_port *dport = to_dport(uport); > > > struct dz_mux *mux = dport->mux; > > > unsigned long flags; > > > - int irq_guard; > > > int ret; > > > u16 tmp; > > > > > > - irq_guard = atomic_add_return(1, &mux->irq_guard); > > > - if (irq_guard != 1) > > > + refcount_inc(&mux->irq_guard); > > > + if (refcount_read(&mux->irq_guard) != 1) > > > return 0; > > > > > > - ret = request_irq(dport->port.irq, dz_interrupt, > > > - IRQF_SHARED, "dz", mux); > > > + ret = request_irq(dport->port.irq, dz_interrupt, IRQF_SHARED, "dz", mux); > > > > How is this related to the above described change? > > No, it is not. My apologies. I must have joined the lines for improved readability > and forgot to revert. I will restore this in next revision based on the feedback > on the other patch of this series. OR I can include this change in the current > change log as a "while at it..." statement. Would you advise me? NEVER have a "while at it..." change as part of a commit unless it is relevant to the main change being made. You know better... thanks, greg k-h