From patchwork Wed Apr 20 15:17:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8892411 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 F400E9F39A for ; Wed, 20 Apr 2016 15:39:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 135242024D for ; Wed, 20 Apr 2016 15:39:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E64A8201F2 for ; Wed, 20 Apr 2016 15:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409AbcDTPjH (ORCPT ); Wed, 20 Apr 2016 11:39:07 -0400 Received: from mail-db3on0146.outbound.protection.outlook.com ([157.55.234.146]:54816 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752082AbcDTPfS (ORCPT ); Wed, 20 Apr 2016 11:35:18 -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=UHeJ1XgX/+CLqA+r8PfFNiZ7hVHK7qEtwJl7revXcFw=; b=GkRHgRfvXTWn1kkhC/LS4ukCFgEMaUvQzzzJzqGXUOxTa62PrkiVN3z3puiDSZ3sa2fW3sfUxSsNIzh6yPwHmbYUhkiF4h1AyMcpyYwbhpkRTvUB2dT3VFd+TP7p95tkvp3DDYPCB4qeAaA4M66EBPk5B29PFjd+ZUqptMuDzho= 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:19:51 +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 11/24] [media] rtl2832: convert to use an explicit i2c mux core Date: Wed, 20 Apr 2016 17:17:51 +0200 Message-ID: <1461165484-2314-12-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: 75564796-4c7d-45e3-c22d-08d3692f3b08 X-Microsoft-Exchange-Diagnostics: 1; VI1PR02MB1312; 2:Rws6iqxAjawjQeYIGchVybToIc0P1jFs3FzPl/B8qysluU3Rofzz9T9WAiePuPlSluPMuxOeARrByk/bbiPyCMntYzJCjbN2h4VuiuFhdZlHCokv95rDTQmXa/8Oh/Hn22IrwpHS14/iLu06kYrtKm860wn88e0ZSGEmwBCWzn7fqytpKguRJaWnDndC+Ok8; 3:HcVAVqZxJkaTkBcvdF2yqGHtEw5aZ92SQ9FzeOCf59OdUN4j6wLgW2D5pof63KDplhtuKdhFCj53+5pejT5jzk0DSzxiXaS72418ZSihwpFb2+X3OhAynG7MOsKA5OIi; 25:Q7/WwJpxTyXxlPOmZqnjEci30VjaLqRJKkDeJQnlj7E4P6N2pGp+eOu/6MLo7M/+ofmVsXVN8QZrtt1JOITU485BOg2trv6AjpYitr1OqrQuxsaUwWLkwWxVZRnJft29DqIpVQ6NuRnMlV4RNHyAQSRen+1ktOQqbvZ8kWfEdYYnHHOD5EuBVmtilAZa8j7z2wSgc6gc+DPfLh8uHL3L+gRnbpZ2bYr5nSCjgSnTA+MLWzV9vu9F1uZy83bPxHZ3I7Je1TowTtaZkY7Yj8FfbgniLbtrtPXMWwH08mZTlw8yVwlblFgefd46ZBeAjdUlkJD1S7zbzNE7Hibzj/nmTA== 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:M18bEGcd5NDcs0ne6YZtBndsVG53YvOGvFi8aHdNTpTXpTZUwzwbbDs1+v2b5S5jX+3isQ7/lwda+ikLNNloAdrfJy1jzhRlwe7U5drXktOMo+G5zN3hvLCBCCCwvKIS+EuLoRPT3m+hhsoxBH4pnFxyGsk6YnQ6y4B/Aqy/yk/1xgPYyA6Pai36iJ0pcM6qylBzEdae96O5l7AwqN8LnPKNGgkDGPtIF6YAvJCM/WuwSIHn3pzzl5xTvnTSTTEctk1jmfeVU2ZrZvMFWCYko1L87MiQYyMRNL70p1PpdqgMOxNznlyLZeneVM8aQ5XRQUvJk6q7jvm4DxqfQnqwgHdnGFIFQEEfk3JIj2p6ysfEzFUp/2q5k71sx2exCktpeuXm1GGQ9Ira/Umd2jSi+CYxJ0E6OZ16tMtv3Xu5piJro7U6VDw8UPGZy4pX0/jpkZriKIfDTI0KWim8jQGDMg== 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:xeNEKGBH4peF5bwvaAlQBr3j8TZGTlrB56i1UmXN7?= =?us-ascii?Q?UsG97g6zvufe8rAmWgmUEyEFhr/rSoAAP8QX3Qqojcg8ooczvf9UO5UzrLt1?= =?us-ascii?Q?LVItAJhlvWl2wos4pedDrFyivCK288sdbO7IQ2EBxB+8xe6mikrq63uhQ3Fd?= =?us-ascii?Q?QDcI0/E6u0bwsjk4s6n5KKg/ViUDx2FZjQd8lwNyRFBamsYUUXau7ePsBHJ+?= =?us-ascii?Q?oZ1JOfAQ3R53NBGKvKP2zoM7x7gpmqehkbqPrHRMnQBEAvpZ7dah4Ku68uUe?= =?us-ascii?Q?aVIzH44yv1BoULBZUjY9HazvKe+AIBO+YDVyjENlWic5UIZcMdHaNAF5QQeB?= =?us-ascii?Q?WUfvOdnF7PzH7N4UBMYiWtkXxhIWAkR0IyHz217BrzTABnt4ce7aIJj3qS3S?= =?us-ascii?Q?Dl+LDPoiIRMvI85pCCFD55pAEcGW1g8jMJ1YNbAwsjbbUA+//V3Op6/j7kb1?= =?us-ascii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qsANh3tB0p5geToJd38cUpaljfc+7P6WbvDUH+f7lw9mXCrwOZjjaCXNQlcaooro6+pDg9hOqMtpjd0M4FXJeXsOgYwpAHXRdlhqPKyu6uFPj3RTFGMdD/lmO1SEA+wslPPxF0blIKiRnQzk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 15:19:51.5429 (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/deselect ops to be in terms of the i2c mux core instead of the child adapter. Reviewed-by: Antti Palosaari Signed-off-by: Peter Rosin --- drivers/media/dvb-frontends/rtl2832.c | 25 ++++++++++++++----------- drivers/media/dvb-frontends/rtl2832_priv.h | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c index 7c96f7679669..1b23788797b5 100644 --- a/drivers/media/dvb-frontends/rtl2832.c +++ b/drivers/media/dvb-frontends/rtl2832.c @@ -847,9 +847,9 @@ err: dev_dbg(&client->dev, "failed=%d\n", ret); } -static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) +static int rtl2832_select(struct i2c_mux_core *muxc, u32 chan_id) { - struct rtl2832_dev *dev = mux_priv; + struct rtl2832_dev *dev = i2c_mux_priv(muxc); struct i2c_client *client = dev->client; int ret; @@ -870,10 +870,9 @@ err: return ret; } -static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv, - u32 chan_id) +static int rtl2832_deselect(struct i2c_mux_core *muxc, u32 chan_id) { - struct rtl2832_dev *dev = mux_priv; + struct rtl2832_dev *dev = i2c_mux_priv(muxc); schedule_delayed_work(&dev->i2c_gate_work, usecs_to_jiffies(100)); return 0; @@ -1059,7 +1058,7 @@ static struct i2c_adapter *rtl2832_get_i2c_adapter(struct i2c_client *client) struct rtl2832_dev *dev = i2c_get_clientdata(client); dev_dbg(&client->dev, "\n"); - return dev->i2c_adapter_tuner; + return dev->muxc->adapter[0]; } static int rtl2832_slave_ts_ctrl(struct i2c_client *client, bool enable) @@ -1242,12 +1241,16 @@ static int rtl2832_probe(struct i2c_client *client, goto err_regmap_exit; /* create muxed i2c adapter for demod tuner bus */ - dev->i2c_adapter_tuner = i2c_add_mux_adapter(i2c, &i2c->dev, dev, - 0, 0, 0, rtl2832_select, rtl2832_deselect); - if (dev->i2c_adapter_tuner == NULL) { - ret = -ENODEV; + dev->muxc = i2c_mux_alloc(i2c, &i2c->dev, 1, 0, 0, + rtl2832_select, rtl2832_deselect); + if (!dev->muxc) { + ret = -ENOMEM; goto err_regmap_exit; } + dev->muxc->priv = dev; + ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0); + if (ret) + goto err_regmap_exit; /* create dvb_frontend */ memcpy(&dev->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); @@ -1282,7 +1285,7 @@ static int rtl2832_remove(struct i2c_client *client) cancel_delayed_work_sync(&dev->i2c_gate_work); - i2c_del_mux_adapter(dev->i2c_adapter_tuner); + i2c_mux_del_adapters(dev->muxc); regmap_exit(dev->regmap); diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h index 6b875f462f8b..d8f97d14f6fd 100644 --- a/drivers/media/dvb-frontends/rtl2832_priv.h +++ b/drivers/media/dvb-frontends/rtl2832_priv.h @@ -36,7 +36,7 @@ struct rtl2832_dev { struct mutex regmap_mutex; struct regmap_config regmap_config; struct regmap *regmap; - struct i2c_adapter *i2c_adapter_tuner; + struct i2c_mux_core *muxc; struct dvb_frontend fe; enum fe_status fe_status; u64 post_bit_error_prev; /* for old DVBv3 read_ber() calculation */