From patchwork Mon Jul 12 06:10:29 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: 472968 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2682903jao; Mon, 12 Jul 2021 00:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPGPo/7c1Dub4xgdBh/ORmRjndUI7BLe56eXIQKd4yDcjqoWw14nR3lj55E2ZSEWaGabGh X-Received: by 2002:a17:906:4b46:: with SMTP id j6mr1850290ejv.247.1626074603012; Mon, 12 Jul 2021 00:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074603; cv=none; d=google.com; s=arc-20160816; b=ZwKLzmVTgKHEyTmPfbgrLtou6X1JEm8llMxal9vfaCB6FlHbfe4xhkgyPE4fHFIFHn 88E94LjkIRaUn/Jd9jrSPLPoaQ7fJ1GVuyiixO9oQHHZT4FZxZXxQtECaTmHzMFpAx/B AylgCfipHbVSrijuSLweJcNZXkJC3wCCXQbEwZ4jvPN06LppZAHSQA22mqw5piliKVer vhF82GR4JkPb0JguIctPQV+YptiW+UY3AW3COESJo33UaTCcCGVosNgjaWxVDrjdah3W AdAWgQ9HaMG/P/7+HpPT5jR7MBqaL58OS2XobdWkNpJd6cW0+bXXi4KF6Db6afk8j2g4 HTZQ== 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=h2SOVk6fkLOyNlNWnK+TxHGE4xIjOKtzYU9FhKazK2g=; b=HkkojfnuBW0q1T3ftsbI9vvOB+4Jkr5IqnD5qnyQQE8Qr/gaIbmWq4xLuGoetwjMZF dOU6FHg0Yva9DXPNZghGxdZ0WuSG25vtJOjUtGvPFqjKMj5odAx7NvpBeyuq9jMcyr/c 7Aalmu4pUFko2es/MMbWNsGrzVZoAhg3Z6Z2gSaQRg03adcAyBrdzxvWUgnGsh6ZyLA0 DNx2K8mXzWwQttRL+bhuX2+DwEUs8riBrM+PwGNR7dJFRj+kAmIuD0fdafSgK4HcZte6 vZ5xPas6cQmI+Zf+ymm6yL2Obca/QCzf9jyNUOKa1epJ1PExNtR3lBBLUGKpURbH6GiL ZV6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sDxpgI8M; 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.23.22; Mon, 12 Jul 2021 00:23:23 -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=sDxpgI8M; 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 S245379AbhGLHXq (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:59684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238665AbhGLHVm (ORCPT ); Mon, 12 Jul 2021 03:21:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0DFC60FF1; Mon, 12 Jul 2021 07:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074334; bh=Ktf0grcfzbxyC5USj04FzTLhNlEuNC8SKhMXtbgkEEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sDxpgI8MlyWscteD3yyumHG3GAEn3+4S03hggFFks647Xnrk0YRMzah3u22H886SB nE7tx4WsiUCs67dmThSviBELTbKGvmTrEypLSU9XKli3DUd8owuCu7n8hB9+cyaxUh UhZUFmGgHkO/0oXHhu2BaGtRssWUDIGXHVwZQhXo= 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 546/700] iio: magn: hmc5843: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:29 +0200 Message-Id: <20210712061034.421788183@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 1ef2f51e9fe424ccecca5bb0373d71b900c2cd41 ] 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: 7247645f6865 ("iio: hmc5843: Move hmc5843 out of staging") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-16-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/magnetometer/hmc5843.h | 8 ++++++-- drivers/iio/magnetometer/hmc5843_core.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h index 3f6c0b662941..242f742f2643 100644 --- a/drivers/iio/magnetometer/hmc5843.h +++ b/drivers/iio/magnetometer/hmc5843.h @@ -33,7 +33,8 @@ enum hmc5843_ids { * @lock: update and read regmap data * @regmap: hardware access register maps * @variant: describe chip variants - * @buffer: 3x 16-bit channels + padding + 64-bit timestamp + * @scan: buffer to pack data for passing to + * iio_push_to_buffers_with_timestamp() */ struct hmc5843_data { struct device *dev; @@ -41,7 +42,10 @@ struct hmc5843_data { struct regmap *regmap; const struct hmc5843_chip_info *variant; struct iio_mount_matrix orientation; - __be16 buffer[8]; + struct { + __be16 chans[3]; + s64 timestamp __aligned(8); + } scan; }; int hmc5843_common_probe(struct device *dev, struct regmap *regmap, diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index 780faea61d82..221563e0c18f 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -446,13 +446,13 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p) } ret = regmap_bulk_read(data->regmap, HMC5843_DATA_OUT_MSB_REGS, - data->buffer, 3 * sizeof(__be16)); + data->scan.chans, sizeof(data->scan.chans)); mutex_unlock(&data->lock); if (ret < 0) goto done; - 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: