public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Evgeniy Polyakov <zbr@ioremap.net>
Cc: linux-kernel@vger.kernel.org, zbr@ioremap.net
Subject: Re: [w1] Allow master IO commands.
Date: Wed, 17 Dec 2008 14:22:41 -0800	[thread overview]
Message-ID: <20081217142241.e05fff98.akpm@linux-foundation.org> (raw)
In-Reply-To: <1229450882-745-2-git-send-email-zbr@ioremap.net>

On Tue, 16 Dec 2008 21:07:59 +0300
Evgeniy Polyakov <zbr@ioremap.net> wrote:

> This patch allows to start IO not against already found slave devices,
> but against the bus itself, which can be used for example to probe device.
> 
> ...
>
> +static int w1_process_command_master(struct w1_master *dev, struct cn_msg *req_msg,
> +		struct w1_netlink_msg *req_hdr, struct w1_netlink_cmd *req_cmd)
> +{
> +	int err = -EINVAL;
> +	struct cn_msg *msg;
> +	struct w1_netlink_msg *hdr;
> +	struct w1_netlink_cmd *cmd;
> +
> +	msg = kzalloc(PAGE_SIZE, GFP_KERNEL);

The use of PAGE_SIZE is odd.  It's either too large (inefficient) or
too small (disaster).

Is it not practical to calculate this precisely?

> +	if (!msg)
> +		return -ENOMEM;
> +
> +	msg->id = req_msg->id;
> +	msg->seq = req_msg->seq;
> +	msg->ack = 0;
> +	msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
> +
> +	hdr = (struct w1_netlink_msg *)(msg + 1);
> +	cmd = (struct w1_netlink_cmd *)(hdr + 1);
> +
> +	hdr->type = W1_MASTER_CMD;
> +	hdr->id = req_hdr->id;
> +	hdr->len = sizeof(struct w1_netlink_cmd);
> +
> +	cmd->cmd = req_cmd->cmd;
> +	cmd->len = 0;
> +
> +	switch (cmd->cmd) {
> +		case W1_CMD_SEARCH:

checkpatch correctly points out that the body of the switch statement
should be indented one tabstop less than this.

> +		case W1_CMD_ALARM_SEARCH:
> +			err = w1_process_search_command(dev, msg,
> +				PAGE_SIZE - msg->len - sizeof(struct cn_msg));

which would give more room for cleaning this up.

> +			break;
> +		case W1_CMD_READ:
> +		case W1_CMD_WRITE:
> +		case W1_CMD_TOUCH:
> +			err = w1_process_command_io(dev, msg, hdr, cmd);
> +			break;
> +		default:
> +			cmd->res = EINVAL;
> +			cn_netlink_send(msg, 0, GFP_KERNEL);
> +			break;
> +	}
> +
> +	kfree(msg);
> +	return err;
> +}
> +


  parent reply	other threads:[~2008-12-17 22:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 18:07 [w1] userspace commands extensions Evgeniy Polyakov
2008-12-16 18:07 ` [w1] Allow master IO commands Evgeniy Polyakov
2008-12-16 18:08   ` [w1] Move w1 commands from defines to enum Evgeniy Polyakov
2008-12-16 18:08     ` [w1] Added w1 reset command Evgeniy Polyakov
2008-12-16 18:08       ` [w1] Send status messages after command processing Evgeniy Polyakov
2008-12-17 22:22   ` Andrew Morton [this message]
2008-12-17 22:33     ` [w1] Allow master IO commands Evgeniy Polyakov
2008-12-17 23:14       ` Andrew Morton
2008-12-17 23:19         ` Evgeniy Polyakov

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=20081217142241.e05fff98.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.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