From patchwork Mon Jul 12 06:10:57 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: 472869 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648620jao; Sun, 11 Jul 2021 23:31:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLGxPNjyLe9LAsfGp8D209KqovbBULPrG7+747gk2pegIHdZFYIhRrFjOK6+jDjdEWPDej X-Received: by 2002:a50:cb8c:: with SMTP id k12mr10073740edi.386.1626071463153; Sun, 11 Jul 2021 23:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071463; cv=none; d=google.com; s=arc-20160816; b=HR3s/zipMXNCtdCgEYH9pK4CWusoLu1tTyQON4IKxhyyt1lJMf4ET+te/K7t4dS7dT /lbGIJq5+NuZ9vrg/QKkRSs6IYoeH2P7RfPoz/VCfdfC8ElJrtzRHyyiNnp4pam3+oFq RlCB4ajlfPadQo+b/V5cZKyN7sQqka3tYfhmykAYHsGIzsH6Nk1Q7BwKmo3ZqetqAjtn lQV6P2zlHBv59WH443kgJmVOk6SNB6OkigoO97GpLMnRMrNEBwPB6NMIxGLAnX2QzE1S JftytpmdSkkKje9O+tWH78I0sO2mf9C5zXgB8RtCuaX5+Xopp+ZkxmmwsDsEvT131e38 TPlg== 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=GdopjBgIuO4Br1WKEUWZfTkjw2Pl7txr9/LxUKxXxYk=; b=sTvAXC/GTKKJyUoOD3Z7e4PgOiZBeuUKBXSFurUcrmtGstQIMA3uCqOgeRpRKZJwdI DhlgP8UFb5vqoFwxmCIWk1CwbYQmzafMODR2Nk0AMFW5aq/hDkN6L4vHJJBIY9XabjCb RwJeMLjNtBjIMzt6hmcv4IfSkxz+2PROsqpQHtqZbx0xff6mTT+ZbGWlHljuUSWBxG6P A9wOHac1v0okZi8/wsdZVhlkqHqc5qktgBUsHViRNgFfecnixcfU91/0TtyCdJu9Z5eS TqvQe9rxk3GCxrJ6zAO44NFYlAINRvq1+otCIHWIkK37KHantA4ZLuft/oAaNCbRx5ZY 0Kew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G2FZeZd3; 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 b1si16242569edx.272.2021.07.11.23.31.02; Sun, 11 Jul 2021 23:31:03 -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=G2FZeZd3; 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 S235377AbhGLGdo (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:46964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235509AbhGLG2m (ORCPT ); Mon, 12 Jul 2021 02:28:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D4B261151; Mon, 12 Jul 2021 06:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071097; bh=I6uD/zlwTea7JWHWedfC3b4Q9Pi/wr274i0zLaQlVwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2FZeZd3lov3uSSltouxJIraW+AjmAnQr7nPWaOOQdQiumTEK7Ez7WWxfJ19qdLKz 1aVmDD11T4kwtidoR6HFKKjkWxfCRbiDYWqI6/l3TDHfCd/ugTLRw14OXQqSl8KgoE +LSsstVRcnQEXXkDmPLKe6TUx5pD+vHxAiRd/MSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Matt Ranostay , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 273/348] iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:57 +0200 Message-Id: <20210712060739.926393435@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 679cc377a03ff1944491eafc7355c1eb1fad4109 ] 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: cb119d535083 ("iio: proximity: add support for PulsedLight LIDAR") Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-14-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 67f85268b63d..0c7617022407 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -43,7 +43,11 @@ struct lidar_data { int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len); int i2c_enabled; - u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u16 chan; + s64 timestamp __aligned(8); + } scan; }; static const struct iio_chan_spec lidar_channels[] = { @@ -228,9 +232,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) struct lidar_data *data = iio_priv(indio_dev); int ret; - ret = lidar_get_measurement(data, data->buffer); + ret = lidar_get_measurement(data, &data->scan.chan); if (!ret) { - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, iio_get_time_ns(indio_dev)); } else if (ret != -EINVAL) { dev_err(&data->client->dev, "cannot read LIDAR measurement");