From patchwork Mon Apr 9 09:44:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 10330923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 641EE6053B for ; Mon, 9 Apr 2018 09:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54BE028AC6 for ; Mon, 9 Apr 2018 09:44:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45B1028AD7; Mon, 9 Apr 2018 09:44:44 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 18BE628AC6 for ; Mon, 9 Apr 2018 09:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752454AbeDIJom (ORCPT ); Mon, 9 Apr 2018 05:44:42 -0400 Received: from mail-by2nam01on0045.outbound.protection.outlook.com ([104.47.34.45]:46071 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752448AbeDIJol (ORCPT ); Mon, 9 Apr 2018 05:44:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.onmicrosoft.com; s=selector1-invensense-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=juZTE3obeEaFW4O/xlHyaKIM//goY0cSZ/vphyCupXg=; b=qId99RQg3q10VcWwgKSPe242l0ys+nUNrill84qT4N0CMsi0Hm6i/H5Bt7bYa3N1gQkk/iPrJxZeKpyxXMXmDyUI1Z4Sp75zOqqwnOo/TwO4G2mMtMsBhWzpiEw9F6mxEGiFkRE3FP4G04zIYsbsgMMZSwSElMRCpb6Yx2ADxzM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=JManeyrol@invensense.com; Received: from [IPv6:2a01:e35:87fd:c140:b95b:f2c8:d4dc:e485] (2a01:e35:87fd:c140:b95b:f2c8:d4dc:e485) by MWHPR1201MB0191.namprd12.prod.outlook.com (2603:10b6:301:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Mon, 9 Apr 2018 09:44:38 +0000 To: linux-iio@vger.kernel.org Cc: jic23@kernel.org From: Jean-Baptiste Maneyrol Subject: [PATCH v3 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux Message-ID: Date: Mon, 9 Apr 2018 11:44:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Language: fr-classic X-Originating-IP: [2a01:e35:87fd:c140:b95b:f2c8:d4dc:e485] X-ClientProxiedBy: PR2P264CA0047.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101:1::35) To MWHPR1201MB0191.namprd12.prod.outlook.com (2603:10b6:301:56::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bbd08a7-9555-4808-ef33-08d59dfe832a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR1201MB0191; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0191; 3:t0XIw0LCeAVCnOLetHf+mNrU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HNjq8qMjXpdAcyvE2jeO3bAE95mJqyWDPGtYQSUgnTuOOzvdCBt+uE22ZP0opX5tgqr6ZcNTPLqtaerZtoOtKL98Z/qgzEALBIv3qdNiHwZWnSq+DZLAMRep6CUkA3ebBb21K1FiCY9b9OBaz4CyZ80UhQOyevr/5sL0/kWW+qmsUghldFuKbM1osq7iscvsGa22GenT3ojWNblfMxJT8oacw5jhu1R0XOlm/FQoeCBZQ3Vafl7K01qoS5gCxRNGhenrEu5DY19gjzWfVvBdr8vHXZGC2Dsn0PkhC5zobEdXDNixRNzBdWvRC7h7bq3pHXv0gn; 4:TvKb294wCAZRBO9lJzus65bt+WWBMNW7JtX9udjy7cUE8Me6MuHcDT1qbUtz9YHXLxHS0JW/M738B5MaIp0YxdtxRxJWZJHCuUY9oTTcaWA+syBs6DXnlzUt6aUlvytlqngOtlzRfSNW/c7S0zGn/c6P8nxuYb+F/Pn92ocbVlIDHuit9EhhBXow/fOa+OMp4o14xn/Dg+COibxVdhaCQvFymbvyAFrWFsa+YJphj6Sn3ugxWDSWLhpcGDAt8WOnvJpmjPCVmYYpGJEmwUqb59izD8eU9azE1Do7oPz4E6QgpjiQ82fQUs8+G1Z8RVbUSUMrYhnzyLl3hAjpoPlUlXKLdo++24Lkisac3lWu8/s= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(257004950022427)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231221)(944501327)(52105095)(6041310)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR1201MB0191; BCL:0; PCL:0; RULEID:; SRVR:MWHPR1201MB0191; X-Forefront-PRVS: 0637FCE711 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39850400004)(396003)(366004)(39380400002)(346002)(189003)(199004)(1706002)(47776003)(65806001)(7736002)(386003)(52116002)(59450400001)(4326008)(2486003)(80792005)(6916009)(5660300001)(23676004)(106356001)(52146003)(478600001)(486006)(316002)(305945005)(97736004)(86362001)(2351001)(2361001)(2906002)(50466002)(105586002)(68736007)(31686004)(67846002)(25786009)(2616005)(230700001)(64126003)(53936002)(8676002)(52396003)(81156014)(81166006)(46003)(36756003)(65826007)(65956001)(6666003)(6116002)(31696002)(6486002)(16526019)(186003)(58126008)(8936002)(72206003)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0191; H:[IPv6:2a01:e35:87fd:c140:b95b:f2c8:d4dc:e485]; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyMDFNQjAxOTE7MjM6NVJXdERpdEFrdUtMNzdtS2hkODFCUnRQ?= =?utf-8?B?QnRNRndINzZqbE5Ma1c4cmJRLzNOem5ueXR3Z1NvWDUyaVZDZVUvVlppVFAr?= =?utf-8?B?SzlId0IxYmljV0dJd2tLdW94emV5cEVjckJ2ZnpyTGY2R2o3T0RRMEFTeHM5?= =?utf-8?B?WUdVOU9uVi9PUmpYZngvVFVqNzMrZ1FhMm5mNmc2bHFOMTZveFNFRTBzYUxC?= =?utf-8?B?VDdkbmVCY3ZsbkJiSEYvc3ZzQ0FURVRqTUpDbnYrcTlvTFBwYzhDZE1KTU8v?= =?utf-8?B?OTdiVW5yZllUU3lYNDFyamhmNHk2RDRhVEFVSVdVMHNTUWt1T25iZXJBTTg1?= =?utf-8?B?ZFUyUlJZNkpWdjQzVzVwYytaOFBFWnRaL2ZaQ0lkYWN2Mnh3c29LZTBoUTlj?= =?utf-8?B?WTJvV0J3cUxWU2JYZTZlbEZoKzR4S2hEQkxvU1RwUVRmaHM1ZTd2b2RhWVZG?= =?utf-8?B?UmwzSDZOMFEybUpXcTV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f-8?B?UG91STIyczRKWlZxT2dMSTNEUEpXWFZQUllGSmJ5Y1pvakR2dVN2TGhRWTJy?= =?utf-8?B?ampOSmJjSTl6N1M0bnBLaWdIZEorZ1N4Sm40czdRaHJnOGlmc2xqV0txUFNr?= =?utf-8?B?RW5vQm5VT1N4OGlmVGlTNmcxeUNhUE1JSHdBaTBnSnhVaC9uYkdSSGxjczVF?= =?utf-8?B?VWQvZHllZE5tSzNWQmhSTnFuczlmZm01MDVkVm9IU3RCN256bEEvWVRhVlFR?= =?utf-8?B?NU1CQUdJb0l5c1dMK2E5VGxQMUFySlZJR0hueG54cHIvMlg0ZE0zSy82TitX?= =?utf-8?B?bkhWNkVuMDREaXFQNXpRTFZHbVhmMGljYy8vTHFnZ0hTYTJkKzlnOGFzOW1X?= =?utf-8?B?SVBwOXVYQkp2UUs0cE5mUldFU212T0NzdlZYZjV2ck9QWEREY0dUaWxpUGpz?= =?utf-8?B?Ri9mb3oxaGt2cXdTZnhiTExHcU85eXd1WVU2S2FKQmY0eURtZz09?= X-Microsoft-Antispam-Message-Info: YE6THr65+B/NvS1zbLOmm8pS35woH1pKrOk72ueoqLsfoy7r4u0y1fA/HXr0stSgTfnGuoYsZqSTbPdDLtSj+21EDJKzRlUogbeDweO1NKYGJddiSx7Woo/WkKbOPZWGetsLQRc4osjURHkJrOkJxp58w2HmPl++1TP9pZQXM7/WJWz0BAFANB7vg1qDO1FM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0191; 6:lWxrk5Yhq+OczxPPepKTk2EUKKzttdX7Evy50LuZWq1wkneAP+bhscEABTZe4TXqcXF56uOWpxRtW97p94GCdZ7DUdKHPL+gnHN3cRj/USarzD57miBdTUHtb2bLKIUU+BliHgC+zQim1li5aNPfkPIU+6emBgukUPwHvnMEvf2EuseBrgXEDiwdiyiGdhEWR+g6J2duIMigJSxQh+xwWhBlxme4JWGcK+RhWgnR1Qm5MAl6eXVSH6GW9mbahp48q/uOKS7m5N6qw0cH5acz7jP0ERCIz5As9N9M0kD0ZqaPKPqasCF7TDirSj1mQTevy2Dt6c7lper1ggsmrqQpsZRfYTT8yjBgwrnVH30opb12Bh6qOanepOoQAI1BJNgyhPPdYHRreKLhHX4I3kIh6QDuvuMNcTg51hu4IFLK04UMpgTPnNxYEKyFXFUtR/Ie9uhZceUw2xTEd2ShHrcgZQ==; 5:/Op8reNLgIMZKVdhTMikswe9I+ev2nG8r8mxuIkpXqhryqpPIl3Vup2Bz550SnRxrtsFWEmdmqSxkeIO+BRbvz4eFxECWwqBGsdryqrvi0yyPPesF8dI1hlKeQ9nNIpZ3xKmHJB00xRsc5J4YQWfj7Fqr2n5r1Lr1Zh2V80vK+w=; 24:KdwszPX4JSWJJw6RJR7Axa2qWJf9Cubo5pgHFgStDlkQZ2np+wZGzn6Gdrsjba7DoggTVUQSpDnvhOZj1UncgTvwtCim/IEg0cx1z0R199Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0191; 7:mNLl+562Inj+mF8PM18VpoDIax92vKtdZ1fkCpgWzgTkMpYeolxDauAlBO7y3BXkKGBf7oZSj/z4YZ1KHSLznVHyUL5jQD1Y1T8+2VKWD5nZrGGru4v9W4Jf6f7aWcCJ8miMNmaiDoXUH0UAKWErL0jCCLxDEmzJZGYgFjXbMvRaam5IdmErUbBzpme2JQoIe4+kuRu3ZwNLYN4IkMQgnWTf1XM6j4hhRwiGqbICmtZgb6d309Ajex89LshPvFOh X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2018 09:44:38.2551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bbd08a7-9555-4808-ef33-08d59dfe832a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0191 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 Set power function is rewritten manually inside i2c mux select. Better use the already identical existing function. Signed-off-by: Jean-Baptiste Maneyrol --- drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 33 ++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) return ret; @@ -59,12 +53,11 @@ static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id) struct inv_mpu6050_state *st = iio_priv(indio_dev); mutex_lock(&st->lock); + /* It doesn't really mattter, if any of the calls fails */ regmap_write(st->map, st->reg->int_pin_cfg, INV_MPU6050_INT_PIN_CFG); - st->powerup_count--; - if (!st->powerup_count) - regmap_write(st->map, st->reg->pwr_mgmt_1, - INV_MPU6050_BIT_SLEEP); + inv_mpu6050_set_power_itg(st, false); + mutex_unlock(&st->lock); return 0; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index fcd7a92..8a8a5bd 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -29,25 +29,19 @@ static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id) { struct iio_dev *indio_dev = i2c_mux_priv(muxc); struct inv_mpu6050_state *st = iio_priv(indio_dev); - int ret = 0; + int ret; - /* Use the same mutex which was used everywhere to protect power-op */ mutex_lock(&st->lock); - if (!st->powerup_count) { - ret = regmap_write(st->map, st->reg->pwr_mgmt_1, 0); - if (ret) - goto write_error; - usleep_range(INV_MPU6050_REG_UP_TIME_MIN, - INV_MPU6050_REG_UP_TIME_MAX); - } - if (!ret) { - st->powerup_count++; - ret = regmap_write(st->map, st->reg->int_pin_cfg, - INV_MPU6050_INT_PIN_CFG | - INV_MPU6050_BIT_BYPASS_EN); - } -write_error: + ret = inv_mpu6050_set_power_itg(st, true); + if (ret) + goto error_unlock; + + ret = regmap_write(st->map, st->reg->int_pin_cfg, + INV_MPU6050_INT_PIN_CFG | + INV_MPU6050_BIT_BYPASS_EN); + +error_unlock: mutex_unlock(&st->lock);