Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11635349rwl; Tue, 3 Jan 2023 02:20:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcH5Ud/l74uVk38MrsX17oJGNT3uf8mh5ieBioZrORC/UB2CW3kLMsL9Xcg5/A2lszFiAF X-Received: by 2002:a17:906:d217:b0:7af:1139:de77 with SMTP id w23-20020a170906d21700b007af1139de77mr36429525ejz.4.1672741218071; Tue, 03 Jan 2023 02:20:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672741218; cv=none; d=google.com; s=arc-20160816; b=IZW/J+fMlayN3k/Igpql1Fpk7hD3tYawi3q5HHrXBikgdcX6RywBGVf8FN+O5VtH13 Naqmt3U7sPvURLo9O1tFA2pOUBtKYB0dbfVDR5PJ0DKm7Egy3/F1Y8uup/8ie8/HX+XS 9+QkmHOe2VVw8+DE7vMHKl2N6IBus3zWIhHTLLypWRFE413uKyTBBicTYSyTcfDHEkKe muWyasBmoBD473VbTHaBdcAvQC71Q+Y9qufsElLxI/+C8lSdKxFQG6TtZBoI5BUBCz3D BhU1emtW0CNKSRoQ8OxgpOOWz8axUVCdhnH+U+9lS0uwRXdfgMBKvc5bxso7IGeLZIgT MRWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HDSpqje6dR6swZWp7F9lsCF+sxxwpmlFIBLvfkoFBK8=; b=M2OWJ3aQ3LWl2xSqc2cL4XVolUE2FWIIBNPObSkCPs1ftP3GmOmPVagjFNYdpxlM6Q ImE1OUwUHRgvF0ton9kmBXnfrFHqUFZ7AUEulfhn0V5Xl2u+uilwvHV8MeerpRUc4csl 5QmMppGfbr4252b7s4hS7W0bk6+ENiDnUMJyBlAytXVJM3fxxayk4FJWqwITv5sbRfiJ O7DzSKRmpMPRhYnZuq+gL0lh1fDGzFxcTptXJs6V25kTMqphACljS1l84lsJwpUGywdm OVgeosZegQ8naVbEj/tpzPtzioByAUj3k8ZNFll0PkSwPxJ5mz1Zew4Z0GEVYSWesy0Z kDDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=iqIzdZ4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a50cc4c000000b0047338d1bfcfsi26223585edi.166.2023.01.03.02.20.03; Tue, 03 Jan 2023 02:20:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=iqIzdZ4t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236652AbjACKJh (ORCPT + 62 others); Tue, 3 Jan 2023 05:09:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231250AbjACKJe (ORCPT ); Tue, 3 Jan 2023 05:09:34 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7575D19A; Tue, 3 Jan 2023 02:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672740562; bh=ghGTnVbTjH8LiFna82e0PxqupzzWGkv+g5lVNa8Ra5I=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=iqIzdZ4tQYmJk5OtJ7aZApM2fdnlKovj+4vA3SW33uAS9+NTu/XMvNvuyLdWJoXYB JmWffC3rZzFckNwPEyaa6tL32vZL9LLx0/0z2Dch805CAeVNGJAmYXP3LeQoE7QcHk 1fXy0FDM6k6z9KDZuYF1LGaCABOn2oJ5jCsI4JoE= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 3 Jan 2023 11:09:22 +0100 (CET) X-EA-Auth: uEjUie4sn4W6bvDFzFMTM7q+IgRB6xROsIEPD8IO5ghbYWbhFVxnAngRRwyvmwuzsbcToaSgF1rKxGg44uNLn9OhdaptVPzw Date: Tue, 3 Jan 2023 15:39:17 +0530 From: Deepak R Varma To: Jiri Slaby Cc: "Maciej W. Rozycki" , Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma 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: <3c4e744f-c313-e195-af93-a22382c81bb6@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thank you, ./drv > > -- > js > suse labs >