Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp920253lqp; Thu, 21 Mar 2024 22:49:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHPbwgYn3EYIv6XIbHgSUOtq806OSBXeT9AK3kGF7zFRNxOwkzCd1/b+QHHdy7RxcyuqWlpRwyISeeuOqdRlMNiUhkM02Rhoc20eVeJg== X-Google-Smtp-Source: AGHT+IH62Qn4fbPPSo8jJreG0JfopJ7gHtHn0i5s5MzJz1ifkTJZrTyfAbx3Y4XyXDAPe+J/xwDK X-Received: by 2002:a05:6830:60a:b0:6e4:d70f:3181 with SMTP id w10-20020a056830060a00b006e4d70f3181mr1403069oti.29.1711086547889; Thu, 21 Mar 2024 22:49:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711086547; cv=pass; d=google.com; s=arc-20160816; b=vcWlLAK6rEnTVj3BAdofgmrjQNao7Yoblq9+E/AIPBR7S7mgJ7YOr6chxgAkyhQ0bp EwKyow5cJYNsqFtRrHPitAu6yuSr0bcS7P5fRh64sohiUd7cS1zo9CQyGyGSUDu3SDQB ShArRZREqyUlYa+nctIUYVDt1Bo91hAZA2vt3UNE5kSi2+ctv/JIxQf9EXFjk3qXdOc8 dL4YuYVkfwnR/CAE+dNAZKzuiBDKR0C2Qqg2QpC9JAys+YuXlZr5o2b4iAdpq6DK6z9n P7K42uerNto87+E4ofK7WAYCv73zaHefxWACGivS5ZirzMzaCHv6+KfasyCkariNwjmv IiAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2v9+xfia68QeoWpLPgvZTLinBR+rs9FvXTVbndoolI0=; fh=IykBlCxw5IJ6imCSU5U3frR9bInJ7sVHhLen2vDTFqc=; b=cmtUtsH9oCiRegg2L7kXRFM2Iy1r8+BOrOKCf8d3ebUEX2tbJeigIVmDg3UZVCE/vA H4lIeg914zs/wK+Z38CizMuE5PdMFriIc5WPKgqSlOX241sbU1hwZRPLrenGD8x6PDyX v4BVba64kndac/Bx90yABa7oIHBf2CVN0WismrVD5eFSsWl1W0sKNdzY/zrcJoKWrg2y upeWK+wMeywkeJsv69h8svRyhuX8YsOTmd20XyIsCSDOsJWED2rd8PBb+UEgJa0vM4i3 Rhq0zLd8E2hNkgB+EbfJr3bKuqrfNpr1svQA+I5ibReGpgM8bjiUUz44feJrLnGFSBtS 3ABQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J0R5xp09; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x4-20020a656aa4000000b005e846cc29d0si1293959pgu.226.2024.03.21.22.49.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 22:49:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J0R5xp09; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 45869B20C87 for ; Fri, 22 Mar 2024 05:45:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD99BB67D; Fri, 22 Mar 2024 05:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J0R5xp09" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 477EFBA3F for ; Fri, 22 Mar 2024 05:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711086314; cv=none; b=M9Kd8jkKbdaST9rm+bkqGUcfDLcvo9u/EFfyna+ludPoIizc8gw9WtOagpE0SjZN5GcgD/PcLHOaJtIFnEPG2crFmfwycdH16Y9S4o5ZfOYkFMlPvePeX6Ou5SF3w+qRqfenIA9ZG6KHRXZrQCnj0Zwv8T0zEu4L0U7jW1GIxHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711086314; c=relaxed/simple; bh=b4UeU92r62bIY8HhL/ow3jMfrvwN8JSL7OEhfPL5vDo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ofEcBRitEH7L/Hw/pGn1dyOANEk7SMBQY6Sl0y0pfDKGzB9HxJqhptA0yEAIQmSnI4D2jvSAe1DcbArUObp+ZXdTbIjzlzp/nbkpsNf5pYynAH5tPOLqAaZtdptjvZr6rNqNZwBDsler89MqSbyDhk6iQwSn+g0fa1DgZzcVKkc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=J0R5xp09; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711086312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2v9+xfia68QeoWpLPgvZTLinBR+rs9FvXTVbndoolI0=; b=J0R5xp090oweD5Y/nxjkq9OBeYkAUxo7ZhVbefmID/Jp6I+Oq5r07QIS+1gESq4Q1Ax8Zk t6jqa1DzQ+MKNX9v/a2PysEgFlf/YKMkEgUGdjNdRg1nqTtGUp3Hh6iwDrGHkGDmVrKss0 g56+HM69EyFHkI6s0D5jV+zs4et1I/0= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-ghOdygkuO3OpXStypkHlmw-1; Fri, 22 Mar 2024 01:45:07 -0400 X-MC-Unique: ghOdygkuO3OpXStypkHlmw-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c37ea11ef3so1712066b6e.0 for ; Thu, 21 Mar 2024 22:45:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711086306; x=1711691106; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2v9+xfia68QeoWpLPgvZTLinBR+rs9FvXTVbndoolI0=; b=Niy5MCwevKTDgjmu7eLuFPkJnLWsH16ZOF/hB/sXd7F8MIcFaT3eVesJ/ptoPBk0j6 a3MmBX61Ya4Q+cSZRhzb12TSzxpjVcHbm6qWJujBW/WlwyIw0Q//wg1ttvfLU7rMnHHp P9eu7V9v7P3hd3UKDrtVpLxo0HAtDxn1v8t7HIt/Do3k9xbqOOFXrNhClcoLNmFYaKsG UbxVf8SiSpZBuMIN0lsG2AoHkBQA4DO5fsDBlgc4yIrEk1qRR0XEqszLsp12VWWO4rre kUkz95SozLAfX1VeJxIbUPpVtNjeaPRIUg4e1W2W3j33QqaL6Z4xFRgcd7h0bOPhMWLo l4SQ== X-Forwarded-Encrypted: i=1; AJvYcCWHqwWeoDS62QuRi+IW/bHlO7JgRYJGaTG188hlwTIdruBwqHoboQ8jT5Uem5Yio4kecGjrrKss5fJJni3LDcfD7wN46Ppf//z6NLVd X-Gm-Message-State: AOJu0Yys57PtOFGr/t7kyr6HNzL/S7dL1ckuH2EWQ8omcOSJPS5oA+KX tAFGzspBQcP6CBXR5BKtdkkT54NP7m0N9eQK/NTFn4ozT8723xh7VN1I6kKw+Uk4+bbOQEEs8Og Mz9/Xe+nmYoe9NY2lVTL1yrs1jmOWU9Jdu0ud/RcSuxLWr5KPmMNAN+cSeTkL3CVxTNcFSnuWfb iKkkUaUi+LVpc2WmajbmnWYJ4rOa0zJtEsyLtS X-Received: by 2002:a05:6808:16a2:b0:3c1:7eac:a8a8 with SMTP id bb34-20020a05680816a200b003c17eaca8a8mr1460927oib.26.1711086306431; Thu, 21 Mar 2024 22:45:06 -0700 (PDT) X-Received: by 2002:a05:6808:16a2:b0:3c1:7eac:a8a8 with SMTP id bb34-20020a05680816a200b003c17eaca8a8mr1460912oib.26.1711086306145; Thu, 21 Mar 2024 22:45:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306025801.8814-1-hpa@redhat.com> <20240306025801.8814-3-hpa@redhat.com> In-Reply-To: From: Kate Hsuan Date: Fri, 22 Mar 2024 13:44:54 +0800 Message-ID: Subject: Re: [PATCH v4 2/2] leds: rgb: leds-ktd202x: Get device properties through fwnode to support ACPI To: Andy Shevchenko Cc: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , =?UTF-8?Q?Andr=C3=A9_Apitzsch?= , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Thank you for reviewing. On Tue, Mar 12, 2024 at 7:04=E2=80=AFAM Andy Shevchenko wrote: > > Wed, Mar 06, 2024 at 10:58:01AM +0800, Kate Hsuan kirjoitti: > > This LED controller also installed on a Xiaomi pad2 and it is a x86 > > platform. The original driver is based on device tree and can't be > > used for this ACPI based system. This patch migrated the driver to > > use fwnode to access the properties. Moreover, the fwnode API > > supports device tree so this work won't effect the original > > implementations. > > ... > > > + fwnode_for_each_available_child_node(np, child) { > > Please, rename np to fwnode to avoid confusion. > > > + num_channels++; > > + } > > ... > > > - for_each_available_child_of_node(np, child) { > > + fwnode_for_each_available_child_node(np, child) { > > u32 mono_color; > > u32 reg; > > int ret; > > > > - ret =3D of_property_read_u32(child, "reg", ®); > > + ret =3D fwnode_property_read_u32(child, "reg", ®); > > if (ret !=3D 0 || reg >=3D chip->num_leds) { > > dev_err(chip->dev, "invalid 'reg' of %pOFn\n", ch= ild); > > Must be %pfw now. > > > - of_node_put(child); > > + fwnode_handle_put(child); > > > return -EINVAL; > > Side note: This shouldn't shadow error code when ret !=3D 0. > > > } > > ... > > > - ret =3D of_property_read_u32(child, "color", &mono_color)= ; > > + ret =3D fwnode_property_read_u32(child, "color", &mono_co= lor); > > if (ret < 0 && ret !=3D -EINVAL) { > > dev_err(chip->dev, "failed to parse 'color' of %p= OF\n", child); > > Must be %pfw now. > > > - of_node_put(child); > > + fwnode_handle_put(child); > > return ret; > > } > > ... > > > - ret =3D of_property_read_u32(np, "reg", ®); > > + ret =3D fwnode_property_read_u32(np, "reg", ®); > > if (ret !=3D 0 || reg >=3D chip->num_leds) { > > dev_err(chip->dev, "invalid 'reg' of %pOFn\n", np); > > Must be %pfw now. > > > return -EINVAL; > > > /* Color property is optional in single color case */ > > - ret =3D of_property_read_u32(np, "color", &color); > > + ret =3D fwnode_property_read_u32(np, "color", &color); > > if (ret < 0 && ret !=3D -EINVAL) { > > dev_err(chip->dev, "failed to parse 'color' of %pOF\n", n= p); > > Must be %pfw now. > > > return ret; > > } > > ... > > > + struct fwnode_handle *child, *np; > > Do not use np for sturct fwnode_handle. It will be quite confusing. > > ... > > > - chip->num_leds =3D (int)(unsigned long)of_device_get_match_data(c= hip->dev); > > + count =3D device_get_child_node_count(dev); > > > > > Redundant blank line. > > > - count =3D of_get_available_child_count(np); > > if (!count || count > chip->num_leds) > > return -EINVAL; > > ... > > > + chip->num_leds =3D (unsigned long)i2c_get_match_data(client); > > No warnings during compilation? Yes, the compiler doesn't complain about it. > > ... > > > +static const struct i2c_device_id ktd202x_id[] =3D { > > + {"ktd2026", KTD2026_NUM_LEDS}, > > + {"ktd2027", KTD2027_NUM_LEDS}, > > + {}, > > N ocomma for the terminator entry. > > > +}; > > +MODULE_DEVICE_TABLE(i2c, ktd202x_id); > > ... > > > +#ifndef CONFIG_ACPI > > Please, no. Drop them. Okay, I've dropped them in v5 patch. > > > static const struct of_device_id ktd202x_match_table[] =3D { > > { .compatible =3D "kinetic,ktd2026", .data =3D (void *)KTD2026_NU= M_LEDS }, > > { .compatible =3D "kinetic,ktd2027", .data =3D (void *)KTD2027_NU= M_LEDS }, > > {}, > > }; > > MODULE_DEVICE_TABLE(of, ktd202x_match_table); > > +#endif > > > > static struct i2c_driver ktd202x_driver =3D { > > .driver =3D { > > .name =3D "leds-ktd202x", > > +#ifndef CONFIG_ACPI > > .of_match_table =3D ktd202x_match_table, > > +#endif > > This is quite unusual besides being ugly. > > > }, > > .probe =3D ktd202x_probe, > > .remove =3D ktd202x_remove, > > .shutdown =3D ktd202x_shutdown, > > + .id_table =3D ktd202x_id, > > }; > > -- > With Best Regards, > Andy Shevchenko > > --=20 BR, Kate