From patchwork Mon Jul 12 06:10:59 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: 472870 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648627jao; Sun, 11 Jul 2021 23:31:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuXFiZ+YPAW/ll/vV8UBp36oL3B1F4PRhYCnXDgdHiUXZ2JVdoX1PP6F33v+jjhgkO6nnk X-Received: by 2002:a17:906:3399:: with SMTP id v25mr16641064eja.357.1626071463591; Sun, 11 Jul 2021 23:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071463; cv=none; d=google.com; s=arc-20160816; b=uzCAoxALpcr554/VKYKJ9arAvYxjtxL+UJEZ5pQUM4G4I6n/6lVA/rFXX2A6ypGvbA o784si+fo48VTafTjBKQG6JY2uWZ3leyRY2E0+BLelL9Gk4HkQjawRs4pfligao8Uyu8 9ffZO3h4VWvOo2fWeQmwmGhOsOpSBVOpE3G8lLmMAROsb6LwUS+snYxiAFAz0ZD3ny0e 17zMGNrXkErOD7ODHbKNBzHFjGTrBH1C9wo0Ct9U9S1rZzbQuVoBSyKSfaqpuRS7HoBt oK0vylMDaz5Ief25BYXWKx2olWi4WnVYKoIwYaU0HQr+Cs1jimt4Rtdp2JH3ZlFthqLX hc7A== 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=ObftzdmgNhAD9PlNkNetevP5q/d6Wl+jDcqYSu210/g=; b=njpk7gDJzP3Ph1WwUfaXQK3NZiohrkpLY7VsuyeIyN6M2igfDct6136X/JfnLGdiev /KmmvpCaCqmg9d5MX1GJ48/RRnffr0IEFqXbIPjwWg8rshIhP9kL8dSKRNOlWEXaIhkM B3cS5CC8aexq74U+bTfIBy48lKyusKs29Qdm2wMqgpelhurYf3RhB+S4n1qvu655cBV2 qr7ve+C6BusI1WYv3c3DmDQFyoO6OoOEPibIQH6yqMioPJiCCVfV+YueT6uDwrN9X5bu guXIUi4bEBJTiIpl0cP2rdpWo4YSM3dnbrfDzEaRtSAssR+zWDV6G2CLW2B0tuXhtLlZ hRnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cboMmGpb; 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 b1si16242569edx.272.2021.07.11.23.31.03; Sun, 11 Jul 2021 23:31: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=cboMmGpb; 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 S236984AbhGLGdn (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235512AbhGLG2n (ORCPT ); Mon, 12 Jul 2021 02:28:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 54957610CA; Mon, 12 Jul 2021 06:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071102; bh=znFyREmGg9if5a20JIOBUxc5Wzz1R0D/+kc1y2AyYvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cboMmGpbizmzYo45iFjRlFWK0++6qC1KaUk4hxN/igrKsWpmnX15r7GFR1YaqQ3ir u3TXJIpcvu/gu+ChygIQA/snRy8T/VfvHc+sz4yOdyesuHNGoQ4Ff2EuYWc0PixH55 SIhXm4iuopEYJIDj9oOB9JX3g77AgX/Wb0PqbKeM= 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 275/348] iio: magn: hmc5843: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:59 +0200 Message-Id: <20210712060740.183478706@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 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 b0dee87a8b20..b68bb55909e1 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 c44a4292da92..aef78275260f 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: