Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11571846rwl; Tue, 3 Jan 2023 01:04:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXttA56KGOs7/4tXSWBYGN1++gIom0R03jcoWBshZKlNhuQCQOHsy6/g/3mfzprzDJ01pdJe X-Received: by 2002:a17:906:b041:b0:838:fabb:40b2 with SMTP id bj1-20020a170906b04100b00838fabb40b2mr37650243ejb.32.1672736663608; Tue, 03 Jan 2023 01:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672736663; cv=none; d=google.com; s=arc-20160816; b=GaHRyzxWBhywZwy3WIUXDUJmo7Dzt1C+OJL5W/rPcMYMvIDOOkqLfGRFltIeLRaIaX IXi3vrgNT9El3mV4sBO9NfCMXcget2MF/Ljh6ZTHc/ehvhZh06UDxl9xVmML/dJSDjLG c94gMda7joOiUx/UuofV9clTy4tO6picdZLZDGxMDpxc3klg0HvgPYp8fyuzMMWPKAWS v/ESjwZZnlf3UVmiEN4/02joS4szr8jSUflGZ2SM5Lg3QpZDwfrirK8ECCjabLJlZPMu xOlQ4OEwHNUU/giGRo1oHzMUXppxbtvIZJoyVfSwKLIxe63WkDhrHqiCoW3ra/R5H9dh gcSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=OWuBtAVQiXhHtOCFE/dLo/ozknPRfRlKEoY8cqTUGrg=; b=EREHUAkUPxpt80eSs4oBI+cNQI8iyjH1yoLL+DL37v1IJ2ILmKxWUEkXIqVpqWzdX0 9SMxvC96qEq1wpr2JSfgIIiWKT9HBXUxTS1TsrTOwTx4dK5gQZNEip2bKsXloiab7G4V zDUoDYdmyZzrcllEDsNRH/lZBCX9Nn91DAs0aVv6NYqZxtlLxJSwCPH40kHzr1ryF2eY RZ+qasKiMIgQYAmlwANY/gJa4l4kKYaaPOmsz3kpphZ5Qt9ZZ4uW5cxKZc82LtiXtt1O 46Wl9TNS27X6+4i+bc3YXAIpE9F7fnhPzYw8/nGAow8kSNcOy7X7dqVY7n1GUX1XGWur C2GA== ARC-Authentication-Results: i=1; mx.google.com; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a0564021f1400b00485abdd5460si18929943edb.336.2023.01.03.01.03.50; Tue, 03 Jan 2023 01:04:23 -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; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236937AbjACJAy (ORCPT + 61 others); Tue, 3 Jan 2023 04:00:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233088AbjACJAx (ORCPT ); Tue, 3 Jan 2023 04:00:53 -0500 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB7DD2668; Tue, 3 Jan 2023 01:00:51 -0800 (PST) Received: by mail-ej1-f49.google.com with SMTP id u19so72017143ejm.8; Tue, 03 Jan 2023 01:00:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OWuBtAVQiXhHtOCFE/dLo/ozknPRfRlKEoY8cqTUGrg=; b=O3WdqP7TlsVM27d6kRkSqaaay/Pg/Jb/WCcIR101fMKKiGYZoZvuH2nRHJoxFjUt9D cvnvsvIZRRSHOkEmrRzZ8G53Het6mv47meNh6DSzN6YfbGEFovEqNCLgZm6sURn1EO/Z ZiH8Mwjhwog67mPeRc9guKBHjAxwAaGDp6C1orIgQSmwcv3tuAACUCX0mcAYYtt80zrp 7ffIsH0GyOpmNeXikSAB4kcVLd6ZNFy1BKLCkSEItX/+uZcQ80S8zG8ynIez0Z0CO76D TMHJE7Et1+Sb6owcKrO0SQaXWlATOVvt6S3mRZ5wsLalwawrjyRkGb6ZRqW6U6ObPx/I 9rQQ== X-Gm-Message-State: AFqh2kqUGA5HcEzA9Iwo9RzQEhVUm97IoJ1Z71s+kbQZ3jryN6wQFyUl dHl8L2AVMDDRuzEC20zRad2n9yjpn4k= X-Received: by 2002:a17:906:9688:b0:7c1:1c7:3bad with SMTP id w8-20020a170906968800b007c101c73badmr35605095ejx.36.1672736450357; Tue, 03 Jan 2023 01:00:50 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:49? ([2a0b:e7c0:0:107::aaaa:49]) by smtp.gmail.com with ESMTPSA id nd12-20020a170907628c00b0084cc87c03ebsm2388616ejc.110.2023.01.03.01.00.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 01:00:49 -0800 (PST) Message-ID: <3c4e744f-c313-e195-af93-a22382c81bb6@kernel.org> Date: Tue, 3 Jan 2023 10:00:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v4 2/2] tty: serial: dz: convert atomic_* to refcount_* APIs for irq_guard Content-Language: en-US To: Deepak R Varma , "Maciej W. Rozycki" , Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar References: <51ef854f77779c82010379420139993e12c38776.1671898144.git.drv@mailo.com> From: Jiri Slaby In-Reply-To: <51ef854f77779c82010379420139993e12c38776.1671898144.git.drv@mailo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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 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? -- js suse labs