public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Khalid Aziz <khalid.aziz@oracle.com>
Cc: davem@davemloft.net, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sparc: Add support for seek and shorter read to /dev/mdesc
Date: Fri, 18 Jul 2014 10:35:22 +0200	[thread overview]
Message-ID: <20140718083522.GA20146@ravnborg.org> (raw)
In-Reply-To: <1405618910-17667-1-git-send-email-khalid.aziz@oracle.com>

Hi Khalid.

Looks better now - thanks.

A few nits remaining.
Please fix and submit a v3 - then we will see if David approves.

	Sam

> +/* mdesc_open() - Grab a reference to mdesc_handle when /dev/mdesc is
> + *	opened. Hold this reference until /dev/mdesc is closed to ensure
> + *	mdesc data structure is not released underneath us. Store the
> + *	pointer to mdesc structure in private_data for read and seek to use
Please use one space between "*" and "text" - not a tab.
This is how it is done in the rest of the sparc code.



> + */
> +static int mdesc_open(struct inode *inode, struct file *file)
>  {
>  	struct mdesc_handle *hp = mdesc_grab();
> -	int err;
>  
>  	if (!hp)
>  		return -ENODEV;
>  
> -	err = hp->handle_size;
> -	if (len < hp->handle_size)
> -		err = -EMSGSIZE;
> -	else if (copy_to_user(buf, &hp->mdesc, hp->handle_size))
> -		err = -EFAULT;
> -	mdesc_release(hp);
> +	file->private_data = hp;
> +	return 0;
> +}

Personally I would add an empty line before the return.
But this is not something mandatory.

> +static loff_t mdesc_llseek(struct file *file, loff_t offset, int whence)
> +{
> +	struct mdesc_handle *hp;
> +
> +	switch (whence) {
> +	case SEEK_CUR:
> +		offset += file->f_pos;
> +		break;
> +	case SEEK_SET:
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	hp = file->private_data;
> +	if (offset > hp->handle_size)
> +		return -EINVAL;
> +	else
> +		file->f_pos = offset;
> +	return offset;
> +}
Likewise regarning empty line.

> +
> +/* mdesc_close() - /dev/mdesc is being closed, release the reference to
> + *	mdesc structure.
> + */
Tab => space


	Sam

      reply	other threads:[~2014-07-18  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17 17:41 [PATCH v2] sparc: Add support for seek and shorter read to /dev/mdesc Khalid Aziz
2014-07-18  8:35 ` Sam Ravnborg [this message]

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=20140718083522.GA20146@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=davem@davemloft.net \
    --cc=khalid.aziz@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox