From patchwork Wed Apr 4 15:08:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jean-Baptiste Maneyrol X-Patchwork-Id: 10322661 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 8BFE960467 for ; Wed, 4 Apr 2018 15:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C9AB27EED for ; Wed, 4 Apr 2018 15:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7138B2848B; Wed, 4 Apr 2018 15:08:45 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 BE46B2847E for ; Wed, 4 Apr 2018 15:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751510AbeDDPIo (ORCPT ); Wed, 4 Apr 2018 11:08:44 -0400 Received: from mail-bl2nam02on0073.outbound.protection.outlook.com ([104.47.38.73]:23979 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751414AbeDDPIn (ORCPT ); Wed, 4 Apr 2018 11:08:43 -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=fMbJFzh9+dTVJwyabxuUlJ8Op6Oc2horFYCuwWI7Fcs=; b=rxI9HTgaVvNaFOeVU6mxZ4aoDr8/jfu2vaffpmpdQRDnJM4l4IorMUCpHFqcNaWFrR+ue9Q02iYSj7Niy90kftKvluIBE/y/2/wAubWEXGAQhmyMoCCS8wkK1yya+feUpON8vrrI2Nk7Jd/sCCEyLextX3DCqEi2Idx5NgceCFc= Received: from CY4PR1201MB0184.namprd12.prod.outlook.com (10.172.78.141) by CY4PR1201MB0152.namprd12.prod.outlook.com (10.172.78.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.10; Wed, 4 Apr 2018 15:08:41 +0000 Received: from CY4PR1201MB0184.namprd12.prod.outlook.com ([fe80::6cd9:f753:b84b:7f85]) by CY4PR1201MB0184.namprd12.prod.outlook.com ([fe80::6cd9:f753:b84b:7f85%13]) with mapi id 15.20.0631.015; Wed, 4 Apr 2018 15:08:41 +0000 From: Jean-Baptiste Maneyrol To: linux-iio , Jonathan Cameron Subject: [PATCH v2 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux Thread-Topic: [PATCH v2 2/2] iio: imu: inv_mpu6050: use set_power_itg function in i2c mux Thread-Index: AQHTzCbQ0gp+Mn18gEaFdXFta5ebDw== Date: Wed, 4 Apr 2018 15:08:41 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a01:e35:87fd:c140:9cdc:7fa2:6cad:bd4f] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY4PR1201MB0152; 7:tBtz8CQwPA8fePo+wTAHDQJZF9Y3iNJBGpKBF99hfsALhhprKTz5TfwpQEMLnO1PFA6fzq+EMSODVqHBWdsBDAhAE9k/B4iXokVjsZcPlP1q2sxQivdcnBRxfkYK1pil+OEci1aI7FZD6pz3frBI9cedbn6Ls4Nzx7mC7mYLwr0jiv6q0hRZdmYSaqkP+KPcOHfcDUiIy1YTaLsenEThUAcSxSZ2n5pd5mwcieo17pGFAIPyBJREgAiIS7/QaUu8 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: ec556066-7bcd-4542-e600-08d59a3df38c x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR1201MB0152; x-ms-traffictypediagnostic: CY4PR1201MB0152: authentication-results: spf=none (sender IP is ) smtp.mailfrom=JManeyrol@invensense.com; 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)(93006095)(93001095)(3002001)(10201501046)(3231221)(944501327)(52105095)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:CY4PR1201MB0152; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB0152; x-forefront-prvs: 0632519F33 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(396003)(346002)(39850400004)(39380400002)(189003)(199004)(316002)(6506007)(74316002)(72206003)(305945005)(186003)(106356001)(46003)(5660300001)(8676002)(6116002)(446003)(81156014)(33656002)(476003)(110136005)(81166006)(59450400001)(8936002)(102836004)(478600001)(11346002)(86362001)(7736002)(76176011)(14454004)(9686003)(25786009)(3280700002)(5250100002)(3660700001)(68736007)(7696005)(53936002)(2900100001)(105586002)(2906002)(99286004)(55016002)(6436002)(486006)(80792005)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB0152; H:CY4PR1201MB0184.namprd12.prod.outlook.com; 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-antispam-message-info: 69W4xCZnQKjCFA5/uULkkf9igkdcEz9ysXIAwDSbYTtwb7PnIHHZAuDSpbU9gTdao4ZIScotXod1R4DY8+ZeNmIze5Xzx1oP0TeiJJBiZVbp4956WPZcnfSX1NLB7bMyFLdu2xSLSz18eRyUrjxXN85CWOerx1ykd0SSimJ/ca1LlMv6gV4oflC1c6lGyFtNlbN3z8of5lQOjkv+2VSE8SSkZJZxRzDbNRZ0Q9tDMimoalcMKmNjNT2CgwJuLDM93TP8tzoTEndwKA4rDphZRTzNwTbkZPvmjUGBd4/a3P7NhiM3woi1qOIEmXVr3USmEen9DSk3zUgSzzYfq0E7Iqz0FJo5apoEsi65qKYfsxQESO381tUaL1RzGUZ8zzgjNUK5Ih2BYFBA/J2YSqhP6UE0tQ50lEoSYRBLMtxA/Fg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: invensense.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec556066-7bcd-4542-e600-08d59a3df38c X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2018 15:08:41.1010 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 462b3b3b-e42b-47ea-801a-f1581aac892d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0152 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(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);         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;