From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH 1/7] debugfs: Add debugfs_create_xul() for hexadecimal unsigned long Date: Mon, 21 Oct 2019 08:37:26 -0700 Message-ID: <0f91839d858fcb03435ebc85e61ee4e75371ff37.camel@perches.com> References: <20191021143742.14487-1-geert+renesas@glider.be> <20191021143742.14487-2-geert+renesas@glider.be> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20191021143742.14487-2-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org To: Geert Uytterhoeven , Greg Kroah-Hartman , Ludovic Desroches , Ulf Hansson , Nicolas Ferre , Alexandre Belloni , Jaehoon Chung , "David S . Miller" , "Rafael J . Wysocki" , Johannes Berg Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-mmc@vger.kernel.org On Mon, 2019-10-21 at 16:37 +0200, Geert Uytterhoeven wrote: > The existing debugfs_create_ulong() function supports objects of > type "unsigned long", which are 32-bit or 64-bit depending on the > platform, in decimal form. To format objects in hexadecimal, various > debugfs_create_x*() functions exist, but all of them take fixed-size > types. > > Add a debugfs helper for "unsigned long" objects in hexadecimal format. > This avoids the need for users to open-code the same, or introduce > bugs when casting the value pointer to "u32 *" or "u64 *" to call > debugfs_create_x{32,64}(). [] > diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h [] > @@ -356,4 +356,14 @@ static inline ssize_t debugfs_write_file_bool(struct file *file, > > #endif > > +static inline void debugfs_create_xul(const char *name, umode_t mode, > + struct dentry *parent, > + unsigned long *value) > +{ > + if (sizeof(*value) == sizeof(u32)) > + debugfs_create_x32(name, mode, parent, (u32 *)value); > + else > + debugfs_create_x64(name, mode, parent, (u64 *)value); trivia: the casts are unnecessary. This might be more sensible using #ifdef static inline void debugfs_create_xul(const char *name, umode_t mode, struct dentry *parent, unsigned long *value) { #if BITS_PER_LONG == 64 debugfs_create_x64(name, mode, parent, value); #else debugfs_create_x32(name, mode, parent, value); #endif } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62AC6CA9EAF for ; Mon, 21 Oct 2019 15:37:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34A3B2077C for ; Mon, 21 Oct 2019 15:37:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pTj0/4IH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34A3B2077C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uVTpAFOq3czApkHrSfgERyQTuXrK74CKYDtoj4QG+AY=; b=pTj0/4IHeKeiTT A+Yl+Hl7z69e5lFe3jBDUxKxgEAai6NPjJdDlJx9PgLDtwQ0jyo1cBt9WRammVfjGcLVyPqYmkM3e 9v8938iYxN3A3F+6ytbz22SKPCQV/M6kfu8jwvv7qMnz0EB6n0i0tzykdDJYMa5JW0IBe+stL9VY5 XKich3F/11qHMwSaCN4iJW5F3O+0BQn6a4rNrxceKPLT8+7nZ36euBw46tcP3wETFTaHEjIjDfTpO UVJMQ3LJj7Rpp2b8QXer+pxkyCM8y9xmB6DelBj41M+Bp2xW7v8pWTYCBEtTmQfn43rf73I+TA2HQ hRsODajv0V5xzO8u2kHA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMZkk-0002HQ-Aq; Mon, 21 Oct 2019 15:37:50 +0000 Received: from smtprelay0063.hostedemail.com ([216.40.44.63] helo=smtprelay.hostedemail.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMZkh-0002GW-GH for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2019 15:37:48 +0000 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 1B985182CF66C; Mon, 21 Oct 2019 15:37:30 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: dolls01_240eb4bb83a00 X-Filterd-Recvd-Size: 2849 Received: from XPS-9350.home (unknown [47.151.135.224]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Mon, 21 Oct 2019 15:37:27 +0000 (UTC) Message-ID: <0f91839d858fcb03435ebc85e61ee4e75371ff37.camel@perches.com> Subject: Re: [PATCH 1/7] debugfs: Add debugfs_create_xul() for hexadecimal unsigned long From: Joe Perches To: Geert Uytterhoeven , Greg Kroah-Hartman , Ludovic Desroches , Ulf Hansson , Nicolas Ferre , Alexandre Belloni , Jaehoon Chung , "David S . Miller" , "Rafael J . Wysocki" , Johannes Berg Date: Mon, 21 Oct 2019 08:37:26 -0700 In-Reply-To: <20191021143742.14487-2-geert+renesas@glider.be> References: <20191021143742.14487-1-geert+renesas@glider.be> <20191021143742.14487-2-geert+renesas@glider.be> User-Agent: Evolution 3.32.1-2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_083747_611496_A6BCF147 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 2019-10-21 at 16:37 +0200, Geert Uytterhoeven wrote: > The existing debugfs_create_ulong() function supports objects of > type "unsigned long", which are 32-bit or 64-bit depending on the > platform, in decimal form. To format objects in hexadecimal, various > debugfs_create_x*() functions exist, but all of them take fixed-size > types. > > Add a debugfs helper for "unsigned long" objects in hexadecimal format. > This avoids the need for users to open-code the same, or introduce > bugs when casting the value pointer to "u32 *" or "u64 *" to call > debugfs_create_x{32,64}(). [] > diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h [] > @@ -356,4 +356,14 @@ static inline ssize_t debugfs_write_file_bool(struct file *file, > > #endif > > +static inline void debugfs_create_xul(const char *name, umode_t mode, > + struct dentry *parent, > + unsigned long *value) > +{ > + if (sizeof(*value) == sizeof(u32)) > + debugfs_create_x32(name, mode, parent, (u32 *)value); > + else > + debugfs_create_x64(name, mode, parent, (u64 *)value); trivia: the casts are unnecessary. This might be more sensible using #ifdef static inline void debugfs_create_xul(const char *name, umode_t mode, struct dentry *parent, unsigned long *value) { #if BITS_PER_LONG == 64 debugfs_create_x64(name, mode, parent, value); #else debugfs_create_x32(name, mode, parent, value); #endif } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel