From patchwork Mon Jul 12 06:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 472964 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2682742jao; Mon, 12 Jul 2021 00:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw66Z02KB2lpRR04iX0/rEdGoSvOXwlPDiU6oD7eK1ghuNjME1Vb4r5GJwVe4o7fHsUOcu5 X-Received: by 2002:a50:d64a:: with SMTP id c10mr65026056edj.199.1626074590547; Mon, 12 Jul 2021 00:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074590; cv=none; d=google.com; s=arc-20160816; b=U2YEEKkGNYpcar81903SDRt1Wdmur1NTS7oOAQOx1Iyi4pl00zvS3eJU4k3QF0fFxa r9m8kkF659v6jhHMa53DzfHYkYa8nFWwI/6VVX6qdygaoeJPyb0xKNTy9KjhcYZT2qb1 JAoVItJRRpcUsL3LzVFlxDnARpZchJVidoM2nolGlF1jcc9BtMz4QaW70F+rsdQfH0m+ 8gEYpPF8k/3QnfB+REh6U3qej6cND81ilElhQa+vRZj8bqnkmadQbokDmPLP7PHjdGHw 7VX8f4v4RBhOIfY0WDNQ3/v7q96pEb5gAWDohd/2MR5Q7kn8yZ5LLJLI4W8JiVnkVF7A WJhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6e2AKJGMA1j4P23V6qgzPNQ08qmeNAsLpPMjPGhlcIU=; b=GNFulrYZMkQVZsUVbU/+7K3YMfNZIL3hG2xfw8iXzu6AdJLH5wcBdgit7qJYvWgI9a 9MC0Z5tQ+88E6i/TRrruQTyjBqKK1drm7tbGiRT6yNaqKLeKZyFn4Umrmk6CD7ZpRjae nhxLhrkwSls5VlntsBR9sz/tx5aY8Ev7jXgLyxt6LDmhcEs8KpEurD0poWSVwCYrzPvi RamNiCauuXUEKvotIpp+HeB7nkrJpHVSNJAL1aJtbjtXqyUiyz35FUoJ3bOxWQFf1fi6 MVg5i8D6kr7adan9gUK0IknBB2Ev6oXujkhXjFg+nxsA26jYhQRPlIOuniFx9fEUuwGk n+jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VdRElPuu; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si16909677edq.169.2021.07.12.00.23.10; Mon, 12 Jul 2021 00:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VdRElPuu; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241580AbhGLHXX (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:59546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344909AbhGLHVd (ORCPT ); Mon, 12 Jul 2021 03:21:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4529660FF1; Mon, 12 Jul 2021 07:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074325; bh=e/KKfcWa+CIdZ83CTH8/LMGfbSFDCGfD8TBqyrOQMtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VdRElPuuQBKARbeG1U0Ah23hsdB+4vre0og5XSZ39ybgr/7/jhfyiPHv1f7TMz4wE czvV0JQId+wrV3iDn2hmlxo25ecJHvu7mWdkVsv0IAqdqKKuVn30clheeKxLwab9qh bBo8eu2afikwTNhMhQZPPlMSx3PnrlLxSxsWMTYw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Andreas Klinger , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 543/700] iio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:26 +0200 Message-Id: <20210712061034.112651345@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 19f1a254fe4949fff1e67db386409f48cf438bd7 ] To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of uses of iio_push_to_buffers_with_timestamp() Fixes: 78f839029e1d ("iio: distance: srf08: add IIO driver for us ranger") Signed-off-by: Jonathan Cameron Cc: Andreas Klinger Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-13-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/proximity/srf08.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.30.2 diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c index 70beac5c9c1d..9b0886760f76 100644 --- a/drivers/iio/proximity/srf08.c +++ b/drivers/iio/proximity/srf08.c @@ -63,11 +63,11 @@ struct srf08_data { int range_mm; struct mutex lock; - /* - * triggered buffer - * 1x16-bit channel + 3x16 padding + 4x16 timestamp - */ - s16 buffer[8]; + /* Ensure timestamp is naturally aligned */ + struct { + s16 chan; + s64 timestamp __aligned(8); + } scan; /* Sensor-Type */ enum srf08_sensor_type sensor_type; @@ -190,9 +190,9 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p) mutex_lock(&data->lock); - data->buffer[0] = sensor_data; + data->scan.chan = sensor_data; iio_push_to_buffers_with_timestamp(indio_dev, - data->buffer, pf->timestamp); + &data->scan, pf->timestamp); mutex_unlock(&data->lock); err: