Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1046267oof; Tue, 25 Sep 2018 07:38:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV605pP9yuEdfJVRqhlyjYNJz6XQOeb8CqZRyUjDY2JFGTSUcTHf9jKP4dLVwdK2m1W70jNHj X-Received: by 2002:a17:902:7887:: with SMTP id q7-v6mr1537589pll.111.1537886314809; Tue, 25 Sep 2018 07:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537886314; cv=none; d=google.com; s=arc-20160816; b=dHT6EjQPxsYQ3XlnmcGetHopGeROfSN0evVqZXN7N9xo+C9iOqhJFAedXT4VBkMnH7 FvZ1JvSS8Le61QxMrUSF8v8wDbqUs/3xZ42lzsU/jIms4dipsIJXV+bLv+0MA1fwd69y NFYv2PnlbB7oCUKyFkwXhRhW8eRUQBT1NG8/00aoL4+T+ZiY/SCy00pq2Z4oZ7nNFmj+ iupDcgZpv1nJPaXSVk57R2TcZ2h9bumdY8Hjn8Yguj3Jz/xwkM7oiHLE0p0erJ3haJRy BYZHN3OSr3OXjkol5kP8Xb0fT8aCRi0Bw+xe5Hinyq1pE+P+u6O1aNOBDcr2KrC4Rwst MZuQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Dqeo2kG17mPVuctm0KtJZjYc6gBuxY5sE6sgFcOr/1w=; b=seDrizGAaudhCKpBY1dKVMdRTpMV9Cq5+kKjm8/kHna/jA0DKpNXZtD3/I/KCujkBR FLk5B99QKL7enBmwBJYp/rSe6h1StcGmVzt6LhAhSNhdxYGL97wJaYSLfHjnEnJf0r/b dpXo3dr1FR+xB/OIcGd9qYQ8HnJIvQmEe1lmRGP6s7T4fMlEziukSx+O1zyzDzV5Ho61 y0CCAv92yfVf+KdKBvYsgDkCuMvgIy9XgLpcrlQAyycVfJnp3mhi86ryPpkZ4ROtmC4/ rm/ju/7k1xsWGO4rUcIhb3rOdQ03sC7WQu68MiGvD9R0Mt07umqN2Ic1NOF4FGUvH0yB pn1g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11-v6si1713310plq.63.2018.09.25.07.37.59; Tue, 25 Sep 2018 07:38:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729399AbeIYUov (ORCPT + 99 others); Tue, 25 Sep 2018 16:44:51 -0400 Received: from anchovy2.45ru.net.au ([203.30.46.146]:53139 "EHLO anchovy2.45ru.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729320AbeIYUou (ORCPT ); Tue, 25 Sep 2018 16:44:50 -0400 Received: (qmail 6821 invoked by uid 5089); 25 Sep 2018 14:37:01 -0000 Received: by simscan 1.2.0 ppid: 6739, pid: 6741, t: 0.3026s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 spam: 3.1.4 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on anchovy2 X-Spam-Level: X-Spam-Status: No, score=-1.0 required=6.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.1 X-RBL: $rbltext Received: from unknown (HELO ?10.1.1.211?) (preid@electromag.com.au@124.148.255.50) by anchovy3.45ru.net.au with ESMTPA; 25 Sep 2018 14:37:00 -0000 Subject: Re: [PATCH 2/2] iio: magnetometer: Add driver support for PNI RM3100 To: Jonathan Cameron , Song Qiang Cc: 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 References: <20180925031724.21399-1-songqiang1304521@gmail.com> <20180925031724.21399-2-songqiang1304521@gmail.com> <20180925143054.00007fcb@huawei.com> From: Phil Reid Message-ID: <57d8a9d6-c402-068e-0a21-bbd6c20a7816@electromag.com.au> Date: Tue, 25 Sep 2018 22:36:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180925143054.00007fcb@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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