From patchwork Wed Feb 20 14:00:56 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: 10822183 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 1E68213BF for ; Wed, 20 Feb 2019 14:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0709F2E34D for ; Wed, 20 Feb 2019 14:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF83D28736; Wed, 20 Feb 2019 14:07:18 +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 9243C2E363 for ; Wed, 20 Feb 2019 14:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbfBTOHS (ORCPT ); Wed, 20 Feb 2019 09:07:18 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([81.169.146.174]:15468 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfBTOHS (ORCPT ); Wed, 20 Feb 2019 09:07:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550671636; 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=2LcgofzNxEjPO3GVT4ckoQGiD6xO6IBxIdmdzI73Vn0=; b=eMsQsmMYyqUxssnOx7HFL7fP14Tg4+ifnFyKttZppS5KxyQ4ybSmBsCduFO4OUzDex e35qKG0Cl9H4PanzpJ7MHw8hqOmErRvl7I/p2RClBf6x5usESVlRjm8gbX5MCKF1SWDX iOD5s5nzcjS3WWdvoIg8vouRYPEP2GU53/E/Vg9p4LnkMQtGpfeJoy0VKcItNXYfM/xW kxlJMxuVL4LaWJG59N6gKYjh3tmc/bYYYu1KoJxICRWQftcvraAptO76ALNRXFdNpmm2 gr7m8i2W64IonwKvF1CeCZ49ThcXh8jKDQCr9JFG5UqZqs5JJ36aRnEK5Tu8jhqqDkCW //Hw== 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 608499v1KE12Eqb (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:01:02 +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 9/9] iio: magnetometer: hmc5843: add mount matrix support Date: Wed, 20 Feb 2019 15:00:56 +0100 Message-Id: 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/magnetometer/hmc5843.h | 1 + drivers/iio/magnetometer/hmc5843_core.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h index a75224cf99df..e3e22d2508d3 100644 --- a/drivers/iio/magnetometer/hmc5843.h +++ b/drivers/iio/magnetometer/hmc5843.h @@ -43,6 +43,7 @@ struct hmc5843_data { struct mutex lock; struct regmap *regmap; const struct hmc5843_chip_info *variant; + struct iio_mount_matrix orientation; __be16 buffer[8]; }; diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index ada142fb7aa3..e6b6da70c152 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -237,6 +237,13 @@ int hmc5843_set_measurement_configuration(struct iio_dev *indio_dev, return hmc5843_set_meas_conf(data, meas_conf); } +static const struct iio_mount_matrix * +hmc5843_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + return &((struct hmc5843_data *)iio_priv(indio_dev))->orientation; +} + static const struct iio_enum hmc5843_meas_conf_enum = { .items = hmc5843_meas_conf_modes, .num_items = ARRAY_SIZE(hmc5843_meas_conf_modes), @@ -247,6 +254,7 @@ static const struct iio_enum hmc5843_meas_conf_enum = { static const struct iio_chan_spec_ext_info hmc5843_ext_info[] = { IIO_ENUM("meas_conf", true, &hmc5843_meas_conf_enum), IIO_ENUM_AVAILABLE("meas_conf", &hmc5843_meas_conf_enum), + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, hmc5843_get_mount_matrix), { }, }; @@ -260,6 +268,7 @@ static const struct iio_enum hmc5983_meas_conf_enum = { static const struct iio_chan_spec_ext_info hmc5983_ext_info[] = { IIO_ENUM("meas_conf", true, &hmc5983_meas_conf_enum), IIO_ENUM_AVAILABLE("meas_conf", &hmc5983_meas_conf_enum), + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, hmc5843_get_mount_matrix), { }, }; @@ -635,6 +644,11 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap, data->variant = &hmc5843_chip_info_tbl[id]; mutex_init(&data->lock); + ret = of_iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &hmc5843_info;