From patchwork Thu Feb 21 17:02:52 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: 10824387 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 4405E6C2 for ; Thu, 21 Feb 2019 17:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CC123195B for ; Thu, 21 Feb 2019 17:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ABB231319; Thu, 21 Feb 2019 17:04:03 +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 A302431314 for ; Thu, 21 Feb 2019 17:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726232AbfBURDz (ORCPT ); Thu, 21 Feb 2019 12:03:55 -0500 Received: from mo4-p03-ob.smtp.rzone.de ([85.215.255.103]:20738 "EHLO mo4-p03-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfBURDE (ORCPT ); Thu, 21 Feb 2019 12:03:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1550768581; 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=Bb4qNjnoSsFX6gssQVbJgzru/6GuCa9xGr0eyLH83FA=; b=ffPPfWLkotfHb3HpVXEnLTUKKW1atQgrt81VYDHS8sg3k/psMPjP9/WJPnbjTkhaKs WDLwtlh85wN1XZ14A4S6IkqOuD67/lq6D4xEo11lnQQO57tEksxi3E6Rlv/B8MgCl8aT RgHM5nAjE/UEcVeDVSlcbI5SiQSHkOxkcK5xI1NZIVI5GuNVBdzqVR1An3cDceFncseE 2dBEDdoVXOH9mL4mQtZPhyr0POtN+4wMhdaAikoxHbso5RCO0hHsUKRe74gqtkZFD2sv k7eMvZ4bFCIlU3lHpCAeJt20PexaEwNIYuoKKGwDECn6oyKnDPCmZO3wUf5ahRG7LT2h tszw== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o1OAA2UNf2MzNl43D1ri" X-RZG-CLASS-ID: mo00 Received: from iMac.fritz.box by smtp.strato.de (RZmta 44.9 DYNA|AUTH) with ESMTPSA id 608499v1LH31LXI (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); Thu, 21 Feb 2019 18:03:01 +0100 (CET) From: "H. Nikolaus Schaller" To: Linus Walleij , Jonathan Cameron , Rob Herring , Mark Rutland , "H. Nikolaus Schaller" , Andy Shevchenko , Charles Keepax , Song Qiang , Jean-Baptiste Maneyrol , Martin Kelly , Jonathan Marek , Brian Masney , Stephan Gerhold 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 v2 07/10] iio: magnetometer: bmc150: add mount matrix support Date: Thu, 21 Feb 2019 18:02:52 +0100 Message-Id: <92f9b04e6540612b8bb8450803df1fcda21e364b.1550768574.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/magnetometer/bmc150_magn.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d91cb845e3d6..b0d8b036d9bb 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -143,6 +143,7 @@ struct bmc150_magn_data { */ struct mutex mutex; struct regmap *regmap; + struct iio_mount_matrix orientation; /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */ s32 buffer[6]; struct iio_trigger *dready_trig; @@ -612,6 +613,20 @@ static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev, return len; } +static const struct iio_mount_matrix * +bmc150_magn_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bmc150_magn_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info bmc150_magn_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmc150_magn_get_mount_matrix), + { } +}; + static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(bmc150_magn_show_samp_freq_avail); static struct attribute *bmc150_magn_attributes[] = { @@ -638,6 +653,7 @@ static const struct attribute_group bmc150_magn_attrs_group = { .storagebits = 32, \ .endianness = IIO_LE \ }, \ + .ext_info = bmc150_magn_ext_info, \ } static const struct iio_chan_spec bmc150_magn_channels[] = { @@ -861,6 +877,11 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap, data->irq = irq; data->dev = dev; + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + if (!name && ACPI_HANDLE(dev)) name = bmc150_magn_match_acpi_device(dev);