From patchwork Mon Jul 12 06:10:21 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: 472972 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683374jao; Mon, 12 Jul 2021 00:24:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxstgfdcw6V/jhWqZdfPgxl4xUWUDCk3wsDTppfCI06ya64twit2XkLYgT2hu3Zio9pw8DW X-Received: by 2002:a17:906:a24c:: with SMTP id bi12mr6622049ejb.530.1626074643614; Mon, 12 Jul 2021 00:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074643; cv=none; d=google.com; s=arc-20160816; b=kseuzv9+VOvbsXrE7xXA38KMproQhrHvszGWZzksTaW8TrVpFSUhAOnsXkEYSPYmmE ZlClPWjx4y9NVHrvht08vHq4JZOQv1n8lwN/XWhkhDFj19s0dIWfZAjrLtx9GtZAk3Fn vqMxNd4SDN6mdq319c8m6OsC7pNp+sqk050s5FWp7qxZsiZhoXfyeX7kDGC83Ctr2ts1 Rj3MJZjHMK/ekoMa+M6m28ZEXsMZC6IE506yXE8EBvBq3AuztcaPjPER4WU/qVsoHFWD OzW0o3RXH4zAg1fREyEq9EPqnhN36HaPXFVC8SToEtJG4U4TQA089mYZ8fGsJm7G/Hy7 iFhw== 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=kAtFrAHyoS9K5J1wiYLqhdcYA6BOFMm3gzBFKBlvdoQ=; b=RPTit5VdnvnCZ/j4rbuP+ClP4URxF/tb7xPGiY0xTsw5PUan8NW/laBiKLp1L552Qi kRd88aqZyPEQOde9TkvMKrenITrJux7A5LP/MgIG+yndzeUl1inp8iCuFc3HuvEsd3GZ kgtz35G2ten3AVZldmKUi5ulaXABaQMlIMFtc5p8tTq7qxvXD2DABLkT2I2byNRyjsH9 x7p/6B+IcCPfldh/ryEw+lRlJ1TwvjHPVTgeKbIDJHEzEeIcqZ5s8Xk9lO02qmVhq8wj /ZFtzwlZVBR5iNgzhHnmWSWWA/hufE9aOcXsp94vMcvXywW3NKdaPSP6FY+zVBHrf3ml jSKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jlrXVSv7; 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.24.03; Mon, 12 Jul 2021 00:24: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=jlrXVSv7; 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 S239669AbhGLH0N (ORCPT + 12 others); Mon, 12 Jul 2021 03:26:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:35096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240071AbhGLHX3 (ORCPT ); Mon, 12 Jul 2021 03:23:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 08C3E6113B; Mon, 12 Jul 2021 07:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074441; bh=uLfCrMqsvIrxqcCzs2c8dhu0bVbzvqwRuC0fGYazn7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jlrXVSv7Q2XS3Zq8n2B3iWV9ufaLsEihKGZwHFtrCnaaZJEDAvzrYuMSGtVc+WUmT 5iIy3exb2khjg+0yzhP12VZOqgNJTJsj3/sxMuFSS/+QvmT2gV3IysHETrZW3mz4/w GlROq1Q92c1bnckkhAAtm2L/onPz2HY8thfcldqw= 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.12 538/700] iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:21 +0200 Message-Id: <20210712061033.638762368@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 334883894bc1e145a1e0f5de1b0d1b6a1133f0e6 ] 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 this function. Fixes: db6a19b8251f ("iio: accel: Add trigger support for STK8BA50") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-8-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/stk8ba50.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index 3ead378b02c9..e8087d7ee49f 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -91,12 +91,11 @@ struct stk8ba50_data { u8 sample_rate_idx; struct iio_trigger *dready_trig; bool dready_trigger_on; - /* - * 3 x 16-bit channels (10-bit data, 6-bit padding) + - * 1 x 16 padding + - * 4 x 16 64-bit timestamp - */ - s16 buffer[8]; + /* Ensure timestamp is naturally aligned */ + struct { + s16 chans[3]; + s64 timetamp __aligned(8); + } scan; }; #define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \ @@ -324,7 +323,7 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) ret = i2c_smbus_read_i2c_block_data(data->client, STK8BA50_REG_XOUT, STK8BA50_ALL_CHANNEL_SIZE, - (u8 *)data->buffer); + (u8 *)data->scan.chans); if (ret < STK8BA50_ALL_CHANNEL_SIZE) { dev_err(&data->client->dev, "register read failed\n"); goto err; @@ -337,10 +336,10 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) if (ret < 0) goto err; - data->buffer[i++] = ret; + data->scan.chans[i++] = ret; } } - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, pf->timestamp); err: mutex_unlock(&data->lock);