From patchwork Tue Sep 22 13:04:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11792519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D2FD92C for ; Tue, 22 Sep 2020 13:08:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EA2F02396D for ; Tue, 22 Sep 2020 13:08:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mMpyqes+"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AgwGvqV5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA2F02396D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6/TMwhimTVPFXaQQpufnUzHWAS99cY67XRA9dgTTtJ8=; b=mMpyqes+CZs2g8k7r3yEgw+px bs1MRBCaFkg97wRm0/j2mc6uhHdoEIDpaL1mxKkff8kxYsSdZ8O2cV8iDEfc26JuhPMxBm/dlLx+1 O2km5EWWPUpiLZ8Js8lGlGE5VygmUZwiwtfxx+2etcjDKtMV4CdQHb+aNHCIXjyMOok/Sz0DPZGG1 IA8eqN6/EKvmN3tmA5ZYSdJvgr98Uxv9n5bb6s4T9mTjLb2/wdNuO0OOoOww8LitPkcU7Y0+D8pnf 6AmfN2IJwO/9SAt47lsl0Moz2trZsp4cwu08HoNRnp1DdiON7i2sP0bQAytAHW+7z0xUFdGx3EVJG EhPz5Dcsg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKhzs-0002lb-MT; Tue, 22 Sep 2020 13:06:18 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKhyn-0002QF-Ip for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2020 13:05:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600779908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WhCqGMhbTPpzuMxFH08XGb+AsIJ09aFNt8j1Zra1m9Q=; b=AgwGvqV5cjPsiXBub5B7IXPlE6B9LRz+/gv6IdWfNS5jI6fmjIstAW84BVXWp6JPgD2L/m 5AGU0g2KkFdUnofUgp6IJ+qRw3PT2XAjccDJykBi8sP+iVv72KmBH5LGm5uXInLZZn1LqT 8mpcu8AA90tXg/NBUgLFabmZ9SJvMUM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-P8Cq0BK5OZGMTdClNBMHhg-1; Tue, 22 Sep 2020 09:05:06 -0400 X-MC-Unique: P8Cq0BK5OZGMTdClNBMHhg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3E0AADC00; Tue, 22 Sep 2020 13:05:04 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-30.bne.redhat.com [10.64.54.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8632373670; Tue, 22 Sep 2020 13:05:02 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 09/13] firmware: arm_sdei: Remove while loop in sdei_event_unregister() Date: Tue, 22 Sep 2020 23:04:19 +1000 Message-Id: <20200922130423.10173-10-gshan@redhat.com> In-Reply-To: <20200922130423.10173-1-gshan@redhat.com> References: <20200922130423.10173-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_090511_025356_1CD2DE49 X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: -1.7 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H5 RBL: Excellent reputation (+5) [216.205.24.124 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [216.205.24.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -1.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, james.morse@arm.com, shan.gavin@gmail.com, Jonathan.Cameron@huawei.com, will@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This removes the unnecessary while loop in sdei_event_unregister() because of the following two reasons. This shouldn't cause any functional changes. * The while loop is executed for once, meaning it's not needed in theory. * With the while loop removed, the nested statements can be avoid to make the code a bit cleaner. Signed-off-by: Gavin Shan Reviewed-by: Jonathan Cameron --- drivers/firmware/arm_sdei.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 6595bd66aa73..790bff70d169 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -491,24 +491,23 @@ int sdei_event_unregister(u32 event_num) mutex_lock(&sdei_events_lock); event = sdei_event_find(event_num); - do { - if (!event) { - pr_warn("Event %u not registered\n", event_num); - err = -ENOENT; - break; - } + if (!event) { + pr_warn("Event %u not registered\n", event_num); + err = -ENOENT; + goto unlock; + } - spin_lock(&sdei_list_lock); - event->reregister = false; - event->reenable = false; - spin_unlock(&sdei_list_lock); + spin_lock(&sdei_list_lock); + event->reregister = false; + event->reenable = false; + spin_unlock(&sdei_list_lock); - err = _sdei_event_unregister(event); - if (err) - break; + err = _sdei_event_unregister(event); + if (err) + goto unlock; - sdei_event_destroy(event); - } while (0); + sdei_event_destroy(event); +unlock: mutex_unlock(&sdei_events_lock); return err;