From: Hiroshi Doyu <hdoyu@nvidia.com>
To: "joe@perches.com" <joe@perches.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [RFC 1/1] driver core: Add dev_*_ratelimited() family
Date: Mon, 14 May 2012 09:45:12 +0200 [thread overview]
Message-ID: <20120514.104512.775373956832728793.hdoyu@nvidia.com> (raw)
In-Reply-To: <1336975539.2656.21.camel@joe2Laptop>
Joe Perches <joe@perches.com> wrote @ Mon, 14 May 2012 08:05:39 +0200:
> On Mon, 2012-05-14 at 07:40 +0200, Hiroshi Doyu wrote:
> > Joe Perches <joe@perches.com> wrote @ Mon, 14 May 2012 07:25:55 +0200:
> > > On Mon, 2012-05-14 at 07:00 +0200, Hiroshi Doyu wrote:
> > > > Joe Perches <joe@perches.com> wrote @ Sat, 12 May 2012 17:31:35 +0200:
> > > > > On Sat, 2012-05-12 at 12:52 +0200, Hiroshi Doyu wrote:
> > > > > > An unclosed "if" statement in the MACRO seems a bit risky, but I don't
> > > > > > have any better/simple solution for this, ATM. Is there any alternative?
> > > > >
> > > > > maybe something like:
> > > > >
> > > > > #define dev_ratelimited_level(dev, level, fmt, ...)
> > > > > do {
> > > > > static DEFINE_RATELIMIT_STATE(_rs, \
> > > > > DEFAULT_RATELIMIT_INTERVAL, \
> > > > > DEFAULT_RATELIMIT_BURST); \
> > > > > if (__ratelimit(&_rs)) \
> > > > > dev_##level(fmt, ##__VA_ARGS__); \
> > > > > } while (0)
> > > > >
> > > > > #define dev_emerg_ratelimited(dev, fmt, ...) \
> > > > > dev_ratelimited_level(dev, emerg, fmt, ##__VA_ARGS__)
> [...]
> > > > > #define dev_dbg_ratelimited(dev, fmt, ...) \
> > > > > dev_ratelimited_level(dev, dbg, fmt, ##__VA_ARGS__)
> > > >
> > > > "dev" isn't handled separately with __VA_ARGS__, and failed to build
> > > > as below:
> > > >
> > > > Example:
> > > > dev_err_ratelimited(&pdev->dev, "%d\n", __LINE__);
> > > >
> > > > After preprocessded:
> > > > do { ... if (___ratelimit(&_rs, __func__)) dev_err("%d\n", 18); } while (0);
> > > >
> > >
> > > Sorry, I was just typing in the email client and
> > > I missed the "dev" argument.
> > >
> > > Add "dev" to the dev_##level statement like:
> > >
> > > #define dev_ratelimited_level(dev, level, fmt, ...) \
> > > do { \
> > > static DEFINE_RATELIMIT_STATE(_rs, \
> > > DEFAULT_RATELIMIT_INTERVAL, \
> > > DEFAULT_RATELIMIT_BURST); \
> > > if (__ratelimit(&_rs)) \
> > > dev_##level(dev, fmt, ##__VA_ARGS__); \
> > > } while (0)
> >
> > Verified that the above works. Would you mind sending the complete version of this patch?
>
> Hello Hiroshi.
>
> It's your patch and your idea.
> I think you should submit it.
> You were just asking for alternatives or a bit
> of guidance.
Thanks.
> Maybe a better name for dev_ratelimited_level is
> dev_level_ratelimited and the macro should be
>
> #define dev_level_ratelimited(dev_level, dev, fmt, ...) \
> do { \
> static DEFINE_RATELIMIT_STATE(_rs, \
> DEFAULT_RATELIMIT_INTERVAL, \
> DEFAULT_RATELIMIT_BURST); \
> if (__ratelimit(&_rs)) \
> dev_level(dev, fmt, ##__VA_ARGS__); \
> } while (0)
>
> with uses like
>
> #define dev_notice_ratelimited(dev, fmt, ...) \
> dev_level_ratelimited(dev_notice, fmt, ##__VA_ARGS__)
>
>
> Your choice though I think the last option above
> may be better because it more closely follows the
> style a dev_printk_ratelimited would use.
Agree. The complete version of the above patch follows this email.
next prev parent reply other threads:[~2012-05-14 7:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-12 10:52 Hiroshi Doyu
2012-05-12 11:32 ` Bernd Petrovitsch
2012-05-12 15:31 ` Joe Perches
2012-05-14 5:00 ` Hiroshi Doyu
2012-05-14 5:25 ` Joe Perches
2012-05-14 5:40 ` Hiroshi Doyu
2012-05-14 6:05 ` Joe Perches
2012-05-14 7:45 ` Hiroshi Doyu [this message]
2012-05-14 7:47 ` [PATCH 1/2] " Hiroshi DOYU
2012-05-14 7:47 ` [PATCH 2/2] memory: tegra{20,30}-mc: Use dev_err_ratelimited() Hiroshi DOYU
2012-05-14 10:07 ` [v2 1/1] " Hiroshi DOYU
2012-05-14 18:33 ` Stephen Warren
2012-05-14 18:57 ` Hiroshi Doyu
2012-05-14 19:09 ` Greg Kroah-Hartman
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=20120514.104512.775373956832728793.hdoyu@nvidia.com \
--to=hdoyu@nvidia.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
/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®