From patchwork Mon Jul 19 14:50:14 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: 479905 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4226268jao; Mon, 19 Jul 2021 08:22:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS66NhhlIM84C8zkJmPSGVtb++mQag0VXMgqwamWXFsx0JEeirvE+uKuPYDHmN7ZGq6vEx X-Received: by 2002:a17:906:dfc2:: with SMTP id jt2mr28807293ejc.388.1626708139527; Mon, 19 Jul 2021 08:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708139; cv=none; d=google.com; s=arc-20160816; b=LQ7bazORcWb87+yt/rquXGiD9skG4Zuy0hn1AJx96s69rjQIKCA6v4clqDA3yNqDGQ 64FC6T7NUTVzNFOV8DRi/K2OIPAdx/rmsKMQZAKbZXwGxej+DPMRCtZ+R88x8vufZ8gi OjOEWTM26Gf3+3sMtDUQsIxCp0fpknSXigh30/SpSjgynWw2GpcKYgoVd/Pzof2NHw1Y 8u1NXcFbGdeua8HRwe/pXErRiITIOSzZcOVWokgQarGiCptDFAo/iGf3vIxpejLpdJ6M f/r/w/l0FVYAiokEk7V3AqNBDTsV2bndyTc4EvQfeknrbjwJ1R66wlhT7EgVleUT1xUr BsIQ== 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=DkK/0bsLszFlnYrlRhiQGMS4LTZnkb850vlHSWf4hiE=; b=ZWBBt3s/UcZP+8GGcHsw+5g2RIZx4D6SktbiPhLWYxIPz2yXZoa1ka+bA3Xy9Ro36J xrBHanTKI6lFcDgtGPbUOQMJhC0WyPqjIJUtOpp65h5YFWUd0lFHLacYsoZg6sB9dfXw URO6cx1hTi9Yg0rvWl1Mu6xBHVtAvP4ipBXlHKQHPlzFM8Ohi7OLFrL74T0OaYwOpXaX WCbdfRc/7PQTOyrHnYXT9KmZsFsaoNSiNkL0+2H7PR/ZON8VTUlLNGlRuUkBeHyKEbax Gx3W1F4E1sRMz8PjuFhJj7VqPvU+3ytvv8DTZ/7fgTua7cZA1UBODn3wUrRjIni9XYyx 3ENg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v2H2D5RE; 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.19; Mon, 19 Jul 2021 08:22:19 -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=v2H2D5RE; 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 S243962AbhGSOlb (ORCPT + 12 others); Mon, 19 Jul 2021 10:41:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:57588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343633AbhGSOjg (ORCPT ); Mon, 19 Jul 2021 10:39:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A3976120D; Mon, 19 Jul 2021 15:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707959; bh=VEgMdwBiQktzj/sMFwJdWP+QRa95aVvG5rso1E1ngQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v2H2D5REP3WcvWYOH+TRJs4Z3fTWjZo+MUi5Pi2OJ8jK2Ht45Qj/ZAOWAn6g6P2/K FDAugVWQlaQwLj0BmolWiBHoxBARFtD5afzDL7NmBNXXtjXUNeeEY1eiufqxe/NOBo mf5khTSEFjLOcAo8AT9Tb8F/HjQdQ5C5HRFALbnE= 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 4.14 125/315] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:14 +0200 Message-Id: <20210719144946.981175383@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 f40a71ffec808e7e51848f63f0c0d3c32d65081b ] 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: 95c12bba51c3 ("iio: accel: Add buffer mode for Sensortek STK8312") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-7-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/stk8312.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index e31023dc5f1b..24a7499049f1 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -106,7 +106,11 @@ struct stk8312_data { u8 mode; struct iio_trigger *dready_trig; bool dready_trigger_on; - s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s8 chans[3]; + s64 timestamp __aligned(8); + } scan; }; static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL); @@ -443,7 +447,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) ret = i2c_smbus_read_i2c_block_data(data->client, STK8312_REG_XOUT, STK8312_ALL_CHANNEL_SIZE, - data->buffer); + data->scan.chans); if (ret < STK8312_ALL_CHANNEL_SIZE) { dev_err(&data->client->dev, "register read failed\n"); mutex_unlock(&data->lock); @@ -457,12 +461,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) mutex_unlock(&data->lock); goto err; } - data->buffer[i++] = ret; + data->scan.chans[i++] = ret; } } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig);