From patchwork Mon Jul 19 14:50:10 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: 479912 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4228472jao; Mon, 19 Jul 2021 08:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw17Sih7eskVrFet5PaNBRwNA6oM16T552jy7JQbKd8FttvWQmyEkkvoXWN4zlvBN8AO+8h X-Received: by 2002:a05:6638:3452:: with SMTP id q18mr20056234jav.111.1626708179972; Mon, 19 Jul 2021 08:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708179; cv=none; d=google.com; s=arc-20160816; b=UbMwMJWOrokXoGzkjmKbGw23PHEHYpXANwuch1VTFLwnAfOhnOfW8zR/VMxFSbfCzC 4z3gbj7VM1wl+iN/9vFqHBlZHzLtbpmcton0eyU5KEy6b+L7feQbF+fmWLL1QMKiuYZA uvKrcsGQk02k6fnpy+X3MOxLac6pex4pmZZGKHGy6QPTsM3PK27lt6WhmadENHhfX0At OtXVJbwG8FYAciwwX6m4qozOp4SJMXuqBtHFBKC6JWazZYALAQJ6On3AzfnQRhJ2sMyT mGtnkOQTGiCutKmBMng1ivY64O6PR87RunA/A38c6fJvzidlpMI2vRYQ+w3L7q6cHBHq sSRA== 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=KebrYpPs/pbsney8pZfb1W5X6usrieHyrzv1YFH0PUY=; b=RsBJK/Gacds1LfH5env3vi4UFm6mKJDG2vUnyf3sPqFGKof7imnoLw3O/qMA2yuWxE iYPPSLxfMYItMTGrkagcNKgsower7xK4qhqLN1lbc/3v6iynmKmfhZuDIq4B6nqF3wGI nt2vBltgubvLHJ2JXfWfh/xkN7Wfjv1JWM7fx3f51Oi7Ne80EZKhfHxQnZ+RzN3eoAtj XUNTlJAtHcMNvEIlezKtiO670zyAcugX4+drSEhXLxjVbUoFnLMJ4YR27eQbSzPn/KTN w9X/0filIocVBUf9U2PtPNm+kYM/M1JO2qd6+scMO3eknZgMLlscWqNS1cLR/Cj2a5eD SqGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tN7UPWzA; 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 g15si9692004iln.71.2021.07.19.08.22.59; Mon, 19 Jul 2021 08:22:59 -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=tN7UPWzA; 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 S244613AbhGSOmS (ORCPT + 12 others); Mon, 19 Jul 2021 10:42:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:53290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343614AbhGSOjf (ORCPT ); Mon, 19 Jul 2021 10:39:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E6C1461364; Mon, 19 Jul 2021 15:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707949; bh=UlxK49/2O/vY7teo2N8gZC7tT53j0N5Z4BzcduEFvcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tN7UPWzAZ8RA2p2vtJSSbmRFSrB0TgNVPWx6t8ks/DKPEYzV24LadqMP8Coh3jdXa +5WsLc/c4IV3QC2Wz6phVGGEIz/j4Fv9leg7vS80FkZnLc+7tUsoPEOGzHIwIrPp4Z wczwseG9KsdcrgNerY3tiVrWlW0KbIZFaSZ9YWac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Peter Meerwald , Andy Shevchenko , Sasha Levin Subject: [PATCH 4.14 121/315] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:10 +0200 Message-Id: <20210719144946.847312389@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 fc36da3131a747a9367a05caf06de19be1bcc972 ] 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: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()") Signed-off-by: Jonathan Cameron Cc: Peter Meerwald Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-2-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/bma180.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 3dec972ca672..dabe4717961f 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -121,7 +121,11 @@ struct bma180_data { int scale; int bw; bool pmode; - u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s16 chan[4]; + s64 timestamp __aligned(8); + } scan; }; enum bma180_chan { @@ -668,12 +672,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); goto err; } - ((s16 *)data->buff)[i++] = ret; + data->scan.chan[i++] = ret; } mutex_unlock(&data->mutex); - iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns); + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns); err: iio_trigger_notify_done(indio_dev->trig);