From patchwork Sat Feb 17 19:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 202678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp471289dyc; Sat, 17 Feb 2024 11:11:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3wUWutwDkvk2KFc3uoEg+DwGjytJb93mVtN96XziiPI4pstMDEPlWPcoZ8daK+Wstbn4tqt/tPr7ri06r/j8Ai7mUrw== X-Google-Smtp-Source: AGHT+IE+THwKFNPcCu9DfSQAha3F6CEPNa/t3NFXJN3Lc4ynER1MvRWR2KbFmxgiY8bHYJEF3Qzd X-Received: by 2002:a05:622a:181:b0:42c:7323:79c3 with SMTP id s1-20020a05622a018100b0042c732379c3mr10487531qtw.23.1708197111793; Sat, 17 Feb 2024 11:11:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708197111; cv=pass; d=google.com; s=arc-20160816; b=mwssbTGDqxsYMi0HooQUTh9MXKGGicxVbGNg+UDKJeZet93BRQZZITzUuNfe2dIAG8 TaorFGXpAhyBb5l0wAAB+BL81SNaVZwlBz+7EMIh4c/2+rVQNXyaPLj3CGr01XJgunCB w56YWFKvPU1wxQbOi0nPieFEupdFGpeig2sc3l1G7W/GKTdp289OT5+HtVKTrHMJW/Di Lin63koJH9pwVhtexAPVHMvSPI94eeMcw1n/ts9Cnl9f4hT2oR3scNBhrsQigpucuK9e AsgEcB/o24kLUapiiPjN+43kefBpDTx0z9qiXrUSlMewlMsUVH+fJilTrqXuQ+gJJ/RK /5EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=/gtqH8WkshCqvNYJewpUB4BZez7LbuxOjhqxgbHalf0=; fh=2U33a0H/OYjyUmH2ticKjq++YD/uTyLMP1uR2sOi8iY=; b=AFM1uKlNmEW+yPlzwrjucY+6Hc0OdMh6qNCudFvNcn6lNIt9LNpgGg8r4cKI1E2Sia YnxU6aEAVAQFkrAA0fnQMa+VjjAA10gZx2QxtxlZd085rRbpv0gX6rB8t7RF5sjqFiby 4dBUReOUgl9PuhR3IIwLjbDPHny8gxhAGT2dnPrVDEEYnIqNwjhsKpSQoNBFDT+zfM91 fvlqBj5JjCus2Z3V6vEVHhMT+1yvCY3qB7kvSa3alY21Zm29wL6MMgBGioJtu6mJ2maB U7f1kV1GXo7vHe3z3pRg2johKMxDMTuNmPFVUhcCnf1PywbtQJspfnhHm8q4vCwkKl7T c3ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=Pv1oJgBe; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-70028-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e26-20020ac8491a000000b0042de7998b54si2454633qtq.432.2024.02.17.11.11.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 11:11:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70028-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=Pv1oJgBe; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-70028-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70028-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz 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 92AD91C22894 for ; Sat, 17 Feb 2024 19:11:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 703A47E580; Sat, 17 Feb 2024 19:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="Pv1oJgBe" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA0466DCF5; Sat, 17 Feb 2024 19:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708197099; cv=none; b=qufFA+7vXvQiFXtSLX7dzUcfdxpqcpdyIt4IavlU01N1fUzzMIIQgZ2BODy+kawROFuKqiQff2c85zKdpBBdGuI/QcHyeZ6+hJ2fyynlWYL9DwpkRpBx1GwRDx52+WUInR3TRxW5QA75HxpMnA+kn834nSadWTpOF1Ul8pClZnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708197099; c=relaxed/simple; bh=GXGNf/8UKXSGI7yOkkdhqhIWE80JGkrZF+91e9t4620=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QI5KOXMFox1wI+gssot3XSO2WmFd3KRriAHHqMj6QqglHRMUdX2lxf0n+bg6+e+Jn51JRgG3gVfxjlvK0Y3HS1wIN0f+f7IYpa5qWkqz7YtF9TzxW3zzoWk6ZptSvHS/QxR2q6DUZ0FMJxslxC5Q3MoAWRchPfW1Z/zuNt5naVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=Pv1oJgBe; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708197094; bh=GXGNf/8UKXSGI7yOkkdhqhIWE80JGkrZF+91e9t4620=; h=From:To:Cc:Subject:Date:From; b=Pv1oJgBex+u11cRTONnBTCfm4kJcvGpqNkMhXzkPIkxQkAcGruP2BAM9PW0W7wCCu GEmysxPg/OuZgVNd0aymo+T6JJNSOPfBBhYk7h5iCsCA0mP2HBkVmGotj5V7KlLUP+ xgYVbODzu9UApAVV5TQF5ri08rtaVMCWcG4AHOUI= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: linux-kernel@vger.kernel.org Cc: Ondrej Jirman , Pavel Machek , Lee Jones , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Raymond Hackley , Luca Weiss , linux-leds@vger.kernel.org (open list:LED SUBSYSTEM) Subject: [PATCH] leds: sgm3140: Add missing timer cleanup and flash gpio control Date: Sat, 17 Feb 2024 20:11:30 +0100 Message-ID: <20240217191133.1757553-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791174494594641334 X-GMAIL-MSGID: 1791174494594641334 From: Ondrej Jirman Enabling strobe and then setting brightness to 0 causes the driver to enter invalid state after strobe end timer fires. We should cancel strobe mode resources when changing brightness (aka torch mode). Fixes: cef8ec8cbd21 ("leds: add sgm3140 driver") Signed-off-by: Ondrej Jirman --- I also have a sense the driver has other issues, like running regulator_disable in atomic context, and lacking locking in general. But that's for another time. I don't think this device is typically used from multiple threads/processes. But writing strobe = 1 and then brightness = 0 affects real usecases. drivers/leds/flash/leds-sgm3140.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/leds/flash/leds-sgm3140.c b/drivers/leds/flash/leds-sgm3140.c index eb648ff54b4e..db0ac6641954 100644 --- a/drivers/leds/flash/leds-sgm3140.c +++ b/drivers/leds/flash/leds-sgm3140.c @@ -114,8 +114,11 @@ static int sgm3140_brightness_set(struct led_classdev *led_cdev, "failed to enable regulator: %d\n", ret); return ret; } + gpiod_set_value_cansleep(priv->flash_gpio, 0); gpiod_set_value_cansleep(priv->enable_gpio, 1); } else { + del_timer_sync(&priv->powerdown_timer); + gpiod_set_value_cansleep(priv->flash_gpio, 0); gpiod_set_value_cansleep(priv->enable_gpio, 0); ret = regulator_disable(priv->vin_regulator); if (ret) {