Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp88493rdb; Tue, 31 Oct 2023 01:16:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVzGUovNWTYp410EoVkHulnfONOg6KB7xrStDMHkXRmt1ZqiG4ALCVleKnnchNMjwB55G3 X-Received: by 2002:a05:6602:2a4d:b0:7a9:4268:fc26 with SMTP id k13-20020a0566022a4d00b007a94268fc26mr17232181iov.10.1698740189544; Tue, 31 Oct 2023 01:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698740189; cv=none; d=google.com; s=arc-20160816; b=HAVb712vorgXWLPuElbyZYUXF7YAgpPsuz0jj81JKz0VVbmRdPEGETMzvlcgQR3rG5 IoeVRa3DMon6jdFKaAfrjaKj0IZaRgPP6Ww35nXyquD7cfONBmlevNR9d0NQ50nIy0Qm lgYqf5cS620sjCg0x+cVBV+rD76cgKGZDpgAPCNuGir9ITsGHOGGgwSb8NEH7bJISPIq g9e6I8XMHosTcVDXbUYjkCywbcjTNlhYraPi7w6hOM+PJOuu8qI/OLsno0xvATxNpnji wDuNeCtpZT1Su/yfb1qxnY3Z/ALLncurDVrQC5a60a+NeqexeOmUArkuy8mJml0TOT3E 3tFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=goof15RNeU0KLHtGHQUeg5uXRfnDboIB8cpBpI1bxBs=; fh=I2fnKJCgS33rrxrf7T8IpjVNHXOXsyY5ywnmlQrrkOk=; b=klmJ3+TO/SgfTJ8Q2ic7zr2SMySfuWgpw694YTWd5W9I2dawEdlFCmrXJhLboGgTr+ FuTi8gFsA4zQEOQmW6iGXXYW8t6DfuKcJbboUtrQsxpGJ4DMt3oYel7LyH0z9jDj1rRY 6+dP90tqA8kH3mtyyAFhNFENfoVuysXAEMdZg1XMxHIJ3qPmPHQI2w6FFy1g7dEbjit5 5H84gfG+k54rb6ZaEEdYnngh4dAUGOqZsa2HOtgIPT8nqUKuYqz9T24JV6O4DV8jeH9Q +XN2ppNx7JKGUaaW86nMWlJN7+bhkHgHZ5MjHzreMU9qTU0otxMeNP8YEBYANYD0zECB YOow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X51vj4Ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id p5-20020a625b05000000b0068a6eb3b548si645020pfb.401.2023.10.31.01.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 01:16:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X51vj4Ig; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B75688092CAF; Tue, 31 Oct 2023 01:16:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231301AbjJaIQR (ORCPT + 99 others); Tue, 31 Oct 2023 04:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbjJaIQQ (ORCPT ); Tue, 31 Oct 2023 04:16:16 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F914DE for ; Tue, 31 Oct 2023 01:16:12 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-99c3c8adb27so792817766b.1 for ; Tue, 31 Oct 2023 01:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698740170; x=1699344970; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=goof15RNeU0KLHtGHQUeg5uXRfnDboIB8cpBpI1bxBs=; b=X51vj4IgtJlDylKdzk/D2cw31TexiCzaOPxPFLD0Xji1B6eo28Fbs9qRVGMmTdbodl 0w3BPnAqx0hpcsc3WPBpfd8B66etK7U1GlGHD2X3w+BXK06b/SKUlIBQ4QUwDxtEOtPU WdrlkP7DEYGJ4tUVaomTngSPQNUKF50MWM4kMBc2ILZlKTlq/tvqEHaMrjmc5spRBFqv ubdPGtGo2l93D98wGqc0TDZlP3bhIKHlwv6hFPPIGzkUko5l8Q0ZSis+nTUCLjk7Ucyz wmPCbZFUA3wyhX/AAbfTcXutKtRdSQw74TJ765hKrptuYDOIAng7XV++Ux+c2wwfTe8S LN4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698740170; x=1699344970; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=goof15RNeU0KLHtGHQUeg5uXRfnDboIB8cpBpI1bxBs=; b=iAj71ZxFin45pj9iFoYycWINw5379Sdf5hnjtHdoTpIYEOlM9WhDt+pbNfrlurP5Kr 9qqIuYNA/dIc0h4Fe00LDnmsVQgW/j+yFBT/Wog7Q+oxvIXAv29kdv3McDGLvYYi2AcE Td1+xZF5yJDCDE/R3OJFC4gkBliry8iwWYWSXqgH0Z8deHOnmD7ZZSpD5vZLocKSkYDE w+eRtw5gDe+9R9Pzv+zWMcKyurqz/8sLbDRKaMHB+9uxr3FbEPJY7zdu/2JyATD5JH1F CiQGXlwFNucpN02MlzOkUkgKgHN0elAh3ZVydC7lZ6dl92WJ8K1mjGYT0lOT7b++N8Vt HOgQ== X-Gm-Message-State: AOJu0YxswCK+Nic2L8vsPG4gGYtBraMXnffgiCM+OG3Sgrps5jFdFrRV m8yNRNHTG12z8oZq45enBrGQIw== X-Received: by 2002:a17:907:6015:b0:9d1:a628:3e3f with SMTP id fs21-20020a170907601500b009d1a6283e3fmr4997256ejc.45.1698740170539; Tue, 31 Oct 2023 01:16:10 -0700 (PDT) Received: from [192.168.1.20] ([178.197.218.126]) by smtp.gmail.com with ESMTPSA id z7-20020a50cd07000000b0053e5a1bf77dsm704672edi.88.2023.10.31.01.16.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Oct 2023 01:16:09 -0700 (PDT) Message-ID: Date: Tue, 31 Oct 2023 09:16:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] leds: add mp3326 driver Content-Language: en-US To: "Yuxi (Yuxi) Wang" , "pavel@ucw.cz" , "lee@kernel.org" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" Cc: "linux-leds@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "wyx137120466@gmail.com" References: From: Krzysztof Kozlowski Autocrypt: addr=krzysztof.kozlowski@linaro.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZo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MGZ2rZ6zITrMip+12jgw4mGjy 5y06JZvA02rZT2k9aa7i9dUUFggaanI09jNGbRA/ABEBAAHCwXwEGAEKACYCGwwWIQSb0H4O DFH41ZZ3t1Qbk0N9O0FimwUCYDzvagUJFF+UtgAKCRAbk0N9O0Fim9JzD/0auoGtUu4mgnna oEEpQEOjgT7l9TVuO3Qa/SeH+E0m55y5Fjpp6ZToc481za3xAcxK/BtIX5Wn1mQ6+szfrJQ6 59y2io437BeuWIRjQniSxHz1kgtFECiV30yHRgOoQlzUea7FgsnuWdstgfWi6LxstswEzxLZ Sj1EqpXYZE4uLjh6dW292sO+j4LEqPYr53hyV4I2LPmptPE9Rb9yCTAbSUlzgjiyyjuXhcwM qf3lzsm02y7Ooq+ERVKiJzlvLd9tSe4jRx6Z6LMXhB21fa5DGs/tHAcUF35hSJrvMJzPT/+u /oVmYDFZkbLlqs2XpWaVCo2jv8+iHxZZ9FL7F6AHFzqEFdqGnJQqmEApiRqH6b4jRBOgJ+cY qc+rJggwMQcJL9F+oDm3wX47nr6jIsEB5ZftdybIzpMZ5V9v45lUwmdnMrSzZVgC4jRGXzsU EViBQt2CopXtHtYfPAO5nAkIvKSNp3jmGxZw4aTc5xoAZBLo0OV+Ezo71pg3AYvq0a3/oGRG KQ06ztUMRrj8eVtpImjsWCd0bDWRaaR4vqhCHvAG9iWXZu4qh3ipie2Y0oSJygcZT7H3UZxq fyYKiqEmRuqsvv6dcbblD8ZLkz1EVZL6djImH5zc5x8qpVxlA0A0i23v5QvN00m6G9NFF0Le D2GYIS41Kv4Isx2dEFh+/Q== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 01:16:26 -0700 (PDT) On 31/10/2023 08:01, Yuxi (Yuxi) Wang wrote: > > This patch adds mp3326 led driver. > > Signed-off-by: Yuxi Wang > --- > drivers/leds/Kconfig | 7 + > drivers/leds/Makefile | 1 + > drivers/leds/leds-mp3326.c | 632 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 640 insertions(+) > create mode 100644 drivers/leds/leds-mp3326.c > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index b92208eccdea..ac8115bffc2e 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -260,6 +260,13 @@ config LEDS_MIKROTIK_RB532 > This option enables support for the so called "User LED" of > Mikrotik's Routerboard 532. > > +config LEDS_MP3326 > + tristate "LED Support for MPS MP3326" > + depends on LEDS_CLASS > + help > + This option enables support for on-chip LED drivers found on > + MPS MP3326. > + > config LEDS_MT6323 > tristate "LED Support for Mediatek MT6323 PMIC" > depends on LEDS_CLASS > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > index d7348e8bc019..196befb56278 100644 > --- a/drivers/leds/Makefile > +++ b/drivers/leds/Makefile > @@ -63,6 +63,7 @@ obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o > obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o > obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o > obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o > +obj-$(CONFIG_LEDS_MP3326) += leds-mp3326.o > obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o > obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o > obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o > diff --git a/drivers/leds/leds-mp3326.c b/drivers/leds/leds-mp3326.c > new file mode 100644 > index 000000000000..140c71b334f7 > --- /dev/null > +++ b/drivers/leds/leds-mp3326.c > @@ -0,0 +1,632 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * MP3326 Led driver > + * > + * Copyright 2023 Monolithic Power Systems, Inc > + * > + * Author: Yuxi Wang > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MP3326_PWM_DIM_FREQUENCY_CONFIG 0x00 > +#define MP3326_PWM_CTRL 0x01 > +#define MP3326_PWM_DIM_FREQUENCY_CONFIG 0x00 > +#define MP3326_PWM_CTRL_CHANNEL_9_16 0x04 > +#define MP3326_PWM_CTRL_CHANNEL_1_8 0x05 > +#define MP3326_PWM_OPEN_FAULT_CHANNEL_9_16 0x06 > +#define MP3326_PWM_OPEN_FAULT_CHANNEL_1_8 0x07 > +#define MP3326_PWM_SHORT_FAULT_CHANNEL_9_16 0x08 > +#define MP3326_PWM_SHORT_FAULT_CHANNEL_1_8 0x09 > +#define MP3326_PWM_CURRENT_SET_CHANNEL1 0x0A > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL1 0x0B > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL1 0x0C > +#define MP3326_PWM_CURRENT_SET_CHANNEL2 0x0D > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL2 0x0E > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL2 0x0F > +#define MP3326_PWM_CURRENT_SET_CHANNEL3 0x10 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL3 0x11 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL3 0x12 > +#define MP3326_PWM_CURRENT_SET_CHANNEL4 0x13 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL4 0x14 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL4 0x15 > +#define MP3326_PWM_CURRENT_SET_CHANNEL5 0x16 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL5 0x17 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL5 0x18 > +#define MP3326_PWM_CURRENT_SET_CHANNEL6 0x19 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL6 0x1A > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL6 0x1B > +#define MP3326_PWM_CURRENT_SET_CHANNEL7 0x1C > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL7 0x1D > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL7 0x1E > +#define MP3326_PWM_CURRENT_SET_CHANNEL8 0x1F > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL8 0x20 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL8 0x21 > +#define MP3326_PWM_CURRENT_SET_CHANNEL9 0x22 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL9 0x23 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL9 0x24 > +#define MP3326_PWM_CURRENT_SET_CHANNEL10 0x25 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL10 0x26 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL10 0x27 > +#define MP3326_PWM_CURRENT_SET_CHANNEL11 0x28 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL11 0x29 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL11 0x2A > +#define MP3326_PWM_CURRENT_SET_CHANNEL12 0x2B > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL12 0x2C > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL12 0x2D > +#define MP3326_PWM_CURRENT_SET_CHANNEL13 0x2E > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL13 0x2F > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL13 0x30 > +#define MP3326_PWM_CURRENT_SET_CHANNEL14 0x31 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL14 0x32 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL14 0x33 > +#define MP3326_PWM_CURRENT_SET_CHANNEL15 0x34 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL15 0x35 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL15 0x36 > +#define MP3326_PWM_CURRENT_SET_CHANNEL16 0x37 > +#define MP3326_PWM_DUTY_LSB_SET_CHANNEL16 0x38 > +#define MP3326_PWM_DUTY_MSB_SET_CHANNEL16 0x39 > +#define MAX_BRIGHTNESS 63 > + > +enum led_ctrl { > + ENABLE = 0, > + BRIGHTNESS, > + COLOR_L4, > + COLOR_H8, > + OPEN_FAULT, > + SHORT_FAULT, > + Max_CTRL, Dpn't use CamelCase > +}; > + > +enum mp3326_channel { > + Channel1, > + Channel2, > + Channel3, > + Channel4, > + Channel5, > + Channel6, > + Channel7, > + Channel8, > + Channel9, > + Channel10, > + Channel11, > + Channel12, > + Channel13, > + Channel14, > + Channel15, > + Channel16, Ditto > + Max_Channel,> +}; > + > +#define MP3326_Reg_Connect_Inner(prefix, range) prefix##range > +#define MP3326_Reg_Connect(prefix, range) MP3326_Reg_Connect_Inner(prefix, range) > +#define MP3326_Reg_Field(reg, minbit, maxbit) REG_FIELD(reg, minbit, maxbit) > +#define Range1(a, b) MP3326_Reg_Connect_Inner(a, b) > +#define Range2(a, b) MP3326_Reg_Connect_Inner(a, b) OK, so this driver was copied from some out-of-tree, poor quality old code not even using Linux coding style. Please rewrite everything to match Linux coding style. > + > +#define MP3326_Channel_FIELD(bit, num, range) { \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_CTRL_CHANNEL_, range), bit, bit), \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_CURRENT_SET_CHANNEL, num), 0, 5), \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_DUTY_LSB_SET_CHANNEL, num), 0, 3), \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_DUTY_MSB_SET_CHANNEL, num), 0, 7), \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_OPEN_FAULT_CHANNEL_, range), bit, bit), \ > + MP3326_Reg_Field(MP3326_Reg_Connect(MP3326_PWM_SHORT_FAULT_CHANNEL_, range), bit, bit), \ > + } > +struct mp3326_led { > + struct mp3326 *private_data; > + struct led_classdev cdev; > + struct mc_subled *subled_info; > + int num_colors; > +}; ... > + > + for_each_available_child_of_node(np, child) { > + ret = of_property_read_u32(child, "reg", ®); > + if (ret || reg > Max_Channel) { > + dev_err(&chip->client->dev, > + "reg must less or equal than %d\n", Max_Channel); > + return -EINVAL; > + } > + > + ret = of_property_read_u32(child, "color", &color); > + if (ret) { > + dev_err(&chip->client->dev, "color must have value\n"); > + return ret; > + } > + > + if (color > 3 || !color) { > + dev_err(&chip->client->dev, > + "color must be Red, Green and Blue. The color is %d\n", color); Broken indentation. Everywhere. Be sure that checkpatch --strict does not print any (any!) warnings. > + return ret; > + } > + info[i].color_index = color; > + info[i].channel = reg - 1; > + info[i].brightness = 0; > + i++; > + } > + > + led->subled_info = info; > + led->num_colors = 3; > + cdev = &led->cdev; > + cdev->max_brightness = MAX_BRIGHTNESS; > + cdev->brightness_set_blocking = led_brightness_set; > + cdev->groups = led_sysfs_groups; > + init_data.fwnode = &np->fwnode; > + > + ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); > + > + if (ret) { > + dev_err(&chip->client->dev, "Unable register multicolor:%s\n", cdev->name); > + return ret; > + } > + } else { > + ret = of_property_read_u32(np, "reg", ®); > + if (ret || reg > Max_Channel) { > + dev_err(&chip->client->dev, > + "reg must less or equal than %d\n", Max_Channel); > + return -EINVAL; > + } > + info = devm_kcalloc(&chip->client->dev, 1, sizeof(*info), GFP_KERNEL); > + led->num_colors = 1; > + info[i].color_index = LED_COLOR_ID_WHITE; > + info[i].channel = reg - 1; > + info[i].brightness = 0; > + led->subled_info = info; > + cdev = &led->cdev; > + cdev->max_brightness = MAX_BRIGHTNESS; > + cdev->brightness_set_blocking = led_brightness_set; > + cdev->groups = led_sysfs_groups; > + init_data.fwnode = &np->fwnode; > + ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); > + if (ret) { > + dev_err(&chip->client->dev, "Unable register led:%s\n", cdev->name); > + return ret; > + } > + } > + return ret; > +} > + > +static int mp3326_parse_dt(struct mp3326 *chip) > +{ > + struct device_node *np = dev_of_node(&chip->client->dev); > + struct device_node *child; > + int ret; > + int index; iteration variables have name 'i'. Not index. > + int val; > + > + for_each_available_child_of_node(np, child) { > + ret = mp3326_add_led(chip, child, index); > + if (ret) > + return ret; > + index++; > + } > + ret = of_property_read_u32(np, "led-protect", &val); > + if (ret) > + return ret; > + > + ret = regmap_update_bits(chip->regmap, 0x01, BIT(4) | BIT(5), val << 4); > + > + ret = regmap_write(chip->regmap, MP3326_PWM_CTRL_CHANNEL_9_16, 0); > + if (ret) > + return ret; > + ret = regmap_write(chip->regmap, MP3326_PWM_CTRL_CHANNEL_1_8, 0); > + if (ret) > + return ret; > + return 0; > +} > + > +static int mp3326_leds_probe(struct i2c_client *client) > +{ > + struct mp3326 *chip; > + const struct reg_field *reg_fields; > + int count, i, j; > + > + count = device_get_child_node_count(&client->dev); > + if (!count) { > + return dev_err_probe(&client->dev, -EINVAL, > + "Incorrect number of leds (%d)", count); > + } > + chip = devm_kzalloc(&client->dev, struct_size(chip, leds, count), GFP_KERNEL); > + if (!chip) > + return -ENOMEM; > + > + chip->client = client; > + chip->num_of_leds = count; > + i2c_set_clientdata(client, chip); > + chip->regmap = devm_regmap_init_i2c(client, &MP3326_regmap_config); > + if (IS_ERR(chip->regmap)) > + return PTR_ERR(chip->regmap); > + > + for (i = 0; i < Max_Channel; i++) { > + reg_fields = channels_reg_fields[i]; > + for (j = 0; j < Max_CTRL; j++) { > + chip->regmap_fields[i][j] = devm_regmap_field_alloc(&client->dev, > + chip->regmap, reg_fields[j]); > + if (IS_ERR(chip->regmap_fields[i][j])) { > + dev_err(&client->dev, > + "regmap field alloc fail, channel:%d, item: %d\n", i, j); > + return PTR_ERR(chip->regmap_fields[i][j]); Messed indentation. Anyway, memory allocation errors are not usually printed. Why should they be printed here? > + } > + } > + } > + if (mp3326_parse_dt(chip)) > + return 1; > + else > + return 0; > +} > + > +static const struct i2c_device_id mp3326_id[] = { > + {"mp3326", 0}, > + {} > +}; > +MODULE_DEVICE_TABLE(i2c, mp3326_id); > + > +static const struct of_device_id mp3326_of_match[] = { > + { .compatible = "mps,mp3326" }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, mp3326_of_match); > + > +static struct i2c_driver mp3326_driver = { > + .probe_new = mp3326_leds_probe, > + .driver = { > + .owner = THIS_MODULE, Drop. Kernel does not have it since few years. > + .name = "MP3326_led", One less indent. > + .of_match_table = mp3326_of_match, > + }, > + .id_table = mp3326_id, > +}; > + > +module_i2c_driver(mp3326_driver); > +MODULE_AUTHOR("Yuxi Wang "); > +MODULE_DESCRIPTION("MPS MP3326 LED driver"); > +MODULE_LICENSE("GPL"); Best regards, Krzysztof