Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp177548imm; Wed, 12 Sep 2018 20:52:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYQcJ7BOqSHoTOfVJMK5/D53BHMSPUshBCfmFt/nQCVbGtAKzOZ6LcjZp9j7RTSR8K5+vo7 X-Received: by 2002:a63:b44c:: with SMTP id n12-v6mr5174485pgu.337.1536810734309; Wed, 12 Sep 2018 20:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536810734; cv=none; d=google.com; s=arc-20160816; b=uZRuBKg8NGFtVAVrANpPRSBJtR6dh4QrfcDQgx6jHyXTCCG/h9d0kdKn6LMEHCNe0N rQupee39owBkMYOTrOM7boOEdQdO/4zfLovdljO9SyUl5ZH6KKnlH2EhggNyHWNC0G36 HM3PjCVKYafsDKVXRX9l/3HGoyDLUpbY13gOZBtHzQIQI9uKSUI/J37TmaLtN7Wosp5h /tuC/6jVhG8uvUTJRYw3WPN7pK5kMrRB7KFGdwGh9oehgWHjGUTGEQT8hy3T9RHbkQsI URDFMNQdbMBYnuW13UlW5Sc+NH7+OQitCKsg9KO35NU4ATLODCjlCHQP9KX2k/KUwabC /wYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=m9xhX8/BiQDyqokLrSJV49GjJPvdwE/vv1tVO/83JB4=; b=JzC2UPqeL1D93GlrGl9stNnUFgk1kYLIf26a2XHi77s6k0MYhUict9ahqlq5aZUa99 VDBbbzTNwHmFGsej5ClUyMSkyDD9hG0oGH5YOUCYLCxOHPkkcdjhvHxcqeXmNMOQUrtr Tdo11GZT8liL+KmTVXf4BmJGQ7+hT/YaFTYzLkcdrUxEwUyQGAEraGucxvoLqB0G+J3U IN5LobRSxCRB84K1sIh6fKaRG9xY5JzSsMYjysfObEh08Ft4wlVXvjgCALS0qvpxmn1l qCsDe9JDON1pRlcPU8Hw+atghWMsNCTRMoRR7Vp/4/zP2nE+tZU+HZR/WRJRSkPmHLRv 7e2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tz6MHqpz; 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 j15-v6si3067641pgk.440.2018.09.12.20.51.57; Wed, 12 Sep 2018 20:52:14 -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=tz6MHqpz; 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 S1726694AbeIMI73 (ORCPT + 99 others); Thu, 13 Sep 2018 04:59:29 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44187 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbeIMI72 (ORCPT ); Thu, 13 Sep 2018 04:59:28 -0400 Received: by mail-pg1-f196.google.com with SMTP id r1-v6so2076806pgp.11; Wed, 12 Sep 2018 20:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=m9xhX8/BiQDyqokLrSJV49GjJPvdwE/vv1tVO/83JB4=; b=tz6MHqpzXUn48EOsTIkd5kaYzdpSTA4zAkMmMu9ouTw/t3es2yTTNYDiY2xtXAHtf2 RAZurBQktwAbQ/Dq2BY3KteDjqp6rM2OuiFM1br00QGoAeipjE6yzL8JsoX61lgD6QFH tfC0MOkIf9xgQUQ2SzUcueoHkW4T8Ea4h62phv3yx5xIaCEfMIpOB3lZyk6/v2NkisJV FbfYO+hBbCKW+zXioNTmaRpZZV4fAe81Rxtw3Mhb7vU3U8gLfEr2CaYMSMCj5RygwaQW jBLCtK/lwEiHZVKhHpCma1pdrA4JNz1GKDztuLO+Bf3cXh3ykvAAYkXrMgPX5d1AiMFi yZHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m9xhX8/BiQDyqokLrSJV49GjJPvdwE/vv1tVO/83JB4=; b=mKT0saecwu1CGZNgOJ9o+05ar4NMdL6MKqXHulZldkLq4V2xY8afL7FRJFrijFp/tZ rm78SoMkxlxpUGEKWsEyc1TBxs8/B1jW/5yA8IA5DOEhlOldejMMU5rqDgE0Q37EQoEr MAjytCoVAn1zLqdhXKv0AZ+yIR/VtFjBCxBN4XIUkPq+4zGbp0oWqxtK+UmCOfxbhKQG 6tz0/xhNgxU4T3bC4YR2bIeqiEgejkPEzu/jzH4uHs1Uzpb4tNGq4CABrqfQeu6a9HAc inO87w03F6MeTZfLyXXbN4xZNPsYJ44HVZtxdlUjbQKJt9JpmPVvzJBJinlcIx53enXr B3qg== X-Gm-Message-State: APzg51CCh4gnLcqXJ6l9j1oBPCt2B50+7IDiDGhlTmve7+7zRa2JlMwq 1k8zpVokL4RxQ5rtje2mJlg= X-Received: by 2002:a63:4386:: with SMTP id q128-v6mr5055254pga.353.1536810711881; Wed, 12 Sep 2018 20:51:51 -0700 (PDT) Received: from localhost (104.176.229.35.bc.googleusercontent.com. [35.229.176.104]) by smtp.gmail.com with ESMTPSA id 83-v6sm4949499pft.40.2018.09.12.20.51.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Sep 2018 20:51:51 -0700 (PDT) From: Song Qiang X-Google-Original-From: Song Qiang To: jic23@kernel.org Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, matt.ranostay@konsulko.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Song Qiang Subject: [PATCH] iio: proximity: lidar-v2: replace i2c block access method with the one already implemented. Date: Thu, 13 Sep 2018 11:51:45 +0800 Message-Id: <20180913035145.28056-1-songqiang.1304521@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver tries to access a block of data on a i2c bus and it tries to manually make a device command frame and a consecutively read frame, then uses i2c_transfer() to read data. But this has already been implemented in i2c_smbus_read_i2c_block_data(). Sorry for not having this device by my hand, which is a little expansive for me, but I have another i2c device and tested with both i2c_transfer() and i2c_smbus_read_i2c_block_data() and they all ends the same. I'm not familiar with the SMBus, don't know if the lidar_smbus_xfer() function is the same as i2c_smbus_read_block_data()? The original code is commented with something I'm not sure, but I think if it's a standard SMBus, it should be able to use in here. Hoping for someone to explain. Signed-off-by: Song Qiang --- .../iio/proximity/pulsedlight-lidar-lite-v2.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 47af54f14756..ca880ba8e820 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -63,23 +63,7 @@ static const struct iio_chan_spec lidar_channels[] = { static int lidar_i2c_xfer(struct lidar_data *data, u8 reg, u8 *val, int len) { - struct i2c_client *client = data->client; - struct i2c_msg msg[2]; - int ret; - - msg[0].addr = client->addr; - msg[0].flags = client->flags | I2C_M_STOP; - msg[0].len = 1; - msg[0].buf = (char *) ® - - msg[1].addr = client->addr; - msg[1].flags = client->flags | I2C_M_RD; - msg[1].len = len; - msg[1].buf = (char *) val; - - ret = i2c_transfer(client->adapter, msg, 2); - - return (ret == 2) ? 0 : -EIO; + return i2c_smbus_read_i2c_block_data(data->client, reg, len, val); } static int lidar_smbus_xfer(struct lidar_data *data, u8 reg, u8 *val, int len) -- 2.17.1