From patchwork Fri Sep 27 22:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831110 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 D9E3F188CA9 for ; Fri, 27 Sep 2024 22:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476198; cv=none; b=oC6lnj31a1yJpKmQPDSkRKVWnXYGjL+sTHt/NKR50gChU0WejuqZWdd7/jNK3i3nPsvm5bKs3R/7oHGr4TVi/7SejrJbWqKFfon6kBll4qL1boDqOSLE5dMDF0/dIoVubnfXS/TBl6aqTxaFmEHbFDbRnqQxeGkQrlJ95sOXejk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476198; c=relaxed/simple; bh=Xtn246ffe+DO8hn0Ugf8AMOw+Lw1qO4c2sSOIr/ZryM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QIsnmiLqF5pPcm6xBgZ4F8tFZrVcQ3Es8S5uaU0OUBBbT/dtYrhasi8JhAr9TRqGs3ZRInfj30iTMGzFkRi2/Ho2XXUZj9AuWXg4ZHR0Y0dTI+YDJwTwHO+IU1HJq/qd5DRYHA8P7f8oAfQ9rToJ3zJlCFKzMMgvz31674bJ4Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WDOFKvIv; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WDOFKvIv" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a8d60e23b33so350775266b.0 for ; Fri, 27 Sep 2024 15:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476195; x=1728080995; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sWnKbsxefkmEHGrZFlS1qac5gpq5RncaWSP6AZtVnA0=; b=WDOFKvIv4neao9vZQtslmU4Jlvl+KVpFCpzKYIfNTWALJjr6ay1cacMNTQiL4yaImn HoqX+qUzps9dfLlJzpeo7ksl7iPi7lOxbN+QDL8vBTfvD+DxZSniMhHc0ONULAG/yfxE 1ROCQJYMSI7uQF9HpeqQVUY8ZReQ3CfIeLtG/Uv3jl2hxYgmEWHp7QV/CQyjRtKYfKAw NhXI//yAhjkDzJpapZ5osV/MLjWnejncgti+JBqoHN6FeIldc3VrrJJSkxFO6JWoiaPi tiTj2HD6MH7ZZhTlEPH2UeJa3iLsYEHKQ3PdI+Q5nCCuzYbkIO+VLpSxKliVru0WFdRb O+Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476195; x=1728080995; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sWnKbsxefkmEHGrZFlS1qac5gpq5RncaWSP6AZtVnA0=; b=GGhEo1MmAPFcRF7EMAI21fnU7wstOaJMslD7wUwDNUkfCUuXZ+vQTThoEjJ5rfX5dh cXuXCB2/TxdK91mIPNEzyHFu8la/igNHo8CJSpxeVs5qva1p5CaG5sCfeoZ/0wE8bsTe VywwZzODz8YbFSEryn3wRq5PPy1wxx0aITVnqRzn3Hk/XFObvPaL/fuVFwQV8GLlamjI V4DdxfAa0IuNv54w1U7g8Gs0m+Y6aHqlb+ZZ6y/WaGQZ6gc+XgBj1xXQoPNKXqjlEApu x+3W42UR1riE5r2bl7mDjfTVTw0m2/1TF+zJkE64FWAkICO/X1qtx134hnBhLysrdLo/ izFg== X-Gm-Message-State: AOJu0YwBgHAN0p8HThyD/dffkcsq5HEpuSpZqMJWrSo0jbq4FD5AASdO udE4XEnvsJrxDaZB5Q3VDzW/s+wX6FGgNk0sgZbWu2vKMGCG/JWc30iehivovOw= X-Google-Smtp-Source: AGHT+IEOTcEGxxl1GF0PinK1NeaeqxJkKelV79iOWepyZC9Lm/huNFkmzogsSUwTSIpX/ag79RoKAg== X-Received: by 2002:a17:907:25c3:b0:a91:158b:122c with SMTP id a640c23a62f3a-a93c496952emr400472466b.38.1727476195059; Fri, 27 Sep 2024 15:29:55 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:54 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:48 +0200 Subject: [PATCH v2 2/4] leds: bcm63138: Use scopes and guards Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-2-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 Use scoped helpers and guards to handle DT node iterations and spinlocks. This cuts some lines of code and eliminates common mistakes (such as the missing of_node_put()). Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- drivers/leds/blink/leds-bcm63138.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 3a5e0b98bfbc..374f68f4f277 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2021 Rafał Miłecki */ +#include #include #include #include @@ -125,17 +126,14 @@ static void bcm63138_leds_brightness_set(struct led_classdev *led_cdev, { struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev); struct bcm63138_leds *leds = led->leds; - unsigned long flags; - spin_lock_irqsave(&leds->lock, flags); + guard(spinlock_irqsave)(&leds->lock); bcm63138_leds_enable_led(leds, led, value); if (!value) bcm63138_leds_set_flash_rate(leds, led, 0); else bcm63138_leds_set_bright(leds, led, value); - - spin_unlock_irqrestore(&leds->lock, flags); } static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, @@ -144,7 +142,6 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, { struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev); struct bcm63138_leds *leds = led->leds; - unsigned long flags; u8 value; if (!*delay_on && !*delay_off) { @@ -179,13 +176,11 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, return -EINVAL; } - spin_lock_irqsave(&leds->lock, flags); + guard(spinlock_irqsave)(&leds->lock); bcm63138_leds_enable_led(leds, led, BCM63138_MAX_BRIGHTNESS); bcm63138_leds_set_flash_rate(leds, led, value); - spin_unlock_irqrestore(&leds->lock, flags); - return 0; } @@ -259,7 +254,6 @@ static int bcm63138_leds_probe(struct platform_device *pdev) struct device_node *np = dev_of_node(&pdev->dev); struct device *dev = &pdev->dev; struct bcm63138_leds *leds; - struct device_node *child; leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL); if (!leds) @@ -280,7 +274,7 @@ static int bcm63138_leds_probe(struct platform_device *pdev) bcm63138_leds_write(leds, BCM63138_SERIAL_LED_POLARITY, 0); bcm63138_leds_write(leds, BCM63138_PARALLEL_LED_POLARITY, 0); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { bcm63138_leds_create_led(leds, child); } From patchwork Fri Sep 27 22:29:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831109 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 28071195FFA for ; Fri, 27 Sep 2024 22:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476202; cv=none; b=oFClVnGgL169D09YxnDX46z+XewU9ihYk6Poikwvqp/E+PhuIVwh4OHgKZH88sj8Pg+q0TbPl7H32dSNfoOdyJmP1uVpUd/vtZAW55rJyh3U+tgGFdoDojcE24p//Ys3VLlhdRF/Bz4LrfUxejNpg0TjCGUR7e6et1nQMVVrYNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476202; c=relaxed/simple; bh=VzOZ0OjBtRVKiOzN7FNFk/cdUjMZXgMfwiyK8St+tx4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c0l7vuQ9P3CMMQLCKsx2T1GnZjUhhLgqHQkCMsHMWhwVz11plujuhZ4LWm76AdvEUQ6KFJ44OCio1j19piL2281rX7NUemk8PnDG94Oh4p9O2wJzAhxKGys+K+ddBON3mCj1n07bA01pLDSkCMw1Ay3aJAqAA1JetD24y5pTbq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g+ggPMjk; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g+ggPMjk" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a8d0d82e76aso375667166b.3 for ; Fri, 27 Sep 2024 15:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476199; x=1728080999; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ch6AGylS4Nguwv4PhgtiCfmSrgOswaxxBAnBe3xKbKw=; b=g+ggPMjkU3RL8s+MhAUmRxYT6FvZacaAdTcd4PXtoWPsW6raWyJTVz6ff9+dX7Av5n UbrYvE0iTYwW9Fj0E+ROQ3+WXNj0zHWoZ7CriVSIAKgPaOaI/emRHjdwnrQ1e9E2ufWS OjkHrGLIXHDx1GSrUTVhB60nymzk4zRrvqh8/p4cT6trrqRfmsJ2k5NHxpJCKkR55H/h 8Zv6RlUUZZ5KxfmYh8IZ3NsUFEiRNnCKnmaT5Pz3cQrFAJ2ASsHNXhoP5iZjYLaRKjaH Iwz0FSJOQtaEog3dpayFpLdDXU0e/KaV2MMPh241K5NERwxi6USLnZ5+viuJTJGO0WY5 fPUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476199; x=1728080999; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ch6AGylS4Nguwv4PhgtiCfmSrgOswaxxBAnBe3xKbKw=; b=GkhB0Rx7i3p6En80M8N10ieeXi4/hoB+r6dPxzuHkU665M9OaF/yk1TDQJ0kSfI+zD DbEgA+UvND2+sOl7X1Kl30bO+ETz7utMAf5cga+OMgMmKuU7n5tu/VJCWslwx37Wnqta SOCgqUpvD/nXFbrXC9t9/n4y81m3RUk0m3TwsDYWnFVtwo796O3QwBbI/Att2TdQ9vOd JKwtFkWeBn7uyTxZanSg4b8uTurbvo0+NszD5DLJR74TzWg3uTayyeZGYHGpKluC5Umg QIpoYFxiilxc+uV/zO99CPGnoPZrWeBlXKTZgiu+UPpGVRx4ySJpxnCQxyh1XQYOvmv7 IIeA== X-Gm-Message-State: AOJu0Yzl/3JaNf0nAHKd64Y/1DLKM3Cq0cULk/1yuMTw24JmaTFpgHi3 lrJ73y5xGHQDcpXKrcxH1SehIO+IkuNfnMz5uavxWZeZ7Wtcx4RAwo8Y3Re6wgQ= X-Google-Smtp-Source: AGHT+IHv4uMBRChUtKmto4PiKOdp1c4MseKfg6DWruwE+gJLuyChTJZenIMzqOsEUsbfKWPmZB7EGg== X-Received: by 2002:a17:906:4788:b0:a86:9e84:dddc with SMTP id a640c23a62f3a-a93c4a98dd7mr452734866b.61.1727476199423; Fri, 27 Sep 2024 15:29:59 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:57 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:50 +0200 Subject: [PATCH v2 4/4] leds: bcm63138: Add some register defines Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-4-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 The Power LUT (Look-up Table) register base was missing, also add the bit define for sending serial LED data in reverse order, and use the BIT() macro to define the bits in the control register. Signed-off-by: Linus Walleij --- drivers/leds/blink/leds-bcm63138.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 9fe1af156c80..190d9774164b 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -21,8 +21,9 @@ #define BCM63138_LEDS_PER_REG (32 / BCM63138_LED_BITS) /* 8 */ #define BCM63138_GLB_CTRL 0x00 -#define BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL 0x00000002 -#define BCM63138_GLB_CTRL_SERIAL_LED_EN_POL 0x00000008 +#define BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL BIT(1) +#define BCM63138_GLB_CTRL_SERIAL_LED_EN_POL BIT(3) +#define BCM63138_GLB_CTRL_SERIAL_LED_MSB_FIRST BIT(4) #define BCM63138_MASK 0x04 #define BCM63138_HW_LED_EN 0x08 #define BCM63138_SERIAL_LED_SHIFT_SEL 0x0c @@ -35,6 +36,7 @@ #define BCM63138_BRIGHT_CTRL3 0x28 #define BCM63138_BRIGHT_CTRL4 0x2c #define BCM63138_POWER_LED_CFG 0x30 +#define BCM63138_POWER_LUT 0x34 /* -> b0 */ #define BCM63138_HW_POLARITY 0xb4 #define BCM63138_SW_DATA 0xb8 #define BCM63138_SW_POLARITY 0xbc