Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp548029rwi; Thu, 13 Oct 2022 01:39:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kP1cxK5E7G3m6FkJdyLiy0CijG57u5jKjdYtCqzkIANbYZ5BnBiA0PdIktrjnhZlXTcdE X-Received: by 2002:a17:90b:1d8a:b0:20c:a6db:5713 with SMTP id pf10-20020a17090b1d8a00b0020ca6db5713mr10044204pjb.135.1665650346610; Thu, 13 Oct 2022 01:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665650346; cv=none; d=google.com; s=arc-20160816; b=gmJFt2dDE+cr2y0UeVqzQ6ycxZdBMYABfpQL5F5oqQMl5o3Ng/As0UfeQsE3XEnpn4 kr04VySGR1f2mODRYK1uJUkJBav5WVqySY57Sf9r1EbMusJygiGL+yq1UVW6nn6YXAjd WRsUouqgLs+9P2AmOkkYRsk+jM3diXl2bNHJZR41AtD1WUO7rL9OB6I6r9ZMFTaKLSlN nMbp8e0IR3+uKEVAwTAsZe9AeZujbj4qtPEZxMXP39RQ5bTsONw9GC98v2l89JN/FYaM PoSoDcNxU50rksYEVXxLin7mMSZTMg+JFIcmn3/mq0iW5TYFbq33TkAt4/rHaryKbyG3 8n5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ch5+32Tspfl3nAjse8cgjSZNdAMlKaOr5BHFnI6rUJ8=; b=jiwDKzaCcBh/kNMwTMqcmyhOhKNjmCSWw9Hc50Vqwq44ZajUEx3jaJGPE52NoouKKa PkMwCNX/KSDp9ERJKnqYtboTebmNhoikdDlyHl1vZJixXgOmjBmDtExVcnCYQJdxTAkz U8ATib4lHrDs7g7b3JQD4suSGk2SPslZ/k/55Tir7TIsCIvY4kTCnDT528b3VP0+9o8v W0T0l5YCsn6RXYsqPN5O+pd8nDNqLTP/in379wO13Q8LZ76M8vS/IAuTa75vwlMkbZD0 BsGhdjqyW6O2gVSa2X42WAJHIce8b4p6wg0Evu+zI9yPRLFMddUv52/oFecqh1/0NY8y ELSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hyKizyv5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a656687000000b00439e40a8664si24718959pgw.374.2022.10.13.01.38.54; Thu, 13 Oct 2022 01:39:06 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20210112 header.b=hyKizyv5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbiJMINW (ORCPT + 99 others); Thu, 13 Oct 2022 04:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJMINR (ORCPT ); Thu, 13 Oct 2022 04:13:17 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D6514BB42 for ; Thu, 13 Oct 2022 01:13:08 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k9so722466pll.11 for ; Thu, 13 Oct 2022 01:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ch5+32Tspfl3nAjse8cgjSZNdAMlKaOr5BHFnI6rUJ8=; b=hyKizyv5Sz154nkuJUT0CxaLvDggdaQ3RjD3kspBDqOaAmnsXdFdzPt3omWexYc0AF 4dcUlD36dcjD2yhZK6S8FIkU0Ek/V5zDrkfFgokMesqjtPyR+7w0an0EmS4UbuJZ8Lnc 8Dh7O6eLTbAVCppouIiRte7+TpgTBVOx18wRgOSndgXLTI1FZlT6N1SoiKuMqf4A1zxV 5/6SbuOSwHZDlKXtnlKfPyziZiwkgVTcgKjSpZ+op5iuU6chLfKQShoR1l62trXC8qEx ce6iQ0eh/3rSRIBrwzbsHwrsjbh+LQImbu+jsxvj1LjP3SZDcwKRSZwfXinkhCHquwKJ CCYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ch5+32Tspfl3nAjse8cgjSZNdAMlKaOr5BHFnI6rUJ8=; b=amQsz/iC5+NmUOghZWmCEadiWT7S3w+suskmN2q12JQrJDmgj190+t0YVe6TqVqWM8 DdLesa567sFgeFbk1ffHdHqjDvFZY/fB09VDmi2kV1Uj8X5QcRYZhDh6ycXFmwHjb7ou 7a4eHD1/8INoscbNlQ8//JGDW9at+sMIAVxJY6fOteEtYZh5yIeAnHCAhjYRcN9h1a+T pV1Zc3UAQ7vcfnH1LdyZeWpbyzQXF2JAY1I+dG8LUkhGuNG9Ncdpu63pbp4gDpcaZOLP +3U3Ts3Igzy2bVcLehTYj9JQfCzsH+SIKLkrh0kXzMCsBKpOeK/tOE63Rc5FWqkGs9Bc k2eQ== X-Gm-Message-State: ACrzQf3C5oXwdXdE7GEIaxbS1F+Piy2aJiEhQAwmokCdEzbysqhVgXFe ZT8H04TjvDDFOl3Q7boITzE7fIp74v9YJg== X-Received: by 2002:a17:90b:1b4f:b0:20d:363d:7943 with SMTP id nv15-20020a17090b1b4f00b0020d363d7943mr10045814pjb.106.1665648788001; Thu, 13 Oct 2022 01:13:08 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id 186-20020a6217c3000000b005613220346asm1246445pfx.205.2022.10.13.01.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 01:13:07 -0700 (PDT) From: xu.panda668@gmail.com To: macro@orcam.me.uk Cc: jirislaby@kernel.org, linux-kernel@vger.kernel.org, Xu Panda , Zeal Robot Subject: [PATCH linux-next v2] serial: dz: use atomic_inc and atomic_dec instead of atomic_add Date: Thu, 13 Oct 2022 08:12:22 +0000 Message-Id: <20221013081220.351415-1-xu.panda668@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 From: Xu Panda It's better to use atomic_dec_return() etc. instead of atomic_add_return(). Reported-by: Zeal Robot Signed-off-by: Xu Panda --- drivers/tty/serial/dz.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c index 829b452daee9..84476cef3278 100644 --- a/drivers/tty/serial/dz.c +++ b/drivers/tty/serial/dz.c @@ -404,14 +404,14 @@ static int dz_startup(struct uart_port *uport) int ret; u16 tmp; - irq_guard = atomic_add_return(1, &mux->irq_guard); + irq_guard = atomic_inc_return(&mux->irq_guard); if (irq_guard != 1) return 0; ret = request_irq(dport->port.irq, dz_interrupt, IRQF_SHARED, "dz", mux); if (ret) { - atomic_add(-1, &mux->irq_guard); + atomic_dec(&mux->irq_guard); printk(KERN_ERR "dz: Cannot get IRQ %d!\n", dport->port.irq); return ret; } @@ -448,7 +448,7 @@ static void dz_shutdown(struct uart_port *uport) dz_stop_tx(&dport->port); spin_unlock_irqrestore(&dport->port.lock, flags); - irq_guard = atomic_add_return(-1, &mux->irq_guard); + irq_guard = atomic_dec_return(&mux->irq_guard); if (!irq_guard) { /* Disable interrupts. */ tmp = dz_in(dport, DZ_CSR); @@ -668,7 +668,7 @@ static void dz_release_port(struct uart_port *uport) iounmap(uport->membase); uport->membase = NULL; - map_guard = atomic_add_return(-1, &mux->map_guard); + map_guard = atomic_dec_return(&mux->map_guard); if (!map_guard) release_mem_region(uport->mapbase, dec_kn_slot_size); } @@ -691,11 +691,11 @@ static int dz_request_port(struct uart_port *uport) int map_guard; int ret; - map_guard = atomic_add_return(1, &mux->map_guard); + map_guard = atomic_inc_return(&mux->map_guard); if (map_guard == 1) { if (!request_mem_region(uport->mapbase, dec_kn_slot_size, "dz")) { - atomic_add(-1, &mux->map_guard); + atomic_dec(&mux->map_guard); printk(KERN_ERR "dz: Unable to reserve MMIO resource\n"); return -EBUSY; @@ -703,7 +703,7 @@ static int dz_request_port(struct uart_port *uport) } ret = dz_map_port(uport); if (ret) { - map_guard = atomic_add_return(-1, &mux->map_guard); + map_guard = atomic_dec_return(&mux->map_guard); if (!map_guard) release_mem_region(uport->mapbase, dec_kn_slot_size); return ret; -- 2.15.2