From patchwork Tue Jul 17 16:46:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Novotny X-Patchwork-Id: 10530141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F005E60545 for ; Tue, 17 Jul 2018 16:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E071E283FE for ; Tue, 17 Jul 2018 16:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D532728710; Tue, 17 Jul 2018 16:56:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 221862854F for ; Tue, 17 Jul 2018 16:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729684AbeGQRaR (ORCPT ); Tue, 17 Jul 2018 13:30:17 -0400 Received: from hosting.pavoucek.net ([46.28.107.168]:60787 "EHLO hosting.pavoucek.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbeGQRaR (ORCPT ); Tue, 17 Jul 2018 13:30:17 -0400 Received: from tomas.local.tbs-biometrics.cz (unknown [176.74.132.138]) (Authenticated sender: tomas@novotny.cz) by hosting.pavoucek.net (Postfix) with ESMTPSA id 00B3A1056FD; Tue, 17 Jul 2018 18:47:04 +0200 (CEST) From: Tomas Novotny To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [PATCH v2 3/4] iio: vcnl4000: warn on incorrectly specified device id Date: Tue, 17 Jul 2018 18:46:54 +0200 Message-Id: <20180717164655.27142-4-tomas@novotny.cz> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180717164655.27142-1-tomas@novotny.cz> References: <20180717164655.27142-1-tomas@novotny.cz> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We can detect incorrectly specified device id for some chips, so warn user in that case. Signed-off-by: Tomas Novotny --- drivers/iio/light/vcnl4000.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 0688214fc152..642a366c1479 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -83,8 +83,20 @@ static int vcnl4000_init(struct vcnl4000_data *data) return ret; prod_id = ret >> 4; - if (prod_id != VCNL4010_PROD_ID && prod_id != VCNL4000_PROD_ID) + switch (prod_id) { + case VCNL4000_PROD_ID: + if (data->id != VCNL4000) + dev_warn(&data->client->dev, + "wrong device id, use vcnl4000"); + break; + case VCNL4010_PROD_ID: + if (data->id != VCNL4010) + dev_warn(&data->client->dev, + "wrong device id, use vcnl4010"); + break; + default: return -ENODEV; + } data->rev = ret & 0xf; data->al_scale = 250000;