Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp468653rdb; Fri, 17 Nov 2023 04:16:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHphIZ2Xr1VUSuHm2yF3xNVyJjOrh4DvsI319eEPeAIbf0/1TByAQuG9ND3oFZSjdgpMNjh X-Received: by 2002:a17:90a:cb95:b0:27c:f1f8:261f with SMTP id a21-20020a17090acb9500b0027cf1f8261fmr14849566pju.20.1700223404459; Fri, 17 Nov 2023 04:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700223404; cv=none; d=google.com; s=arc-20160816; b=jWW1uBfTq+m0f4cpGGBTNwCU5xLdtIw0yZ1dLv856xLTIr3MVfM3GhHa7VhFpa/Gcs uQzOK9RqmThLZIuCoRUuMGvau3h3tc0N5/ANxO2PjJL/o60zr0EqDkT6vD/rWDnGSWTJ diojw0MN34wX8QlFzybizXScv5ZyRvT9N+TCYXZblyTwhQGVIywL2zrSXxiYU94Z71RN KLtNtVqSEIEsbSKAtcf21HDKNohhvW9CvA1oMhXTmfXrOXz0GS3ndvKEbdV+5GDswMaE lPg15iTVSUjyXYVyxmAEUyHQsLveS9AFpdgH7QFYDuKE1q03Hyl1smsPGmVrrN61+VZH m+8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+TyUWoupQRRBOTggUzgET3NiC/6CFQQBfltDN/6IVAk=; fh=EfUYTw2lHfLAltvlJLKlEYB3rSkRpQbAFcu6EqYGfBY=; b=laKLdwaThOXFeLZCTx5kEIvU3VDpVPCpAnfr0QpAbsSUoDNi8pBc7JKP86/VdTZx6d 6GaMg69+zrcYgq/YmOrVF/L9IYW0PNFrNFRj6XX7+yw6ELXNuT0qs4+3gtCJCbt1D2Ng ecNchtrWIq44fVwdN6HKXw2r6W3va+6/b8SeCwrnE5Ar3GmCvQfzofiDhrrbZJYERWxm 7HbcmZSGQxEKvjxzIo71519H59+ETB2Sbhob7NeTtMOMU7xXYQ9Iw51sKj1SRYuYjYzu Q3PXDMn5VhmEDUsmbxYd5ismdVsyuNL5CQJe0KXO6pch9KD4lxgJWhMQdcJOXFDLB9jM NQtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bGz6trMK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id g14-20020a17090a4b0e00b0027740192bc9si1739289pjh.152.2023.11.17.04.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 04:16:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bGz6trMK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AB6798089864; Fri, 17 Nov 2023 04:15:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345794AbjKQMPk (ORCPT + 99 others); Fri, 17 Nov 2023 07:15:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKQMPk (ORCPT ); Fri, 17 Nov 2023 07:15:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96014196 for ; Fri, 17 Nov 2023 04:15:36 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7F63C433C8; Fri, 17 Nov 2023 12:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700223336; bh=gus7ga/hslqFc90wOge8RCSDecxTYpVkhWQk6MjClOA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bGz6trMKWPqu5saBtofRgNGtLC6NRcKmuuEr9LV/K064zWRQmHi9RqbD1WgdZxrtw VN75+bY+DS3/N/kdzxGRyhgscaTY0+HdWn8dkJsp/Hy/0vMHGAkze2MxXfnZYv7yyz sbsXiZMtT42LgQnqC/0aDuLgrNcI6ttN6Vk0h4vULd777XyMMp/4XZP0u2bnq7NPES RNVTbiXambLxkiPDQiuyKENApFT9oDbOouUTgW7keYLBeIagU/kRktU9XKS+XJV3NM e9y7XFjnNi8i5/tRtt82HkNh2MFohkS8baYgpY050UuleOonHmrZOKdoxXyuE76SVo m0/Q+uT+rF/Sg== Date: Fri, 17 Nov 2023 12:15:31 +0000 From: Lee Jones To: Naresh Solanki Cc: Pavel Machek , Patrick Rudolph , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [RESEND PATCH v3] leds: max5970: Add support for max5970 Message-ID: <20231117121531.GC137434@google.com> References: <20230914114521.1491390-1-naresh.solanki@9elements.com> <20230920130528.GG13143@google.com> <20230921103156.GB3449785@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 17 Nov 2023 04:15:50 -0800 (PST) On Thu, 09 Nov 2023, Naresh Solanki wrote: > Hey Lee, > > Is there anything specific you'd suggest changing in the current > patchset, or are we good to proceed? What do you mean by proceed? You are good to make changes and submit a subsequent version. Not entirely sure what you're asking. > On Mon, 30 Oct 2023 at 14:22, Naresh Solanki > wrote: > > > > Hi, > > > > On Thu, 21 Sept 2023 at 16:02, Lee Jones wrote: > > > > > > On Thu, 21 Sep 2023, Naresh Solanki wrote: > > > > > > > Hi > > > > > > > > > > > > On Wed, 20 Sept 2023 at 18:35, Lee Jones wrote: > > > > > > > > > > On Thu, 14 Sep 2023, Naresh Solanki wrote: > > > > > > > > > > > From: Patrick Rudolph > > > > > > > > > > > > The MAX5970 is hot swap controller and has 4 indication LED. > > > > > > > > > > > > Signed-off-by: Patrick Rudolph > > > > > > Signed-off-by: Naresh Solanki > > > > > > --- > > > > > > Changes in V3: > > > > > > - Drop array for ddata variable. > > > > > > Changes in V2: > > > > > > - Add of_node_put before return. > > > > > > - Code cleanup > > > > > > - Refactor code & remove max5970_setup_led function. > > > > > > --- > > > > > > drivers/leds/Kconfig | 11 ++++ > > > > > > drivers/leds/Makefile | 1 + > > > > > > drivers/leds/leds-max5970.c | 110 ++++++++++++++++++++++++++++++++++++ > > > > > > 3 files changed, 122 insertions(+) > > > > > > create mode 100644 drivers/leds/leds-max5970.c > > > > > > > > > > Couple of nits and you're good to go. > > > > > > > > > > Once fixed please resubmit with my: > > > > > > > > > > Reviewed-by: Lee Jones > > > > > > > > > > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > > > > > > index b92208eccdea..03ef527cc545 100644 > > > > > > --- a/drivers/leds/Kconfig > > > > > > +++ b/drivers/leds/Kconfig > > > > > > @@ -637,6 +637,17 @@ config LEDS_ADP5520 > > > > > > To compile this driver as a module, choose M here: the module will > > > > > > be called leds-adp5520. > > > > > > > > > > > > +config LEDS_MAX5970 > > > > > > + tristate "LED Support for Maxim 5970" > > > > > > + depends on LEDS_CLASS > > > > > > + depends on MFD_MAX5970 > > > > > > + help > > > > > > + This option enables support for the Maxim MAX5970 & MAX5978 smart > > > > > > + switch indication LEDs via the I2C bus. > > > > > > + > > > > > > + To compile this driver as a module, choose M here: the module will > > > > > > + be called leds-max5970. > > > > > > + > > > > > > config LEDS_MC13783 > > > > > > tristate "LED Support for MC13XXX PMIC" > > > > > > depends on LEDS_CLASS > > > > > > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > > > > > > index d7348e8bc019..6eaee0a753c6 100644 > > > > > > --- a/drivers/leds/Makefile > > > > > > +++ b/drivers/leds/Makefile > > > > > > @@ -56,6 +56,7 @@ obj-$(CONFIG_LEDS_LP8501) += leds-lp8501.o > > > > > > obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o > > > > > > obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o > > > > > > obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o > > > > > > +obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o > > > > > > obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o > > > > > > obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o > > > > > > obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o > > > > > > diff --git a/drivers/leds/leds-max5970.c b/drivers/leds/leds-max5970.c > > > > > > new file mode 100644 > > > > > > index 000000000000..c9685990e26e > > > > > > --- /dev/null > > > > > > +++ b/drivers/leds/leds-max5970.c > > > > > > @@ -0,0 +1,110 @@ > > > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > > > +/* > > > > > > + * Device driver for leds in MAX5970 and MAX5978 IC > > > > > > + * > > > > > > + * Copyright (c) 2022 9elements GmbH > > > > > > + * > > > > > > + * Author: Patrick Rudolph > > > > > > + */ > > > > > > + > > > > > > +#include > > > > > > +#include > > > > > > +#include > > > > > > +#include > > > > > > +#include > > > > > > + > > > > > > +#define ldev_to_maxled(c) container_of(c, struct max5970_led, cdev) > > > > > > + > > > > > > +struct max5970_led { > > > > > > + struct device *dev; > > > > > > + struct regmap *regmap; > > > > > > + struct led_classdev cdev; > > > > > > + unsigned int index; > > > > > > +}; > > > > > > + > > > > > > +static int max5970_led_set_brightness(struct led_classdev *cdev, > > > > > > + enum led_brightness brightness) > > > > > > +{ > > > > > > + struct max5970_led *ddata = ldev_to_maxled(cdev); > > > > > > + int ret, val; > > > > > > + > > > > > > + /* Set/clear corresponding bit for given led index */ > > > > > > + val = !brightness ? BIT(ddata->index) : 0; > > > > > > + > > > > > > + ret = regmap_update_bits(ddata->regmap, MAX5970_REG_LED_FLASH, BIT(ddata->index), val); > > > > > > + if (ret < 0) > > > > > > + dev_err(cdev->dev, "failed to set brightness %d", ret); > > > > > > + > > > > > > + return ret; > > > > > > +} > > > > > > + > > > > > > +static int max5970_led_probe(struct platform_device *pdev) > > > > > > +{ > > > > > > + struct device *dev = &pdev->dev; > > > > > > + struct device_node *np = dev_of_node(dev->parent); > > > > > > + struct regmap *regmap; > > > > > > + struct device_node *led_node; > > > > > > + struct device_node *child; > > > > > > > > > > Nit: You can place these on the same line. > > > > Ack > > > > > > > > > > > + struct max5970_led *ddata; > > > > > > + int ret = -ENODEV, num_leds = 0; > > > > > > + > > > > > > + regmap = dev_get_regmap(pdev->dev.parent, NULL); > > > > > > + if (!regmap) > > > > > > + return -EPROBE_DEFER; > > > > > > > > > > Why are you deferring here? > > > > This is a Leaf driver. Making sure the parent driver has initialized regmap. > > > > > > How can this driver initialise before the parent driver? > > The parent driver in this case is simple_i2c_mfd. > > Based on reference from other similar implementations, the regmap > > check was adapted. > > As you mentioned, your right that leaf driver will not start before parent > > driver is loaded successfully so probably the DEFER might not be needed > > here. > > > > Thanks, > > Naresh > > > > > > -- > > > Lee Jones [李琼斯] -- Lee Jones [李琼斯]