From: Joe Perches <joe@perches.com>
To: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
mchehab@kernel.org, sean@mess.org
Subject: Re: [PATCH v2] drivers/media/dvb-frontends: Implement probe/remove for stv6110x
Date: Wed, 29 May 2019 11:45:33 -0700 [thread overview]
Message-ID: <bcd12350374533ef090ae911be444e702e85134b.camel@perches.com> (raw)
In-Reply-To: <20190529165633.8779-1-tobias.johannes.klausmann@mni.thm.de>
On Wed, 2019-05-29 at 18:56 +0200, Tobias Klausmann wrote:
> Refactor out the common parts of stv6110x_probe() and stv6110x_attach()
> into separate functions.
>
> This provides the needed functionality to use dvb_module_probe() instead
> of dvb_attach()!
>
> v2:
> - Impovments based on comments by Sean Young
> - Fix checkpatch.pl --strict errors
trivia:
> diff --git a/drivers/media/dvb-frontends/stv6110x.c b/drivers/media/dvb-frontends/stv6110x.c
[]
> @@ -333,6 +333,41 @@ static void stv6110x_release(struct dvb_frontend *fe)
> kfree(stv6110x);
> }
>
> +void st6110x_init_regs(struct stv6110x_state *stv6110x)
> +{
> + u8 default_regs[] = {0x07, 0x11, 0xdc, 0x85, 0x17, 0x01, 0xe6, 0x1e};
static const u8...
> +
> + memcpy(stv6110x->regs, default_regs, 8);
memcpy(stv6110x->regs, default_regs, ARRAY_SIZE(default_regs));
> +}
> +
> +void stv6110x_setup_divider(struct stv6110x_state *stv6110x)
> +{
> + switch (stv6110x->config->clk_div) {
> + default:
> + case 1:
> + STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2],
> + CTRL2_CO_DIV,
> + 0);
> + break;
> + case 2:
> + STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2],
> + CTRL2_CO_DIV,
> + 1);
> + break;
> + case 4:
> + STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2],
> + CTRL2_CO_DIV,
> + 2);
> + break;
> + case 8:
> + case 0:
> + STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2],
> + CTRL2_CO_DIV,
> + 3);
> + break;
> + }
> +}
Probably more sensible (and smaller object code) written using
an automatic like:
{
int div;
switch (stv6110x->config->clk_div) {
case 8:
div = 3;
break;
case 4:
div = 2;
break;
case 2:
div = 1;
break;
case 1:
default:
div = 0;
break;
}
STV6110x_SETFIELD(stv6110x->regs[STV6110x_CTRL2], CTRL2_CO_DIV, div);
}
> diff --git a/drivers/media/dvb-frontends/stv6110x_priv.h b/drivers/media/dvb-frontends/stv6110x_priv.h
[]
> @@ -54,11 +54,12 @@
> #define REFCLOCK_MHz (stv6110x->config->refclk / 1000000)
>
> struct stv6110x_state {
> + struct dvb_frontend *frontend;
> struct i2c_adapter *i2c;
> const struct stv6110x_config *config;
> u8 regs[8];
Perhaps this 8 should be a define?
next prev parent reply other threads:[~2019-05-29 18:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 19:51 [PATCH] " Tobias Klausmann
2019-05-12 14:53 ` Tobias Klausmann
2019-05-26 9:33 ` Sean Young
2019-05-26 13:11 ` Tobias Klausmann
2019-05-29 16:56 ` [PATCH v2] " Tobias Klausmann
2019-05-29 18:45 ` Joe Perches [this message]
2019-05-29 19:03 ` Tobias Klausmann
2019-05-30 4:20 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bcd12350374533ef090ae911be444e702e85134b.camel@perches.com \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sean@mess.org \
--cc=tobias.johannes.klausmann@mni.thm.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®