All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Josh Cartwright <joshc@codeaurora.org>
Cc: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <rob.herring@calxeda.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	Sagar Dharia <sdharia@codeaurora.org>,
	Gilad Avidov <gavidov@codeaurora.org>,
	Michael Bohan <mbohan@codeaurora.org>
Subject: Re: [PATCH RFC v2 2/5] spmi: Linux driver framework for SPMI
Date: Thu, 22 Aug 2013 16:10:54 -0700	[thread overview]
Message-ID: <20130822231054.GA31973@kroah.com> (raw)
In-Reply-To: <46db5901fe4d04d09cee8fd81ea1c62068ee9503.1377202730.git.joshc@codeaurora.org>

On Fri, Aug 09, 2013 at 01:37:09PM -0700, Josh Cartwright wrote:
> +static char dbgfs_help[] =
> +	"SPMI Debug-FS support\n"
> +	"\n"
> +	"Hierarchy schema:\n"
> +	"/sys/kernel/debug/spmi\n"
> +	"       /help                -- Static help text\n"
> +	"       /spmi-0              -- Directory for SPMI bus 0\n"
> +	"       /spmi-0/0-1          -- Directory for SPMI device '0-1'\n"
> +	"       /spmi-0/0-1/address  -- Starting register for reads or writes\n"
> +	"       /spmi-0/0-1/count    -- Number of registers to read (only used for reads)\n"
> +	"       /spmi-0/0-1/data     -- Initiates the SPMI read (formatted output)\n"
> +	"       /spmi-0/0-1/data_raw -- Initiates the SPMI raw read or write\n"
> +	"       /spmi-n              -- Directory for SPMI bus n\n"
> +	"\n"
> +	"To perform SPMI read or write transactions, you need to first write the\n"
> +	"address of the slave device register to the 'address' file.  For read\n"
> +	"transactions, the number of bytes to be read needs to be written to the\n"
> +	"'count' file.\n"
> +	"\n"
> +	"The 'address' file specifies the 20-bit address of a slave device register.\n"
> +	"The upper 4 bits 'address[19..16]' specify the slave identifier (SID) for\n"
> +	"the slave device.  The lower 16 bits specify the slave register address.\n"
> +	"\n"
> +	"Reading from the 'data' file will initiate a SPMI read transaction starting\n"
> +	"from slave register 'address' for 'count' number of bytes.\n"
> +	"\n"
> +	"Writing to the 'data' file will initiate a SPMI write transaction starting\n"
> +	"from slave register 'address'.  The number of registers written to will\n"
> +	"match the number of bytes written to the 'data' file.\n"
> +	"\n"
> +	"Example: Read 4 bytes starting at register address 0x1234 for SID 2\n"
> +	"\n"
> +	"echo 0x21234 > address\n"
> +	"echo 4 > count\n"
> +	"cat data\n"
> +	"\n"
> +	"Example: Write 3 bytes starting at register address 0x1008 for SID 1\n"
> +	"\n"
> +	"echo 0x11008 > address\n"
> +	"echo 0x01 0x02 0x03 > data\n"
> +	"\n"
> +	"Note that the count file is not used for writes.  Since 3 bytes are\n"
> +	"written to the 'data' file, then 3 bytes will be written across the\n"
> +	"SPMI bus.\n\n";

The help file within the kernel is a nice touch :)

I do know the only rule for debugfs is "There are no rules", but this
looks like you are going to have the way to interact to this bus and
devices as debugfs, is that correct?

Or is this only for "debugging"?  If so, please document it as such.

> +void spmi_dfs_controller_add(struct spmi_controller *ctrl)
> +{
> +	ctrl->dfs_dir = debugfs_create_dir(dev_name(&ctrl->dev),
> +					   spmi_debug_root);
> +	WARN_ON(!ctrl->dfs_dir);

Why?  What is a user going to be able to do with something like this?
You do this in a number of places, please provide "valid" error messages
instead of just kernel stack tracebacks, failing to show the device for
which the error occured (hint, use dev_err()).

Again, never use WARN_ON() as error handling, it's lazy, and wrong.

thanks,

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: gregkh@linuxfoundation.org (Greg Kroah-Hartman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC v2 2/5] spmi: Linux driver framework for SPMI
Date: Thu, 22 Aug 2013 16:10:54 -0700	[thread overview]
Message-ID: <20130822231054.GA31973@kroah.com> (raw)
In-Reply-To: <46db5901fe4d04d09cee8fd81ea1c62068ee9503.1377202730.git.joshc@codeaurora.org>

On Fri, Aug 09, 2013 at 01:37:09PM -0700, Josh Cartwright wrote:
> +static char dbgfs_help[] =
> +	"SPMI Debug-FS support\n"
> +	"\n"
> +	"Hierarchy schema:\n"
> +	"/sys/kernel/debug/spmi\n"
> +	"       /help                -- Static help text\n"
> +	"       /spmi-0              -- Directory for SPMI bus 0\n"
> +	"       /spmi-0/0-1          -- Directory for SPMI device '0-1'\n"
> +	"       /spmi-0/0-1/address  -- Starting register for reads or writes\n"
> +	"       /spmi-0/0-1/count    -- Number of registers to read (only used for reads)\n"
> +	"       /spmi-0/0-1/data     -- Initiates the SPMI read (formatted output)\n"
> +	"       /spmi-0/0-1/data_raw -- Initiates the SPMI raw read or write\n"
> +	"       /spmi-n              -- Directory for SPMI bus n\n"
> +	"\n"
> +	"To perform SPMI read or write transactions, you need to first write the\n"
> +	"address of the slave device register to the 'address' file.  For read\n"
> +	"transactions, the number of bytes to be read needs to be written to the\n"
> +	"'count' file.\n"
> +	"\n"
> +	"The 'address' file specifies the 20-bit address of a slave device register.\n"
> +	"The upper 4 bits 'address[19..16]' specify the slave identifier (SID) for\n"
> +	"the slave device.  The lower 16 bits specify the slave register address.\n"
> +	"\n"
> +	"Reading from the 'data' file will initiate a SPMI read transaction starting\n"
> +	"from slave register 'address' for 'count' number of bytes.\n"
> +	"\n"
> +	"Writing to the 'data' file will initiate a SPMI write transaction starting\n"
> +	"from slave register 'address'.  The number of registers written to will\n"
> +	"match the number of bytes written to the 'data' file.\n"
> +	"\n"
> +	"Example: Read 4 bytes starting at register address 0x1234 for SID 2\n"
> +	"\n"
> +	"echo 0x21234 > address\n"
> +	"echo 4 > count\n"
> +	"cat data\n"
> +	"\n"
> +	"Example: Write 3 bytes starting at register address 0x1008 for SID 1\n"
> +	"\n"
> +	"echo 0x11008 > address\n"
> +	"echo 0x01 0x02 0x03 > data\n"
> +	"\n"
> +	"Note that the count file is not used for writes.  Since 3 bytes are\n"
> +	"written to the 'data' file, then 3 bytes will be written across the\n"
> +	"SPMI bus.\n\n";

The help file within the kernel is a nice touch :)

I do know the only rule for debugfs is "There are no rules", but this
looks like you are going to have the way to interact to this bus and
devices as debugfs, is that correct?

Or is this only for "debugging"?  If so, please document it as such.

> +void spmi_dfs_controller_add(struct spmi_controller *ctrl)
> +{
> +	ctrl->dfs_dir = debugfs_create_dir(dev_name(&ctrl->dev),
> +					   spmi_debug_root);
> +	WARN_ON(!ctrl->dfs_dir);

Why?  What is a user going to be able to do with something like this?
You do this in a number of places, please provide "valid" error messages
instead of just kernel stack tracebacks, failing to show the device for
which the error occured (hint, use dev_err()).

Again, never use WARN_ON() as error handling, it's lazy, and wrong.

thanks,

greg k-h

  reply	other threads:[~2013-08-22 23:10 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22 20:18 [PATCH RFC v2 0/3] Add support for the System Power Management Interface (SPMI) Josh Cartwright
2013-08-22 20:18 ` Josh Cartwright
2012-12-10 19:41 ` [PATCH RFC v2 1/5] of: Add empty for_each_available_child_of_node() macro definition Josh Cartwright
2013-08-22 22:57   ` Josh Cartwright
2013-08-09 20:37 ` [PATCH RFC v2 4/5] spmi: Add MSM PMIC Arbiter SPMI controller Josh Cartwright
2013-08-09 20:37   ` Josh Cartwright
2013-08-09 20:37 ` [PATCH RFC v2 5/5] spmi: document the PMIC arbiter SPMI bindings Josh Cartwright
2013-08-09 20:37   ` Josh Cartwright
2013-08-23 21:55   ` Stephen Warren
2013-08-23 21:55     ` Stephen Warren
2013-08-09 20:37 ` [PATCH RFC v2 2/5] spmi: Linux driver framework for SPMI Josh Cartwright
2013-08-09 20:37   ` Josh Cartwright
2013-08-22 23:10   ` Greg Kroah-Hartman [this message]
2013-08-22 23:10     ` Greg Kroah-Hartman
2013-08-23 16:06     ` Josh Cartwright
2013-08-23 16:06       ` Josh Cartwright
2013-09-09 15:52       ` Mark Brown
2013-09-09 15:52         ` Mark Brown
2013-09-09 16:56         ` Josh Cartwright
2013-09-09 16:56           ` Josh Cartwright
2013-08-22 19:59 ` [PATCH RFC v2 3/5] spmi: add generic SPMI controller binding documentation Josh Cartwright
2013-08-22 19:59   ` Josh Cartwright
2013-08-23 21:58   ` Stephen Warren
2013-08-23 21:58     ` Stephen Warren
2013-08-27 17:01     ` Josh Cartwright
2013-08-27 17:01       ` Josh Cartwright
2013-08-27 21:55       ` Stephen Warren
2013-08-27 21:55         ` Stephen Warren
2013-08-28 18:00         ` Josh Cartwright
2013-08-28 18:00           ` Josh Cartwright
2013-08-28 18:32           ` Stephen Warren
2013-08-28 18:32             ` Stephen Warren
2013-10-06  6:11         ` Bjorn Andersson
2013-10-06  6:11           ` Bjorn Andersson
     [not found]           ` <CAJAp7Oi-bPytsLtsppdanOi_p0Y5vfBriGB-B5by7w5Z7SGU-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-07 21:17             ` Josh Cartwright
2013-10-07 21:17               ` Josh Cartwright
2013-10-07 21:17               ` Josh Cartwright

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=20130822231054.GA31973@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=gavidov@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=joshc@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbohan@codeaurora.org \
    --cc=rob.herring@calxeda.com \
    --cc=sdharia@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.