From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 622D43AD538 for ; Tue, 5 May 2026 05:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777958211; cv=none; b=XhVnFX15tewICKCw++KL1SLKf83qvSeLaRpJoo2Z3Vx0HMj0+Ln0DX1GQAXE8m8tzp26ZuajRPOjAHyqsRJuWNz1qU+G9NdkvR0/9774IBckMcm6d3xStgJhjjEw7PMNxXwFZ9mGDzMKxqv41BAs7qTWrsLsLxL+YYLAJJK75wM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777958211; c=relaxed/simple; bh=9aVXjpEN1EsDzBkG0rzh6qG0mYi2nsBKUor+T138jNc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=d5GzST+awiha8bXcZ1OxdDn6AlW05O4KeBl64r372iVMuULdyYJ9Bz1b44eapaIldii/QXhPdW4HJmIE/xzR7YKlAjF6okll/GSNuIa3dYaoRPPgeKAa3B7u6pbUxFH0SaAeinc7HprquM7l9zI30AAd7Hg1s1EF0LrriSoHuuY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=ratatoskr.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1wK89G-0006ZA-I1; Tue, 05 May 2026 07:16:46 +0200 From: Steffen Trumtrar To: Jacek Anaszewski Cc: Nam Tran , Lee Jones , Pavel Machek , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH v9] leds: add support for TI LP5860 LED driver chip In-Reply-To: <1b418b30-7b28-4559-9808-7a68132c273a@gmail.com> (Jacek Anaszewski's message of "Mon, 4 May 2026 21:33:45 +0200") References: <20260424-v6-14-topic-ti-lp5860-v9-1-b44d7025d741@pengutronix.de> <87zf2gqrsv.fsf@pengutronix.de> <1b418b30-7b28-4559-9808-7a68132c273a@gmail.com> User-Agent: mu4e 1.12.13; emacs 30.2 Date: Tue, 05 May 2026 07:16:45 +0200 Message-ID: <87cxzabflu.fsf@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.trumtrar@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org On 2026-05-04 at 21:33 +02, Jacek Anaszewski w= rote: Hi, > On 5/3/26 8:19 PM, Steffen Trumtrar wrote: > > On 2026-04-26 at 14:41 +02, Jacek Anaszewski > > wrote: > > Hi, > >=20 > >> Hi Steffen, > >> > >> On 4/24/26 3:28 PM, Steffen Trumtrar wrote: > >> > Add support for the Texas Instruments LP5860 LED driver chip > >> > via SPI interfaces. > >> > The LP5860 is an LED matrix driver for up to 196 LEDs, which supports > >> > short and open detection of the individual channel select lines. > >> > It can be connected to SPI or I2C bus. For now add support for SPI o= nly. > >> > Signed-off-by: Steffen Trumtrar > >> > --- > >> [...] > >> > diff --git a/drivers/leds/rgb/leds-lp5860-core.c b/drivers/leds/rgb/ > >> leds-lp5860-core.c > >> > new file mode 100644 > >> > index 0000000000000..648bf168f94bf > >> > --- /dev/null > >> > +++ b/drivers/leds/rgb/leds-lp5860-core.c > >> > @@ -0,0 +1,231 @@ > >> > +// SPDX-License-Identifier: GPL-2.0-only > >> > +/* > >> > + * Copyright (c) 2025 Pengutronix > >> > + * > >> > + * Author: Steffen Trumtrar > >> > + */ > >> > + > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > +#include > >> > + > >> > +#include "leds-lp5860.h" > >> > + > >> > +static struct lp5860_led *mcled_cdev_to_led(struct led_classdev_mc > >> *mc_cdev) > >> > +{ > >> > +=C2=A0=C2=A0=C2=A0 return container_of(mc_cdev, struct lp5860_led, = mc_cdev); > >> > +} > >> > + > >> > +static int lp5860_set_dot_onoff(struct lp5860_led *led, unsigned in= t dot, > >> bool enable) > >> > +{ > >> > +=C2=A0=C2=A0=C2=A0 unsigned int offset =3D dot / LP5860_MAX_DOT_ONO= FF_GROUP_NUM; > >> > +=C2=A0=C2=A0=C2=A0 unsigned int mask =3D BIT(dot % LP5860_MAX_DOT_O= NOFF_GROUP_NUM); > >> > + > >> > +=C2=A0=C2=A0=C2=A0 if (dot > LP5860_MAX_LED) > >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL; > >> > + > >> > +=C2=A0=C2=A0=C2=A0 return regmap_update_bits(led->chip->regmap, > >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 LP5860_REG_DOT_ONOFF_START + offset, m= ask, > >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enable ? LP5860_DOT_ALL_ON : LP5860_DO= T_ALL_OFF); > >> > +} > >> > + > >> > +static int lp5860_set_mc_brightness(struct led_classdev *cdev, > >> > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum led_brightness bright= ness) > >> > +{ > >> > +=C2=A0=C2=A0=C2=A0 struct led_classdev_mc *mc_cdev =3D lcdev_to_mcc= dev(cdev); > >> > +=C2=A0=C2=A0=C2=A0 struct lp5860_led *led =3D mcled_cdev_to_led(mc_= cdev); > >> > >> You need mutex locking while accessing hw to avoid leaving the > >> device in an inconsistent state in case of two parallel requests from > >> different processes. > >> > > The hw is only accessed via regmap. It handles locking AFAIK or do I > > misunderstand you? >=20 >=20 > You're calling regmap_write() per subLED, so internal regmap > locking has nothing to do with synchronizing the state of multicolor > LED. It is possible that another Process2 jumps in while Process1 > has already written two subLEDs. Let's say that there are two > parallel calls, where Process2 has greater priority: >=20 > Process1: > echo "10 20 30" > multi_intensity > Process2: > echo "40 50 60" > multi_intensity >=20 > Process1: > regmap_write subLED 1 10 > regmap_write subLED 2 20 > Process2: > regmap_write subLED 1 40 > regmap_write subLED 2 50 > regmap_write subLED 3 60 > Process1: > regmap_write subLED 3 30 >=20=09 >=20 > Which leaves the multicolor LED registers in the state: >=20 > subLED1: 40 > subLED2: 50 > subLED3: 30 Okay, got it. Makes sense. Thanks, Steffen --=20 Pengutronix e.K. | Dipl.-Inform. Steffen Trumtrar | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686| Fax: +49-5121-206917-5555 |