public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cheah Kok Cheong <thrust73@gmail.com>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: hsweeten@visionengravers.com, gregkh@linuxfoundation.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: comedi: drivers: comedi_test: Add auto-configuration capability
Date: Sat, 11 Feb 2017 08:53:29 +0800	[thread overview]
Message-ID: <20170211005328.GA2613@linux-Precision-WorkStation-T5500> (raw)
In-Reply-To: <a52ea0e6-ab56-2243-78d8-d21d5fb8cd48@mev.co.uk>

Dear Ian,
  Thank you for taking the trouble to review this.

On Thu, Feb 09, 2017 at 12:25:15PM +0000, Ian Abbott wrote:
> 
> I think the "manual" parameter is misnamed, since this parameter controls
> whether a dummy hardware device is created by the driver or not.  Reserved
> COMEDI devices can still be configured manually to use this driver
> irrespective of the setting of the "manual" parameter.
> 
> Some possible options are to rename the parameter "noauto" (or "nocreate"),
> or to name it "auto" (or "create") with default value 1.
> 

Info noted. "noauto" will be better in this case. Like this perhaps.

module_param_named(noauto, config_mode, bool, 0444);
MODULE_PARM_DESC(noauto, "Disable auto-configuration: (1=disable [defaults to enable])");

> >+#define DEV_NAME "comedi_testd"
> >+#define CLASS_NAME "comedi_char"
> 
> I'm not sure about the class name "comedi_char".  Perhaps "comedi_test"
> would be better to associate it with this module.
> 

The best name actually is "comedi_test". I was discouraged by the many
instances of it and went for a unique one. [proc entry,printks,driver name etc]
But I'm no good at naming. I'll switch to "comedi_test".

> >+static int __init comedi_test_init(void)
> >+{
> >+	int ret;
> >+
> >+	if (!config_mode) {
> >+		ctcls = class_create(THIS_MODULE, CLASS_NAME);
> >+		if (IS_ERR(ctcls)) {
> >+			pr_err("comedi_test: unable to create class\n");
> >+			return PTR_ERR(ctcls);
> >+		}
> >+
> >+		ctdev = device_create(ctcls, NULL, MKDEV(0, 0), NULL, DEV_NAME);
> >+		if (IS_ERR(ctdev)) {
> >+			pr_err("comedi_test: unable to create device\n");
> >+			ret = PTR_ERR(ctdev);
> >+			goto clean3;
> >+		}
> >+	}
> >+
> >+	ret = comedi_driver_register(&waveform_driver);
> >+	if (ret) {
> >+		pr_err("comedi_test: unable to register driver\n");
> >+		if (!config_mode)
> >+			goto clean2;
> >+		else
> >+			return ret;
> >+	}
> >+
> >+	if (!config_mode) {
> >+		ret = comedi_auto_config(ctdev, &waveform_driver, 0);
> >+		if (ret) {
> >+			pr_err("comedi_test: unable to auto configure device\n");
> >+			goto clean;
> >+		}
> >+	}
> >+
> >+	return 0;
> >+
> >+clean:
> >+	comedi_driver_unregister(&waveform_driver);
> >+clean2:
> >+	device_destroy(ctcls, MKDEV(0, 0));
> >+clean3:
> >+	class_destroy(ctcls);
> >+
> >+	return ret;
> >+}
> >+module_init(comedi_test_init);
> 
> I think the error handling paths look a bit untidy.  I think calling
> comedi_driver_register() first would help.  It would also be nice if failure
> to create the device class and test device did not prevent the module from
> initializing completely, since the module could still be used by manually
> configured COMEDI devices even if they fail.
> 

You are right. I'll put comedi_driver_register() first.
Again your idea is better, I'll convert it to continue loading even if
auto-configuration is unsuccessful.

> >+static void __exit comedi_test_exit(void)
> >+{
> >+	if (!config_mode)
> >+		comedi_auto_unconfig(ctdev);
> >+
> >+	comedi_driver_unregister(&waveform_driver);
> >+
> >+	if (!config_mode) {
> >+		device_destroy(ctcls, MKDEV(0, 0));
> >+		class_destroy(ctcls);
> >+	}
> >+}
> >+module_exit(comedi_test_exit);

On second thought, the if statement here seems to be redundant.
They seems to be able to handle non existent device and class.
I'll remove it. Further more we are going to let the module
to continue loading even if auto-configuration is unsuccessful.

Thks.
Brgds,
CheahKC

      reply	other threads:[~2017-02-11  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 17:31 [PATCH] Staging: comedi: drivers: comedi_test: Add auto-configuration capability Cheah Kok Cheong
2017-01-27 15:55 ` [PATCH] Staging: comedi: drivers: comedi_test: Set max input value for auto config Cheah Kok Cheong
2017-02-09 12:28   ` Ian Abbott
2017-02-11  1:29     ` Cheah Kok Cheong
2017-02-08  7:42 ` [PATCH] Staging: comedi: drivers: comedi_test: Add auto-configuration capability Cheah Kok Cheong
2017-02-09 12:25 ` Ian Abbott
2017-02-11  0:53   ` Cheah Kok Cheong [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=20170211005328.GA2613@linux-Precision-WorkStation-T5500 \
    --to=thrust73@gmail.com \
    --cc=abbotti@mev.co.uk \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@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