Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp909988imm; Fri, 3 Aug 2018 13:57:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFxLVRZAaNDvcq0MyGWiP5LIbWxIgCTl2BK/7GyCChp178+0NaG39dlloDd7nQEfnwMkhV X-Received: by 2002:a63:5421:: with SMTP id i33-v6mr5296498pgb.417.1533329827095; Fri, 03 Aug 2018 13:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533329827; cv=none; d=google.com; s=arc-20160816; b=zEx6QscJ6nHvI8gOjRaP/gOdzBytUdV34eMAuEmwuYTOseZicjHYE+BHiHh2bZxOh0 JNUB14X/siV7enNA4TL5cSbIoS1LU9eBk19kltMODTmSt300V9FXylcag378CdWqwfCi LwFAPytJC2RQcmdkUc6qIXCt3N5toBMKBpxtoMS7Hb6WZrtYxXGx/jaPjlyWqYUSd30m Flv0a8blV4oeR8bckHDHJKnSK6h3/ns6dLzlV6PJDDgrZnYlZbewTNaU0fd7ngpvm/b6 BZYnpkX6WNGJtaO56E1fx5sy67DZuE4wmaDUHteOidY3AVq0pEnzEU182fgNA/1i9om/ k7sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=QL4rfRrF6ET99AuRQIwoV+Qe5okPDx+bg12mqfiFI1w=; b=WONlxZ/NCinH6kVS5bgNichMD0Mie3+1lGeZWlc6xkzRycD/9TqZTVFWqvDeiuDyDZ V4LA5py1zV/YJszCqYAEAO0RGIafPaZi65Rbi5pPujF2qxgIhp9GARwGGF7HTskYaFT4 at46jCa8QQbG1LXFPV4+s8yNoPxjz9eWlxgTe999JHJwyXpa133R5vqdfkV6+SQ14wq5 yb3SPzwIhO36VLNGW3wiG1sgkN588XcvAwkQ2sslD+lbh1nl0KJti9q+9cGolljZeJXP aQdcVy3+tifJ6vc4txw4zloPX1/qEbL0wiUFEOmcOVZ6xylHIuaMaqRPRA4fCNnW84pJ j/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=boOuAqxR; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18-v6si6098097pgg.332.2018.08.03.13.56.52; Fri, 03 Aug 2018 13:57:07 -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=@kernel.org header.s=default header.b=boOuAqxR; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732140AbeHCWxb (ORCPT + 99 others); Fri, 3 Aug 2018 18:53:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:57860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729876AbeHCWxb (ORCPT ); Fri, 3 Aug 2018 18:53:31 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2DAFF217A2; Fri, 3 Aug 2018 20:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533329734; bh=1wInzgfFYXz03b+rlnjAPPvo8pMAOV/6XNdXzEq7awQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=boOuAqxRzH/KBhuRT8vgTvcOht7kmqtDN9y/n8G0mYIqa/mwVXR+psa+s9VZAH+7j YP23T7DMqnhHmDapYElTc30B++VuMo57vI9rvHUdvm+iCY02U03IoVaruHevwRi+HF 572sehZQ5/uJCAKsfXKlqeq06AoDQraNtvr0WosE= Date: Fri, 3 Aug 2018 21:55:29 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: Parthiban Nallathambi , 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 Subject: Re: [PATCH v4 2/3] iio: light: Add support for vishay vcnl4035 Message-ID: <20180803215529.2069df4f@archlinux> In-Reply-To: References: <20180802182729.2061830-1-pn@denx.de> <20180802182729.2061830-2-pn@denx.de> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Aug 2018 22:34:14 +0300 Andy Shevchenko wrote: > 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. I'm not sure we should. The docs are fairly clear on this: "In order to use autosuspend, subsystems or drivers must call pm_runtime_use_autosuspend() (preferably before registering the device), and thereafter they should use the various *_autosuspend() helper functions instead of the non-autosuspend counterparts:" (Documentation/runtime_pm.txt) It also makes more logical sense to have removed the userspace interfaces before unwinding this as then we don't have annoying races around the inevitable set_suspended. > > > + 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. >