From patchwork Mon Jul 19 14:50:20 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: 479902 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4226243jao; Mon, 19 Jul 2021 08:22:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw11/WY0vmsoaj3ihDRR3S7hFKHOUwcYNgT1fTJBwK+Y1sPpWYNvH7NQzbNL/smZQe74hto X-Received: by 2002:a05:6402:2023:: with SMTP id ay3mr34621624edb.383.1626708137755; Mon, 19 Jul 2021 08:22:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708137; cv=none; d=google.com; s=arc-20160816; b=WB+H0MHHTpN1S03ML8APVSBX0qRs+9ilBCjiQrJF0KPuGY67L15DgQN8/sTZ6YXQMA DnX59u1Ay0rZpHgEwrwJ/IUBtGiQnoH0AUZ1CY1R4/dXbXsXmYQDeHztF77LsUJFjJb1 MkM2qwLDfW/MSNJlX4voRfVmzg2PavVxLrbds4R3muBu/WweU8bbNHK7scm32rN+dfjP x3LP4sSjIthETr4WOle1+HVLL1BM4+p/taTtBwd1/z2qP5TCdekitZRI9Uw73mzc2Fgn sdo0+xIjOzmUafbmCGhWizcZRFKlUllMqnqHPSVwr7AeZvEhFWxqmzivvYgh3ci0ScGF HP6Q== 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=OJkecD2wXd3fJMXrtAw1LIWleQ0NpVZo8jcVnbkXyr8=; b=kg0wKx0Dkr1Q8C3/33EPmvL2aUmf9EHN+VyyGl2qn3OHAXsuS1e3xVrGN1MqzML5bL jk5cSlcTuo+dDAthkbO/4guyKmq82wjQtLJ9P2MWMK/I7BJlKrhoNoA7glwgxoP606Qq 6CAlSpeXr9fluBc3u32HAlHFT0SH1VlvlmCTL+PjN8Vsyb1/UCsFm/g5LM5LGQlLOa7I lBMGH32lx08McSTQl/wWB3Sm892v9p9q096NCkwPdIRKASNpaEio70dGK9+yse4Pbv5K zh+CWE2FOmZz0xJp6fEe7NqpPzKfpJoVfEYXoMi7v130cZdzu53NUIaPfz2wBWMcKnB7 E+MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h5aB2Xqs; 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 l3si24719878ejo.634.2021.07.19.08.22.17; Mon, 19 Jul 2021 08:22:17 -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=h5aB2Xqs; 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 S244851AbhGSOl0 (ORCPT + 12 others); Mon, 19 Jul 2021 10:41:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343738AbhGSOjn (ORCPT ); Mon, 19 Jul 2021 10:39:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BB2C61249; Mon, 19 Jul 2021 15:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707978; bh=zD4Wf14Ui7EbW8wYCW5BlyIC1U2GZrGZijH2h5s/Jtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h5aB2XqsWkXMAsOBMOT9HaJTzG1b6W/1ZWNZhRuvT5g0rPtSyAH/CJziK4ZuTIntZ Gif15oGursmK0d+J39IPdZuIqf1Aoasq3+xRUdGALCnF5KEHYj2nkKLjmFXs6bIoSv 0GQY1A2Mr5HZSYbjw5LC278yeoKNAcR7qsJIErR8= 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 4.14 131/315] iio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:20 +0200 Message-Id: <20210719144947.190525278@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 9380d545aab1..d36f634a22d6 100644 --- a/drivers/iio/proximity/srf08.c +++ b/drivers/iio/proximity/srf08.c @@ -66,11 +66,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; @@ -193,9 +193,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: