Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp175070imm; Tue, 25 Sep 2018 18:50:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UhHyvH35DYQToJxT0T3rSNWZvyx9TZoEjgMKTK/O7FrnachkOVIRrMtN3BekqTA+0e7Ql X-Received: by 2002:a65:6398:: with SMTP id h24-v6mr3441065pgv.245.1537926621585; Tue, 25 Sep 2018 18:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537926621; cv=none; d=google.com; s=arc-20160816; b=UBy5WyS92tG93JLOctqsBqtsWwAaT/sjRgTZzh43KCyToMukYrKrnGIiKq9Co09/SO cKOXz0Rb0l3kqOBd+L9AmMJlbb9RvS9vwFGud2+gMsfehfuWmcI9Gh7wIyRfrFkG35bz JbB1lLCSye0710Ziygd8rIjlF+vnnf/NJZl7plmsdXthSjTMJPRI+rQxmo8wkEbdgkhr WlJYVtSXOWHq9OctYk2PFFoIBcQU213nd8okTIkEua5wO4QmXssRzrW5UJsJatxsW30a 1/hyqsCrR/r97ZZDkF7fuPDUkOGS+eEurhFDGZGEopCfnr/tUWyYWZXUkoyyTuSQEN8l 6VYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Eaoa1jIwKvUqpGYuYJP6cUqaoeX2VSBALumixehSr7A=; b=pHlvGQz1TYfVAXnEQ5XwVfOE5OzG9o7gJn1lveW8rEI4LqiErmjnUF7l6dbezybAVk cC29BPTLp5WERCWMxqp0T7v7LhrkVIyxep4Dzov9/68EsElGeFFZSnINIPWj9kvYWW+H IfMXgHw6LVIFnryBghdYh17JnPQ6N+OkjXvlmTax0KhYU+nzZdl8i9/7tgAl9jT5xuoK D1WsX6P0LHWM8rWC7OJMJR9/xKHCdKvRmvxsA9zzn65WD7RBT3iPEFvMgVGxKKDaOE4u zIIaWfRtY7Nupwvmp8RHpzOPSFOrfJ2MEcvj5HZzgaL5QmDjZY+WvQWXUEVLW/1X+bO4 xwAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MtNRyWL7; 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 137-v6si3578173pfb.45.2018.09.25.18.50.05; Tue, 25 Sep 2018 18:50:21 -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=MtNRyWL7; 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 S1727151AbeIZIAV (ORCPT + 99 others); Wed, 26 Sep 2018 04:00:21 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38201 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbeIZIAV (ORCPT ); Wed, 26 Sep 2018 04:00:21 -0400 Received: by mail-pg1-f196.google.com with SMTP id r77-v6so7770132pgr.5; Tue, 25 Sep 2018 18:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Eaoa1jIwKvUqpGYuYJP6cUqaoeX2VSBALumixehSr7A=; b=MtNRyWL7bOMWAhTvZMdA8JguPd5qdeg5M9Xt4v6ICj47U88eo/S3kVSLX/oVkTCJX2 mYP2twnw3bypaXsk9q9QfoN8cOkYV1+zH0hm68/2cP/0XyeSFJPGdvsT+5qXUmcfMzml vD5bwGc+VRshQOQgwpOxt7TRZ4HW61rL+ca6XBMJh4G20jqAQSsiymm49+F2E8wgF5/3 kEhGFv2KVCsh77Dt9kcclJBYOtLl4bv8Ro7Sw6hVmqhoRzb3Uqoh4mbxmOJ4eHpCG5Eg vMMyBVh68w5qa3LUKET5EDasoZAduyYECskazjdudRTITG7RfH0qQg/bCfmCdQpHlcpv 4LqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Eaoa1jIwKvUqpGYuYJP6cUqaoeX2VSBALumixehSr7A=; b=DCLcWsLyo3Rm+axKQDC4V8Y1LlRYgDri4u5QNrEjFwM1EPle3lggae/ORuvlcMPSuI d/HHoHtuqfnbIJqHAVnru2ol/fIj/YZZRUWsHIu6gu7yw9JMg2rGn7SyoJqSPryeFTNH 2zC25/K3p0ZSIH8pwmSRw7ClQorUMsmg8r93vRKKyYAa/Tf3oCRVFp9nuMgzArfaBWI7 9MEXxxm7Yx8Dog4cAZ0bVwLhIhbdCMtAnmzsXOkLTntDQ0iA/sPkWqM1mDT9aTE8tlmp m+OuaxqD+6xqs7pb63vEbuCRrFsu2UzxJZTvCbJrjinS/8V4yKS1PzXg0MgAf+HqIx/f 3gmQ== X-Gm-Message-State: ABuFfojuaqxPfa61MDh389++MlsIuEUX5AyJTr/YjeqMIqKn55vZmNSb 7vBwbCwJKC213vWYton/dcc= X-Received: by 2002:aa7:83cd:: with SMTP id j13-v6mr3722191pfn.236.1537926598919; Tue, 25 Sep 2018 18:49:58 -0700 (PDT) Received: from Eros (104.176.229.35.bc.googleusercontent.com. [35.229.176.104]) by smtp.gmail.com with ESMTPSA id r205-v6sm4662416pgr.11.2018.09.25.18.49.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Sep 2018 18:49:58 -0700 (PDT) Date: Wed, 26 Sep 2018 09:49:51 +0800 From: Song Qiang To: Phil Reid Cc: Jonathan Cameron , jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, rtresidd@electromag.com.au, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] iio: magnetometer: Add driver support for PNI RM3100 Message-ID: <20180926014951.GA7094@Eros> References: <20180925031724.21399-1-songqiang1304521@gmail.com> <20180925031724.21399-2-songqiang1304521@gmail.com> <20180925143054.00007fcb@huawei.com> <57d8a9d6-c402-068e-0a21-bbd6c20a7816@electromag.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57d8a9d6-c402-068e-0a21-bbd6c20a7816@electromag.com.au> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 25, 2018 at 10:36:54PM +0800, Phil Reid wrote: > On 25/09/2018 9:30 PM, Jonathan Cameron wrote: > > > +static irqreturn_t rm3100_trigger_handler(int irq, void *p) > > > +{ > > > + struct iio_poll_func *pf = p; > > > + struct iio_dev *indio_dev = pf->indio_dev; > > > + struct rm3100_data *data = iio_priv(indio_dev); > > > + struct regmap *regmap = data->regmap; > > > + u8 buffer[9]; > > > + int ret; > > > + int i; > > > + > > > + mutex_lock(&data->lock); > > > + ret = rm3100_wait_measurement(data); > > > + if (ret < 0) { > > > + mutex_unlock(&data->lock); > > > + goto done; > > > + } > > > + > > > + ret = regmap_bulk_read(regmap, RM3100_REG_MX2, buffer, sizeof(buffer)); > > > + mutex_unlock(&data->lock); > > > + if (ret < 0) > > > + goto done; > > > + > > > + /* Convert XXXYYYZZZxxx to XXXxYYYxZZZx. x for padding. */ > > > + for (i = 0; i < 3; i++) > > > + memcpy(data->buffer + i * 4, buffer + i * 3, 3); > > Firstly X doesn't need copying. > > Secondly the copy of Y actually overwrites the value of Z > > XXXYYYZZZxxx > > XXXxYYYZZxxx > > XXXxYYYxYZZx > > > > I think... > > > > > + > > > + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, > > > + iio_get_time_ns(indio_dev)); > > memcpy target is a different buffer so should be ok. > > But that raises the question of does it need to be? > 'buffer' could be 12 bytes long and just shuffle Z then Y. > Do the unused bytes need to be zeroed? or does libiio mask them anyway? > > > > -- > Regards > Phil Reid Hi Phil, This is interesting, last patch I submitted uses three transactions and shuffles X, Y and Z respectively. You said it should be better to use one transactions, I thought it makes point, and one transaction may reduce IO pressure of the i2c bus. :) And that's not necessary for unused bytes to be zero. I'm not familiar with libiio, actually just been studying it, can't say anything about it. yours, Song Qiang