Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935401AbcKWOJR (ORCPT ); Wed, 23 Nov 2016 09:09:17 -0500 Received: from mail-db5eur01on0132.outbound.protection.outlook.com ([104.47.2.132]:52867 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934926AbcKWOJP (ORCPT ); Wed, 23 Nov 2016 09:09:15 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; From: Peter Rosin To: CC: Peter Rosin , Peter Korsgaard , Wolfram Sang , Subject: [PATCH v2] i2c: i2c-mux-gpio: update mux with gpiod_set_array_value_cansleep Date: Wed, 23 Nov 2016 14:33:55 +0100 Message-ID: <1479908035-18284-1-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB5PR08CA0059.eurprd08.prod.outlook.com (10.166.166.155) To DB6PR0201MB2311.eurprd02.prod.outlook.com (10.169.222.150) X-MS-Office365-Filtering-Correlation-Id: d43b8c2f-59fe-4a99-f06c-08d413a56456 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0201MB2311; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;3:Afbz3B3XyaW7iV+pJEb6bsC7eRtP6JbP703EpOSl9J5zba/6YE4wktlX0Wf5uu1rEsDsfT6254Bp38WLI6X1oLBqlWKy/0eGMCVhhgAZIXqJppfKRYYWvGM4lqVxjGnd6ceH9lyD+dwrDLdWQvRmeYbRR82gf3U9grDzMTIM1gqDopWex2mZdvwu4Sevjw5pQDEWxPakTmF8YCXkQnfxUsyvolWI6CR/TMlDobmiqPePu0th/4Yrb5E8hGdk2akjsHkM1cbePlgJSkpQrP2Q9A== X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;25:7wBaCBHNd9mij3prnfLPRi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S7F3Lchl7GscwMFPSnjm7qwTUkpoADBaduEw=;4:8JihuTATpWMuhsId8jisMB2EDZD/bvYjdRvFMdT57W6VVAR1PKPAtuTj/n+X5gG4vswsryhfmP7QrLzddZhb2/h0GY66JQyOlXHTxDrvE2/B7BLGb1YeOZz07YlyrR9QmOCDgdZv39LlwvP5gsZcKufeX0W4cbn0B7o2dva2upVFV3seE6Zc6A479VFptvKYJ4kwgZzKLAm5+FHwQ9ldhIHOaH5cerH5X3XQMc6Dyk4S1phJVbL4T0whICNq1bVsK+G6/T9IMREX6CN6VUZe6XY63e+LvIuQQkLuuc2ZUydELRfpxiFJfLU9b+X1ed388zzXB29xhpQ8xj0Aw5i05TvAyjzV8qZAAW5kdkBuf0T4bvXY3FDIhzUYNYYl+bMCFPdCqiHbttfR4NVW3NQI8Qr2/ybCWW+2Qgq0BEzZzBUAIUgq3zSPhKdK2RU7CtG6CXGqKwye2NwvB/R60vnHsWIX3x4UNb3A6PxUYOg9ypexqbEiHUl7rSi42dDvtLF8sxSfRS1+BFhwDrNeG2aKzw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(6040307)(6045199)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6061324)(6041248)(2016111802025)(6043046);SRVR:DB6PR0201MB2311;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0201MB2311; X-Forefront-PRVS: 013568035E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(52314003)(68736007)(50986999)(86362001)(47776003)(33646002)(110136003)(5003940100001)(230783001)(92566002)(105586002)(97736004)(81166006)(81156014)(38730400001)(74482002)(8676002)(106356001)(305945005)(50466002)(77096005)(101416001)(48376002)(6666003)(6916009)(7736002)(2351001)(66066001)(36756003)(15650500001)(50226002)(6116002)(4326007)(3846002)(42186005)(189998001)(7846002)(5660300001)(2906002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0201MB2311;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0201MB2311;23:iqG1RZgISsDX6VR5IHLrH0MDdgYJ/vjAsOEQ/0E?= =?us-ascii?Q?ov4jC+C16y+2LOcJ8ui4M/rtW/0kCldFw1gZudK8fBNp2ag52O7IgxNWa1yq?= =?us-ascii?Q?P4WPHOaK6AIFb7UCiF61l82DFS1UV/vGZGQHUX27QWhN8B8PmJcKR87bAlA8?= =?us-ascii?Q?k7iCekH0WW92ULhIJwDCG7mAKFePYooLS81hII6acC1Nf4nwSXWMJFa8O7b8?= =?us-ascii?Q?W9cZomQrkDL6+M23Kh4MrA0Ys1vcvqxnsNkrs2fT6s/2t09WC7NN2d8oVtP/?= =?us-ascii?Q?GJ5P4e0twyJsmdxu2xY8VFmqH2PM/7R9efKdIM8NFVSAO4RuP0ErV3Hzd1K1?= =?us-ascii?Q?Y+nZ2kYgrztMZCGBkaapyiMRsIDe9tYpGxL6yBdmq04qFfnZYy72AauqjFI8?= =?us-ascii?Q?HqxPFgB+jTdpCHbO+fn3SzQlQ9WlleZRpb64F+sLPJhjidldZsvW2tQXYb7B?= =?us-ascii?Q?g24lqW/kqujbj2FAMA3QMs/6qokt4xTXtM/j1/RYUXyMcAoB7bkoZ2HHA8ZH?= =?us-ascii?Q?LvSF1vdHCOwmuizhYcPPMq8EFzVo4yjQN0ZmWoNEcExAtqb5G430pxmkJcaO?= =?us-ascii?Q?NY5K1UfL1QWmb6G2VhbfRfx1rboO3SOBY5smUnMfW09d2FNaBvRgt02dQfDu?= =?us-ascii?Q?fz/L22lDHRDfbv/0eak09YfYyYmBezvyfVPgd3R578/rYqQ34MNbuQ+QXFAo?= =?us-ascii?Q?DDmzYB4l8bOobx/1Q1aepkVC9HAiqc/V0lyT9jUJU2ZySw7M0TnTpR2mEP5s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QO4wrfSv7VH9xeUu+Sh8XaGk8jwVZbYrRuLIRwaZEwja2aG9Y2tfAfKOSc6ygYRTfurXeDhDneA572KY7sZg==;24:0pCbz2g7nz2Yt2gCSUNCUcxes6p0r1rEPmjITvuG767EvoMZHY9xdu8sEdI1sN8e1zbxysiu97lWC2+5TGrVYtMM70eQnsbD+ZfFVFu5FB4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2311;7:PbPy0z4yYzyk1VsNTVmrS3tCs9E/4HqyO2uV+5JSeAz78YH6S7RSTv3apsMbfjLrCwYCC7a4ANiY7JUoXkQprimbWBmEEAcId4iYUWFd15QNK5FhlSEA3YgTglJ1PtkrzdyCoOK+pUHorHYA6sHpDkaDkYsU9iMt+tTGdr90bvO39HbzXA3PLBA7mRyY21yeaMdTKgD05qRVrzTcejBJnRyBo2LzH0oxc0zyS+JG8bpJKiSIWzGXfi3Gvk5Err0ZWZWcmTnC5868JkPnZxGeyKj8wRoezv7YUz0rxcLBiv4rTHuMbjqez7eOxg9ACNiOnMY0IlSvH0BCFRo6bhYpGovyj6SvlQTWrnJEgVbVkm3xGh9q7RLtd1iTO/h0b1avcUy/OE0N704/hIta5rp52g1dxEep+qDae3BvzCqNfqBmbeHOm/Rof3xnWP4z1W6zkXlpz/q3ogs+e0s8d+g7Hw== X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2016 13:34:03.2527 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0201MB2311 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2184 Lines: 74 If the gpio controller supports it and the gpio lines are concentrated to one gpio chip, the mux controller pins will get updated simultaneously. Signed-off-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-gpio.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) Sorry about any confusion with v1, it had another unrelated patch underneath that made it hard to apply it. I had forgot about that one... Anyway, this version should be better. Sorry again. Cheers, Peter diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index e5cf26eefa97..62d033a7adf2 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -21,15 +21,18 @@ struct gpiomux { struct i2c_mux_gpio_platform_data data; unsigned gpio_base; + struct gpio_desc **gpios; }; static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) { + int values[mux->data.n_gpios]; int i; for (i = 0; i < mux->data.n_gpios; i++) - gpio_set_value_cansleep(mux->gpio_base + mux->data.gpios[i], - val & (1 << i)); + values[i] = (val >> i) & 1; + + gpiod_set_array_value_cansleep(mux->data.n_gpios, mux->gpios, values); } static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan) @@ -176,12 +179,14 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) if (!parent) return -EPROBE_DEFER; - muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 0, 0, + muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, + mux->data.n_values * sizeof(*mux->gpios), 0, i2c_mux_gpio_select, NULL); if (!muxc) { ret = -ENOMEM; goto alloc_failed; } + mux->gpios = muxc->priv; muxc->priv = mux; platform_set_drvdata(pdev, muxc); @@ -219,10 +224,12 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) goto err_request_gpio; } + gpio_desc = gpio_to_desc(gpio_base + mux->data.gpios[i]); + mux->gpios[i] = gpio_desc; + if (!muxc->mux_locked) continue; - gpio_desc = gpio_to_desc(gpio_base + mux->data.gpios[i]); gpio_dev = &gpio_desc->gdev->dev; muxc->mux_locked = i2c_root_adapter(gpio_dev) == root; } -- 2.1.4