mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KY Srinivasan <kys@microsoft.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"olaf@aepfle.de" <olaf@aepfle.de>,
	"apw@canonical.com" <apw@canonical.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>
Subject: RE: [PATCH V4 1/1] Drivers: hv: Implement the file copy service
Date: Sun, 9 Feb 2014 01:56:02 +0000	[thread overview]
Message-ID: <bfeacfefc0f04367ae447840cfe3abc5@BY2PR03MB299.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20140207231718.GA16221@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Friday, February 07, 2014 3:17 PM
> To: KY Srinivasan
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org; olaf@aepfle.de;
> apw@canonical.com; jasowang@redhat.com
> Subject: Re: [PATCH V4 1/1] Drivers: hv: Implement the file copy service
> 
> On Tue, Jan 21, 2014 at 05:43:53PM -0800, K. Y. Srinivasan wrote:
> > +/*
> > + * Create a char device that can support read/write for passing
> > + * the payload.
> > + */
> > +static struct cdev fcopy_cdev;
> > +static struct class *cl;
> > +static struct device *sysfs_dev;
> 
> Why not just be a misc device, you only want 1 minor number for a char
> device:
> 
> > +static int fcopy_dev_init(void)
> > +{
> > +	int result;
> > +
> > +	result = alloc_chrdev_region(&fcopy_dev, 1, 1, "hv_fcopy");
> 
> See, one minor.
> 
> > +	if (result < 0) {
> > +		pr_err("Cannot get major number\n");
> > +		return result;
> > +	}
> > +
> > +	cl = class_create(THIS_MODULE, "chardev");
> 
> That's a _really_ generic name, come on, you know better than that.
> 
> > +	if (IS_ERR(cl)) {
> > +		pr_err("Error creating fcopy class.\n");
> 
> Your error string is wrong :(
> 
> > +		result = PTR_ERR(cl);
> > +		goto err_unregister;
> > +	}
> > +
> > +	sysfs_dev = device_create(cl, NULL, fcopy_dev, "%s", "hv_fcopy");
> 
> A device at the root of sysfs?  No, you have a bus to hang devices off
> of, use that.  What do you need this device for anyway?
> 
> > +	if (IS_ERR(sysfs_dev)) {
> > +		pr_err("Device creation failed\n");
> > +		result = PTR_ERR(cl);
> > +		goto err_destroy_class;
> > +	}
> > +
> > +	cdev_init(&fcopy_cdev, &fcopy_fops);
> > +	fcopy_cdev.owner = THIS_MODULE;
> > +	fcopy_cdev.ops = &fcopy_fops;
> > +
> > +	result = cdev_add(&fcopy_cdev, fcopy_dev, 1);
> 
> Ah, to get udev to pay attention to the char device, no, just use a misc
> device, should make this whole code a lot simpler and more "obvious" as
> to what you want/need.
> 
> > +	if (result) {
> > +		pr_err("Cannot cdev_add\n");
> > +		goto err_destroy_device;
> > +	}
> > +	return result;
> > +
> > +err_destroy_device:
> > +	device_destroy(cl, fcopy_dev);
> > +err_destroy_class:
> > +	class_destroy(cl);
> > +err_unregister:
> > +	unregister_chrdev_region(fcopy_dev, 1);
> > +	return result;
> 
> 
> Ugh, I hate the cdev interface, one of these days I'll fix it up, it's
> so unwieldy...
> 
> > +static void fcopy_dev_deinit(void)
> > +{
> > +	/*
> > +	 * first kill the daemon.
> > +	 */
> > +	if (dtp != NULL)
> > +		send_sig(SIGKILL, dtp, 0);
> 
> We kill userspace daemon's from the kernel?  That's a recipe for
> disaster...
> 
> Why?  What does it matter here if the daemon keeps running, it should
> fail gracefully if the character device is removed, right?  If not, that
> needs to be fixed anyway.

Greg,

Thanks for the detailed comments; I will address these in the next version.


Regards,

K. Y

      reply	other threads:[~2014-02-09  1:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22  1:43 K. Y. Srinivasan
2014-01-23 22:57 ` Olaf Hering
2014-02-07 23:17 ` Greg KH
2014-02-09  1:56   ` KY Srinivasan [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=bfeacfefc0f04367ae447840cfe3abc5@BY2PR03MB299.namprd03.prod.outlook.com \
    --to=kys@microsoft.com \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    /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

all inboxes | Powered by JetHome®