mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremy Kerr <jeremy.kerr@canonical.com>
To: MyungJoo Ham <myungjoo.ham@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Ben Herrenchmidt <benh@kernel.crashing.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] Add a common struct clk
Date: Mon, 12 Jul 2010 10:19:13 +0800	[thread overview]
Message-ID: <1278901153.9235.6.camel@pororo.lan> (raw)
In-Reply-To: <AANLkTilitnz8eiBclky74FTOeKua3LjM3cbRdfwzkpnW@mail.gmail.com>

Hi MyungJoo,

> > +int clk_enable(struct clk *clk)
> > +{
> > +       int ret = 0;
> > +
> > +       if (!clk->ops->enable)
> > +               return 0;
> 
> Wouldn't it be better (safer?) to check "clk" and "clk->ops" before
> accessing clk->ops->enable?
> For example,
> 
>         if (IS_ERR_OR_NULL(clk))
>                 return -EINVAL;
> 
>         if (!clk->ops || !clk->ops->enable)
>                 return 0;
> 
> Or, do you think it'd be better not to check and save some time?
> 
> Anyway, if we intend to check the input, the patch for the patch
> including kernel/clk.c would be...

I think that we should leave it as-is; although it may be 'safer', it
may mean more subtle bugs can arise because we've been handed an invalid
clock pointer.

I'd rather the code oops on first usage so that the developer realises
that something is broken, rather than fail with an error code.

BTW - nice work on the samsung implementation, I will check it out soon.

Cheers,


Jeremy


  reply	other threads:[~2010-07-12  2:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21  5:35 [PATCH 0/2] Common struct clk implementation, v5 Jeremy Kerr
2010-06-21  5:35 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-06-21 20:43   ` Ryan Mallon
2010-06-22  1:05     ` Jeremy Kerr
2010-06-21  5:35 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-06-22  4:43   ` Baruch Siach
2010-07-05  2:33   ` MyungJoo Ham
2010-07-12  2:19     ` Jeremy Kerr [this message]
2010-06-21  7:54 ` [PATCH 0/2] Common struct clk implementation, v5 Linus Walleij
2010-07-12  2:37 [PATCH 0/2] Common struct clk implementation, v6 Jeremy Kerr
2010-07-12  2:37 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-12-08  2:05 Jeremy Kerr
2010-12-08 10:21 ` Uwe Kleine-König
2010-12-10  1:58   ` Jeremy Kerr
2010-12-08  2:08 [PATCH 0/2] Common struct clk implementation, v8 Jeremy Kerr
2010-12-08  2:08 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-01-05  3:51 [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-05  3:51 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-01-06 16:07   ` Richard Cochran
2011-01-06 20:11     ` Uwe Kleine-König
2011-01-07  0:10       ` Jeremy Kerr
2011-01-07  0:32         ` Russell King - ARM Linux
2011-01-07  9:40           ` Uwe Kleine-König
2011-01-08 13:15   ` Sascha Hauer
2011-01-10  2:43     ` Jeremy Kerr
2011-01-10 10:41       ` Sascha Hauer
2011-01-10 11:00         ` Russell King - ARM Linux
2011-01-11  0:54           ` Jeremy Kerr
2011-01-16  7:26             ` Grant Likely
2011-01-16 20:41               ` Ryan Mallon
2011-01-16 21:07                 ` Uwe Kleine-König
2011-01-16 21:39                   ` Ryan Mallon
2011-01-11 10:16   ` Sascha Hauer
2011-01-11 10:27     ` Jeremy Kerr
2011-01-11 11:22       ` Sascha Hauer
2011-01-18  8:44         ` Paul Mundt
2011-01-18  9:21           ` Sascha Hauer
2011-01-18  9:23             ` Paul Mundt
2011-01-18 12:21   ` Russell King - ARM Linux
2011-02-21  2:50 [PATCH 0/2] Common struct clk implementation, v13 Jeremy Kerr
2011-02-21  2:50 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-02-22 20:17   ` Uwe Kleine-König
2011-02-23  2:49     ` Jeremy Kerr
2011-03-03  6:40 [PATCH 0/2] Common struct clk implementation, v14 Jeremy Kerr
2011-03-03  6:40 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-04-14 12:49   ` Tony Lindgren

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=1278901153.9235.6.camel@pororo.lan \
    --to=jeremy.kerr@canonical.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@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

all inboxes | Powered by JetHome®