Received: by 10.223.185.116 with SMTP id b49csp1217054wrg; Wed, 21 Feb 2018 14:21:41 -0800 (PST) X-Google-Smtp-Source: AH8x224/E6bOPLCEax+s8ZyE4u9VZ4NCh7F8b2JT2i1ImrOdU8D1mO9+tY/OWl+UBGpTVsFefnti X-Received: by 2002:a17:902:d83:: with SMTP id 3-v6mr4579746plv.47.1519251701371; Wed, 21 Feb 2018 14:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519251701; cv=none; d=google.com; s=arc-20160816; b=Lb+5kSI0eX25l8LLvwpC5bzGS79yeVIJh2a880B2nGtMWJKiptVCj9RmQY+sxp0SoS feErwS1cI+NhVlmUEnaUWTJbI9Fjm2GOBzBVL9cN+4PV6Ri1g7im/8xgVftnqwsEQKex t67pfRD8733gQmKr1k7sKiCRfJTEam7YEdDvw7mHgdReskSVdSvq+ZRyzfeMtBjpVIhK 8n6Ejwz4l7qK6lgrGP7fuE3VaHt5CeUxwlUKN1+E7ajdmB8L7ra7PSm7b4T3Nk1MW8pV wpO7/zUzM+wW3r0yQ/UgzoN81X4ZW/p4X/UUa5WA+qAmYlXTb2oWf1Y33txX9QRzDukv XcUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=hVw9nJmuLNUNEe/rzGwuLjfLyb4kHSCNYhVMf0m5jDE=; b=i4PXWprcArtBR+GGiUuEZM9SOCW+xo533154/gVNjL47Sx1qWLfOy/4gpsaUzUwI7B J++Kx9/m/cISHY4q3xuGG9nAlRmnyJ6WwKbGrXH6T9EONR3mdTOoc+y0//xzv0yArqaV Xz/pYQvzUjmCqZnVnUVz+9jKp8lI4pFd9ADE7Cjs3xT+3EFpZDNJR9kQBm6KgIdGGelY TzQEkp5HMbRjEmmyymedA3pQd8tkwl0bmqoBdW8oOms8UCZqIa+szt/1YIeQC5VpXlHK yZMTWmcpQj3C34AvweDW8MEWy3uB0vmPpK2qrkMdh45Q3Y7nKlpYn/Yk81XC0IDUwbGJ eA1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b6xOghaS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si2311596pli.474.2018.02.21.14.21.27; Wed, 21 Feb 2018 14:21:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b6xOghaS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751367AbeBUWUr (ORCPT + 99 others); Wed, 21 Feb 2018 17:20:47 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:44069 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbeBUWUo (ORCPT ); Wed, 21 Feb 2018 17:20:44 -0500 Received: by mail-qt0-f195.google.com with SMTP id g60so3970913qtd.11; Wed, 21 Feb 2018 14:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hVw9nJmuLNUNEe/rzGwuLjfLyb4kHSCNYhVMf0m5jDE=; b=b6xOghaSXmMwbryYClPAkxHxmftg4m0IWNiX+7MtG4QasXrbyobbRGYsuWx786Ilae R1yf2SdR4SHyNRrUU1pW6MEWW6bc59wyh8ObAuIH7c7N7V21JXj173Ll5yoCPtOUVbHb oaGpgZGu6086ytoTy/ziF/4fBlRvWsb4ioPP5xxoWXB1Ro99WnLq5ORa3FaeBa/8skrf qmURfz1vcpA1xtwhBGkWdq2T9h+GmV1JAL+lxJ0pChDo4faKHzy1mXhd9JFjee5VDkhE Uc9bdPkHBVtc8QYcCPyDcTAHqW+dqx6YjKLsEJNLQd7jpt9Mi9RRQFZGs6qvTNkuoZUs FQ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hVw9nJmuLNUNEe/rzGwuLjfLyb4kHSCNYhVMf0m5jDE=; b=r7qGfYNVbY5/hHdaE+1xRPvhl0vVpNPtfBH+49ogZTIRnNYO4FVDId6em4dtv648mR BvbeqO2XuzMJS+NweK1sAgh7HQJwM3//NWmxM91ySFLQ1O4SHFAOISrZ+VtRri6TsgDx mMGBKVwfdJTlCm9tkcm01quikFTcEemYXjZOz0K55npDVSaYnBANO/iXKx0tlepRp+u6 3223x/uLeHuYam/27P5CMZHfHbJEnmtDsujzD/GLdjDDRBH2S2W2+9iDUq87T6JXpKqx MuhiNZq8jfNT8R1gzqhKR1go9EMjpA++D2H4P3Xmp3iiHVmAT8HsduMiXfqhbt6Mhm73 wktQ== X-Gm-Message-State: APf1xPC+bgS+Jd1WAFUVz27Szg1bMVQ4ZYKkOr4Fjr/hza5YUewPEfLk QOjLSPjEomyh0lXRjiGdk5a/VDUkgkHhYFYYjVnx62M2 X-Received: by 10.200.18.3 with SMTP id x3mr7750551qti.40.1519251644033; Wed, 21 Feb 2018 14:20:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Wed, 21 Feb 2018 14:20:43 -0800 (PST) In-Reply-To: <20180221214654.3306-3-florian.vaussard@gmail.com> References: <20180221214654.3306-1-florian.vaussard@gmail.com> <20180221214654.3306-3-florian.vaussard@gmail.com> From: Andy Shevchenko Date: Thu, 22 Feb 2018 00:20:43 +0200 Message-ID: Subject: Re: [PATCH v4 2/2] leds: Add driver for NCP5623 3-channel I2C LED driver To: Florian Vaussard Cc: Jacek Anaszewski , Pavel Machek , Linux LED Subsystem , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 11:46 PM, Florian Vaussard wrote: > The NCP5623 is a 3-channel LED driver from On Semiconductor controlled > through I2C. The PWM of each channel can be independently set with 32 > distinct levels. In addition, the intensity of the current source can be > globally set using an external bias resistor fixing the reference > current (Iref) and a dedicated register (ILED), following the > relationship: > > I = 2400*Iref/(31-ILED) > > with Iref = Vref/Rbias, and Vref = 0.6V. First of all, why it's rebased on top of v4.15 while we have v4.16-rc2 already? > +/* > + * Copyright 2018 Florian Vaussard > + * > + * SPDX-License-Identifier: GPL-2.0 > + */ Check license-rules.rst. > +#define NCP5623_CMD_SHIFT 5 > +#define CMD_SHUTDOWN (0x00 << NCP5623_CMD_SHIFT) > +#define CMD_ILED (0x01 << NCP5623_CMD_SHIFT) > +#define CMD_PWM1 (0x02 << NCP5623_CMD_SHIFT) > +#define CMD_PWM2 (0x03 << NCP5623_CMD_SHIFT) > +#define CMD_PWM3 (0x04 << NCP5623_CMD_SHIFT) > +#define CMD_UPWARD_DIM (0x05 << NCP5623_CMD_SHIFT) > +#define CMD_DOWNWARD_DIM (0x06 << NCP5623_CMD_SHIFT) > +#define CMD_DIM_STEP (0x07 << NCP5623_CMD_SHIFT) Just put 5 instead. My eyes hurts by above. > +#define LED_TO_PWM_CMD(led) ((0x02 + led - 1) << NCP5623_CMD_SHIFT) led -> (led) > + > +#define NCP5623_DATA_MASK GENMASK(NCP5623_CMD_SHIFT - 1, 0) While here is OK. > +static struct ncp5623_led *ldev_to_led(struct led_classdev *ldev) More usual pattern is to_ncp5623_led() > + return (err < 0 ? err : 0); Where this style comes from? I mean redundant parens. > + err = of_property_read_u32(np, "onnn,led-iref-microamp", > + &priv->led_iref); Don't we have some generic property for iref:s? > +static int ncp5623_probe(struct i2c_client *client, > + const struct i2c_device_id *id) > +{ > + struct device *dev = &client->dev; > + struct device_node *np = dev->of_node; > + struct ncp5623_priv *priv; > + int err; > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->client = client; > + i2c_set_clientdata(client, priv); > + > + err = ncp5623_parse_dt(priv, np); > + if (err) > + return err; > + > + return ncp5623_configure(dev, priv); This sounds wrong. You call configure while it does two unrelated things: configure + registration. Name it properly and move closer to ->probe(). > +static const struct i2c_device_id ncp5623_id[] = { > + { "ncp5623" }, > + {}, > +}; > +MODULE_DEVICE_TABLE(i2c, ncp5623_id); Do you really need this? Consider to switch to ->probe_new(). > + .of_match_table = of_match_ptr(ncp5623_of_match), Here you will get a compiler warning. Remove this pointless of_match_ptr(). -- With Best Regards, Andy Shevchenko