On Dec 28 2007 11:09, Jiri Slaby wrote:
>
>+struct mxser_cardinfo {
>+ unsigned int nports;
>+ char *name;
>+ unsigned int flags;
>+};
const char *name. Maybe name could also be put at the front
to get closer struct packing on 64-bit?
>
>+static int mxvar_baud_table[] = {
>+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
>+ 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
>+};
>+static unsigned int mxvar_baud_table1[] = {
>+ 0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
>+ B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
>+};
Constify both, if possible?
>+struct mxser_port {
>+ struct mxser_board *board;
>+ struct tty_struct *tty;
>+
>+ unsigned long ioaddr;
>+ unsigned long opmode_ioaddr;
>+ int max_baud;
>
> int rx_high_water;
> int rx_trigger; /* Rx fifo trigger level */
> int rx_low_water;
> int baud_base; /* max. speed */
>+ long realbaud;
> int type; /* UART type */
realbaud could also be reordered one up or one down.
There are probably more fields around.
>-static int CheckIsMoxaMust(int io)
>+static int __devinit CheckIsMoxaMust(unsigned long io)
> {
> u8 oldmcr, hwid;
> int i;
>@@ -434,90 +336,15 @@ static int CheckIsMoxaMust(int io)
> }
>
> GET_MOXA_MUST_HARDWARE_ID(io, &hwid);
>- for (i = 0; i < UART_TYPE_NUM; i++) {
>- if (hwid == Gmoxa_uart_id[i])
>+ for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */
>+ if (hwid == Gpci_uart_info[i].type)
> return (int)hwid;
I do not think a cast is necessary, hwid is implicitly upconverted to int.
>+static int mxser_get_serial_info(struct mxser_port *info,
>+ struct serial_struct __user *retinfo)
> {
>- struct mxser_struct *info = tty->driver_data;
>- int retval;
>+ struct serial_struct tmp;
>+
>+ if (!retinfo)
>+ return -EFAULT;
>+ memset(&tmp, 0, sizeof(tmp));
>+ tmp.type = info->type;
>+ tmp.line = info->tty->index;
>+ tmp.port = info->ioaddr;
>+ tmp.irq = info->board->irq;
>+ tmp.flags = info->flags;
>+ tmp.baud_base = info->baud_base;
>+ tmp.close_delay = info->close_delay;
>+ tmp.closing_wait = info->closing_wait;
>+ tmp.custom_divisor = info->custom_divisor;
>+ tmp.hub6 = 0;
>+ if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
>+ return -EFAULT;
>+ return 0;
>+}
>+
Maybe without the extra memcpy?:
static int mxser_get_serial_info(struct mxser_port *info,
struct serial_struct __user *retinfo)
{
struct mxser_struct *info = tty->driver_data;
int retval;
struct serial_struct tmp = {
.type = info->type,
.line = info->tty->index,
.port = info->ioaddr,
.irq = info->board->irq,
.flags = info->flags,
.baud_base = info->baud_base,
.close_delay = info->close_delay,
.closing_wait = info->closing_wait,
.custom_divisor = info->custom_divisor,
.hub6 = 0,
};
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
return -EFAULT;
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]