Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1582436
| Path | csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Ian Abbott <abbotti@mev.co.uk> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] Staging: comedi: drivers: comedi_test: Add auto-configuration capability |
| Date | Thu, 16 Feb 2017 11:20:02 +0100 |
| Message-ID | <tbrkm-4KJ-11@gated-at.bofh.it> (permalink) |
| References | <t9KKu-47s-7@gated-at.bofh.it> <tamPN-2Yu-27@gated-at.bofh.it> <tb8rp-107-47@gated-at.bofh.it> |
| X-Original-To | Cheah Kok Cheong <thrust73@gmail.com> |
| X-Session-Marker | 69616E406162626F74742E6F7267 |
| X-Spam-Summary | 50,0,0,,d41d8cd98f00b204,abbotti@mev.co.uk,:::::::::,RULES_HIT:41:355:379:599:800:960:967:973:988:989:1260:1261:1263:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1683:1711:1730:1747:1777:1792:1801:2393:2525:2553:2560:2563:2612:2682:2685:2693:2859:2911:2933:2937:2939:2942:2945:2947:2951:2954:3000:3022:3138:3139:3140:3141:3142:3354:3865:3867:3868:3870:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4425:4605:5007:7652:9025:9036:9094:10004:10400:10848:11026:11232:11658:11914:12043:12295:12438:12740:12760:12895:13255:13972:14181:14571:14685:14721:21080:21451,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none |
| X-He-Tag | cap16_79a22b55d7417 |
| X-Filterd-Recvd-Size | 3420 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 99 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | hsweeten@visionengravers.com, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Thu, 16 Feb 2017 10:10:34 +0000 |
| X-Original-Message-ID | <0ec646fc-d72c-a2a4-351b-cf7f6498e0f1@mev.co.uk> |
| X-Original-References | <1486809467-5434-1-git-send-email-thrust73@gmail.com> <a5a9a523-f025-f0da-1265-7e3e507f194e@mev.co.uk> <20170215060548.GA10944@linux-Precision-WorkStation-T5500> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1582436 |
Show key headers only | View raw
On 15/02/17 06:05, Cheah Kok Cheong wrote:
> On Mon, Feb 13, 2017 at 11:14:14AM +0000, Ian Abbott wrote:
>> On 11/02/17 10:37, Cheah Kok Cheong wrote:
[snip]
>>> +static void __exit comedi_test_exit(void)
>>> +{
>>> + comedi_auto_unconfig(ctdev);
>>> +
>>> + device_destroy(ctcls, MKDEV(0, 0));
>>> +
>>> + class_destroy(ctcls);
>>
>> If the driver init returned successfully, but failed to set-up the
>> auto-configured device, the device and class will not exist at this point,
>> so those three calls need to go in an 'if' statement. Perhaps you could use
>> 'if (ctcls) {', and set 'ctcls = NULL;' after calling
>> 'class_destroy(ctcls);' in the init function.
>>
>> Apart from that, it looks fine.
>>
>
> Thanks for pointing out those two pointers have to be "NULL" if
> auto-configuration fails.
>
> Please review below snippet.
> Sorry for the inconvenience caused.
>
> [ Snip ]
>
> static int __init comedi_test_init(void)
> {
> int ret;
>
> ret = comedi_driver_register(&waveform_driver);
> if (ret) {
> pr_err("comedi_test: unable to register driver\n");
> return ret;
> }
>
> if (!config_mode) {
> ctcls = class_create(THIS_MODULE, CLASS_NAME);
> if (IS_ERR(ctcls)) {
> pr_warn("comedi_test: unable to create class\n");
> goto clean3;
> }
>
> ctdev = device_create(ctcls, NULL, MKDEV(0, 0), NULL, DEV_NAME);
> if (IS_ERR(ctdev)) {
> pr_warn("comedi_test: unable to create device\n");
> goto clean2;
> }
>
> ret = comedi_auto_config(ctdev, &waveform_driver, 0);
> if (ret) {
> pr_warn("comedi_test: unable to auto-configure device\n");
> goto clean;
> }
> }
>
> return 0;
>
> clean:
> device_destroy(ctcls, MKDEV(0, 0));
> clean2:
> class_destroy(ctcls);
> ctdev = NULL;
> clean3:
> ctcls = NULL;
>
> return 0;
> }
> module_init(comedi_test_init);
>
> static void __exit comedi_test_exit(void)
> {
> if (ctdev)
> comedi_auto_unconfig(ctdev);
>
> if (ctcls) {
> device_destroy(ctcls, MKDEV(0, 0));
> class_destroy(ctcls);
> }
>
> comedi_driver_unregister(&waveform_driver);
> }
> module_exit(comedi_test_exit);
>
> [ Snip ]
>
> Thks.
> Brgds,
> CheahKC
>
Yes, that looks fine.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH v2] Staging: comedi: drivers: comedi_test: Add auto-configuration capability Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-15 15:10 +0100
Re: [PATCH v2] Staging: comedi: drivers: comedi_test: Add auto-configuration capability Ian Abbott <abbotti@mev.co.uk> - 2017-02-16 11:20 +0100
Re: [PATCH v2] Staging: comedi: drivers: comedi_test: Add auto-configuration capability Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-16 15:10 +0100
csiph-web