From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752456AbcAEPom (ORCPT ); Tue, 5 Jan 2016 10:44:42 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:36874 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752036AbcAEPoj (ORCPT ); Tue, 5 Jan 2016 10:44:39 -0500 Date: Tue, 5 Jan 2016 15:44:31 +0000 From: Mark Brown To: Chen Feng Cc: lee.jones@linaro.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, yudongbin@hisilicon.com, saberlily.xia@hisilicon.com, suzhuangluan@hisilicon.com, kong.kongxinwei@hisilicon.com, xuyiping@hisilicon.com, z.liuxinliang@hisilicon.com, puck.chenfeng@gmail.com, weidong2@hisilicon.com, w.f@huawei.com, qijiwen@hisilicon.com, peter.panshilin@hisilicon.com, dan.zhao@hisilicon.com, linuxarm@huawei.com, liguozhu@hisilicon.com, shimingxing@hisilicon.com, albert.lubing@hisilicon.com, oliver.fu@hisilicon.com, haojian.zhuang@linaro.org Message-ID: <20160105154431.GB6588@sirena.org.uk> References: <1451910472-126417-1-git-send-email-puck.chen@hisilicon.com> <1451910472-126417-5-git-send-email-puck.chen@hisilicon.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1UWUbFP1cBYEclgG" Content-Disposition: inline In-Reply-To: <1451910472-126417-5-git-send-email-puck.chen@hisilicon.com> X-Cookie: APL hackers do it in the quad. User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH v4 4/5] regulator: add regulator driver of hi655x pmic X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --1UWUbFP1cBYEclgG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jan 04, 2016 at 08:27:51PM +0800, Chen Feng wrote: > +/*LDO 2 & LDO 14*/ Please use the normal kernel coding style for comments, I'm surprised checkpatch didn't warn you about this. > +static const unsigned int ldo2_voltages[] = { > + 2500000, 2600000, 2700000, 2800000, > + 2900000, 3000000, 3100000, 3200000, This looks like a linear range from 2.5V in steps of 100mV? A linear range is better than a table since values can be mapped directly without having to scan a table. > +/*LDO7 & LDO10*/ > +static const unsigned int ldo7_voltages[] = { > + 1800000, 1850000, 2850000, 2900000, > + 3000000, 3100000, 3200000, 3300000, This is the sort of thing a voltage table is for where the voltages aren't evenly spaced and don't map onto a formula. > +static const struct of_device_id of_hi655x_regulator_match_tbl[] = { > + { > + .compatible = "hisilicon,hi655x-regulator", > + }, > +}; > +MODULE_DEVICE_TABLE(of, of_hi655x_regulator_match_tbl); A couple of problems here. One is that the compatible strings should be for specific devices, not use a wildcard. The other is that since this is part of a PMIC and we already have a compatible string for the PMIC so this is really just a set of properties for that device rather than a totally separate device - we're not achieving any real reuse over multiple devices or anything. > + for (i = 0; i < ARRAY_SIZE(regulators); i++) { > + if (!of_node_cmp(np->name, regulators[i].rdesc.name)) > + break; > + } > + > + if (i == ARRAY_SIZE(regulators)) { > + dev_err(dev, "error regulator %s int dts\n", np->name); > + return -ENODEV; > + } > + > + regulator = ®ulators[i]; > + init_data = of_get_regulator_init_data(dev, np, > + ®ulator->rdesc); > + if (!init_data) > + return -EINVAL; Don't open code this, use the standard support with of_match and regulators_node. > + config.dev = dev; > + config.init_data = init_data; > + config.driver_data = regulator; > + config.regmap = pmic->regmap; > + config.of_node = pdev->dev.of_node; > + rdev = devm_regulator_register(dev, ®ulator->rdesc, > + &config); > + if (IS_ERR(rdev)) > + return PTR_ERR(rdev); Though this looks like it's trying to have a device per regulator which is an unusual pattern and if we are doing that then relying on the node name to figure out which device this is a bit broken. --1UWUbFP1cBYEclgG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWi+TeAAoJECTWi3JdVIfQzg4H/2siyUd+S+lUJckUF165EmNt TxA07QQ+JoxyqfmQsqZn3YVOQp6msedF4eWs9qiXdu8uhw/OmJlkBmE9c7SfTJSp nw8GR4mt+nPTCS+jzScO9iVZMHl798oJS122yfZbPNaSmeNDq/hTVR257l4tti2I b/T5jIKjpX1P6aXQKr8ixN6w1lfM+X4uWYyLKz/L30HdLaEsViixJLkFpS7WUfKo PY58c7R7g4bSfjvz8F62ncqDXfYBXIBj2ylXJNzVbS1jDrQwfO0GGwUTm0Bv5T8+ uGAxiK6dda3/hMfKPl4z9tcOqbV/RsEBmitT+JOGNATiA0HdtjIfD+TIP5jXoMw= =xL9N -----END PGP SIGNATURE----- --1UWUbFP1cBYEclgG--