From patchwork Mon Jul 19 14:50:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479881 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4219742jao; Mon, 19 Jul 2021 08:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGcCLExKRz+T0Um84V6K8FokSammovld410WdoRSFVnviW/4noX5eZbtu08m8VMztE0b/J X-Received: by 2002:a5d:6481:: with SMTP id o1mr31154223wri.164.1626707565262; Mon, 19 Jul 2021 08:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707565; cv=none; d=google.com; s=arc-20160816; b=e5LeHnWNd20LXcTtvT0xdMMmzGJU05gKt3Hdx/mOImkxg6+K30uo7cbWEb55LcRlER dWflREYUZmKwuIVSNsRwzzLLPx8H40tUOTCRlUAEa+xLTnLXXIk09Gjyd/SSZzcRTNAc hWcnc10Vfv9Lm2rMk4Co5RJ2YllMLxlz3Ec3+gw0UsqoRyL+b6cynvm7UeWYhFicZpG3 EIkqOEmWue8jiu5cbq9HJk7uKBRr6XMc9NlWnINa5r2iOVFB/PLEcVvZXhNBXbTwdSC1 VQhlO5tMMV9v/+/UyjmAqF5sh4NmeM1UWCYSoBcFHLvYloh1YQxfUc1kOsxN/DADZ9Lg veGQ== 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=nSf51yO6jk+ZQw56pk0v7WDFdDXnQhMxPJ7d+8rJneg=; b=S79zk6Wtc9K+C6p1wDqLlXYGnr3c8ZriEZZy/L2FIiZpxO1YefFLFYKMy/IJI7frnJ 93225f8YJB4DzJYnRFsb2XvLKPRMgp7hxj97Qeuc0ntjq66bvUvN+5WYF6E133h3r6E/ szS1ymKo9GM7i9BQcNYQ3xMZr5WKL9IaQqmzLICKDeH6RfXoF6fLrDVkOReO2m0PxI51 BtEbbcBHFVCvIFRJF5SibTx0T6ogrngqxE19OVkoirRVmG15CD1gCQI3/35mqL//1EyG gJtaTsl+xJffnw/skgYatk4Wd3Ip2RL9Co4CdvVLNpBKcvyJk6Nm9cvwi4vPtRipSqsp vE/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x6+kgbD+; 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 d26si20449114ejc.620.2021.07.19.08.12.45; Mon, 19 Jul 2021 08:12:45 -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=x6+kgbD+; 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 S243298AbhGSObn (ORCPT + 12 others); Mon, 19 Jul 2021 10:31:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244436AbhGSO3q (ORCPT ); Mon, 19 Jul 2021 10:29:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 265D860FDC; Mon, 19 Jul 2021 15:09:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707373; bh=kEwWaMOI6TJiRC7j1KouIgmDwjJioPK5FYgLyi3eNGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x6+kgbD+5Q81f5a/HMiVhoIOfezNS6oXIzKxe4ev98JQfWlyoGfUrc1RScEIWAZPj v5zMeHky1bblpS3yauplYypQR+ynlp6J7ur6LxfUiOHtht7JogIpLs+04it21DZtgj F22luKlrm9gWZO43O8gsL3+0Ct65y1jva90bdrnQ= 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 4.9 103/245] iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:45 +0200 Message-Id: <20210719144943.752092403@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 46e969a3a9b7..ed7397f0b4c8 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -51,7 +51,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[] = { @@ -236,9 +240,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");