Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1845186imm; Wed, 16 May 2018 04:05:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo70SzmkF23/V7sgcrWYMlTkf9zyqF2F3CnB88S9b15y/PFoSNM0Wp2MUdOKNr7rYq5VArJ X-Received: by 2002:a17:902:8486:: with SMTP id c6-v6mr456319plo.23.1526468725829; Wed, 16 May 2018 04:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526468725; cv=none; d=google.com; s=arc-20160816; b=YdK75O0nCE9RuW2EtvFc48X/ZG1acjZupXVfXvecamUWq4sZEev+CIcAUpTcl5uqrK mfK6zgOD9eDNP8PBlKYFCj0yxcryXZgLgkHMK8iTl06cdJpcs5tSU3iMLYff8sGnN8w9 zJ86PY8eoVzcAHKciN3VpeKRsHMUat/UxctsnyzyZCAE0O6wwdYwVyKQD5OY5TWROuSX 8nBAHMXhvLPE5UYYCuLWd4iF6flMQuT5diVSyuPpPSsB1yTWJj6Gd1EwRSWFLUa8tZLJ tKeKApDXLvk3STTAD9YHNawxreAvsJWDiD1OnNpqeohL7sK8mq5ZdZTJZkTHO1PJ7T7K ruNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ERexJY8D7Q7TwTY+rF0HZrqO95HRBAXSeMjNEpqzqT0=; b=KOHxWU9xZOjFMaAkC5LWx3f5plr+hq0oi8hfEwFfhQwYYLj3vbeCPOXByJC4u0iUnP rBhqVZ80AAHu77rGHLJs7FKBxdnRNrK46T8fX6IPCqCvivhgyMM9IiNvKO36E+aYO5qh exUGs8JZ8lokENkbg2zEkra5KsYcd67YHxR5C1DAv43CQMCBcDvtI5y/F5T6/x0/Dtv2 1z4OCGdIMBbN4SY5uA2goUYL7KyWzRCirQr/z+Vil+kjxPrwjl3VP8y4sqAwEmVEw3Hk JYRD1WTytmlbgxCaK6oT/Jqgpkgr4Fc9jojGwZpa31AZbcnlm8/mPTo5Z8km3GW9lKWh IHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@netup.ru header.s=imap header.b=PuFYmN+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=netup.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18-v6si1826286pgv.202.2018.05.16.04.05.08; Wed, 16 May 2018 04:05:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@netup.ru header.s=imap header.b=PuFYmN+q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=netup.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608AbeEPLEu (ORCPT + 99 others); Wed, 16 May 2018 07:04:50 -0400 Received: from imap.netup.ru ([77.72.80.14]:37784 "EHLO imap.netup.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbeEPLEq (ORCPT ); Wed, 16 May 2018 07:04:46 -0400 Received: from mail-pg0-f46.google.com (mail-pg0-f46.google.com [74.125.83.46]) by imap.netup.ru (Postfix) with ESMTPSA id C94E9F820A4; Wed, 16 May 2018 13:58:10 +0300 (MSK) X-DKIM: OpenDKIM Filter v2.6.8 imap.netup.ru C94E9F820A4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=netup.ru; s=imap; t=1526468291; bh=Jdun7nHMqMgX3Feev0AExZT62FroeFevDiN9W221E1M=; h=In-Reply-To:References:From:Date:Subject:To:Cc; b=PuFYmN+qQ/TcvoaQLvTTMX5TInz/J6j5/DFFdxjxO8lvsnEiWsHrMpk6i5WDZSw16 Hjlg9AOkD2ywqpak3fOUb4+byESy/lAJIhdOlBEKtcOR6BIGyWVLSdbaNvQmPoclIE Z0V4WyMkuocEdVdnBLtoRy2CKDEe+jipHp5j1Ffg= Received: by mail-pg0-f46.google.com with SMTP id w4-v6so124701pgq.8; Wed, 16 May 2018 03:58:10 -0700 (PDT) X-Gm-Message-State: ALKqPwdOtaWIt99KiSQL1N4UolAEDdxhwkLFC0+I7FUGkAGHsQKV13wT oqVolkVwx8DmYrxlI4XpDOadzhO0ZOhT7sRHze8= X-Received: by 2002:a65:4586:: with SMTP id o6-v6mr312427pgq.197.1526468288374; Wed, 16 May 2018 03:58:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:8598:0:0:0:0 with HTTP; Wed, 16 May 2018 03:57:48 -0700 (PDT) In-Reply-To: <20180516083753.15510-1-suzuki.katsuhiro@socionext.com> References: <20180516083753.15510-1-suzuki.katsuhiro@socionext.com> From: Abylay Ospan Date: Wed, 16 May 2018 06:57:48 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] media: helene: add I2C device probe function To: Katsuhiro Suzuki Cc: Mauro Carvalho Chehab , linux-media , Masami Hiramatsu , Jassi Brar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Katsuhiro, Thanks for patch. What is the purpose to rework helene_set_params(_t|_s) ? other part of this patch looks ok for me, but not tested due to lack of spare time ;( 2018-05-16 4:37 GMT-04:00 Katsuhiro Suzuki : > This patch adds I2C probe function to use dvb_module_probe() > with this driver. > > Signed-off-by: Katsuhiro Suzuki > > --- > > Changes since v1: > - Add documents for dvb_frontend member of helene_config > --- > drivers/media/dvb-frontends/helene.c | 88 ++++++++++++++++++++++++++-- > drivers/media/dvb-frontends/helene.h | 3 + > 2 files changed, 87 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c > index a0d0b53c91d7..04033f0c278b 100644 > --- a/drivers/media/dvb-frontends/helene.c > +++ b/drivers/media/dvb-frontends/helene.c > @@ -666,7 +666,7 @@ static int helene_set_params_s(struct dvb_frontend *fe) > return 0; > } > > -static int helene_set_params(struct dvb_frontend *fe) > +static int helene_set_params_t(struct dvb_frontend *fe) > { > u8 data[MAX_WRITE_REGSIZE]; > u32 frequency; > @@ -835,6 +835,19 @@ static int helene_set_params(struct dvb_frontend *fe) > return 0; > } > > +static int helene_set_params(struct dvb_frontend *fe) > +{ > + struct dtv_frontend_properties *p = &fe->dtv_property_cache; > + > + if (p->delivery_system == SYS_DVBT || > + p->delivery_system == SYS_DVBT2 || > + p->delivery_system == SYS_ISDBT || > + p->delivery_system == SYS_DVBC_ANNEX_A) > + return helene_set_params_t(fe); > + > + return helene_set_params_s(fe); > +} > + > static int helene_get_frequency(struct dvb_frontend *fe, u32 *frequency) > { > struct helene_priv *priv = fe->tuner_priv; > @@ -843,7 +856,7 @@ static int helene_get_frequency(struct dvb_frontend *fe, u32 *frequency) > return 0; > } > > -static const struct dvb_tuner_ops helene_tuner_ops = { > +static const struct dvb_tuner_ops helene_tuner_ops_t = { > .info = { > .name = "Sony HELENE Ter tuner", > .frequency_min = 1000000, > @@ -853,7 +866,7 @@ static const struct dvb_tuner_ops helene_tuner_ops = { > .init = helene_init, > .release = helene_release, > .sleep = helene_sleep, > - .set_params = helene_set_params, > + .set_params = helene_set_params_t, > .get_frequency = helene_get_frequency, > }; > > @@ -871,6 +884,20 @@ static const struct dvb_tuner_ops helene_tuner_ops_s = { > .get_frequency = helene_get_frequency, > }; > > +static const struct dvb_tuner_ops helene_tuner_ops = { > + .info = { > + .name = "Sony HELENE Sat/Ter tuner", > + .frequency_min = 500000, > + .frequency_max = 1200000000, > + .frequency_step = 1000, > + }, > + .init = helene_init, > + .release = helene_release, > + .sleep = helene_sleep, > + .set_params = helene_set_params, > + .get_frequency = helene_get_frequency, > +}; > + > /* power-on tuner > * call once after reset > */ > @@ -1032,7 +1059,7 @@ struct dvb_frontend *helene_attach(struct dvb_frontend *fe, > if (fe->ops.i2c_gate_ctrl) > fe->ops.i2c_gate_ctrl(fe, 0); > > - memcpy(&fe->ops.tuner_ops, &helene_tuner_ops, > + memcpy(&fe->ops.tuner_ops, &helene_tuner_ops_t, > sizeof(struct dvb_tuner_ops)); > fe->tuner_priv = priv; > dev_info(&priv->i2c->dev, > @@ -1042,6 +1069,59 @@ struct dvb_frontend *helene_attach(struct dvb_frontend *fe, > } > EXPORT_SYMBOL(helene_attach); > > +static int helene_probe(struct i2c_client *client, > + const struct i2c_device_id *id) > +{ > + struct helene_config *config = client->dev.platform_data; > + struct dvb_frontend *fe = config->fe; > + struct device *dev = &client->dev; > + struct helene_priv *priv; > + > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->i2c_address = client->addr; > + priv->i2c = client->adapter; > + priv->set_tuner_data = config->set_tuner_priv; > + priv->set_tuner = config->set_tuner_callback; > + priv->xtal = config->xtal; > + > + if (fe->ops.i2c_gate_ctrl) > + fe->ops.i2c_gate_ctrl(fe, 1); > + > + if (helene_x_pon(priv) != 0) > + return -EINVAL; > + > + if (fe->ops.i2c_gate_ctrl) > + fe->ops.i2c_gate_ctrl(fe, 0); > + > + memcpy(&fe->ops.tuner_ops, &helene_tuner_ops, > + sizeof(struct dvb_tuner_ops)); > + fe->tuner_priv = priv; > + i2c_set_clientdata(client, priv); > + > + dev_info(dev, "Sony HELENE attached on addr=%x at I2C adapter %p\n", > + priv->i2c_address, priv->i2c); > + > + return 0; > +} > + > +static const struct i2c_device_id helene_id[] = { > + { "helene", }, > + {} > +}; > +MODULE_DEVICE_TABLE(i2c, helene_id); > + > +static struct i2c_driver helene_driver = { > + .driver = { > + .name = "helene", > + }, > + .probe = helene_probe, > + .id_table = helene_id, > +}; > +module_i2c_driver(helene_driver); > + > MODULE_DESCRIPTION("Sony HELENE Sat/Ter tuner driver"); > MODULE_AUTHOR("Abylay Ospan "); > MODULE_LICENSE("GPL"); > diff --git a/drivers/media/dvb-frontends/helene.h b/drivers/media/dvb-frontends/helene.h > index c9fc81c7e4e7..8562d01bc93e 100644 > --- a/drivers/media/dvb-frontends/helene.h > +++ b/drivers/media/dvb-frontends/helene.h > @@ -39,6 +39,7 @@ enum helene_xtal { > * @set_tuner_callback: Callback function that notifies the parent driver > * which tuner is active now > * @xtal: Cristal frequency as described by &enum helene_xtal > + * @fe: Frontend for which connects this tuner > */ > struct helene_config { > u8 i2c_address; > @@ -46,6 +47,8 @@ struct helene_config { > void *set_tuner_priv; > int (*set_tuner_callback)(void *, int); > enum helene_xtal xtal; > + > + struct dvb_frontend *fe; > }; > > #if IS_REACHABLE(CONFIG_DVB_HELENE) > -- > 2.17.0 > -- Abylay Ospan, NetUP Inc. http://www.netup.tv