public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: Stephen Boyd <sboyd@kernel.org>, mturquette@baylibre.com
Cc: linux-clk@vger.kernel.org, robh@kernel.org,
	devicetree@vger.kernel.org, Daniel Mack <zonque@gmail.com>
Subject: Re: [PATCH v2 2/2] clk: Add driver for MAX9485
Date: Sat, 2 Jun 2018 13:14:25 +0200	[thread overview]
Message-ID: <6bcfa930-f317-dd20-b2d7-c708a7be5d6b@zonque.org> (raw)
In-Reply-To: <152792003850.225090.13213694533140196613@swboyd.mtv.corp.google.com>

Hi Stephen,

Thanks for the review!

On Saturday, June 02, 2018 08:13 AM, Stephen Boyd wrote:
> Quoting Daniel Mack (2018-05-25 11:20:58)

>> +enum {
>> +       MAX9485_FS_12KHZ        = 0 << 0,
>> +       MAX9485_FS_32KHZ        = 1 << 0,
>> +       MAX9485_FS_44_1KHZ      = 2 << 0,
>> +       MAX9485_FS_48KHZ        = 3 << 0,
>> +};
>> +
>> +enum {
>> +       MAX9485_SCALE_256       = 0 << 2,
>> +       MAX9485_SCALE_384       = 1 << 2,
>> +       MAX9485_SCALE_768       = 2 << 2,
>> +};
> 
> Any reason to be an enum? Maybe they can just be #defines.

No particular reason, but an enum shows these values are grouped 
together. But I can also turn them into defines, it's just a matter of 
taste I guess.

>> +struct max9485_driver_data {
>> +       struct clk *xclk;
>> +       struct i2c_client *client;
>> +       u8 reg_value;
>> +       unsigned long clkout_rate;
>> +       struct regulator *supply;
>> +       struct gpio_desc *reset_gpio;
>> +       struct max9485_clk_hw hw[MAX9485_NUM_CLKS];
>> +
>> +       struct {
>> +               struct clk_hw_onecell_data data;
>> +               struct clk_hw *hw[MAX9485_NUM_CLKS];
> 
> I don't quite understand this one. There's already an array of clk_hw
> pointers inside of clk_hw_onecell_data so just use that? But then
> there's also an array of max9485_clk_hw structures, so maybe roll your
> own clk_hw getter function?

Ah, yes. The latter makes most sense. I was somehow stuck with the idea 
that the onecell helper makes sense here. Thanks for the heads-up.

>> +static int max9485_update_bits(struct max9485_driver_data *drvdata,
>> +                              u8 mask, u8 value)
>> +{
>> +       int ret;
>> +
>> +       drvdata->reg_value &= ~mask;
>> +       drvdata->reg_value |= value;
>> +
>> +       dev_dbg(&drvdata->client->dev,
>> +               "updating mask %02x value %02x -> %02x\n",
>> +               mask, value, drvdata->reg_value);
>> +
>> +       ret = i2c_master_send(drvdata->client,
>> +                             &drvdata->reg_value,
>> +                             sizeof(drvdata->reg_value));
> 
> Maybe use a regmap instead? Then you could use regmap_update_bits() in
> the places you need it.

I wish, but nope, regmap doesn't work for devices that don't actually 
have registers, like this one. There's no extra byte for a register 
address or such, just one plain byte of payload.

[...]

>> +               return -ENOMEM;
>> +
>> +       drvdata->xclk = devm_clk_get(dev, "xclk");
>> +       if (IS_ERR(drvdata->xclk))
>> +               return PTR_ERR(drvdata->xclk);
>> +
>> +       freq = clk_get_rate(drvdata->xclk);
>> +       if (freq != MAX9485_INPUT_FREQ) {
>> +               dev_err(dev, "Illegal xclk frequency of %ld\n", freq);
>> +               return -EINVAL;
>> +       }
> 
> Is this necessary? Seems pretty useless to do everywhere to make sure
> that someone didn't design the hardware incorrectly. It would be better
> to return the rate of the parent "xclk" by not having a recalc_rate hook
> and relying on the parent's rate.

Hmm, but the hardware doesn't work if the clock is anything else than 
27.0MHz. But I'll remove the check no problem. After all, we don't check 
the regulator voltages either.

I've addressed all other comments. Will resend v3.


Thanks again!
Daniel

      reply	other threads:[~2018-06-02 11:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 18:20 [PATCH v2 0/2] clk: Add driver for MAX9485 Daniel Mack
2018-05-25 18:20 ` [PATCH v2 1/2] dts: clk: add devicetree bindings " Daniel Mack
2018-05-31  3:37   ` Rob Herring
2018-05-25 18:20 ` [PATCH v2 2/2] clk: Add driver " Daniel Mack
2018-05-31  5:28   ` Daniel Mack
2018-06-02  6:13   ` Stephen Boyd
2018-06-02 11:14     ` Daniel Mack [this message]

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=6bcfa930-f317-dd20-b2d7-c708a7be5d6b@zonque.org \
    --to=daniel@zonque.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=zonque@gmail.com \
    /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