From patchwork Mon Jan 30 18:48:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 9545965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9796C604A0 for ; Mon, 30 Jan 2017 18:50:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A33127813 for ; Mon, 30 Jan 2017 18:50:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E8882818B; Mon, 30 Jan 2017 18:50:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E04127813 for ; Mon, 30 Jan 2017 18:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754069AbdA3SuP (ORCPT ); Mon, 30 Jan 2017 13:50:15 -0500 Received: from mailrelay112.isp.belgacom.be ([195.238.20.139]:4625 "EHLO mailrelay112.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754000AbdA3Ssd (ORCPT ); Mon, 30 Jan 2017 13:48:33 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2ASAwBCiY9Y/+M5QFddHQEXAQYBgl1pQ?= =?us-ascii?q?YEpjlCROwGQNYJEgg+CDIJsgzaCJEAYAQIBAQEBAQEBYiiFRiMpcSQTiVQRrVW?= =?us-ascii?q?EEIc1hkuJHoV/BZtUkW4NkHdIkjcfOIEuGhiEKAFOHIFiPzWIMgEBAQ?= X-IPAS-Result: =?us-ascii?q?A2ASAwBCiY9Y/+M5QFddHQEXAQYBgl1pQYEpjlCROwGQNYJ?= =?us-ascii?q?Egg+CDIJsgzaCJEAYAQIBAQEBAQEBYiiFRiMpcSQTiVQRrVWEEIc1hkuJHoV/B?= =?us-ascii?q?ZtUkW4NkHdIkjcfOIEuGhiEKAFOHIFiPzWIMgEBAQ?= Received: from 227.57-64-87.adsl-dyn.isp.belgacom.be (HELO localhost.localdomain) ([87.64.57.227]) by relay.skynet.be with ESMTP; 30 Jan 2017 19:48:16 +0100 From: Fabian Frederick To: Andrew Morton Cc: linux-kernel@vger.kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, Fabian Frederick Subject: [PATCH 10/14] PM / Hibernate: use atomic_dec_not_zero() Date: Mon, 30 Jan 2017 19:48:12 +0100 Message-Id: <20170130184812.18826-1-fabf@skynet.be> X-Mailer: git-send-email 2.9.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP instead of atomic_add_unless(value, -1, 0) Signed-off-by: Fabian Frederick --- kernel/power/hibernate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index b26dbc4..cfa7930 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -691,7 +691,7 @@ int hibernate(void) lock_system_sleep(); /* The snapshot device should not be opened while we're running */ - if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { + if (!atomic_dec_not_zero(&snapshot_device_available)) { error = -EBUSY; goto Unlock; } @@ -866,7 +866,7 @@ static int software_resume(void) goto Unlock; /* The snapshot device should not be opened while we're running */ - if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { + if (!atomic_dec_not_zero(&snapshot_device_available)) { error = -EBUSY; swsusp_close(FMODE_READ); goto Unlock;