Re: [PATCH 1/2] serial/8250: Add support for RS485 IOCTLs

From: One Thousand Gnomes
Date: Thu Jul 31 2014 - 10:09:59 EST


> This patch allow the users of the 8250 infrastructure to define a
> handler for RS485 configration.

This feels to me like the right code in the wrong place.

> If no handler is defined the 8250 driver will work as usual.

Is there any reasons we can't have uart_ops.rs485_config and the RS485
ioctl logic in the serial_core, or even push rs485_get/put into the tty
ioctl handler and tty ops so it's not duplicated everywhere ?

> + switch (cmd) {
> + case TIOCSRS485:
> + if (copy_from_user(&rs485_config, (void __user *)arg,
> + sizeof(rs485_config)))
> + return -EFAULT;
> +
> + ret = up->rs485_config(up, &rs485_config);
> + if (ret)
> + return ret;
> +
> + memcpy(&up->rs485, &rs485_config, sizeof(rs485_config));
> +
> + return 0;
> + case TIOCGRS485:
> + if (copy_to_user((void __user *)arg, &up->rs485,
> + sizeof(up->rs485)))
> + return -EFAULT;
> + return 0;

Possibly your mutex needs to cover parallel get an set, but then again
anyone doing that may well deserve what they get 8)

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/