From patchwork Mon Jan 15 23:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 1886878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=RTFGw23B; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-rtc+bounces-531-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TDSq44hMmz23dm for ; Tue, 16 Jan 2024 10:22:40 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3B97B1F22418 for ; Mon, 15 Jan 2024 23:22:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34AF41B7E3; Mon, 15 Jan 2024 23:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RTFGw23B" X-Original-To: linux-rtc@vger.kernel.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36F2C1AADB; Mon, 15 Jan 2024 23:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 6919D240003; Mon, 15 Jan 2024 23:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705360940; 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; bh=0t7+FP/+mQFoKBOTbHR2wVStwAOI2dnROp2npalSLyE=; b=RTFGw23BA2qfjFX8tCbOVWqGgpdpN3zsi+iD98iSIbyJqySkD8EO7lsw3BRlfTJAAeyCas ZuQykBVOy3Su46f//E5L2qV9C6rp+vQh/BM6uSA5mPsFcQPzZ+c4wJSWsqOMLP8D3kO1cr MXssSafMCDDjWkqW/J7SkblFWuGI79JCjy5hrMBposskrk+tCP1g9+YY/NKD0qV8FiZA3d grUmJC69IsUm82V6c/x1wV2387gqJfrgXdR2mvpXYzplWku4lopntj7tzl9vkqLDVpEQ6m EhuFFg9moNssSqG3ThYCwhvl47Gs3bFB668yo0VRxEQGktz1RisEaQkV4VqxWw== From: alexandre.belloni@bootlin.com To: Antoniu Miclaus , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] rtc: max31335: remove unecessary locking Date: Tue, 16 Jan 2024 00:22:13 +0100 Message-ID: <20240115232215.273374-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: alexandre.belloni@bootlin.com From: Alexandre Belloni There is no race condition when accessing MAX31335_STATUS1 because it is always about clearing the alarm interrupt bit. Signed-off-by: Alexandre Belloni Reviewed-by: Antoniu Miclaus --- drivers/rtc/rtc-max31335.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c index 3ddfe71bbb56..2ce23f60a7f3 100644 --- a/drivers/rtc/rtc-max31335.c +++ b/drivers/rtc/rtc-max31335.c @@ -348,27 +348,19 @@ static int max31335_alarm_irq_enable(struct device *dev, unsigned int enabled) static irqreturn_t max31335_handle_irq(int irq, void *dev_id) { struct max31335_data *max31335 = dev_id; - struct mutex *lock = &max31335->rtc->ops_lock; int ret, status; - mutex_lock(lock); - ret = regmap_read(max31335->regmap, MAX31335_STATUS1, &status); if (ret) - goto exit; + return IRQ_HANDLED; if (FIELD_GET(MAX31335_STATUS1_A1F, status)) { - ret = regmap_update_bits(max31335->regmap, MAX31335_STATUS1, - MAX31335_STATUS1_A1F, 0); - if (ret) - goto exit; + regmap_update_bits(max31335->regmap, MAX31335_STATUS1, + MAX31335_STATUS1_A1F, 0); rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF); } -exit: - mutex_unlock(lock); - return IRQ_HANDLED; } From patchwork Mon Jan 15 23:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 1886877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=oKaeMWgN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-rtc+bounces-532-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TDSq44cCzz1yPJ for ; Tue, 16 Jan 2024 10:22:40 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 78C301C22266 for ; Mon, 15 Jan 2024 23:22:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94DC51B7EA; Mon, 15 Jan 2024 23:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oKaeMWgN" X-Original-To: linux-rtc@vger.kernel.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5AAE1B7E0; Mon, 15 Jan 2024 23:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 1229E240004; Mon, 15 Jan 2024 23:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705360941; 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=MZoQRbudR0nr1ST4F7AMUIQKL7EqS+GqfmQTeUc6QIo=; b=oKaeMWgN2U9zyL8KCCc6vNlnMxv6Ju6RPulN0NB8l9Nsu92PSH/kHAmc+22HC0HS7Hxi2H wgQkaV3Z5wdSetHfxSe+g/+2xXpUin7PdoQgFBtSVWkHfj7Askk+orH8qG5rvzl4UKUcQy DB329L8FadlEF8APxitAWWg1ez5B+U8k6eVkLJyaTThatErwF36Lg5G+ffy3JEjV4PBK/t J1Q9W8qnLVR3oc4GQ4r/IE1NPCkEaSWb0uGq9/8sDO892d/5G9u/k+aVdjapdyzIn4RV7k 9n6PKgmmQHZZLewFiAuvpdt+xXFb8RtDuQ0awGXuKPGtkR2yRIK3948p3u2qKw== From: alexandre.belloni@bootlin.com To: Antoniu Miclaus , Alexandre Belloni Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] rtc: max31335: use regmap_update_bits_check Date: Tue, 16 Jan 2024 00:22:14 +0100 Message-ID: <20240115232215.273374-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115232215.273374-1-alexandre.belloni@bootlin.com> References: <20240115232215.273374-1-alexandre.belloni@bootlin.com> Precedence: bulk X-Mailing-List: linux-rtc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: alexandre.belloni@bootlin.com From: Alexandre Belloni Simplify the IRQ handler by using regmap_update_bits_check. Signed-off-by: Alexandre Belloni Reviewed-by: Antoniu Miclaus --- drivers/rtc/rtc-max31335.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c index 2ce23f60a7f3..a38d303d9df4 100644 --- a/drivers/rtc/rtc-max31335.c +++ b/drivers/rtc/rtc-max31335.c @@ -348,18 +348,16 @@ static int max31335_alarm_irq_enable(struct device *dev, unsigned int enabled) static irqreturn_t max31335_handle_irq(int irq, void *dev_id) { struct max31335_data *max31335 = dev_id; - int ret, status; + bool status; + int ret; - ret = regmap_read(max31335->regmap, MAX31335_STATUS1, &status); + ret = regmap_update_bits_check(max31335->regmap, MAX31335_STATUS1, + MAX31335_STATUS1_A1F, 0, &status); if (ret) return IRQ_HANDLED; - if (FIELD_GET(MAX31335_STATUS1_A1F, status)) { - regmap_update_bits(max31335->regmap, MAX31335_STATUS1, - MAX31335_STATUS1_A1F, 0); - + if (status) rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF); - } return IRQ_HANDLED; }