From patchwork Mon Jul 19 14:50:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479874 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4217882jao; Mon, 19 Jul 2021 08:12:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCjpl1Qpy2NwUjWgmEm0xbex2gavddEVwsnnH5FtvcKb6FLqD4kYDfX0uxc9mabT4uWm4r X-Received: by 2002:a17:906:190c:: with SMTP id a12mr27847638eje.37.1626707547467; Mon, 19 Jul 2021 08:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707547; cv=none; d=google.com; s=arc-20160816; b=pGj9BUrFH1tUy1B6J/sJg1k+v9HSuKE2dI26JzxGTStSgEQd6rASr+P2B3SRNaxn4h QypBmTz42mKC1YB6fC2E98QJTikbVgyxw/ggu0sP2IoF2R/Q9lEojxviFEsb+wvFxns/ OhoCslc3eg8mZ+Q/DxhG770vENcbqD03+D4cY8Etf6MJiAtF5/LtnS8nQB+3wQH86gJA UJMr/rHmlrLB3I5+xukiCQ9BRSiMqwl1TxRaB0MoRv1I84S/Tvzg24i65LhhtUfJcIBZ WUameCIJvvUsg7VKQJm+qK+pWyi3GlH+CX4s5cWZhxdDdpBtF8328qzlzvXlgiWFj3x3 jBKA== 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=A44woacFK5ld5IQLVPyVXLsoj2DYOJ2S19iUfrTiE31xRIfIVYT4xZneByF7gf//MM OtmfQ1+z/h9UdtWEOgdEdWvzAl6roVhvqbpVs3RE2g5nWFOkNepm9hUR8Doq1N3cdzhQ xei7Y9YP03Cz5bwg6756tgWetAtyMPZEiu0JuW/CjAUsgyB8LzyfUnm2p4vNrE36QFb6 FQVS9Ez7VILrS3gab51GxVNOISWtVG3AD/ThO5irVNr/eaPzDUVGsLodQzhGPd3FXyw3 IfNkp1RytHHopVTUVK0KVGskjLM53XUnl+J3J3W2h7sq1eN4PG92jvF5pKBwwVf4TbXd Fvzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uwL7/dZ8"; 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 d26si20449114ejc.620.2021.07.19.08.12.27; Mon, 19 Jul 2021 08:12:27 -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="uwL7/dZ8"; 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 S243452AbhGSObS (ORCPT + 12 others); Mon, 19 Jul 2021 10:31:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:38648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243252AbhGSO2P (ORCPT ); Mon, 19 Jul 2021 10:28:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 473E561073; Mon, 19 Jul 2021 15:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707283; bh=VEgMdwBiQktzj/sMFwJdWP+QRa95aVvG5rso1E1ngQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwL7/dZ8YsPMiWqMZnwNCgUZe7FMSkBSN1CL6kW1co0BVMb/4/34xpvdveldIZAou fhsjEUhJRppWE0BAXSjrw3EZyab+TqmP1JFTyrblF18xcwaWeTxW0rZNCVDMX9R0bL 8vgbebbr2/W67D6O2IjGFp/LsJYCXHO/JtKWTSBY= 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.9 097/245] iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:39 +0200 Message-Id: <20210719144943.550000448@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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);