From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: "Jimmy Chen" <jimmy.chen@moxa.com>
Cc: <linux-kernel@vger.kernel.org>, <gregkh@suse.de>
Subject: Re: [PATCH 2/2] misc: add real function open/read/write/ioctl/close for moxa_serial_io driver
Date: Mon, 25 Apr 2011 12:40:49 +0100 [thread overview]
Message-ID: <20110425124049.0a852385@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <ECB3782BB8F03341905DD923270296115D5AC2@mhqms01.moxa.com>
> Add real function and GPL license.
We really don't need an entire extra copy of the GPL. There is one in the
source tree already to which you can refer!
In code terms:
- We have an expected interface for RS485/RS232 switching which
is in the serial drivers. So the functionality is good but it
really wants connecting to the serial driver.
> -/* write function called when to /dev/mxsio is written */
> -static ssize_t io_write (struct file *file, const char *buf,
> - size_t count, loff_t *ppos) {
> - int err;
> - err = copy_from_user(string,buf,count);
> -
> - if(count < 3)
> - return -EINVAL;
> - if (err != 0)
> - return -EFAULT;
> -
> - outb((unsigned char)string[2], (((unsigned short)string[0])<<8)|((unsigned short)string[1]));
This can access anything so is entirely unsafe and unsuitable. Also you
have no locking but use static buffers.
> - outb(do_state_keep,BASEPORT+5);
BASEPORT appears to be a magic constant - where does it come from given
0x8000 is usually in PCI space ?
> - outb(do_state_keep, BASEPORT+5);
> - outb(0x00, BASEPORT);
> -
> - /* set default serial mode to RS232 */
> - outb(0x88, BASEPORT+4);
No checks to see if the relevant hardware is really present - so it will
crash other systems
> -void superio_enter_config(void) {
> -#if defined(DA681)
> - outb (0x87, SUPERIO_CONFIG_PORT);
> - outb(0x80, 0xeb); // a Small delay
> - outb (0x87, SUPERIO_CONFIG_PORT);
> - outb(0x80, 0xeb); // a Small delay
> -#elif defined(V21XX)
> - outb (0x87, SUPERIO_CONFIG_PORT);
> - outb (0x01, SUPERIO_CONFIG_PORT);
> - outb (0x55, SUPERIO_CONFIG_PORT);
> - outb (0x55, SUPERIO_CONFIG_PORT);
> -#endif
And what if a kernel is being built for two different configs at once ?
> -}
> -
> -void superio_exit_config(void) {
> - outb(0x02, SUPERIO_CONFIG_PORT);
> - outb( 0x80, 0xeb); // a Small delay
Use outb_p()
the kernel then will figure out the right way to do the delay. Poking
random I/O ports won't do what you want on some systems and may even
crash them.
next prev parent reply other threads:[~2011-04-25 11:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-22 10:07 [PATCH 0/2] misc: add support to MOXA V2100 serial io driver Jimmy Chen (陳永達)
2011-04-25 2:28 ` [PATCH 1/2] misc: add option in menu to support " Jimmy Chen (陳永達)
2011-04-25 2:35 ` [PATCH 2/2] misc: add real function open/read/write/ioctl/close for moxa_serial_io driver Jimmy Chen (陳永達)
2011-04-25 2:47 ` Joe Perches
2011-04-25 3:01 ` Greg KH
2011-04-25 3:44 ` Jimmy Chen (陳永達)
2011-04-25 14:13 ` Greg KH
2011-04-26 9:01 ` Jimmy Chen (陳永達)
2011-04-26 13:20 ` Greg KH
2011-04-25 11:40 ` Alan Cox [this message]
2011-04-25 11:34 ` [PATCH 1/2] misc: add option in menu to support MOXA V2100 serial io driver Alan Cox
2011-04-25 6:44 [PATCH 2/2] misc: add real function open/read/write/ioctl/close for moxa_serial_io driver Jimmy Chen (陳永達)
2011-04-25 7:30 ` Joe Perches
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=20110425124049.0a852385@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@suse.de \
--cc=jimmy.chen@moxa.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
all inboxes | Powered by JetHome®