Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753758Ab2ELPbx (ORCPT ); Sat, 12 May 2012 11:31:53 -0400 Received: from perches-mx.perches.com ([206.117.179.246]:49678 "EHLO labridge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751244Ab2ELPbh (ORCPT ); Sat, 12 May 2012 11:31:37 -0400 Message-ID: <1336836695.17605.12.camel@joe2Laptop> Subject: Re: [RFC 1/1] driver core: Add dev_*_ratelimited() family From: Joe Perches To: Hiroshi Doyu Cc: "linux-kernel@vger.kernel.org" , "linux-tegra@vger.kernel.org" Date: Sat, 12 May 2012 08:31:35 -0700 In-Reply-To: <20120512.135227.1196366807162247040.hdoyu@nvidia.com> References: <20120512.135227.1196366807162247040.hdoyu@nvidia.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1571 Lines: 40 On Sat, 2012-05-12 at 12:52 +0200, Hiroshi Doyu wrote: > Hi, > > 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_alert_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, alert, fmt, ##__VA_ARGS__) #define dev_crit_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, crit, fmt, ##__VA_ARGS__) #define dev_err_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, err, fmt, ##__VA_ARGS__) #define dev_warn_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, warn, fmt, ##__VA_ARGS__) #define dev_notice_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, notice, fmt, ##__VA_ARGS__) #define dev_info_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, info, fmt, ##__VA_ARGS__) #define dev_dbg_ratelimited(dev, fmt, ...) \ dev_ratelimited_level(dev, dbg, fmt, ##__VA_ARGS__) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/