From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) (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 9D420382F06 for ; Fri, 13 Mar 2026 21:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.67.36.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773436223; cv=none; b=GRcGB5HcqxZFPl3ZVq/l+nAY2lZaWUyKyUzlNLi2jI4JhMeO7MYB7VDjk5tXVapbm7WzpuEhcYgF0kLvYxJsBlPwny9DYaraca47bpSxRAb9xLb9Ar7IA3crz/RgpfDo8fpptd9Cu3tOARyK16pJsY5PHM1a6tzFvptqCVj/cjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773436223; c=relaxed/simple; bh=Nn27dLLrR1BZTviS/aNzCnDksi17JGC0l/eH6b0dXc0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=BGGkWdAwgLYRN+yBLuG2Pp0regKJoFrkU7+tUJwRjRx9MTO9hHEDGenLNMtCt+2ej32EoFgXauPBuxxtsndgfIz6T4YQhua2XD9TlyararoJ8MEooS5QOyEwwSYpw5hg1DaC2vnhXA00b6tuOwFGsukY4ZiUodk5fz96Hz+EH4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.de; spf=pass smtp.mailfrom=posteo.de; dkim=pass (2048-bit key) header.d=posteo.de header.i=@posteo.de header.b=U43oTnNu; arc=none smtp.client-ip=185.67.36.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=posteo.de header.i=@posteo.de header.b="U43oTnNu" Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 26A19240027 for ; Fri, 13 Mar 2026 22:10:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.de; s=2017; t=1773436220; bh=+fftayEPLXkMX740k0XjlMVOkoEUiQnXBk0GASyGG94=; h=Message-ID:Subject:From:To:Cc:Date:Autocrypt:Content-Type: MIME-Version:OpenPGP:From; b=U43oTnNugX9LgYsYJPliWFN0u7ZaDdEUAnFWt1sDxeegjJBlhc3/Lrmt4oKO2roQf oEd9mfJRKg9ZggeNIS8L1UaIbYEhxDtxi1Dxt544B1ar3Lh3EDU/vijYxEPDykraEc DymwCWZTILq3NpaaH3L3WOTh7VJa3gkWgGdhSRy7tsRkD5J/YS0tkAA2iDZ7GyuB7S FvUqnctIvBgRPPqiVof/ftR1+0oN9l7W5Ih5T11pbttz9lO/RQkuEnBSzObxhsht0N FYbZlV+ohcvYTKwdxcd6oLXadOm9Dryq2dTInAP6FRfvD6GcAl/2vBD6BsgXXecFX6 1kqveWfMAZyQA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4fXcZc0FTvz6v0p; Fri, 13 Mar 2026 22:10:16 +0100 (CET) Message-ID: <9f7fefeca19d2636b7a5802668dff516b2a3e5aa.camel@posteo.de> Subject: Re: [PATCH v3 7/7] leds: add synology microp led driver From: Markus Probst To: Danilo Krummrich , Markus Probst via B4 Relay Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , Miguel Ojeda , Boqun Feng , Gary Guo , =?ISO-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , "Rafael J. Wysocki" , Igor Korotin , Daniel Almeida , Bjorn Helgaas , Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , Pavel Machek , Len Brown , Robert Moore , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev, linux-pci@vger.kernel.org, linux-leds@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev Date: Fri, 13 Mar 2026 21:10:18 +0000 In-Reply-To: References: <20260313-synology_microp_initial-v3-0-ad6ac463a201@posteo.de> <20260313-synology_microp_initial-v3-7-ad6ac463a201@posteo.de> Autocrypt: addr=markus.probst@posteo.de; prefer-encrypt=mutual; keydata=mQINBGiDvXgBEADAXUceKafpl46S35UmDh2wRvvx+UfZbcTjeQOlSwKP7YVJ4JOZrVs93 qReNLkOWguIqPBxR9blQ4nyYrqSCV+MMw/3ifyXIm6Pw2YRUDg+WTEOjTixRCoWDgUj1nOsvJ9tVA m76Ww+/pAnepVRafMID0rqEfD9oGv1YrfpeFJhyE2zUw3SyyNLIKWD6QeLRhKQRbSnsXhGLFBXCqt 9k5JARhgQof9zvztcCVlT5KVvuyfC4H+HzeGmu9201BVyihJwKdcKPq+n/aY5FUVxNTgtI9f8wIbm fAjaoT1pjXSp+dszakA98fhONM98pOq723o/1ZGMZukyXFfsDGtA3BB79HoopHKujLGWAGskzClwT jRQxBqxh/U/lL1pc+0xPWikTNCmtziCOvv0KA0arDOMQlyFvImzX6oGVgE4ksKQYbMZ3Ikw6L1Rv1 J+FvN0aNwOKgL2ztBRYscUGcQvA0Zo1fGCAn/BLEJvQYShWKeKqjyncVGoXFsz2AcuFKe1pwETSsN 6OZncjy32e4ktgs07cWBfx0v62b8md36jau+B6RVnnodaA8++oXl3FRwiEW8XfXWIjy4umIv93tb8 8ekYsfOfWkTSewZYXGoqe4RtK80ulMHb/dh2FZQIFyRdN4HOmB4FYO5sEYFr9YjHLmDkrUgNodJCX CeMe4BO4iaxUQARAQABtCdNYXJrdXMgUHJvYnN0IDxtYXJrdXMucHJvYnN0QHBvc3Rlby5kZT6JAl QEEwEIAD4CGwMFCwkIBwICIgIGFQoJCAs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ELWeQVHSNDi9JabR/UzlR4NSnhfAjRIVlRM+eFbUl8XwxwVrAkojF5IraH2qRvg VCmuFsHUW07FUlrDrzpjXsD73cKppoFGDCdDR0BHJepXbFLS9+AqkT+guRJlnCTg2p+TQtnbwPgKp Vj98JixovCl99zRYTsL2bRNU5+q8iET65VMJ1ydyNanvLd5vI/NqDkXhlXLsGmdaDTtu4R21PkToX dQNGrZ91M9nlIBKw8Y7c7xZ4098qX2b8JX/CxD+gC1r4C8vuA3GkhFLx+KlkON7LyiJPkrePp6Qky jfGillcaQOqFZ3WwVqyzG1BUfTow== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-5ct7ygorhIxza/AlNDgo" Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 OpenPGP: url=https://posteo.de/keys/markus.probst@posteo.de.asc; preference=encrypt --=-5ct7ygorhIxza/AlNDgo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2026-03-13 at 22:00 +0100, Danilo Krummrich wrote: > On Fri Mar 13, 2026 at 8:03 PM CET, Markus Probst via B4 Relay wrote: > > +impl Command { > > + fn write(self, dev: &platform::Device) -> Result { > > + // SAFETY: Since we have no of and no acpi match table, we ass= ume this is a mfd sub-device > > + // and our parent is a serial device bus device, bound to the = synology microp core driver. > > + let parent =3D unsafe { dev.as_ref().parent_unchecked::>() }; >=20 > Despite being accurate description, "assume" is not what you want to read= for a > safety justification. :) Apparently this is how all C mfd sub-devices I have seen yet do it. Not directly using the parent device, but assuming there is a parent device, and accessing the drvdata of that parent device with most of the time to little checking. Some examples: drivers/leds/leds-lm3533.c: - assuming there is a parent device - assuming the drvdata of the parent device has the type `lm3533_led` - It does check however if drvdata is set. drivers/leds/leds-upboard.c: - assuming there is a parent device - assuming drvdata of the parent device is set - assuming drvdata of the parent device has the type `upboard_fpga` >=20 > We don't want to directly access the serial device from this driver. Inst= ead, > there should be an abstraction layer of the resource you are accessing. >=20 > If this would be I2C or SPI you would request the regmap of the parent at= this > point, e.g. >=20 > dev.parent().regmap("led_registers") >=20 > Now, this is a serial device, but regmap still works perfectly fine for t= his > case. It even allows you to ensure from the MFD driver to restrict the LE= D > driver of sending commands that are not LED specific by exposing a LED sp= ecific > regmap. Additionally, if you need additional locking etc. it can all be d= one > within the regmap implementation, so you entirely avoid custom APIs. >=20 > I'm not sure how common regmap is for serial devices to be honest, but > apparently there are drivers doing this and I don't really see a reason a= gainst > it. >=20 > For instance, there is drivers/iio/imu/bno055/, which is a chip that work= s on > both serial and I2C busses and fully abstracts this fact with regmap. >=20 > In Rust a regmap will probably become a backend of the generic I/O > infrastructure we are working on, which will also allow you to use the > register!() infrastructure, etc. >=20 > register!() and some other generic I/O improvements will land this cycle,= I/O > projections are more likely to land next cycle. >=20 > > + parent.write_all( > > + match self { > > + Self::Power(State::On) =3D> &[0x34], > > + Self::Power(State::Blink) =3D> &[0x35], > > + Self::Power(State::Off) =3D> &[0x36], > > + > > + Self::Status(_, State::Off) =3D> &[0x37], > > + Self::Status(StatusLedColor::Green, State::On) =3D> &[= 0x38], > > + Self::Status(StatusLedColor::Green, State::Blink) =3D>= &[0x39], > > + Self::Status(StatusLedColor::Orange, State::On) =3D> &= [0x3A], > > + Self::Status(StatusLedColor::Orange, State::Blink) =3D= > &[0x3B], > > + > > + Self::Alert(State::On) =3D> &[0x4C, 0x41, 0x31], > > + Self::Alert(State::Blink) =3D> &[0x4C, 0x41, 0x32], > > + Self::Alert(State::Off) =3D> &[0x4C, 0x41, 0x33], > > + > > + Self::Usb(State::On) =3D> &[0x40], > > + Self::Usb(State::Blink) =3D> &[0x41], > > + Self::Usb(State::Off) =3D> &[0x42], > > + }, > > + serdev::Timeout::Max, > > + )?; > > + Ok(()) > > + } > > +} But this looks like a better solution (the same would probably apply to the existing C drivers). Thanks - Markus Probst --=-5ct7ygorhIxza/AlNDgo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmm0fS0bFIAAAAAABAAO bWFudTIsMi41KzEuMTEsMiwyAAoJEDR2H/jnrUPStiQQAIlgVAoXwNxlG8EJ5RWH Pnedd9MNqrzEIod+exeQyGM8bmTdt+Eg4qp8fjjpyzZjeyhAQUWC23nqwCj3IVxb xwPfSt6WX9XozjUwQgmou4oaI5L39IFZwZyYwU4fdAQOg6abI1rClip7W2LNq+RW 7UucoAZmMgp5dQb9GUnTwETPWRlfSbv2cvylX1HU4hJmeojpTuDKoSmKiCRm/dvZ KySk0I4dTOuKE7Wp1prfq1F4q02AfodS2xLLWzCjiLjUKL2xkUzD74i0odlG3c9e P3lyIV4D0XU5fC1IzEopGosY5jrDGF3SXTUQDaIOZGfsePjCrBC4XwvUK2khcaHi yja17O7ePiQUo137s5bk7//6CuCqXrTbPutJpbEH2bW1XyHu7ytfT9BrTgDMrGDl znsVWfz5W2qxEiXM//envyqYjWvgJpYml37SBQZgwggACDO3fmQgJVKbtY1FRPta LGAXlH1T19xlwVHT6feZsmiZ0wgnjCp3GuJhjUyQPYeWrpSwiQ3DyZttnPq+XfQU Ys7MkksUA2o2ZGmO+8F4ItSp/J/wTzv3LEtkV/roWh8grhQGLlhZLm74aqrg4bbb gfGIZxfnd+aTPqhP7P2Jq1qL2SfJfbT3bmA+vO6mfn1znsytfbaPqzGnJi1U5OSI K43XsglexPpzCQ8pSW9xqpux =hU9n -----END PGP SIGNATURE----- --=-5ct7ygorhIxza/AlNDgo--