Received: by 10.223.185.116 with SMTP id b49csp1197215wrg; Wed, 21 Feb 2018 13:58:57 -0800 (PST) X-Google-Smtp-Source: AH8x224I5b9BOSx5XHeDIUvVIRS2oTXNCj0lsz4pf4oc04zBBISiCvpooWIqzPzCh2GOC0IMGu8P X-Received: by 10.101.92.196 with SMTP id b4mr3749153pgt.27.1519250337696; Wed, 21 Feb 2018 13:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519250337; cv=none; d=google.com; s=arc-20160816; b=s38xY8VVb3aHxxq+7FuucA62QB5hlJmZComD+nY4j65YDHGCfn5fbwUEljN0C6OtfY x70zqebwgY6wGEL4A9zW4CbCZ7Ctpze4vkUItEHaK/CCrwNQLv9QqspfShVYdtlgwlG3 WI0pl2tYeWCfLVfJjFqeSUPEE0tybaYbMxkS79o8u/AShIhJT0Jv/OXrN43FxrPzfRwz A4QmVBOFybxSKPdL8vRwvHIBfzBN9n7lqFvJqOW2IteVtaKd96EcxHX9u5K4jNYjwlPT NXbyTa9GWJ8zaFCYsYR3zGJtgbq/ST6YzV+taPew3fHjqpvFolzGLLQXJPC0QLu3dw2y pp7w== 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=CaVoIP4GFjxuOD3UPNOeKbxjhStY+c6jpjVHE16yuss=; b=TRqtC1lWqt68bi3I+hWf522xC4zDFyUq5K+A86wONs+0UmGYxCR2BBfv1u/KV0BdRE 5J//eMzxTkHWdFNqi2kCfGXeBqDJPnSYwvLO7li5pmR9xeFZY7r6dAbJEC9DWh3himYA R8X7rhdw/UOB2lq5okeE+5OL2/RL8kWMPZbKFOzqPmTHWU5hjBk2bMTTp7vdDRGRWYsf eZ8reRI1uwM7l3otxm/gFWQP1nWKcsyoAbIuE8zhZxVn5cZ4Ip6fU6k58SVJNmkIZDUq YpPP97I5fIzdOGW6C51lkxFQMLpRaeKJwwpezfqBQsvqv2aen1DjVotkSZ09XdMUITZ7 Oylw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=duR98an5; 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 n7si2466796pgv.705.2018.02.21.13.58.43; Wed, 21 Feb 2018 13:58:57 -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=duR98an5; 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 S1751274AbeBUV55 (ORCPT + 99 others); Wed, 21 Feb 2018 16:57:57 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35877 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbeBUV5z (ORCPT ); Wed, 21 Feb 2018 16:57:55 -0500 Received: by mail-qt0-f193.google.com with SMTP id c7so3915663qtn.3; Wed, 21 Feb 2018 13:57:55 -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=CaVoIP4GFjxuOD3UPNOeKbxjhStY+c6jpjVHE16yuss=; b=duR98an55OaKBLS7+OXWJn3UQhIZGNozuHXyXodQIE9Tqe2s9nVNRQSNrOIClQULz9 BZOAv5VH+yVLp48/1mYYLz0ygrY+Gv8jWEVPzKWS+3LxvRv4J8ZuBUCysGtUVaq0Or3f JmB8vOaYdHw2sIehMrCRO4NePNUclj+u5D1sba7FeJQywRBRXVGFLlxIh/Q7ggxYcnSy IOzXp9p2HmgHDOfIgGSqDW3P4jEFsTgQt+TszZbXHKFK92lwIhsWCietH0Rt4FLQlW18 01Y8VssbcEJ/YhNrJW3zVzwStop71J7cbiSw/7ELBdp7rdmyWebKzzmaSNYyWanyGSVe m3iA== 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=CaVoIP4GFjxuOD3UPNOeKbxjhStY+c6jpjVHE16yuss=; b=knP0h3D0Zo37TPba74ToxFlbTQI4l/HRbYdK+S3xZdQNjOCS47oKZQwP6f1HRYo1xO tRbljfpwYol1Wp2PHq5pt/pepAuc1V2k/p7/sHwjCCBvjI6u+Zb7+qsi15K207JTERVq zZrZtlhGn0kHfsIb2o6U+7ts4tlYOTvkqKM/QimjfVLPgPbyiFjMJ/0KoM96Qzo//ZKs 3jUQ9zd2rB39tmA+nEyDgEzX0EKpm6J/dVX9PiflEipnWjYjKEhHgP56hzhImciLb/kD Ryf7SQ+Sn0l3Zj2n1Iw0/btrlXZrsIMJOCFVUr0KsoHX/zUJAyjk/lrXpdRlp714z1JF lvog== X-Gm-Message-State: APf1xPA8KUREIZyABSTTVbMDQ0mVQ9fIxW1JZf7V0UojbJunKIIbUPJu dMK+NmYi0dNllm7CaKYA3qANGbIb8dKKJL0/NYw= X-Received: by 10.237.48.196 with SMTP id 62mr7641480qtf.39.1519250274720; Wed, 21 Feb 2018 13:57:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Wed, 21 Feb 2018 13:57:53 -0800 (PST) In-Reply-To: <20180221194526.49183-1-delroth@google.com> References: <20180221125512.8265-1-delroth@google.com> <20180221194526.49183-1-delroth@google.com> From: Andy Shevchenko Date: Wed, 21 Feb 2018 23:57:53 +0200 Message-ID: Subject: Re: [PATCH v2 1/2] iio: light: add driver for bh1730fvc chips To: Pierre Bourdon Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, Rob Herring , Mark Rutland , devicetree , Linux Kernel Mailing List , Daniel Baluta 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 9:45 PM, Pierre Bourdon wrote: > Ambient light sensor that supports visible light and IR measurements and > configurable gain/integration time. > > Changed in v2: > * Split off DT documentation change into a separate commit. > * Use i2c's probe_new. Btw, how big the difference with existing drivers? > + default: > + return -1; Better to return -EINVAL; > + highest = max(visible, ir); > + > + /* > + * If the read value is being clamped, assume the worst and go to the > + * lowest possible gain. The alternative is doing multiple > + * recalibrations, which would be slower and have the same effect. > + */ > + if (highest == USHRT_MAX) > + highest *= 128; > + else > + highest = (highest * 128) / bh1730_gain_multiplier(bh1730); In both cases you multiply. Why not just highest = max(visible, ir) * 128; if (highest < USHRT_MAX) ... ? > + millilux = (u64)USEC_PER_MSEC * (visible_coef * visible - ir_coef * ir); I'm not sure I understand how time units is related to lux one. > + millilux /= bh1730_gain_multiplier(bh1730); > + millilux *= 103; > + millilux /= itime_us; > + return millilux; > +} > + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*bh1730)); > + if (!indio_dev) > + return -ENOMEM; > + > + indio_dev->dev.parent = &client->dev; Strange, it's not done in IIO core... Jonathan, is it true that in case of devm_iio_device_alloc() all drivers use supplied struct device as a parent one? If so, doesn't make sense to modify IIO core to do this? > +static int bh1730_remove(struct i2c_client *client) > +{ > + struct iio_dev *indio_dev = i2c_get_clientdata(client); > + struct bh1730_data *bh1730 = iio_priv(indio_dev); > + > + iio_device_unregister(indio_dev); Hmm... Do you still need this even with devm IIO in ->probe()? > +#ifdef CONFIG_OF > +#endif This... > + .of_match_table = of_match_ptr(of_bh1730_match), ...and of_match_ptr() now pointless. -- With Best Regards, Andy Shevchenko