Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6704538ybi; Wed, 29 May 2019 11:47:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEHGG5tK5qFRN5BgiVom5vNsTSMmZqcqbXHAAUat7ijw1MMw/0TxzDjicitXIsm+cKllNp X-Received: by 2002:aa7:93ba:: with SMTP id x26mr90210152pff.238.1559155635912; Wed, 29 May 2019 11:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559155635; cv=none; d=google.com; s=arc-20160816; b=PcjXSCq5yleXj5RRfoh59pQAAMMEIdRv0gVINADpNkCshZORP9apApCexIC1s/cxn/ 9CgmverCM6mqh9QEKeXG4Fr08aNoCePPgFAbCaJLLqC8l/sHFwgec8FIs82sskK8yKkd oJBNPfKY5DW2Geo6HMvzo+V8dkpQ9iywVfDeBeBo+ExRhQw4JOns32nkTDNaFvyjiQjv BQ1kD/xnU7M1snJwQU4GvffXxC5ovcMOo0A2yXsVxLeF9Jjd9jBpaQwzC26gTeJo3ShD I4AyJJpookPvL1i2BG3ugK1txisOPZy3tKviP6K4zf/duRHkdrBn88v1OCQ02PXSnkTU MZsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id; bh=wxN02d6qexpDWdDxZBQAS2WUdn8+JzL+Fd5sogL3o94=; b=lBDDdr4BZiQGTMpaQjPBNCNo/Rs1HTj7+1fvaXOjaVwTyAldSs8O/HmDtQ/ZXRMBVI C0EYioxjlXJ1b0QopaV6FhJwQ2z3XPpC6mI7v9ED2j+Ad090eEgCo4mnOaY3oceLzdnr nhRamQI/S008iJ+p36z+nOq+wZALZqVq9jEJmX6o5gYNrkWhG51oXE8/GOF33dGyjpkl YAwPnBsIgMz0LqDLxaRVwCpo6T+BEKDXTNdzoez0JAJ6treE3M4ac28a8YlKFI7lkaDw HVohhAiLxEIRBQd77lDxYoUd41AuWmY4w+p7rpTrGOuWiHZQaKOS0WQ/tkFU/n7SGGqI EXRw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i98si465708plb.104.2019.05.29.11.46.59; Wed, 29 May 2019 11:47:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726131AbfE2Spj (ORCPT + 99 others); Wed, 29 May 2019 14:45:39 -0400 Received: from smtprelay0106.hostedemail.com ([216.40.44.106]:38670 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726012AbfE2Spj (ORCPT ); Wed, 29 May 2019 14:45:39 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 984F9100E86C2; Wed, 29 May 2019 18:45:37 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:599:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1381:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:4321:4385:5007:7875:7903:10004:10400:10848:11026:11232:11473:11658:11914:12043:12048:12296:12438:12555:12663:12740:12760:12895:13439:14181:14659:14721:21080:21451:21627:21789:30012:30054:30091,0,RBL:23.242.196.136:@perches.com:.lbl8.mailshell.net-62.14.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: mark05_4ddac67b04548 X-Filterd-Recvd-Size: 3252 Received: from XPS-9350 (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA; Wed, 29 May 2019 18:45:34 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] drivers/media/dvb-frontends: Implement probe/remove for stv6110x From: Joe Perches To: Tobias Klausmann , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, mchehab@kernel.org, sean@mess.org Date: Wed, 29 May 2019 11:45:33 -0700 In-Reply-To: <20190529165633.8779-1-tobias.johannes.klausmann@mni.thm.de> References: <20190509195118.23027-1-tobias.johannes.klausmann@mni.thm.de> <20190529165633.8779-1-tobias.johannes.klausmann@mni.thm.de> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?