Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2496754imm; Thu, 2 Aug 2018 12:35:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdTdD42hNOfj+YUMustpwBx1SHMw5o7JdY7kvO+NAq7kBWuCQzJsYSeeTJ6N+m/Lkg1m2z4 X-Received: by 2002:a65:5307:: with SMTP id m7-v6mr750780pgq.431.1533238535504; Thu, 02 Aug 2018 12:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533238535; cv=none; d=google.com; s=arc-20160816; b=v7mi54DDuFvE6AFUbD1JMYtceukpZ+rWYEm6+kfxfUJKN8/f8XPMdpUFrMUbY2Ld3C 5d7BCe4wHL162YCpA/zTCpGQaMzZkGZ4VAOZH80sitQk48p+i+BdGPxODqDLu86zpiqP RSrct0jT7Ha3zZLXW4Kth0hzhLmzbRnxS9hzr6qyQ+4CuExtNHlsF7WmnTHmmq+AZ243 ZjqcMaVH+StMWzWFGcR3DUVJzp6a6Pj6kpvEg5zVZa3nPf3hPXUUn+AVE1JuvKZFws+h 6BuG9dU0yBSAESlWOc4eeny7e6H5bllGgEaFhBIK4pB5fB+NTXUZAt6k2L3YiWpT7IFX cIZQ== 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=vexjNJyG7eeqNxR5o3CgJRpP4VtSZMHwcOLuHZy0O28=; b=bi5uze6Bmf3RMnTL1RBgwiQo3QH4oHHNLnWy3+kCN8PS2ZWTcFfky+JtgRG1DxgWV+ nOQ3HnaQD5Qkj0ZYi/a7KlL5MrMY5MH8IOrHnTYAJBZ2asgWk74nBIuf6nWRxpz0Dh5y +2SvK85Iptmmn65PjiU8cmcoMhtnNjVs9IH15ts3It9knOGBj4kE3FwihOSs/JslzFQD mAxiN4KF8SNtPKCtEeL2KD1yGEh/yQOnSvgU5s7Zme0C6qLJpPO3y/5ot0Jb7W6mSlaC YpfcgCdl+AunYSkwj2iJKqwyNunoBDjF2ZGUatN6YKiyS7B3U9fuDciIPsJ85wI3JMol Lmvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ThRWxLiD; 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 t80-v6si2976999pfk.228.2018.08.02.12.35.19; Thu, 02 Aug 2018 12:35:35 -0700 (PDT) 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=ThRWxLiD; 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 S1729660AbeHBV0s (ORCPT + 99 others); Thu, 2 Aug 2018 17:26:48 -0400 Received: from mail-ua0-f195.google.com ([209.85.217.195]:32902 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726910AbeHBV0s (ORCPT ); Thu, 2 Aug 2018 17:26:48 -0400 Received: by mail-ua0-f195.google.com with SMTP id i4-v6so2273068uak.0; Thu, 02 Aug 2018 12:34:15 -0700 (PDT) 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=vexjNJyG7eeqNxR5o3CgJRpP4VtSZMHwcOLuHZy0O28=; b=ThRWxLiD3bSEPLSxnKHPj5KGsrG4XlQZ0kzQvnbpu9CkEyYNUpQYeEKSUiMw6bAJm/ TP+fjrXz3PyQzSczSRD7y7BwDILCsZafTFd79Vr7hn9IB/ie8ATZkqrXWuEtNuR58EdS RbQKU+Wb4h6I4RD4LzpVV+fjzfjRaefujCXhTGUZo+OtEx5c+pDFMsdsVojmY6LYnmPM 7He8kr0gGjEMXNpqxD+qcTzvD3iYwLzCRnh76aCInJcLBxf2wAxx5X7UfDAlOLATS0gv hRrwWS8J3DrVBAEfXL7iUcRhFTJV/8AEAXj08DWJpRDBcd0byzlaREENHsv8GLLE/JF4 Wv2Q== 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=vexjNJyG7eeqNxR5o3CgJRpP4VtSZMHwcOLuHZy0O28=; b=rOQN0Hs7qeAv3BJ6JVQ+ImOGiXaJmhzSwmoaQIcsujV8E7eqs1JSLd+KOUnuo8C/i3 rO8TKwuMKkUFL1IwK3JLqZMM6ogRXs7yAh/Ir8/MskhS3z6TOh1JVRayWKHpMtCY7O1B FGmu3bZcxVhEoe41VF57xQK74KasHrIZP8L3u/XpzClnLNd5mMjVGUsseoFLP5Hi8blZ S0Jus0qD0bOilCc4bYowv8HaudoFkZTOcCZ04YigDzBLPdgmANM825zfcxWjdPTBhNKu akG4QArl0JuI+f0zKsaqhJWYhO13x05uT+4PG9z4okUzRqIE35olXCH1rFpInVxLAUOm jXWQ== X-Gm-Message-State: AOUpUlEFA0VzQvyVduZztv2mxrJ6T4DRaCQNUuDc3B+L0/SkvLc6FgdV jjNdV6Jzn/wBqDjShncmEoPGsB55FhSgh1DosFM= X-Received: by 2002:ab0:13c7:: with SMTP id n7-v6mr640500uae.47.1533238454960; Thu, 02 Aug 2018 12:34:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Thu, 2 Aug 2018 12:34:14 -0700 (PDT) In-Reply-To: <20180802182729.2061830-2-pn@denx.de> References: <20180802182729.2061830-1-pn@denx.de> <20180802182729.2061830-2-pn@denx.de> From: Andy Shevchenko Date: Thu, 2 Aug 2018 22:34:14 +0300 Message-ID: Subject: Re: [PATCH v4 2/3] iio: light: Add support for vishay vcnl4035 To: Parthiban Nallathambi Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Rob Herring , linux-iio , Linux Kernel Mailing List , Mark Rutland , devicetree , Matthias Brugger , wd@denx.de, sbabic@denx.de, Heiko Schocher 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 Thu, Aug 2, 2018 at 9:27 PM, Parthiban Nallathambi wrote: > Add support for VCNL4035, which is capable of Ambient light > sensing (ALS) and proximity function. This patch adds support > only for ALS function > +#include > +#include > +#include > +#include > +#include Sort? > +#include > +#include > +#include > +#include > +#include > +#include > +#include Ditto. > + if (reg & (VCNL4035_INT_ALS_IF_H_MASK | VCNL4035_INT_ALS_IF_L_MASK)) > + return true; > + else > + return false; return !!(reg & ...); ? > +static irqreturn_t vcnl4035_drdy_irq_thread(int irq, void *private) > +{ > + struct iio_dev *indio_dev = private; > + struct vcnl4035_data *data = iio_priv(indio_dev); > + > + if (vcnl4035_is_triggered(data)) { Here is negative conditional suits. > +#ifndef CONFIG_PM Why? > + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE); > + if (ret < 0) > + return ret; > +#endif > + pr_err("regmap_write default THDH returned %d\n", ret); dev_err() > + pr_err("regmap_write default THDL returned %d\n", ret); Ditto. > + ret = pm_runtime_set_active(&client->dev); > + if (ret < 0) > + goto fail_poweroff; > + > + pm_runtime_enable(&client->dev); > + pm_runtime_set_autosuspend_delay(&client->dev, VCNL4035_SLEEP_DELAY_MS); > + pm_runtime_use_autosuspend(&client->dev); Usually we do this after we probed the device. > + if (client->irq) { First of all, it can be negative. Second, care to factor out this rather long branch to a separate function? > + if (ret < 0) { > + dev_err(&client->dev, "request irq %d for trigger0 failed\n", > + client->irq); > + goto fail_buffer_clean; > + } Indentation. > + } So, do I understand correctly that IRQ is optional for this device? > +#ifdef CONFIG_PM > +static int vcnl4035_runtime_suspend(struct device *dev) Perhaps __maybe_unused > +static int vcnl4035_runtime_resume(struct device *dev) Ditto. > +{ > + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); > + struct vcnl4035_data *data = iio_priv(indio_dev); > + int ret; > + > + regcache_sync(data->regmap); > + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE); > + if (ret < 0) > + return ret; + blank line > + /* wait for 1 ALS integration cycle */ > + msleep(data->als_it_val * 100); > + > + return 0; > +} > +#endif > +static const struct of_device_id vcnl4035_of_match[] = { > + { .compatible = "vishay,vcnl4035", }, > + { }, Better w/o comma. > +}; > +MODULE_DEVICE_TABLE(of, vcnl4035_of_match); > + > +static const struct i2c_device_id vcnl4035_id[] = { > + { "vcnl4035", 0 }, > + { } > +}; > +MODULE_DEVICE_TABLE(i2c, vcnl4035_id); Are you expecting legacy code to use this? I would rather switch to ->probe_new() and also remove this. -- With Best Regards, Andy Shevchenko