From patchwork Wed Feb 20 14:00:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 10822175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6141E17FB for ; Wed, 20 Feb 2019 14:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B21F2909D for ; Wed, 20 Feb 2019 14:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48C8F2E367; Wed, 20 Feb 2019 14:07:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E44F92E364 for ; Wed, 20 Feb 2019 14:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726194AbfBTOHF (ORCPT ); Wed, 20 Feb 2019 09:07:05 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([81.169.146.169]:22521 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfBTOHF (ORCPT ); Wed, 20 Feb 2019 09:07:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550671623; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=fpSW80QpWjD2k3X24vygtHX5CH9W3UT8UeDFbTxrufE=; b=S27aDjQsn2heNBDu45zXPlRSiDk1Eg9icDZGqtqArylyZVaGNlVRTEXaBUPZrQOYc3 xCMWEL/YDP68/OcnxXeCiNG0Mes6iLJ2laePlDQI0ovYoeKhuJ9mh+7tBdnf/zbDzSbE WfO70Zz8v2KvxwQ52MSV2H8bVrcYfYz6GWJRt/gQm0kBkbAbRFx43kAT57YK98eL4//T 9olEbLwjkYszeP45BYPI36ZJej6oEa01TypgG6HoHKMqkRNcIWeM58rHsDzCIs+ygPDn iDZ2HC+KKowyjbTUhikx7Bf6EREsfFJlKo2LRhzfN/vz3T0sMX80r6kPKWT27Xkq+CkN T8lw== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1OAA2UNf2M0OzzrKQ==" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id 608499v1KE0xEqW (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 20 Feb 2019 15:00:59 +0100 (CET) From: "H. Nikolaus Schaller" To: Linus Walleij , Jonathan Cameron , Rob Herring , Mark Rutland , "H. Nikolaus Schaller" , Andy Shevchenko , Charles Keepax , Song Qiang Cc: letux-kernel@openphoenux.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] iio: accel: bma180: add mount matrix support Date: Wed, 20 Feb 2019 15:00:51 +0100 Message-Id: <445e2cafb4c741859219830bc1204bb3cb87f152.1550671256.git.hns@goldelico.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows to read a mount-matrix device tree property and report to user-space or in-kernel iio clients. Signed-off-by: H. Nikolaus Schaller --- drivers/iio/accel/bma180.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index cb9765a3de60..248be67e4f41 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -116,6 +116,7 @@ struct bma180_data { struct i2c_client *client; struct iio_trigger *trig; const struct bma180_part_info *part_info; + struct iio_mount_matrix orientation; struct mutex mutex; bool sleep_state; int scale; @@ -561,6 +562,13 @@ static int bma180_set_power_mode(struct iio_dev *indio_dev, return ret; } +static const struct iio_mount_matrix * +bma180_accel_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + return &((struct bma180_data *)iio_priv(indio_dev))->orientation; +} + static const struct iio_enum bma180_power_mode_enum = { .items = bma180_power_modes, .num_items = ARRAY_SIZE(bma180_power_modes), @@ -571,6 +579,7 @@ static const struct iio_enum bma180_power_mode_enum = { static const struct iio_chan_spec_ext_info bma180_ext_info[] = { IIO_ENUM("power_mode", true, &bma180_power_mode_enum), IIO_ENUM_AVAILABLE("power_mode", &bma180_power_mode_enum), + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bma180_accel_get_mount_matrix), { }, }; @@ -722,6 +731,11 @@ static int bma180_probe(struct i2c_client *client, chip = id->driver_data; data->part_info = &bma180_part_info[chip]; + ret = of_iio_read_mount_matrix(&client->dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + ret = data->part_info->chip_config(data); if (ret < 0) goto err_chip_disable;