From patchwork Wed Apr 20 15:17:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8892091 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E93DB9F39A for ; Wed, 20 Apr 2016 15:35:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 704F72024F for ; Wed, 20 Apr 2016 15:35:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F52E2024D for ; Wed, 20 Apr 2016 15:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751279AbcDTPfa (ORCPT ); Wed, 20 Apr 2016 11:35:30 -0400 Received: from mail-db3on0126.outbound.protection.outlook.com ([157.55.234.126]:55378 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751811AbcDTPfZ (ORCPT ); Wed, 20 Apr 2016 11:35:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=USFixmgU8P9Orz5R2OKUv6HYMVpxuHOc6Cpwu3S2QvM=; b=PTPeENhvc1y5MY35NmjQtj30c/i6kz6fo+qLiVV4Rt8dtJdUqFZo3XSc9wGE3gD5ufhaaej3T7+AYc8TEj+YGtbiE58nvHAWZFLe4sYGM9//o6WcCc3HnpW7er+KZOkPEGhYXexQkJjM7cAzJ7j4GMAyXCHwv2hsc1SxlK7qMsk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=axentia.se; Received: from localhost.localdomain (217.210.101.82) by VI1PR02MB1312.eurprd02.prod.outlook.com (10.165.231.154) with Microsoft SMTP Server (TLS) id 15.1.466.19; Wed, 20 Apr 2016 15:20:07 +0000 From: Peter Rosin To: CC: Peter Rosin , Wolfram Sang , Jonathan Corbet , Peter Korsgaard , Guenter Roeck , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Antti Palosaari , Mauro Carvalho Chehab , Rob Herring , Frank Rowand , Grant Likely , Andrew Morton , "David S. Miller" , Greg Kroah-Hartman , Kalle Valo , Jiri Slaby , Daniel Baluta , Lucas De Marchi , Adriana Reus , Matt Ranostay , Krzysztof Kozlowski , Hans Verkuil , Terry Heo , Arnd Bergmann , Tommi Rantala , Crestez Dan Leonard , , , , , , Peter Rosin Subject: [PATCH v7 14/24] of/unittest: convert to use an explicit i2c mux core Date: Wed, 20 Apr 2016 17:17:54 +0200 Message-ID: <1461165484-2314-15-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461165484-2314-1-git-send-email-peda@axentia.se> References: <1461165484-2314-1-git-send-email-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB3PR01CA0069.eurprd01.prod.exchangelabs.com (10.242.133.172) To VI1PR02MB1312.eurprd02.prod.outlook.com (10.165.231.154) X-MS-Office365-Filtering-Correlation-Id: 3d96e6d7-ac2a-4323-89a5-08d3692f44a0 X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1312; 2:fJDbDJ1ob14hEn8ItB62c/YR3p3ODsJJT0FDIo+7NH95QQQw/KKRDMK/VJrTDpT4uGXR7KE5z9R4YlimRyR1PJ37MBlj1zbiFDllMl+uGQtV0S0myyiaJ75UCJQgj0H49/9KIyX0FD6pp9k3HCCuOXVsTxj9kaczX5ZgFQZJJjeGtqHk7952V9+4dC7My4Q8; 3:A1ekgsAd7wjt2WgrY251vTiSxpbvGtsbOwuPsaYRDwN7GVh6pUY8RN2shlqVZGkVaXidEqTzzmqMwLVhvtvNTbxJiVr/fyCXhSRoeXNgiLPGgTyjIBHjhPz5SJszSjrO; 25:s+bgnWwTz+9rKeiADJFwGTnSK8fnVj5KhYYh/3Ku244yEOXXg9mstIfnBKkFA2kelvTjgkC0B6Fwvh/UdbJGtOFWOiZmLfQGbnRKBCDw2tDujM75WMoW7ALqt0PH2z8lV2mGT1oHG1+vs1OzN/EfM5ipE7y+OdJicuEql6+OYvWincxvhiBea7lcOiK4xssirydBySPtA+5l1xvGuLXgiiDj9LvVFpfgefSqc/Kl9mJ58um5QOOB1/jX4WJYUbpANgJZvsPKA0c3VVCmBUig2EGHhRR1Cg/N02zIpB2WgTIoZ/j/1BLF3t1NTfRM95QEceIapGIqJ1JHwnTJrlcNSw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB1312; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521026)(6040130)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041046)(6043046); SRVR:VI1PR02MB1312; BCL:0; PCL:0; RULEID:; SRVR:VI1PR02MB1312; X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1312; 4:8JbG3DVgAxpm25pDSJ3TRyRJpwZ3qa2roeGITy64aNc+0SIgAhsR4Q9IUJywgtGM3S1qh/OtoVv3oyVDUiC4QuHVb27rYcrk7m2vH+z49gj/T657cxbF9y55kg1aBPx9eJHQZC5uKuE5kQyaCFjrpwSSTUyWepFt2V4/jg8LBV/ycDrolewo0TH9iuFcfzkz8345rUZtAcoWOR2AScCgUf3gTOoRRU5X9bSMogvopyC+76T+DuOvzHmfuXkMJKCOBn0p6+bZuFNPc8vqN6ttef2k3Y6a/VlsZwE3qbjdNsiC+BosnDGg8Xvbc8bkwfh07OTyIX7tF7xOmtyD5DUNz5NqvSFR3/Td1GZ9ECPzqwOUuWBlvr78s49sP9jHFgKpclsfB2DxNnKP7gQ7NLoZS16LwyLqFhRebdKesoyGHp4jFR733FpC4pKyXSaoot8/jlJ6GURQ3iOkHdoSu3Kzag== X-Forefront-PRVS: 0918748D70 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(66066001)(2906002)(19580395003)(19580405001)(110136002)(92566002)(189998001)(5008740100001)(47776003)(42186005)(33646002)(6116002)(3846002)(5003940100001)(586003)(81166005)(48376002)(2950100001)(4326007)(50466002)(76176999)(1096002)(50226001)(77096005)(50986999)(36756003)(86362001)(2351001)(229853001)(74482002)(5004730100002)(7059030)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR02MB1312; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR02MB1312; 23:Dyhxm8WO5/LWKErQdt2PFE8KPv016x3vMLAJTtM9Q?= =?us-ascii?Q?0mh1uOK/+sX3zUlZuOXgAhYzWoY3Pd66bAxxOumTD0a7ttBwGi4550qgbvbF?= =?us-ascii?Q?UXuFrZpy9G8jNGvqtN60MV0PwDB+4suxox/21BXRiaW4XAd3IJLa5EAXLTwj?= =?us-ascii?Q?60Wa1Ko8DwT5BSVPIyywDT/1GTwsrsiXaMW5fJydU+Lz68A5fGM06+bA+qQ/?= =?us-ascii?Q?A76Omi7X77UEJttpV3Ictw4PfY0zim1p+ZMTC7hV9qY4RhcNPFILXXzWN2hU?= =?us-ascii?Q?hrdhJLmnwclWr4FYJ4++LE20swzkmchyEU/PLnjeWLDKsGAAmCahbxIAl9XD?= =?us-ascii?Q?q32NtscPGw+onv3997Xw9QD38tsFUWOmhEVFiaisRE+1oFGHAwZ7YIP9RWC2?= =?us-ascii?Q?9bTwCVT8Ha9WM32ntBpUHVUEmBoI77wfY8P2t2Lbpu/+3ibl6F8txAd386lZ?= =?us-ascii?Q?a3jjgIErInZkyBA7atVDwAYLGh8EENsmgonqir53mN86zz0qxzaSt9U8GQ5s?= =?us-ascii?Q?4I2aKzRBpnQgiNI/8gkALHA4JCSPEr2oVa8n34F3/YftyUflcHRIafQecBq7?= =?us-ascii?Q?Y/Dhp6VUVMpK4/rvF4gGjuyZc6uvGCzLLtd+y+B1XcM6znF00f8QNJ9GTlz4?= =?us-ascii?Q?AUKAoeYplfaparoLr4VnScDEWnEeKOcJGLQ32ktYYsVyzWiImkImJujLJL76?= =?us-ascii?Q?ZeYq+TqVPEugXI1SFI6dmwhDxj9j+mnK9pOVeoTDYzDXbc2fIK00i8VzyDVu?= =?us-ascii?Q?W932ieOp9+posSm+5gEZ5qguqg/BgVC2tAJUVFxajy5ZhjBmL2Zwa2NgzJj0?= =?us-ascii?Q?yUNsmIY+nmf517IIUqhB61KUdA1AUeKsFGBsoeqls33OLeHYVbzrudcbx+CO?= =?us-ascii?Q?BZutKinSjORA6b5tZDM9Fhux3XCqQMNiriCrJ7yJNZiLGjIhITHQwnWbzWdn?= =?us-ascii?Q?ugKerrQg6YQdHMfgzqfXIZasldfwUycH4/CTF9CLw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1312; 5:2kcHHflFbF0VFvixfO2FsFsOk10bxo3Co9hn9wqMIYg89QktzfIrMY2a/kn0MyAOs9WcBG8ft7AZP6mQHBmzfzdX/ariFnXAD00e9E8QbZtvH6iKQvkymKn6SvunRiNuXtz+3XvR0z4wsyEwQpfdUW6BSEnF/Ak8LMm4huEr+U3oFRzjQXD+bxz9eB0L727Y; 24:qg7dT0R7P8IK5WxmlQgMkDegmZnOHBAksLpY1oSJUa+2Q4l2jkg4TeM69F6nSbMRrurUixxMVpOwA603IzpxDRPD2kANn/4jDdEi92Xaj/Y=; 7:gzbvJ+j3LaqtjFYygtb/hryl8XS/nf/dkZMiwA8aUZh95JAjGbOOUq2CPU7h2wQa/ewEU7V9I7Go057hpIClHElvXq3ZjYxvt3689/yy/qq6CTkwh20xllBuU2ONNwdKd1gMPIb6jhutE292KTHebaZ1IrIWjWNv1P0YkPpdSBGRIxvLlhe6cp43BEt5cVe9/Hv96eNC+vuGfipi0y1QVikRW7F5EQ9zatANoTmVCJ0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 15:20:07.8871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB1312 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allocate an explicit i2c mux core to handle parent and child adapters etc. Update the select op to be in terms of the i2c mux core instead of the child adapter. Acked-by: Rob Herring Signed-off-by: Peter Rosin --- drivers/of/unittest.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index e986e6ee52e0..c1ebbfb79453 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1692,13 +1692,7 @@ static struct i2c_driver unittest_i2c_dev_driver = { #if IS_BUILTIN(CONFIG_I2C_MUX) -struct unittest_i2c_mux_data { - int nchans; - struct i2c_adapter *adap[]; -}; - -static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) +static int unittest_i2c_mux_select_chan(struct i2c_mux_core *muxc, u32 chan) { return 0; } @@ -1706,11 +1700,11 @@ static int unittest_i2c_mux_select_chan(struct i2c_adapter *adap, static int unittest_i2c_mux_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret, i, nchans, size; + int ret, i, nchans; struct device *dev = &client->dev; struct i2c_adapter *adap = to_i2c_adapter(dev->parent); struct device_node *np = client->dev.of_node, *child; - struct unittest_i2c_mux_data *stm; + struct i2c_mux_core *muxc; u32 reg, max_reg; dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); @@ -1734,25 +1728,20 @@ static int unittest_i2c_mux_probe(struct i2c_client *client, return -EINVAL; } - size = offsetof(struct unittest_i2c_mux_data, adap[nchans]); - stm = devm_kzalloc(dev, size, GFP_KERNEL); - if (!stm) { - dev_err(dev, "Out of memory\n"); + muxc = i2c_mux_alloc(adap, dev, nchans, 0, 0, + unittest_i2c_mux_select_chan, NULL); + if (!muxc) return -ENOMEM; - } - stm->nchans = nchans; for (i = 0; i < nchans; i++) { - stm->adap[i] = i2c_add_mux_adapter(adap, dev, client, - 0, i, 0, unittest_i2c_mux_select_chan, NULL); - if (!stm->adap[i]) { + ret = i2c_mux_add_adapter(muxc, 0, i, 0); + if (ret) { dev_err(dev, "Failed to register mux #%d\n", i); - for (i--; i >= 0; i--) - i2c_del_mux_adapter(stm->adap[i]); + i2c_mux_del_adapters(muxc); return -ENODEV; } } - i2c_set_clientdata(client, stm); + i2c_set_clientdata(client, muxc); return 0; }; @@ -1761,12 +1750,10 @@ static int unittest_i2c_mux_remove(struct i2c_client *client) { struct device *dev = &client->dev; struct device_node *np = client->dev.of_node; - struct unittest_i2c_mux_data *stm = i2c_get_clientdata(client); - int i; + struct i2c_mux_core *muxc = i2c_get_clientdata(client); dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); - for (i = stm->nchans - 1; i >= 0; i--) - i2c_del_mux_adapter(stm->adap[i]); + i2c_mux_del_adapters(muxc); return 0; }