From patchwork Sat Feb 17 15:03:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10226227 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 7D1C1602CB for ; Sat, 17 Feb 2018 15:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7933228B05 for ; Sat, 17 Feb 2018 15:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E0DC28C71; Sat, 17 Feb 2018 15:03:44 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 11F4428B05 for ; Sat, 17 Feb 2018 15:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751112AbeBQPDl (ORCPT ); Sat, 17 Feb 2018 10:03:41 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50407 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbeBQPDh (ORCPT ); Sat, 17 Feb 2018 10:03:37 -0500 Received: by mail-wm0-f68.google.com with SMTP id k87so7929474wmi.0 for ; Sat, 17 Feb 2018 07:03:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9CpOBE2NMdsDXNYXtZyfznAv2qgpODE7qgN6u9/hCLk=; b=QFOpJ76aUKJnC1Y4Hdrvgu+YnvaW1cFN67N2dZavjvB3kh894dzakFm+funvPUhjQx bvxTzeQ0O41yfd+RPkw/7SvwHLtnnZStLfLbD87biNYckKtGyfbsSKNtuorT1rI/Fr+v kQBsvSawgbfM0j+eqM4RGR91W0B3lASeuOlkPCmrQ7PJssMGZFqRnWw3XWlwEGFOg8NI 1VRqK2W5/1FWRM4wctBIpKOkanzd80+t4MdB37i13ssdM5pOvUlywS6D/EoeD8c4Kzgx Vy0nzp+74UahOq+2k+bWzfIgIrS6WsTKyIop2Qyf8xxV+y6ZT/WGjV0O87CeubfPW42c q1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9CpOBE2NMdsDXNYXtZyfznAv2qgpODE7qgN6u9/hCLk=; b=bkx7Bhc/FSVOefyZ/LZWylpx2FEdEBZxBBUHJA2I+ZNLeKuwYD6jhVbKA8/BE+awey EnRM5hM7RZ78kmlhVLKXSAu00K16tFvnyaqyVWXASCNUKK3SxjLQ8/nWVcscsRLVlUCs xtOzhaxCFKOhLRZ3l8ydfDDjjVThLSKUwuiUxZVSd83U+nm+BzzALwPPayp0IbUJKJsX L5QnRegK7DToIlYW1f6uYHig6i0GBKhRlC0REBkTZH2SfJA/vvyb4BST/Uwjks3OJL2e MvU6wxq4qCcUyNAFt1ku+cy/GE0fCkbDJofPGFK80pSI66Muwrwmp7Mdzcx8N76ncKD7 8jfg== X-Gm-Message-State: APf1xPBFUc/syByE/Jqtw/2VOL+otJtGQyfrNWTYvWNOlhpJXYMjdsim T3u/x+x7LxF51ony+FQDZvcJKQ== X-Google-Smtp-Source: AH8x226WKyijQ0QXA0I/18aHnlaXdQ8T0EbaIb2fahH0E2Anppp/G2Xut949sbGifXM1qWDttXer5A== X-Received: by 10.28.144.20 with SMTP id s20mr7871100wmd.149.1518879816400; Sat, 17 Feb 2018 07:03:36 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id f142sm2740628wme.15.2018.02.17.07.03.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 07:03:35 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Cc: jasmin@anw.at Subject: [PATCH v2 4/7] [media] ngene: adapt cxd2099 attach to the new i2c_client way Date: Sat, 17 Feb 2018 16:03:25 +0100 Message-Id: <20180217150328.686-5-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180217150328.686-1-d.scheller.oss@gmail.com> References: <20180217150328.686-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Change the way the cxd2099 hardware is being attached to the new I2C client interface way. Also, add I2C_FUNC_I2C to the I2C interface functionality. Signed-off-by: Daniel Scheller Signed-off-by: Jasmin Jessich --- drivers/media/pci/ngene/ngene-core.c | 41 ++++++++++++++++++++++++++++++++---- drivers/media/pci/ngene/ngene-i2c.c | 2 +- drivers/media/pci/ngene/ngene.h | 1 + 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c index 8c92cb7f7e72..80db777cb7ec 100644 --- a/drivers/media/pci/ngene/ngene-core.c +++ b/drivers/media/pci/ngene/ngene-core.c @@ -1562,9 +1562,8 @@ static int init_channels(struct ngene *dev) return 0; } -static struct cxd2099_cfg cxd_cfg = { +static const struct cxd2099_cfg cxd_cfgtmpl = { .bitrate = 62000, - .adr = 0x40, .polarity = 0, .clock_mode = 0, }; @@ -1572,18 +1571,52 @@ static struct cxd2099_cfg cxd_cfg = { static void cxd_attach(struct ngene *dev) { struct ngene_ci *ci = &dev->ci; + struct cxd2099_cfg cxd_cfg = cxd_cfgtmpl; + struct i2c_client *client; + struct i2c_board_info board_info = { + .type = "cxd2099", + .addr = 0x40, + .platform_data = &cxd_cfg, + }; + + cxd_cfg.en = &ci->en; + + request_module(board_info.type); + + client = i2c_new_device(&dev->channel[0].i2c_adapter, &board_info); + if (!client || !client->dev.driver) + goto err_ret; + + if (!try_module_get(client->dev.driver->owner)) + goto err_i2c; + + if (!ci->en) + goto err_i2c; - ci->en = cxd2099_attach(&cxd_cfg, dev, &dev->channel[0].i2c_adapter); ci->dev = dev; + dev->channel[0].i2c_client[0] = client; + return; + +err_i2c: + i2c_unregister_device(client); +err_ret: + printk(KERN_ERR DEVICE_NAME ": CXD2099AR attach failed\n"); return; } static void cxd_detach(struct ngene *dev) { struct ngene_ci *ci = &dev->ci; + struct i2c_client *client; dvb_ca_en50221_release(ci->en); - kfree(ci->en); + + client = dev->channel[0].i2c_client[0]; + if (client) { + module_put(client->dev.driver->owner); + i2c_unregister_device(client); + } + ci->en = NULL; } diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c index 3004947f300b..092d46c2a3a9 100644 --- a/drivers/media/pci/ngene/ngene-i2c.c +++ b/drivers/media/pci/ngene/ngene-i2c.c @@ -147,7 +147,7 @@ static int ngene_i2c_master_xfer(struct i2c_adapter *adapter, static u32 ngene_i2c_functionality(struct i2c_adapter *adap) { - return I2C_FUNC_SMBUS_EMUL; + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; } static const struct i2c_algorithm ngene_i2c_algo = { diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h index 02dbd18f92d0..caf8602c7459 100644 --- a/drivers/media/pci/ngene/ngene.h +++ b/drivers/media/pci/ngene/ngene.h @@ -630,6 +630,7 @@ struct ngene_vopen { struct ngene_channel { struct device device; struct i2c_adapter i2c_adapter; + struct i2c_client *i2c_client[1]; struct ngene *dev; int number;