From patchwork Tue Apr 17 07:19:40 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: 10344447 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 D7E1060542 for ; Tue, 17 Apr 2018 07:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC8A928A20 for ; Tue, 17 Apr 2018 07:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9A03289E3; Tue, 17 Apr 2018 07:20:29 +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 2B89B2899D for ; Tue, 17 Apr 2018 07:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751118AbeDQHUS (ORCPT ); Tue, 17 Apr 2018 03:20:18 -0400 Received: from mail-bl2nam02on0057.outbound.protection.outlook.com ([104.47.38.57]:58912 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751085AbeDQHUR (ORCPT ); Tue, 17 Apr 2018 03:20:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=invensense.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=22Ax9sBiMIQb/tQsIpTYzL/YrVkOQREYDVt5XlimT14=; b=ERks+7kpcWAvwoturbqr/A0Oamdgp56jvIL5xFzEHmoowwkIPUP2vq04aXtcC9BeBxMslDJ/VI6atsusGEMP5T60KcimgkSicVurBV+dam+B6u/Pp0U7Eo/mIzicCl+42hc3IPNbk1PNn/pIThbYlS9pkhSBrC7PHVJnjrYVK08= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=JManeyrol@invensense.com; Received: from frgnb-l-34296kv.invcorp.invensense.com (92.154.85.143) by CY4PR1201MB0181.namprd12.prod.outlook.com (2603:10b6:910:1d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Tue, 17 Apr 2018 07:20:15 +0000 From: Jean-Baptiste Maneyrol To: linux-iio@vger.kernel.org Cc: Jean-Baptiste Maneyrol Subject: [PATCH v4 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux Date: Tue, 17 Apr 2018 09:19:40 +0200 Message-Id: <1523949580-18016-2-git-send-email-jmaneyrol@invensense.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523949580-18016-1-git-send-email-jmaneyrol@invensense.com> References: <1523949580-18016-1-git-send-email-jmaneyrol@invensense.com> MIME-Version: 1.0 X-Originating-IP: [92.154.85.143] X-ClientProxiedBy: AM5PR0701CA0071.eurprd07.prod.outlook.com (2603:10a6:203:2::33) To CY4PR1201MB0181.namprd12.prod.outlook.com (2603:10b6:910:1d::10) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR1201MB0181; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0181; 3:ZNdNxwn/Zt6WWM5cHjeff8lN/SN3IQF+zXwpLu7MuVVmQnSJyAGPkVgvii7Fmc++4f7D9SgZhg0s3INd8huHtcs1UzMzamV+XQ9uKXX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OPjJMFzhup5nx177t3eASA0wTcXiK0SBiUfwDmAGICy5D/AePQ+YeQrGFbEyDNo3GSAZcrMESV1O8IXgs/yD6wgef7/YU0MucFq8p/FPAH4rvcpv7vD3QETNSgHoBa6e3DFJe16m0U8OOE0PVqUbT5QbGHIL3N+sM9u1oyhiGYMcqpe6BN+YUvP/EYw6b5lTi2PjBmp33rKjuud8lcciGA6XS6suBJTZwsaHwCyAiQHR7upV0BE2F; 4:bJDpmazVUYaPhMJXDSKFFyTAZzx5riwpI2zTbrCOLjl1Shu/sc8a1NIszPA2vkWmUotQLm6t1J5ZC/j47SWFuBGLCrd8gxolg49w0RL1PSFnFWNFX+lMh0iXyY8Nr/F6bqkuu/Gvp3tVaYUfva9vvE1IKq4Utz/ozi9NO12Evt1xRVidYen4kIkXT9CiYbEoBOCcvD7Kk11Y4pCAdGIklfVxXSWgwtAwVsw71xAIxbPJYFZA0XJ/TVy8UxZ3MIVJRPIXIyUfblULqUNs4GpDBKky52vKdKoGx9vhNTTDaII+xnlYWzmXBWlsWixmHVmuEocvnSmQBrYe1HQF5qQwBTfh8hgMYzQTTeJeze4aiMg= 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)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231232)(944501327)(52105095)(6041310)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR1201MB0181; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB0181; X-Forefront-PRVS: 0645BEB7AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(376002)(346002)(39380400002)(366004)(199004)(189003)(50226002)(186003)(81156014)(8676002)(8936002)(2906002)(80792005)(81166006)(2351001)(97736004)(66066001)(72206003)(6916009)(47776003)(6666003)(2361001)(386003)(7696005)(36756003)(51416003)(48376002)(52116002)(59450400001)(478600001)(25786009)(68736007)(76176011)(26005)(476003)(5660300001)(4326008)(105586002)(50466002)(106356001)(16586007)(86362001)(316002)(53936002)(486006)(7736002)(3846002)(305945005)(956004)(16526019)(446003)(2616005)(11346002)(107886003)(6116002)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB0181; H:frgnb-l-34296kv.invcorp.invensense.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: invensense.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR1201MB0181; 23:TINcSHjnbGZAWF5EZQOf6j/t+1O39G+fnHKWSIO?= =?us-ascii?Q?ZtngDTOXPTrT66VR+AJUwfjXliaw2hiTwOYD2c8R0vTwFerIt8hWHrcwIz3B?= =?us-ascii?Q?de+F28w01t1aWFgVgtC2lAzLQgXNFoToEsY0dNNHVxw1eHHouvagxCwpX6CG?= =?us-ascii?Q?3f1bviFL8S15AY/XLmThGjLjVAJ0yDtEWWX9g9gT+F5MUAd0psbP8qoirjHn?= =?us-ascii?Q?aeph8yGgYhnHsggKcppLKS6vskP0hsfHqcJE/M3nyQKNS4Eb40p4yCTHEQlC?= =?us-ascii?Q?iHcj8vrwmFdH3ovjGt0FNhrn+fFNFr/Von0n7zfzf5aheL4EJzWJHWI73+39?= =?us-ascii?Q?6IbFJhkdqTLJhKnK92y5FGUiqeddGLeaHdRvT0OGTumRW9Ox9qIBbSD/JoXG?= =?us-ascii?Q?0Gwd70Y6MuemesTZ0CHHUfR3HZoPQcmmLAGND/usG6nsrVwRXq7YDmtchswv?= =?us-ascii?Q?eYMJ4zXt4S8++dojmCtsvhe/8oguYI3+E1UJ1q0J7JqkaD9bReS2xw8Yf+N5?= =?us-ascii?Q?AxstQui1Q8iaA6fRo7c/F2L2zWf/TXJK60Wepc/5tJUiphxucdIIPU1bfmtu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DsGS1lW7B7q2PupceuDeh7u8NDZjsi2pk1JqkbdnoUkGlEZI0/z5q X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0181; 6:0R1Vt0bFRsKpVKi8y3cbLqLF5/ktjlJ5OBal5qCzp3FCdd4/B0G7TePAdk3YGCogce2OWDl+EYAQoWnHWYNo1yuGR9ebV++SL7I0qJLjj+YilCIW5+5t5kE4zUnt1lAl3WMYx89a0AAaPx7L+aMgRg5IOcyqq5GugnOILmbuZDC1VY5c8pCq2Qdgyih6zS5PZcx9cI4mHb92E5HJNPURlC0569YWajBhHoXhepL4pHB7z2omTGk2LTEZdrahcokZIuiHNyqVsJNtVB4wHOU8csYVHZjt9EHil6oodf8rUsuyF+EdyEP1NUgW3ewMjajOFUE7mAl6Fdi1bv1dqhI3iQnUTBtP/PEkYcBE/pBwreOY5ZL4j3xtm7Kay4BO+oMa26KeOrcNHey89M8pPBhX08MP+HlSfVangiCIJuFSZzhn5zMRYvRiMwjoMqjxbhzi2/Yo5Oms7vS2N+/uyP7Nig==; 5:7wE2xTOHBBto4amCDn1wYPC07VpybSoN68+Z025CUFjZ+B7IPJOjiBSnNnEsv3t1KwqGiE0TvBkuUHTjLRKzS2kUfRNhBE5xDgCQqtJ+2ykJMgINXtJ7SmG+ScGUp+Ythe6SjjhhrVpg80KL4U+gVPeMqMrvr8Dc4G8kYypkivQ=; 24:+1XoyTag6q3WE5BCYTtZGx375pLIjl8sBQL6sPVqbIcyrwETzzaHNcWgjhouqFZVtuOBoANWKiaDWtFwnQqEWtYCVCdZrlETIuv2brex7M0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB0181; 7:qxbaVzVWUpKmkaK15yZkb9DbAPuulwbm8gQ1g/wTAZtD2yXISUP0kFlxeXVqdNhj9QLOS3eqY7FPqRYh+msSRSJ/G4Q+C2n7OafcA1TU18fnTQOrB4IDewajEt28BXe6a20o+RW9eAevxZF25kI/iChLkypKkrBTXxvABHJEJ/rczSejUfFSHci5W3c/DFC9jNKDv2g/0lyAbY4kp+Uhrjajxm1OjgydMk7jNkfPZFehcdjzEHLcIfq3jp74jaLx X-MS-Office365-Filtering-Correlation-Id: 3f92d92d-93d6-4126-afe6-08d5a433aad8 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2018 07:20:15.3470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f92d92d-93d6-4126-afe6-08d5a433aad8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0181 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(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index f70e7b9..eca34b9 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); 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;