From patchwork Sun Oct 18 17:13:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 55180 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 8293C22FFA for ; Sun, 18 Oct 2015 17:13:44 +0000 (UTC) Received: by wibhd5 with SMTP id hd5sf787818wib.0 for ; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=n82k9d0fgZpzt52IMvEnyOr/tH9jXNUedQi0yzCbxJs=; b=DHgr3EBAydOXjkoB66M0BzZHsKb4AIJuzk409ddJXvM+PLh+m46MVy4IdQMmlVsycs rIhmlPh1Z0iI50xRBK0WQgxu22CUBKN3jFxSx/6lhCbeF1PBeUyMlQ77KZ41gErEDqEm 0gIecscUrc569Lx0+oJC0bshs2ObWowblmUDkh5Dn5IQDyvPRMznGgR63UhQcrzutcZ0 Y97S4NsXseuyQAbix1E1PDqvqiNnMlZKtEF4l7WSG7f4OuDxZ3wS4slmfK6VALTzpVBX 6yAalJFyEn9xoVIdp5OttZxasqAobzOHRaY+n1inr1Tb1vpYB6C2rjp/d3t89FcnhEpV ccCA== X-Gm-Message-State: ALoCoQnjEPhmpE/lRBc4wFYtSntlhR9l2zw1K8pKF1CRh2Q3bGQ70CpeMibqEKoXdbEloxotDxVl X-Received: by 10.180.9.104 with SMTP id y8mr3449022wia.7.1445188423872; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.28.195 with SMTP id c186ls366644lfc.71.gmail; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) X-Received: by 10.25.19.97 with SMTP id j94mr8445555lfi.106.1445188423719; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id si9si716532lbb.44.2015.10.18.10.13.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 10:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lffy185 with SMTP id y185so97087177lff.2 for ; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) X-Received: by 10.25.28.73 with SMTP id c70mr6633025lfc.76.1445188423566; Sun, 18 Oct 2015 10:13:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1057369lbq; Sun, 18 Oct 2015 10:13:42 -0700 (PDT) X-Received: by 10.68.162.194 with SMTP id yc2mr6292488pbb.40.1445188422355; Sun, 18 Oct 2015 10:13:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si46034881pas.215.2015.10.18.10.13.42; Sun, 18 Oct 2015 10:13:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932117AbbJRRNk (ORCPT + 11 others); Sun, 18 Oct 2015 13:13:40 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33471 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932104AbbJRRNk (ORCPT ); Sun, 18 Oct 2015 13:13:40 -0400 Received: by pabrc13 with SMTP id rc13so166708329pab.0 for ; Sun, 18 Oct 2015 10:13:39 -0700 (PDT) X-Received: by 10.66.228.233 with SMTP id sl9mr29749597pac.139.1445188419750; Sun, 18 Oct 2015 10:13:39 -0700 (PDT) Received: from localhost ([120.59.207.68]) by smtp.gmail.com with ESMTPSA id zn9sm32274937pac.48.2015.10.18.10.13.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 18 Oct 2015 10:13:39 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: linaro-kernel@lists.linaro.org, Rafael Wysocki , linux-kernel@vger.kernel.org, arnd@arndb.de, sboyd@codeaurora.org, linux-pm@vger.kernel.org, linux@arm.linux.org.uk, stern@rowland.harvard.edu, Viresh Kumar Subject: [PATCH V4] debugfs: Add debugfs_create_ulong() Date: Sun, 18 Oct 2015 22:43:19 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add debugfs_create_ulong() for the users of type 'unsigned long'. These will be 32 bits long on a 32 bit machine and 64 bits long on a 64 bit machine. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- V3->V4: - Drop xlong APIs.. fs/debugfs/file.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 8450549d54a9..d2ba12e23ed9 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -243,6 +243,54 @@ struct dentry *debugfs_create_u64(const char *name, umode_t mode, } EXPORT_SYMBOL_GPL(debugfs_create_u64); +static int debugfs_ulong_set(void *data, u64 val) +{ + *(unsigned long *)data = val; + return 0; +} + +static int debugfs_ulong_get(void *data, u64 *val) +{ + *val = *(unsigned long *)data; + return 0; +} +DEFINE_SIMPLE_ATTRIBUTE(fops_ulong, debugfs_ulong_get, debugfs_ulong_set, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(fops_ulong_ro, debugfs_ulong_get, NULL, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(fops_ulong_wo, NULL, debugfs_ulong_set, "%llu\n"); + +/** + * debugfs_create_ulong - create a debugfs file that is used to read and write + * an unsigned long value. + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is %NULL, then the + * file will be created in the root of the debugfs filesystem. + * @value: a pointer to the variable that the file should read to and write + * from. + * + * This function creates a file in debugfs with the given name that + * contains the value of the variable @value. If the @mode variable is so + * set, it can be read from, and written to. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -%ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_ulong(const char *name, umode_t mode, + struct dentry *parent, unsigned long *value) +{ + return debugfs_create_mode(name, mode, parent, value, &fops_ulong, + &fops_ulong_ro, &fops_ulong_wo); +} +EXPORT_SYMBOL_GPL(debugfs_create_ulong); + DEFINE_SIMPLE_ATTRIBUTE(fops_x8, debugfs_u8_get, debugfs_u8_set, "0x%02llx\n"); DEFINE_SIMPLE_ATTRIBUTE(fops_x8_ro, debugfs_u8_get, NULL, "0x%02llx\n"); DEFINE_SIMPLE_ATTRIBUTE(fops_x8_wo, NULL, debugfs_u8_set, "0x%02llx\n"); diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 8321fe3058d6..19c066dce1da 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -79,6 +79,8 @@ struct dentry *debugfs_create_u32(const char *name, umode_t mode, struct dentry *parent, u32 *value); struct dentry *debugfs_create_u64(const char *name, umode_t mode, struct dentry *parent, u64 *value); +struct dentry *debugfs_create_ulong(const char *name, umode_t mode, + struct dentry *parent, unsigned long *value); struct dentry *debugfs_create_x8(const char *name, umode_t mode, struct dentry *parent, u8 *value); struct dentry *debugfs_create_x16(const char *name, umode_t mode,