{"thread":{"id":"21338","subject":"Write and Submit Your First Kernel Patch","startedAt":"2009-10-23T18:46:24Z","lastAt":"2009-10-23T21:26:25Z","messageCount":8,"participants":["Kevyn-Alexandre Paré","Michal Nazarewicz","Junio C Hamano","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"125795","messageId":"dc1d0f40910231146y14028f4el9753debdf334103@mail.gmail.com","threadId":"21338","inReplyTo":null,"subject":"Write and Submit Your First Kernel Patch","fromName":"Kevyn-Alexandre Paré","fromEmail":"kevyn.alexandre.pare@gmail.com","sentAt":"2009-10-23T18:46:24Z","receivedAt":"2009-10-23T18:46:24Z","isPatch":false,"sender":{"key":"kevyn.alexandre.pare@gmail.com","avatar":"https://gravatar.com/avatar/5c2aa3d38a029ed59b3a5f96929affa425310b608bd83294da90fe6efa97a232?d=mp&s=160"},"body":"Hi,\n\nJust before I send my patch I got this error with:\n./scripts/checkpatch.pl --terse --file\n0001-Staging-comedi-driver-fix-coding-style.patch\n\n0001-Staging-comedi-driver-fix-coding-style.patch:27: ERROR: trailing whitespace\n0001-Staging-comedi-driver-fix-coding-style.patch:35: ERROR: trailing whitespace\n0001-Staging-comedi-driver-fix-coding-style.patch:43: ERROR: trailing whitespace\n0001-Staging-comedi-driver-fix-coding-style.patch:53: ERROR: trailing whitespace\n\nI have done a step by step explanation of what I have done:\nhttp://kapare.blogspot.com/2009/09/write-and-submit-your-first-kernel.html\n\nIt seem to me that the whitespace are added after I do this command:\ngit format-patch -s -n master..mybranch\n\nCan someone help me with that because google did help me to found the answer?\n\nThx\n\nkap\n"},{"id":"125802","messageId":"87vdi5uccy.fsf@erwin.mina86.com","threadId":"21338","inReplyTo":"dc1d0f40910231219l600d3579i57c7580fe798d445@mail.gmail.com","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2009-10-23T19:41:33Z","receivedAt":"2009-10-23T19:41:33Z","isPatch":false,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":">> Kevyn-Alexandre Paré <kevyn.alexandre.pare@gmail.com> writes:\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:27: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:35: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:43: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:53: ERROR: trailing whitespace\n>>>\n>>> I have done a step by step explanation of what I have done:\n>>> http://kapare.blogspot.com/2009/09/write-and-submit-your-first-kernel.html>>\n>>> It seem to me that the whitespace are added after I do this command:\n>>> git format-patch -s -n master..mybranch\n\n> On Fri, Oct 23, 2009 at 3:13 PM, Michal Nazarewicz <mina86@tlen.pl> wrote:\n>> Do \"git rebase --whitespace=fix master\" and git will try to fix whitespaces.\n\nKevyn-Alexandre Paré <kevyn.alexandre.pare@gmail.com> writes:\n> thx Michal,\n>\n> But the problem remain:\n\nIf I'm not mistaken \"git rebase --whitespace=fix master\" should do the\ntrick.  I'm out of good ideas if it does not.  Best I can advice is to\nfix the patch by hand -- just edit it in some decent editor and remove\ntrailing whitespaces from those lines.\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"125803","messageId":"7v8wf1c2h9.fsf@alter.siamese.dyndns.org","threadId":"21338","inReplyTo":"dc1d0f40910231146y14028f4el9753debdf334103@mail.gmail.com","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-23T19:52:18Z","receivedAt":"2009-10-23T19:52:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevyn-Alexandre Paré  <kevyn.alexandre.pare@gmail.com> writes:\n\n> Just before I send my patch I got this error with:\n> ./scripts/checkpatch.pl --terse --file\n> 0001-Staging-comedi-driver-fix-coding-style.patch\n>\n> 0001-Staging-comedi-driver-fix-coding-style.patch:27: ERROR: trailing whitespace\n> 0001-Staging-comedi-driver-fix-coding-style.patch:35: ERROR: trailing whitespace\n> 0001-Staging-comedi-driver-fix-coding-style.patch:43: ERROR: trailing whitespace\n> 0001-Staging-comedi-driver-fix-coding-style.patch:53: ERROR: trailing whitespace\n>\n> I have done a step by step explanation of what I have done:\n> http://kapare.blogspot.com/2009/09/write-and-submit-your-first-kernel.html\n>\n> It seem to me that the whitespace are added after I do this command:\n> git format-patch -s -n master..mybranch\n\n\"The whitespace are added after...\" sounds to me that what you committed\nwere checkpatch compliant, and format-patch somehow broke it.  If that is\nthe case we need to fix format-patch.\n\nPlease check if \"git show $commit\" output for the commit that corresponds\nto the \"[Staging] comedi driver: fix coding style\" patch has trailing\nwhitespaces.  That is what you committed.\n\nIf there already is whitespace breakage in what you committed, then we do\nnot have to blame format-patch and look for bugs in it to fix.\n\nOtherwise, please send 0001-*.patch (output from format-patch) and output\nfrom that \"git show $commit\" as separate attachments, so that we can debug\nand fix format-patch.\n\nThanks.\n"},{"id":"125810","messageId":"dc1d0f40910231330n7cc521d0n52aac929c334bc9d@mail.gmail.com","threadId":"21338","inReplyTo":"7v8wf1c2h9.fsf@alter.siamese.dyndns.org","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Kevyn-Alexandre Paré","fromEmail":"kevyn.alexandre.pare@gmail.com","sentAt":"2009-10-23T20:30:25Z","receivedAt":"2009-10-23T20:30:25Z","isPatch":false,"sender":{"key":"kevyn.alexandre.pare@gmail.com","avatar":"https://gravatar.com/avatar/5c2aa3d38a029ed59b3a5f96929affa425310b608bd83294da90fe6efa97a232?d=mp&s=160"},"body":"Thx junio for that analyse!\n\nSo what I understand from what you have said is that the problem is\nnot in format-patch since that I see white space from git show $commit\n?!:\n\nhistory: I was trying to remove coding style problem in\ndrivers/staging/comedi/drivers/pcl726.c\n\n./scripts/checkpatch.pl --terse --file\ndrivers/staging/comedi/drivers/pcl726.c        #### NO warning after\nremoving problems\n### git commit -a\n                      # was done after that\n### git format-patch -s -n master..pcl726\n\nkapare@vostro:~/linux-kernel-patch/linux-2.6$ git show $commit >\nTEST.git.show.commit      #### see whitespace in vim\nkapare@vostro:~/linux-kernel-patch/linux-2.6$ ./scripts/checkpatch.pl\n--terse --file TEST.git.show.commit\nTEST:19: ERROR: trailing whitespace\nTEST:27: ERROR: trailing whitespace\nTEST:35: ERROR: trailing whitespace\nTEST:45: ERROR: trailing whitespace\nTEST:55: ERROR: trailing whitespace\nTEST:60: ERROR: trailing whitespace\nTEST:67: ERROR: trailing whitespace\nTEST:69: ERROR: trailing whitespace\nTEST:80: ERROR: trailing whitespace\nTEST:106: ERROR: trailing whitespace\nTEST:113: ERROR: trailing whitespace\n\nSo what am I doing wrong? Any clues? see attachment you ask\n\nthx\n\nkap\n\nOn Fri, Oct 23, 2009 at 3:52 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Kevyn-Alexandre Paré  <kevyn.alexandre.pare@gmail.com> writes:\n>\n>> Just before I send my patch I got this error with:\n>> ./scripts/checkpatch.pl --terse --file\n>> 0001-Staging-comedi-driver-fix-coding-style.patch\n>>\n>> 0001-Staging-comedi-driver-fix-coding-style.patch:27: ERROR: trailing whitespace\n>> 0001-Staging-comedi-driver-fix-coding-style.patch:35: ERROR: trailing whitespace\n>> 0001-Staging-comedi-driver-fix-coding-style.patch:43: ERROR: trailing whitespace\n>> 0001-Staging-comedi-driver-fix-coding-style.patch:53: ERROR: trailing whitespace\n>>\n>> I have done a step by step explanation of what I have done:\n>> http://kapare.blogspot.com/2009/09/write-and-submit-your-first-kernel.html\n>>\n>> It seem to me that the whitespace are added after I do this command:\n>> git format-patch -s -n master..mybranch\n>\n> \"The whitespace are added after...\" sounds to me that what you committed\n> were checkpatch compliant, and format-patch somehow broke it.  If that is\n> the case we need to fix format-patch.\n>\n> Please check if \"git show $commit\" output for the commit that corresponds\n> to the \"[Staging] comedi driver: fix coding style\" patch has trailing\n> whitespaces.  That is what you committed.\n>\n> If there already is whitespace breakage in what you committed, then we do\n> not have to blame format-patch and look for bugs in it to fix.\n>\n> Otherwise, please send 0001-*.patch (output from format-patch) and output\n> from that \"git show $commit\" as separate attachments, so that we can debug\n> and fix format-patch.\n>\n> Thanks.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe linux-newbie\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> Please read the FAQ at http://www.linux-learn.org/faqs\n>\n\n\nFrom 2313270068581ff425140c1f361b26edd096658f Mon Sep 17 00:00:00 2001\nFrom: =?utf-8?q?Kevyn-Alexandre=20Par=C3=A9?= <kevyn.alexandre.pare@gmail.com>\nDate: Fri, 23 Oct 2009 00:59:40 -0400\nSubject: [PATCH 1/1] Staging: comedi driver: fix coding style\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\n\n\nSigned-off-by: Kevyn-Alexandre Paré <kevyn.alexandre.pare@gmail.com>\n---\n drivers/staging/comedi/drivers/pcl726.c |   41 +++++++++++++++----------------\n 1 files changed, 20 insertions(+), 21 deletions(-)\n\ndiff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c\nindex ccadd09..6208bca 100644\n--- a/drivers/staging/comedi/drivers/pcl726.c\n+++ b/drivers/staging/comedi/drivers/pcl726.c\n@@ -39,27 +39,27 @@ Interrupts are not supported.\n     Options for PCL-726:\n      [0] - IO Base\n      [2]...[7] - D/A output range for channel 1-6:\n-               0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n-\t       4: 4-20mA, 5: unknown (external reference)\n+\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n+\t\t4: 4-20mA, 5: unknown (external reference)\n \n     Options for PCL-727:\n      [0] - IO Base\n      [2]...[13] - D/A output range for channel 1-12:\n-               0: 0-5V, 1: 0-10V, 2: +/-5V,\n-\t       3: 4-20mA\n+\t\t0: 0-5V, 1: 0-10V, 2: +/-5V,\n+\t\t3: 4-20mA\n \n     Options for PCL-728 and ACL-6128:\n      [0] - IO Base\n      [2], [3] - D/A output range for channel 1 and 2:\n-               0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n-\t       4: 4-20mA, 5: 0-20mA\n+\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n+\t\t4: 4-20mA, 5: 0-20mA\n \n     Options for ACL-6126:\n      [0] - IO Base\n      [1] - IRQ (0=disable, 3, 5, 6, 7, 9, 10, 11, 12, 15) (currently ignored)\n      [2]...[7] - D/A output range for channel 1-6:\n-               0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n-\t       4: 4-20mA\n+\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n+\t\t4: 4-20mA\n */\n \n /*\n@@ -127,7 +127,8 @@ struct pcl726_board {\n \tint di_lo;\n \tint do_hi;\n \tint do_lo;\n-\tconst struct comedi_lrange *const *range_type_list;\t/*  list of supported ranges */\n+\tconst struct comedi_lrange *const *range_type_list;\n+\t/*  list of supported ranges */\n };\n \n static const struct pcl726_board boardtypes[] = {\n@@ -204,9 +205,8 @@ static int pcl726_ao_insn_read(struct comedi_device *dev,\n \tint chan = CR_CHAN(insn->chanspec);\n \tint n;\n \n-\tfor (n = 0; n < insn->n; n++) {\n+\tfor (n = 0; n < insn->n; n++)\n \t\tdata[n] = devpriv->ao_readback[chan];\n-\t}\n \treturn n;\n }\n \n@@ -256,10 +256,10 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)\n \n \tiobase = it->options[0];\n \tiorange = this_board->io_range;\n-\tprintk(\"comedi%d: pcl726: board=%s, 0x%03lx \", dev->minor,\n+\tprintk(KERN_WARNING, \"comedi%d: pcl726: board=%s, 0x%03lx \", dev->minor,\n \t       this_board->name, iobase);\n \tif (!request_region(iobase, iorange, \"pcl726\")) {\n-\t\tprintk(\"I/O port conflict\\n\");\n+\t\tprintk(KERN_WARNING, \"I/O port conflict\\n\");\n \t\treturn -EIO;\n \t}\n \n@@ -283,16 +283,16 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)\n \t\tdevpriv->first_chan = 2;\n \t\tif (irq) {\t/* we want to use IRQ */\n \t\t\tif (((1 << irq) & boardtypes[board].IRQbits) == 0) {\n-\t\t\t\tprintk\n-\t\t\t\t    (\", IRQ %d is out of allowed range, DISABLING IT\",\n-\t\t\t\t     irq);\n+\t\t\t\tprintk(KERN_WARNING,\n+\t\t\t\t\t\", IRQ %d is out of allowed range,\"\n+\t\t\t\t\t\" DISABLING IT\", irq);\n \t\t\t\tirq = 0;\t/* Bad IRQ */\n \t\t\t} else {\n \t\t\t\tif (request_irq(irq, interrupt_pcl818, 0,\n \t\t\t\t\t\t\"pcl726\", dev)) {\n-\t\t\t\t\tprintk\n-\t\t\t\t\t    (\", unable to allocate IRQ %d, DISABLING IT\",\n-\t\t\t\t\t     irq);\n+\t\t\t\t\tprintk(KERN_WARNING,\n+\t\t\t\t\t\t\", unable to allocate IRQ %d,\"\n+\t\t\t\t\t\t\" DISABLING IT\", irq);\n \t\t\t\t\tirq = 0;\t/* Can't use IRQ */\n \t\t\t\t} else {\n \t\t\t\t\tprintk(\", irq=%d\", irq);\n@@ -372,9 +372,8 @@ static int pcl726_detach(struct comedi_device *dev)\n /* printk(\"comedi%d: pcl726: remove\\n\",dev->minor); */\n \n #ifdef ACL6126_IRQ\n-\tif (dev->irq) {\n+\tif (dev->irq)\n \t\tfree_irq(dev->irq, dev);\n-\t}\n #endif\n \n \tif (dev->iobase)\n-- \n1.6.0.4\n\n"},{"id":"125811","messageId":"alpine.LNX.2.00.0910231621550.14365@iabervon.org","threadId":"21338","inReplyTo":"dc1d0f40910231146y14028f4el9753debdf334103@mail.gmail.com","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-10-23T20:33:04Z","receivedAt":"2009-10-23T20:33:04Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 23 Oct 2009, Kevyn-Alexandre Paré wrote:\n\n> Hi,\n> \n> Just before I send my patch I got this error with:\n> ./scripts/checkpatch.pl --terse --file\n> 0001-Staging-comedi-driver-fix-coding-style.patch\n\nYou're using checkpatch --file on a patch. I hope you don't intend your \npatch to be added to the kernel source as a file, but rather applied to \nthe kernel source, changing other files. (I bet \"gcc 0001-Staging*.patch\" \nwill get interesting errors, too...) The patch format adds a single \ncharacter at the beginning of each line to say whether it's a addition, a \ndeletion, or a context line, and the context lines are identified by a \nspace character. This means that a blank context line consists of just \nthis space character, which is therefore a trailing space. We get the same \ntype of complaints when we have expected diff output in our test scripts.\n\nI'm kind of surprised that checkpatch doesn't completely blow up when it's \nexpecting a source file and getting a patch (and maybe tell you what \nyou've done). But that's the source of your errors, anyway.\n\n\t-Daniel\n*This .sig left intentionally blank*"},{"id":"125812","messageId":"dc1d0f40910231334x1aed3885p84fede711033a81a@mail.gmail.com","threadId":"21338","inReplyTo":"dc1d0f40910231330n7cc521d0n52aac929c334bc9d@mail.gmail.com","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Kevyn-Alexandre Paré","fromEmail":"kevyn.alexandre.pare@gmail.com","sentAt":"2009-10-23T20:34:03Z","receivedAt":"2009-10-23T20:34:03Z","isPatch":false,"sender":{"key":"kevyn.alexandre.pare@gmail.com","avatar":"https://gravatar.com/avatar/5c2aa3d38a029ed59b3a5f96929affa425310b608bd83294da90fe6efa97a232?d=mp&s=160"},"body":"I forgot my .c file\n\nOn Fri, Oct 23, 2009 at 4:30 PM, Kevyn-Alexandre Paré\n<kevyn.alexandre.pare@gmail.com> wrote:\n> Thx junio for that analyse!\n>\n> So what I understand from what you have said is that the problem is\n> not in format-patch since that I see white space from git show $commit\n> ?!:\n>\n> history: I was trying to remove coding style problem in\n> drivers/staging/comedi/drivers/pcl726.c\n>\n> ./scripts/checkpatch.pl --terse --file\n> drivers/staging/comedi/drivers/pcl726.c        #### NO warning after\n> removing problems\n> ### git commit -a\n>                      # was done after that\n> ### git format-patch -s -n master..pcl726\n>\n> kapare@vostro:~/linux-kernel-patch/linux-2.6$ git show $commit >\n> TEST.git.show.commit      #### see whitespace in vim\n> kapare@vostro:~/linux-kernel-patch/linux-2.6$ ./scripts/checkpatch.pl\n> --terse --file TEST.git.show.commit\n> TEST:19: ERROR: trailing whitespace\n> TEST:27: ERROR: trailing whitespace\n> TEST:35: ERROR: trailing whitespace\n> TEST:45: ERROR: trailing whitespace\n> TEST:55: ERROR: trailing whitespace\n> TEST:60: ERROR: trailing whitespace\n> TEST:67: ERROR: trailing whitespace\n> TEST:69: ERROR: trailing whitespace\n> TEST:80: ERROR: trailing whitespace\n> TEST:106: ERROR: trailing whitespace\n> TEST:113: ERROR: trailing whitespace\n>\n> So what am I doing wrong? Any clues? see attachment you ask\n>\n> thx\n>\n> kap\n>\n> On Fri, Oct 23, 2009 at 3:52 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Kevyn-Alexandre Paré  <kevyn.alexandre.pare@gmail.com> writes:\n>>\n>>> Just before I send my patch I got this error with:\n>>> ./scripts/checkpatch.pl --terse --file\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch\n>>>\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:27: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:35: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:43: ERROR: trailing whitespace\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch:53: ERROR: trailing whitespace\n>>>\n>>> I have done a step by step explanation of what I have done:\n>>> http://kapare.blogspot.com/2009/09/write-and-submit-your-first-kernel.html\n>>>\n>>> It seem to me that the whitespace are added after I do this command:\n>>> git format-patch -s -n master..mybranch\n>>\n>> \"The whitespace are added after...\" sounds to me that what you committed\n>> were checkpatch compliant, and format-patch somehow broke it.  If that is\n>> the case we need to fix format-patch.\n>>\n>> Please check if \"git show $commit\" output for the commit that corresponds\n>> to the \"[Staging] comedi driver: fix coding style\" patch has trailing\n>> whitespaces.  That is what you committed.\n>>\n>> If there already is whitespace breakage in what you committed, then we do\n>> not have to blame format-patch and look for bugs in it to fix.\n>>\n>> Otherwise, please send 0001-*.patch (output from format-patch) and output\n>> from that \"git show $commit\" as separate attachments, so that we can debug\n>> and fix format-patch.\n>>\n>> Thanks.\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe linux-newbie\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>> Please read the FAQ at http://www.linux-learn.org/faqs\n>>\n>\n\n\n/*\n    comedi/drivers/pcl726.c\n\n    hardware driver for Advantech cards:\n     card:   PCL-726, PCL-727, PCL-728\n     driver: pcl726,  pcl727,  pcl728\n    and for ADLink cards:\n     card:   ACL-6126, ACL-6128\n     driver: acl6126,  acl6128\n\n    COMEDI - Linux Control and Measurement Device Interface\n    Copyright (C) 1998 David A. Schleef <ds@schleef.org>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n*/\n/*\nDriver: pcl726\nDescription: Advantech PCL-726 & compatibles\nAuthor: ds\nStatus: untested\nDevices: [Advantech] PCL-726 (pcl726), PCL-727 (pcl727), PCL-728 (pcl728),\n  [ADLink] ACL-6126 (acl6126), ACL-6128 (acl6128)\n\nInterrupts are not supported.\n\n    Options for PCL-726:\n     [0] - IO Base\n     [2]...[7] - D/A output range for channel 1-6:\n\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n\t\t4: 4-20mA, 5: unknown (external reference)\n\n    Options for PCL-727:\n     [0] - IO Base\n     [2]...[13] - D/A output range for channel 1-12:\n\t\t0: 0-5V, 1: 0-10V, 2: +/-5V,\n\t\t3: 4-20mA\n\n    Options for PCL-728 and ACL-6128:\n     [0] - IO Base\n     [2], [3] - D/A output range for channel 1 and 2:\n\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n\t\t4: 4-20mA, 5: 0-20mA\n\n    Options for ACL-6126:\n     [0] - IO Base\n     [1] - IRQ (0=disable, 3, 5, 6, 7, 9, 10, 11, 12, 15) (currently ignored)\n     [2]...[7] - D/A output range for channel 1-6:\n\t\t0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,\n\t\t4: 4-20mA\n*/\n\n/*\n    Thanks to Circuit Specialists for having programming info (!) on\n    their web page.  (http://www.cir.com/)\n*/\n\n#include \"../comedidev.h\"\n\n#include <linux/ioport.h>\n\n#undef ACL6126_IRQ\t\t/* no interrupt support (yet) */\n\n#define PCL726_SIZE 16\n#define PCL727_SIZE 32\n#define PCL728_SIZE 8\n\n#define PCL726_DAC0_HI 0\n#define PCL726_DAC0_LO 1\n\n#define PCL726_DO_HI 12\n#define PCL726_DO_LO 13\n#define PCL726_DI_HI 14\n#define PCL726_DI_LO 15\n\n#define PCL727_DO_HI 24\n#define PCL727_DO_LO 25\n#define PCL727_DI_HI  0\n#define PCL727_DI_LO  1\n\nstatic const struct comedi_lrange range_4_20mA = { 1, {RANGE_mA(4, 20)} };\nstatic const struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} };\n\nstatic const struct comedi_lrange *const rangelist_726[] = {\n\t&range_unipolar5, &range_unipolar10,\n\t&range_bipolar5, &range_bipolar10,\n\t&range_4_20mA, &range_unknown\n};\n\nstatic const struct comedi_lrange *const rangelist_727[] = {\n\t&range_unipolar5, &range_unipolar10,\n\t&range_bipolar5,\n\t&range_4_20mA\n};\n\nstatic const struct comedi_lrange *const rangelist_728[] = {\n\t&range_unipolar5, &range_unipolar10,\n\t&range_bipolar5, &range_bipolar10,\n\t&range_4_20mA, &range_0_20mA\n};\n\nstatic int pcl726_attach(struct comedi_device *dev,\n\t\t\t struct comedi_devconfig *it);\nstatic int pcl726_detach(struct comedi_device *dev);\n\nstruct pcl726_board {\n\n\tconst char *name;\t/*  driver name */\n\tint n_aochan;\t\t/*  num of D/A chans */\n\tint num_of_ranges;\t/*  num of ranges */\n\tunsigned int IRQbits;\t/*  allowed interrupts */\n\tunsigned int io_range;\t/*  len of IO space */\n\tchar have_dio;\t\t/*  1=card have DI/DO ports */\n\tint di_hi;\t\t/*  ports for DI/DO operations */\n\tint di_lo;\n\tint do_hi;\n\tint do_lo;\n\tconst struct comedi_lrange *const *range_type_list;\n\t/*  list of supported ranges */\n};\n\nstatic const struct pcl726_board boardtypes[] = {\n\t{\"pcl726\", 6, 6, 0x0000, PCL726_SIZE, 1,\n\t PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,\n\t &rangelist_726[0],},\n\t{\"pcl727\", 12, 4, 0x0000, PCL727_SIZE, 1,\n\t PCL727_DI_HI, PCL727_DI_LO, PCL727_DO_HI, PCL727_DO_LO,\n\t &rangelist_727[0],},\n\t{\"pcl728\", 2, 6, 0x0000, PCL728_SIZE, 0,\n\t 0, 0, 0, 0,\n\t &rangelist_728[0],},\n\t{\"acl6126\", 6, 5, 0x96e8, PCL726_SIZE, 1,\n\t PCL726_DI_HI, PCL726_DI_LO, PCL726_DO_HI, PCL726_DO_LO,\n\t &rangelist_726[0],},\n\t{\"acl6128\", 2, 6, 0x0000, PCL728_SIZE, 0,\n\t 0, 0, 0, 0,\n\t &rangelist_728[0],},\n};\n\n#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl726_board))\n#define this_board ((const struct pcl726_board *)dev->board_ptr)\n\nstatic struct comedi_driver driver_pcl726 = {\n\t.driver_name = \"pcl726\",\n\t.module = THIS_MODULE,\n\t.attach = pcl726_attach,\n\t.detach = pcl726_detach,\n\t.board_name = &boardtypes[0].name,\n\t.num_names = n_boardtypes,\n\t.offset = sizeof(struct pcl726_board),\n};\n\nCOMEDI_INITCLEANUP(driver_pcl726);\n\nstruct pcl726_private {\n\n\tint bipolar[12];\n\tconst struct comedi_lrange *rangelist[12];\n\tunsigned int ao_readback[12];\n};\n\n#define devpriv ((struct pcl726_private *)dev->private)\n\nstatic int pcl726_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,\n\t\t\t  struct comedi_insn *insn, unsigned int *data)\n{\n\tint hi, lo;\n\tint n;\n\tint chan = CR_CHAN(insn->chanspec);\n\n\tfor (n = 0; n < insn->n; n++) {\n\t\tlo = data[n] & 0xff;\n\t\thi = (data[n] >> 8) & 0xf;\n\t\tif (devpriv->bipolar[chan])\n\t\t\thi ^= 0x8;\n\t\t/*\n\t\t * the programming info did not say which order\n\t\t * to write bytes.  switch the order of the next\n\t\t * two lines if you get glitches.\n\t\t */\n\t\toutb(hi, dev->iobase + PCL726_DAC0_HI + 2 * chan);\n\t\toutb(lo, dev->iobase + PCL726_DAC0_LO + 2 * chan);\n\t\tdevpriv->ao_readback[chan] = data[n];\n\t}\n\n\treturn n;\n}\n\nstatic int pcl726_ao_insn_read(struct comedi_device *dev,\n\t\t\t       struct comedi_subdevice *s,\n\t\t\t       struct comedi_insn *insn, unsigned int *data)\n{\n\tint chan = CR_CHAN(insn->chanspec);\n\tint n;\n\n\tfor (n = 0; n < insn->n; n++)\n\t\tdata[n] = devpriv->ao_readback[chan];\n\treturn n;\n}\n\nstatic int pcl726_di_insn_bits(struct comedi_device *dev,\n\t\t\t       struct comedi_subdevice *s,\n\t\t\t       struct comedi_insn *insn, unsigned int *data)\n{\n\tif (insn->n != 2)\n\t\treturn -EINVAL;\n\n\tdata[1] = inb(dev->iobase + this_board->di_lo) |\n\t    (inb(dev->iobase + this_board->di_hi) << 8);\n\n\treturn 2;\n}\n\nstatic int pcl726_do_insn_bits(struct comedi_device *dev,\n\t\t\t       struct comedi_subdevice *s,\n\t\t\t       struct comedi_insn *insn, unsigned int *data)\n{\n\tif (insn->n != 2)\n\t\treturn -EINVAL;\n\n\tif (data[0]) {\n\t\ts->state &= ~data[0];\n\t\ts->state |= data[0] & data[1];\n\t}\n\tif (data[1] & 0x00ff)\n\t\toutb(s->state & 0xff, dev->iobase + this_board->do_lo);\n\tif (data[1] & 0xff00)\n\t\toutb((s->state >> 8), dev->iobase + this_board->do_hi);\n\n\tdata[1] = s->state;\n\n\treturn 2;\n}\n\nstatic int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)\n{\n\tstruct comedi_subdevice *s;\n\tunsigned long iobase;\n\tunsigned int iorange;\n\tint ret, i;\n#ifdef ACL6126_IRQ\n\tunsigned int irq;\n#endif\n\n\tiobase = it->options[0];\n\tiorange = this_board->io_range;\n\tprintk(KERN_WARNING, \"comedi%d: pcl726: board=%s, 0x%03lx \", dev->minor,\n\t       this_board->name, iobase);\n\tif (!request_region(iobase, iorange, \"pcl726\")) {\n\t\tprintk(KERN_WARNING, \"I/O port conflict\\n\");\n\t\treturn -EIO;\n\t}\n\n\tdev->iobase = iobase;\n\n\tdev->board_name = this_board->name;\n\n\tret = alloc_private(dev, sizeof(struct pcl726_private));\n\tif (ret < 0)\n\t\treturn -ENOMEM;\n\n\tfor (i = 0; i < 12; i++) {\n\t\tdevpriv->bipolar[i] = 0;\n\t\tdevpriv->rangelist[i] = &range_unknown;\n\t}\n\n#ifdef ACL6126_IRQ\n\tirq = 0;\n\tif (boardtypes[board].IRQbits != 0) {\t/* board support IRQ */\n\t\tirq = it->options[1];\n\t\tdevpriv->first_chan = 2;\n\t\tif (irq) {\t/* we want to use IRQ */\n\t\t\tif (((1 << irq) & boardtypes[board].IRQbits) == 0) {\n\t\t\t\tprintk(KERN_WARNING,\n\t\t\t\t\t\", IRQ %d is out of allowed range,\"\n\t\t\t\t\t\" DISABLING IT\", irq);\n\t\t\t\tirq = 0;\t/* Bad IRQ */\n\t\t\t} else {\n\t\t\t\tif (request_irq(irq, interrupt_pcl818, 0,\n\t\t\t\t\t\t\"pcl726\", dev)) {\n\t\t\t\t\tprintk(KERN_WARNING,\n\t\t\t\t\t\t\", unable to allocate IRQ %d,\"\n\t\t\t\t\t\t\" DISABLING IT\", irq);\n\t\t\t\t\tirq = 0;\t/* Can't use IRQ */\n\t\t\t\t} else {\n\t\t\t\t\tprintk(\", irq=%d\", irq);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tdev->irq = irq;\n#endif\n\n\tprintk(\"\\n\");\n\n\tret = alloc_subdevices(dev, 3);\n\tif (ret < 0)\n\t\treturn ret;\n\n\ts = dev->subdevices + 0;\n\t/* ao */\n\ts->type = COMEDI_SUBD_AO;\n\ts->subdev_flags = SDF_WRITABLE | SDF_GROUND;\n\ts->n_chan = this_board->n_aochan;\n\ts->maxdata = 0xfff;\n\ts->len_chanlist = 1;\n\ts->insn_write = pcl726_ao_insn;\n\ts->insn_read = pcl726_ao_insn_read;\n\ts->range_table_list = devpriv->rangelist;\n\tfor (i = 0; i < this_board->n_aochan; i++) {\n\t\tint j;\n\n\t\tj = it->options[2 + 1];\n\t\tif ((j < 0) || (j >= this_board->num_of_ranges)) {\n\t\t\tprintk\n\t\t\t    (\"Invalid range for channel %d! Must be 0<=%d<%d\\n\",\n\t\t\t     i, j, this_board->num_of_ranges - 1);\n\t\t\tj = 0;\n\t\t}\n\t\tdevpriv->rangelist[i] = this_board->range_type_list[j];\n\t\tif (devpriv->rangelist[i]->range[0].min ==\n\t\t    -devpriv->rangelist[i]->range[0].max)\n\t\t\tdevpriv->bipolar[i] = 1;\t/* bipolar range */\n\t}\n\n\ts = dev->subdevices + 1;\n\t/* di */\n\tif (!this_board->have_dio) {\n\t\ts->type = COMEDI_SUBD_UNUSED;\n\t} else {\n\t\ts->type = COMEDI_SUBD_DI;\n\t\ts->subdev_flags = SDF_READABLE | SDF_GROUND;\n\t\ts->n_chan = 16;\n\t\ts->maxdata = 1;\n\t\ts->len_chanlist = 1;\n\t\ts->insn_bits = pcl726_di_insn_bits;\n\t\ts->range_table = &range_digital;\n\t}\n\n\ts = dev->subdevices + 2;\n\t/* do */\n\tif (!this_board->have_dio) {\n\t\ts->type = COMEDI_SUBD_UNUSED;\n\t} else {\n\t\ts->type = COMEDI_SUBD_DO;\n\t\ts->subdev_flags = SDF_WRITABLE | SDF_GROUND;\n\t\ts->n_chan = 16;\n\t\ts->maxdata = 1;\n\t\ts->len_chanlist = 1;\n\t\ts->insn_bits = pcl726_do_insn_bits;\n\t\ts->range_table = &range_digital;\n\t}\n\n\treturn 0;\n}\n\nstatic int pcl726_detach(struct comedi_device *dev)\n{\n/* printk(\"comedi%d: pcl726: remove\\n\",dev->minor); */\n\n#ifdef ACL6126_IRQ\n\tif (dev->irq)\n\t\tfree_irq(dev->irq, dev);\n#endif\n\n\tif (dev->iobase)\n\t\trelease_region(dev->iobase, this_board->io_range);\n\n\treturn 0;\n}\n"},{"id":"125813","messageId":"7vskd9akv6.fsf@alter.siamese.dyndns.org","threadId":"21338","inReplyTo":"alpine.LNX.2.00.0910231621550.14365@iabervon.org","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-23T20:58:05Z","receivedAt":"2009-10-23T20:58:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Fri, 23 Oct 2009, Kevyn-Alexandre Paré wrote:\n>\n>> Just before I send my patch I got this error with:\n>> ./scripts/checkpatch.pl --terse --file\n>> 0001-Staging-comedi-driver-fix-coding-style.patch\n>\n> You're using checkpatch --file on a patch. I hope you don't intend your \n> patch to be added to the kernel source as a file, but rather applied to \n> the kernel source, changing other files. (I bet \"gcc 0001-Staging*.patch\" \n> will get interesting errors, too...) The patch format adds a single \n> character at the beginning of each line to say whether it's a addition, a \n> deletion, or a context line, and the context lines are identified by a \n> space character. This means that a blank context line consists of just \n> this space character, which is therefore a trailing space. We get the same \n> type of complaints when we have expected diff output in our test scripts.\n>\n> I'm kind of surprised that checkpatch doesn't completely blow up when it's \n> expecting a source file and getting a patch (and maybe tell you what \n> you've done). But that's the source of your errors, anyway.\n\nAh, your analysis is correct.  This is a usage error of checkpatch script\nand there is nothing for us to worry about.\n\nThanks; I also failed to spot --file option when I responded.\n--\nTo unsubscribe from this list: send the line \"unsubscribe linux-newbie\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html\nPlease read the FAQ at http://www.linux-learn.org/faqs\n"},{"id":"125815","messageId":"dc1d0f40910231426j45184429qbe3531bc76555c77@mail.gmail.com","threadId":"21338","inReplyTo":"7vskd9akv6.fsf@alter.siamese.dyndns.org","subject":"Re: Write and Submit Your First Kernel Patch","fromName":"Kevyn-Alexandre Paré","fromEmail":"kevyn.alexandre.pare@gmail.com","sentAt":"2009-10-23T21:26:25Z","receivedAt":"2009-10-23T21:26:25Z","isPatch":false,"sender":{"key":"kevyn.alexandre.pare@gmail.com","avatar":"https://gravatar.com/avatar/5c2aa3d38a029ed59b3a5f96929affa425310b608bd83294da90fe6efa97a232?d=mp&s=160"},"body":"My mistake but I learn a lot from you guys!\n\nI should simply have done:\n./scripts/checkpatch.pl --terse --patch\n0001-Staging-comedi-driver-fix-coding-style.patch\n\nor\n\n./scripts/checkpatch.pl --terse --patch\n0001-Staging-comedi-driver-fix-coding-style.patch\n# Since --patch is the default!\n\nNo warning to the output, I will change my blog\n\nthx again\n\nkap\n\nOn Fri, Oct 23, 2009 at 4:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n>\n>> On Fri, 23 Oct 2009, Kevyn-Alexandre Paré wrote:\n>>\n>>> Just before I send my patch I got this error with:\n>>> ./scripts/checkpatch.pl --terse --file\n>>> 0001-Staging-comedi-driver-fix-coding-style.patch\n>>\n>> You're using checkpatch --file on a patch. I hope you don't intend your\n>> patch to be added to the kernel source as a file, but rather applied to\n>> the kernel source, changing other files. (I bet \"gcc 0001-Staging*.patch\"\n>> will get interesting errors, too...) The patch format adds a single\n>> character at the beginning of each line to say whether it's a addition, a\n>> deletion, or a context line, and the context lines are identified by a\n>> space character. This means that a blank context line consists of just\n>> this space character, which is therefore a trailing space. We get the same\n>> type of complaints when we have expected diff output in our test scripts.\n>>\n>> I'm kind of surprised that checkpatch doesn't completely blow up when it's\n>> expecting a source file and getting a patch (and maybe tell you what\n>> you've done). But that's the source of your errors, anyway.\n>\n> Ah, your analysis is correct.  This is a usage error of checkpatch script\n> and there is nothing for us to worry about.\n>\n> Thanks; I also failed to spot --file option when I responded.\n>\n--\nTo unsubscribe from this list: send the line \"unsubscribe linux-newbie\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html\nPlease read the FAQ at http://www.linux-learn.org/faqs\n"}]}