public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ike Panhc <ike.pan@canonical.com>
To: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Cc: Matthew Garrett <mjg@redhat.com>, Randy Dunlap <rdunlap@xenotime.net>
Subject: Re: [PATCH 4/5] ideapad: add debugfs support
Date: Mon, 19 Sep 2011 16:38:55 +0800	[thread overview]
Message-ID: <4E76FF9F.4020505@canonical.com> (raw)
In-Reply-To: <1315247572-9131-1-git-send-email-ike.pan@canonical.com>

Some modification.

On 09/06/2011 02:32 AM, Ike Panhc wrote:
>  
>  static acpi_handle ideapad_handle;
> +static struct ideapad_private *ideapad_priv;

This is not necessary.

>  static bool no_bt_rfkill;
>  module_param(no_bt_rfkill, bool, 0444);
>  MODULE_PARM_DESC(no_bt_rfkill, "No rfkill for bluetooth.");
> @@ -188,6 +192,146 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data)
>  }
>  
>  /*
> + * debugfs
> + */
> +#define DEBUGFS_EVENT_LEN (4096)

No one use this.

> +static int debugfs_cfg_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, debugfs_cfg_show, NULL);

priv structure can be the third argument, so global variable is not necessary.

> +}
> +
> +static const struct file_operations debugfs_cfg_fops = {
> +	.owner = THIS_MODULE,
> +	.open = debugfs_cfg_open,
> +	.read = seq_read,
> +	.llseek = seq_lseek,
> +	.release = single_release,
> +};
> +
> +static int __devinit ideapad_debugfs_init(struct ideapad_private *priv)
> +{
> +	struct dentry *node;
> +
> +	priv->debug = debugfs_create_dir("ideapad", NULL);
> +	if (priv->debug == NULL) {

Use IS_ERR_OR_NULL instead.
When CONFIG_DEBUG_FS is not set, debugfs_create_dir will return ERR_PTR(-ENODEV)

> +		pr_err("failed to create debugfs directory");
> +		goto errout;
> +	}
> +
> +	node = debugfs_create_file("cfg", S_IRUGO, priv->debug, NULL,
> +				   &debugfs_cfg_fops);

priv structure can be the third argument.

> +	if (!node) {
> +		pr_err("failed to create cfg in debugfs");
> +		goto errout;
> +	}
> +
> +	node = debugfs_create_file("status", S_IRUGO, priv->debug, NULL,
> +				   &debugfs_status_fops);
> +	if (!node) {
> +		pr_err("failed to create event in debugfs");
> +		goto errout;
> +	}
> +
> +	return 0;
> +
> +errout:

call ideapad_debugfs_exit when failed.

> +	return -ENOMEM;
> +}
> +

> @@ -573,6 +717,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
>  	if (!priv)
>  		return -ENOMEM;
>  	dev_set_drvdata(&adevice->dev, priv);
> +	ideapad_priv = priv;

Removed

>  	ideapad_handle = adevice->handle;
>  	priv->cfg = cfg;
>  
> @@ -580,6 +725,10 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
>  	if (ret)
>  		goto platform_failed;
>  
> +	ret = ideapad_debugfs_init(priv);
> +	if (ret)
> +		goto debugfs_failed;
> +

Not to fail out when debugfs init failed. debugfs is for developers, not for users.


  reply	other threads:[~2011-09-19  8:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05 18:31 [PATCH 0/5] ideapad: patches for v3.2 kernel Ike Panhc
2011-09-05 18:31 ` [PATCH 1/5] ideapad: define vpc commands Ike Panhc
2011-09-05 18:32 ` [PATCH 2/5] ideapad: change parameter of ideapad_sync_rfk_state Ike Panhc
2011-09-05 18:32 ` [PATCH 3/5] ideapad: add event for Novo key Ike Panhc
2011-09-05 18:32 ` [PATCH 4/5] ideapad: add debugfs support Ike Panhc
2011-09-19  8:38   ` Ike Panhc [this message]
2011-09-19  8:50   ` Ike Panhc
2011-09-05 18:33 ` [PATCH 5/5] ideapad: remove sysfs node for cfg Ike Panhc

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=4E76FF9F.4020505@canonical.com \
    --to=ike.pan@canonical.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    /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