From patchwork Mon Jul 12 06:11:03 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: 472855 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2647494jao; Sun, 11 Jul 2021 23:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO9IEN3yzLaXElnS69LyPvzRjIY7m/Cd/BUP993nMhp7By/VghThY5oHES68xYFK6lSgGg X-Received: by 2002:a17:906:585a:: with SMTP id h26mr51404506ejs.31.1626071358560; Sun, 11 Jul 2021 23:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071358; cv=none; d=google.com; s=arc-20160816; b=UWsv+7JKq9dlVe20DfXjD0HH8OkI8j+xRNtbcIc81F9xHq8gNyeb7yApv0mMOvhMVK wO1wOXbVwK7AveK7a1SrxtLeSpP/KJXjGogeaUYpx2UVDwJRhcEugSN7c17wUIGE4xyX vkISLaK6vBtyJPsfLGj5zsCbI+1YVt60rXdVuvN2/FJxoje7AhljCIYLoR8CaLshAhuA jzuCJbS0xzxm4JkMGJTH7/fikA3E5YmvFKTYO9xAZqv99De94WhW4rw4M0aKk1eYB3ak ZhYgZL0KpolpSBhv19yO/JNhEqz0aql9hwbmT+U/iZP1aL7EwgYIWRDfmf7e9O4zO02a NOoQ== 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=KWo0yPWYBsE0dd2Fg+WVZnCUyUqyXGgprAoJGk3rHww=; b=mysltaoR+QnPbSOWXSW/jgOJFNAUeLcS5vmJPFqOF/XQ/5QR9fF2XmT0t95yvLs8sI 9LmsRObSFRnj+R4QtNNy8ka/RB4FS4cL784wf848EpxvW8uNv0lJHzR0JGwgkWQnF0aB miM1FnoUmw5lj/zYUwmSKTk41Zv+WNMX2FznR3eL1iR7VFe/7KeJgGo+gcfS0MTDmbT/ 8oMHjaPh8HQbxGpJ2LhZSx2zn6roGJVkbHTOYTfonYDthOLmCWr8J+v4LfwnXzoIBah+ lWvTpUM42LjaZ468geOfETVzjFiiBRhlsckHlJIHSONs2t9LRkG1RPJX4yLLPanrps+3 f62Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NlppsT4P; 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 bz6si16420285ejc.610.2021.07.11.23.29.18; Sun, 11 Jul 2021 23:29:18 -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=NlppsT4P; 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 S235315AbhGLGb3 (ORCPT + 12 others); Mon, 12 Jul 2021 02:31:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235321AbhGLG2z (ORCPT ); Mon, 12 Jul 2021 02:28:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D73961185; Mon, 12 Jul 2021 06:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071112; bh=Q+2LZT1Bcn55z2F0p8tlrUYi85vixn6XUe+WHNy1wws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NlppsT4PtqD9UauOnJWRRLTeqhEytQ4ZmfMuzbU+fPgYLosRlQu6ixvOlGzTdp5Hw DVLNrd39g4EqflUjv7MoM7MKlvoGoJrXtccYITWd+5VbYc5VVF0abgnX5wyIYhi/za zKroHxKz27yMVyOvNaXSuIlh6lusPhrNRMg+GRPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 279/348] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:11:03 +0200 Message-Id: <20210712060740.679100501@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 df2f37cffd6ed486d613e7ee22aadc8e49ae2dd3 ] 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 tag is not strictly accurate as prior to that patch there was potentially an unaligned write. However, any backport past there will need to be done manually. Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-20-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/light/tcs3472.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index a30ad151653f..9ea543c5cf5e 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -64,7 +64,11 @@ struct tcs3472_data { u8 control; u8 atime; u8 apers; - u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u16 chans[4]; + s64 timestamp __aligned(8); + } scan; }; static const struct iio_event_spec tcs3472_events[] = { @@ -386,10 +390,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) if (ret < 0) goto done; - data->buffer[j++] = ret; + data->scan.chans[j++] = 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)); done: