Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp448707lqj; Sun, 2 Jun 2024 06:08:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmTPXsWHpKobMPEOl6WVFEsDg9v4RGRglL/FEmKF6mGGu3zOB2XhOAe5urL5BTJ5lC5iWlyrLqV0BfH+IQRBNFgVf1axeFQ79eWSeFbA== X-Google-Smtp-Source: AGHT+IGPtXr5V+CLoigiH7z/53bBwF+kAIShfgpRQsjMtfM1+pQl/LPLLVZYgWYeEGK/fxXd+yJt X-Received: by 2002:a50:d7dc:0:b0:57a:2400:6fb9 with SMTP id 4fb4d7f45d1cf-57a364365c3mr4002914a12.20.1717333709610; Sun, 02 Jun 2024 06:08:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717333709; cv=pass; d=google.com; s=arc-20160816; b=Wh0k5vs2ZKaitHQpbLPGyyuJqgl/XfEhVb19MuLT3ku61qtIhmKdc2NPVb7bovoHGv FDqgz5GBvlK2GmjWJDu9hTWeQXAeXXz5N5wmDNH6Sp31TEEiEZDAE/5K6K0gbHisveDy R02+OR6hS6oKqUs2Dl3L1UkrRik5Z2AAsg69/uRzh69VpIgPDBPWHv3j9mqOO0fT3bnp x55sw7s1psHfDpaZxGcN9ao8hl6l4M2CGbiQOpfUZE8jASrCxgbwFilj7V7lgGOzcM9q 16XxUeihsob7AAS+OZAAqxUn+9Oxoqb+7zdZ3sc7NLTpbrjpNdePwnpM55GXptSBqEIn 3c0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=rzzfuiYLjPPIlKu5Adeu2hm05/GZ388c/XeNR0wDJmo=; fh=6fAjTSgeEY2U4p48eE8TAq07XQgc46ze6aVFK4XRxQ0=; b=k9YCYft1jRv0KjOlY8eWI/UtPpVLuwCqkWUJ8Ockd6ktPqOm5LxiQO1c6+LzFCta81 g3MdIr54iA3mxP4m6QSIua+PvLzwWwdoTmKh7YPFqTLcdfjb52Mqs4ye09PvjEZ5vbVw GNEI9SgFXypCwf/BViHjNBFjvy8higXKD40v2PZ1OoSAZCabM0NVGCMbwEBJc/+Yb9DP 6h6BOZrMktMY7KinQtZknHnFPI4oi+b7xwH9ruxSJJIfoGdNpwfEW5OtguagqlmoZJLf FmQ3J5LOMX2nbKeTc+36OQniBuvWe//aGMLX2EMBmE7ErTfZ6ju+P/MUH8TOzKSJK25G nsnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cu5OP0yy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ca5ae8si3011945a12.527.2024.06.02.06.08.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 06:08:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cu5OP0yy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-198249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4511F1F2179B for ; Sun, 2 Jun 2024 13:08:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19A873BBD5; Sun, 2 Jun 2024 13:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cu5OP0yy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39BB210795; Sun, 2 Jun 2024 13:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717333704; cv=none; b=Yrf/daOrwtmMC4813g6RYpgc2EpN7ScLZ1enRgBpBSlrEFtoIcPqzn4M9SAqtCDzjo7Sl8cZSxExP9tyOxpNt1Hy1P7jMjMfdix5bdoLxL6JRg7Wvl10HXi0PI2fSdiLZsjbV4rjM1KD3n2l1m086M6V4GV2182lEfT3pTkUf9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717333704; c=relaxed/simple; bh=gGA8q7p+HL++NKusv8U13tSZ+AcCuP1M407ZMinv5V8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cS3VvJgY9dtGbBm0AexqdwN2QpjHnq07F6fFIQxqGNxNujgKZUM5egmaNxvWF/HWGDJ8ex8bnOo66MDyOaDNJ7MKo/yc0pwEKpOr9l2yIXn6ivDO+hHMPoO1Up2PvwFzTNcr2Q+yafyh5tdICO19QIx4Me265DCZYJPk3RGOKBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cu5OP0yy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3043C2BBFC; Sun, 2 Jun 2024 13:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717333703; bh=gGA8q7p+HL++NKusv8U13tSZ+AcCuP1M407ZMinv5V8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cu5OP0yy5qkHwglCJBgKIiwSAegEkQGaL7n75TV8f+tz943v0K5NbQMJOvYejY1o1 PMGKAHmSErTQlC0mmYuYoKzDNQB+pdbSPWjxAZXZvvwEBnohGzl6qNCB3mM87/D+Kr BREMP3Cn8ykJIIC52YBxRDaxa916/2mkz4pgN5kgBU2Z51/Gax98LWOspMaUAB13+Y ZEOzTsCxAnnBCZs2tfoMimO+qj8wbw2jDsVr7T00w0/2lndWvGVN6DMAuO129Qu+Ss nMSf8cjUTnzrqhTw2kmW+KMMz5AUmUsTY6kolLq55MLu5LvNkYH56fa1EW+/Z/OI3K nT1HTFWsog3kA== Date: Sun, 2 Jun 2024 14:08:14 +0100 From: Jonathan Cameron To: Val Packett Cc: Lars-Peter Clausen , Stephen Rothwell , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: accel: mma7660: add mount-matrix support Message-ID: <20240602140814.642417b2@jic23-huawei> In-Reply-To: <20240527080043.2709-1-val@packett.cool> References: <20240527080043.2709-1-val@packett.cool> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 27 May 2024 05:00:18 -0300 Val Packett wrote: > Allow using the mount-matrix device tree property to align the > accelerometer relative to the whole device. > > Signed-off-by: Val Packett Applied to the togreg branch of iio.git. Initially pushed out as testing to let 0-day see if it can find anything we missed Thanks, Jonathan > --- > drivers/iio/accel/mma7660.c | 50 ++++++++++++++++++++++++++----------- > 1 file changed, 35 insertions(+), 15 deletions(-) > > diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c > index 260cbceaa..9d23f28d5 100644 > --- a/drivers/iio/accel/mma7660.c > +++ b/drivers/iio/accel/mma7660.c > @@ -38,21 +38,6 @@ > > static const int mma7660_nscale = 467142857; > > -#define MMA7660_CHANNEL(reg, axis) { \ > - .type = IIO_ACCEL, \ > - .address = reg, \ > - .modified = 1, \ > - .channel2 = IIO_MOD_##axis, \ > - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ > - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ > -} > - > -static const struct iio_chan_spec mma7660_channels[] = { > - MMA7660_CHANNEL(MMA7660_REG_XOUT, X), > - MMA7660_CHANNEL(MMA7660_REG_YOUT, Y), > - MMA7660_CHANNEL(MMA7660_REG_ZOUT, Z), > -}; > - > enum mma7660_mode { > MMA7660_MODE_STANDBY, > MMA7660_MODE_ACTIVE > @@ -62,6 +47,21 @@ struct mma7660_data { > struct i2c_client *client; > struct mutex lock; > enum mma7660_mode mode; > + struct iio_mount_matrix orientation; > +}; > + > +static const struct iio_mount_matrix * > +mma7660_get_mount_matrix(const struct iio_dev *indio_dev, > + const struct iio_chan_spec *chan) > +{ > + struct mma7660_data *data = iio_priv(indio_dev); > + > + return &data->orientation; > +} > + > +static const struct iio_chan_spec_ext_info mma7660_ext_info[] = { > + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, mma7660_get_mount_matrix), > + { } > }; > > static IIO_CONST_ATTR(in_accel_scale_available, MMA7660_SCALE_AVAIL); > @@ -75,6 +75,22 @@ static const struct attribute_group mma7660_attribute_group = { > .attrs = mma7660_attributes > }; > > +#define MMA7660_CHANNEL(reg, axis) { \ > + .type = IIO_ACCEL, \ > + .address = reg, \ > + .modified = 1, \ > + .channel2 = IIO_MOD_##axis, \ > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ > + .ext_info = mma7660_ext_info, \ > +} > + > +static const struct iio_chan_spec mma7660_channels[] = { > + MMA7660_CHANNEL(MMA7660_REG_XOUT, X), > + MMA7660_CHANNEL(MMA7660_REG_YOUT, Y), > + MMA7660_CHANNEL(MMA7660_REG_ZOUT, Z), > +}; > + > static int mma7660_set_mode(struct mma7660_data *data, > enum mma7660_mode mode) > { > @@ -187,6 +203,10 @@ static int mma7660_probe(struct i2c_client *client) > mutex_init(&data->lock); > data->mode = MMA7660_MODE_STANDBY; > > + ret = iio_read_mount_matrix(&client->dev, &data->orientation); > + if (ret) > + return ret; > + > indio_dev->info = &mma7660_info; > indio_dev->name = MMA7660_DRIVER_NAME; > indio_dev->modes = INDIO_DIRECT_MODE;