From patchwork Mon Jul 19 14:49:54 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: 479973 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4252236jao; Mon, 19 Jul 2021 08:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPYNC7rQLzyKj9s4kZv1pVwoz4h1YkRDKvBiszSpJdaHBTrHjrVWONff19ZFDAFLx9FLmY X-Received: by 2002:a92:7c07:: with SMTP id x7mr5998836ilc.198.1626709374627; Mon, 19 Jul 2021 08:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626709374; cv=none; d=google.com; s=arc-20160816; b=Y/pg8+/+gaTZARb6czyY/6vzFkCArT52LZ0L9+QaGYB/s6l4TuhRpbjlFKBx+MiJbs tWo5ZWGO2N3qJXT3UBm59VRcOE/R6S4eVo5aGGnJBj86pthcFQ3uJsVJBQGCkZKeZYjF dpNfYS53FcX0qNEU6tnshmI2/HRjN85LX/4bZpQtb1K6+k9zkKtzAluyq1ZPjtGpc9E/ rT2FBnOTJph30HS0nIO8FJmmNi3fNRalyrOr7s+mHN2u9YLHMEWpv+ao42lvZZEV3awR Y0sw65ll43CwZQHCecJpTJUUbc+zEO8PtO9zBD7jcfU85luhwl4AJAPYclIr50AdCXVA khEw== 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=H4HLCtut/y1SXKbIiBUPtsUWEjEDjLVirzVOS0BIQ1A=; b=ImnU2hwYwhzy54u3fx4e6YaoQAfzHQd5hADPkRRQdQxUpC3egKVgi+a+y+t523c5Ub sU0cP9vqc2DlrskHyZAs0f61eddytYv6Sf0mXItWaw14DbBJHu3OD/I7Z/x1juE4ZZJu sue0GUtrNZ2cN2ZTrOMjAyAFiFzF7f8QqwX901wyF/jRQNky2kQzA6nwnfPssmpvKKYw PjEeVCK5c1wg3o8KEr+OhuG834g/exy6jnOqrno58/hKso5qTISIgGHUGseGyxZiGilJ J4UcLth65me/ux5IXSDGu/pIFg/Jmgy+ovyCTv0W1R8HMRF+Dx2NnB7vG1qkEGY8Pfv9 1H6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zETscRXk; 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 ay16si21406520jab.96.2021.07.19.08.42.53; Mon, 19 Jul 2021 08:42:54 -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=zETscRXk; 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 S1344172AbhGSPCI (ORCPT + 12 others); Mon, 19 Jul 2021 11:02:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:53370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245261AbhGSO64 (ORCPT ); Mon, 19 Jul 2021 10:58:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5169D61244; Mon, 19 Jul 2021 15:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708989; bh=uDEsRfUXqu5O5OORtcgIp9bYL4asVcFiUAnOQaB2Wio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zETscRXkDzqvGJk0U9yvDxFq8u7Ymo7aW+UPpl2rHgQFUsCjTiGLZyhIcfMDZNq5i XYaAulLAcBz/25PqyfQHODb83sOZHjWKkY6abqXwHQ0GuiYNi6qiXveiyznTk2gUoA 3G5dcz8IrDBFHz+rP17LhSxmjjFoXIxziTCbqPrw= 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.19 183/421] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:49:54 +0200 Message-Id: <20210719144952.772175547@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144946.310399455@linuxfoundation.org> References: <20210719144946.310399455@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 df2f37cffd6ed486d613e7ee22aadc8e49ae2dd3 ] 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 tag is not strictly accurate as prior to that patch there was potentially an unaligned write. However, any backport past there will need to be done manually. Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-20-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/light/tcs3472.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index 1995cc5cd732..82204414c7a1 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -67,7 +67,11 @@ struct tcs3472_data { u8 control; u8 atime; u8 apers; - u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u16 chans[4]; + s64 timestamp __aligned(8); + } scan; }; static const struct iio_event_spec tcs3472_events[] = { @@ -389,10 +393,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) if (ret < 0) goto done; - data->buffer[j++] = ret; + data->scan.chans[j++] = ret; } - 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: