From patchwork Mon Jul 12 06:10:55 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: 472875 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648724jao; Sun, 11 Jul 2021 23:31:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAYOFSkZbplwCcxxHqT35eNT574TVuHy4u6BGBtVcHhamyNrPVrZn5wi43HjasSyRGCoSQ X-Received: by 2002:a17:906:6811:: with SMTP id k17mr12285928ejr.280.1626071474021; Sun, 11 Jul 2021 23:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071474; cv=none; d=google.com; s=arc-20160816; b=zyLKRKtMzK8bKOPAgZAD4YsRIyC8RhrcXJQlitw3OGWJQKSBWAqP+kX17qanoM99U9 xAfWq9hil66wmll+A9fnW6OLI2JJtny158Y8ewmx2USgKdjntiadbBlTWMcn/ElUuaa+ wRcv6gg+bVwyEiCi4150uuVN21FDtdE8n4CPRWrMFLsnDm1RlTp0JuqZ8oE6UWOFgFBS Q1hlN+yhGDqoKu8sPj5SZZcfKv22VmW6z4zlu9dAggV+MJXZp1xCqu68z8r2sQBdlJ5t Xid1jbQOlwoZ01wQS4ZCtgs+ulkqbNdq0FtaZU8+9Ew18y2OxDRDJNX8b7NZi/ZTKHmm fubA== 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=HtXABbEtVjqAMueBSu+jKzTUfqUrG8On9xVHcxI5zrc=; b=DGaldmCnFMyapY0YrjdsXGguAsU9zUx0Al9T7xXgcpvtEN9dmKSfDQhhQQsjSyTgWb odE8fZvYM/IjTu0xCctfC+PX+NP6ZH1Te/70xH+6KblKzoTj2VgqJjKuAGXnNfcQrQTm SEem8WSGeFBZmCWHgXsFgxifl0IKP+IyY4VZn2HzX2MyCYzTnpMyzC/gBDZGn/41Z1YB GUQsuzA2RyZ0MTtfc4eJiW7I5S0TlJuoiGVam7g9vu0LzleYJMRF7Tjax3ufLOWf/XY8 mEYmmeSAn0lCdzNixEL4zm3Cliks9BPONXHr5dQ88UbLrCFIZT04Mi3XtMvFxQ0nvwz6 3Gjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pNhJ+XiE; 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.13; Sun, 11 Jul 2021 23:31:14 -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=pNhJ+XiE; 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 S236859AbhGLGeA (ORCPT + 12 others); Mon, 12 Jul 2021 02:34:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:46566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbhGLG2b (ORCPT ); Mon, 12 Jul 2021 02:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 22DA861184; Mon, 12 Jul 2021 06:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071090; bh=AGCSYCCTNOp+FhXOxjNeF1Tb0ZUHk01dWn1s6SvZypk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pNhJ+XiEXtTS0/lRTUHmNVrSh/tgSv51re0BBOMYqknXEhVkHoXF1mIk6agHmuRAJ wyzVk/+++mqjHoj63mApl4Rxuzrvr5P63VCzymUA4dSkpA97YE63hCIW4xhs9siIZi U9BYKRnL5Y1W7weMaEwjnI5vuM9T5KMa5xTCIXds= 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 271/348] iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:55 +0200 Message-Id: <20210712060739.595166855@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 f4ca2e2595d9fee65d5ce0d218b22ce00e5b2915 ] 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: 0d96d5ead3f7 ("iio: humidity: Add triggered buffer support for AM2315") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-12-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/humidity/am2315.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index 3bac98e731d9..894922a315fe 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -33,7 +33,11 @@ struct am2315_data { struct i2c_client *client; struct mutex lock; - s16 buffer[8]; /* 2x16-bit channels + 2x16 padding + 4x16 timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s16 chans[2]; + s64 timestamp __aligned(8); + } scan; }; struct am2315_sensor_data { @@ -167,20 +171,20 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p) mutex_lock(&data->lock); if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) { - data->buffer[0] = sensor_data.hum_data; - data->buffer[1] = sensor_data.temp_data; + data->scan.chans[0] = sensor_data.hum_data; + data->scan.chans[1] = sensor_data.temp_data; } else { i = 0; for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { - data->buffer[i] = (bit ? sensor_data.temp_data : - sensor_data.hum_data); + data->scan.chans[i] = (bit ? sensor_data.temp_data : + sensor_data.hum_data); i++; } } 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);