USB: serial: mos7840: Add a product ID for the new product
Subsystems (2)
PATCH v3 1/1 USB: serial: mos7840: Add a product ID for the new product
From: JackyChou <[email protected]>
For now, pause to add PID 0x7843 in the driver.
Simplify the processes of some functions.
Such modifications will not affect the old devices and will make the addition of new product (0x7843) more flexible in the future.
--- drivers/usb/serial/mos7840.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)
MCS_WR_RTYPE, val, reg, NULL, 0,
@@ -332,15 +327,10 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
return -ENOMEM;
/* Wval is same as application number */
- if (port->serial->num_ports == 4) {
+ if (port->serial->num_ports == 2 && port->port_number != 0)
+ Wval = ((__u16)port->port_number + 2) << 8;
+ else
Wval = ((__u16)port->port_number + 1) << 8;
- } else {
- if (port->port_number == 0) {
- Wval = ((__u16)port->port_number + 1) << 8;
- } else {
- Wval = ((__u16)port->port_number + 2) << 8;
- }
- }
dev_dbg(&port->dev, "%s application number is %x\n", __func__,
Wval);
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
MCS_RD_RTYPE, Wval, reg, buf,VENDOR_READ_LENGTH,
@@ -2146,22 +2136,16 @@ static int mos7840_port_probe(struct usb_serial_port *port)
mos7840_port->SpRegOffset = 0x0; mos7840_port->ControlRegOffset = 0x1; mos7840_port->DcrRegOffset = 0x4;
- } else if ((mos7840_port->port_num == 2) && (serial->num_ports ==
4)) {
- mos7840_port->SpRegOffset = 0x8;
- mos7840_port->ControlRegOffset = 0x9;
- mos7840_port->DcrRegOffset = 0x16;
- } else if ((mos7840_port->port_num == 2) && (serial->num_ports ==
2)) {
- mos7840_port->SpRegOffset = 0xa;
- mos7840_port->ControlRegOffset = 0xb;
- mos7840_port->DcrRegOffset = 0x19;
- } else if ((mos7840_port->port_num == 3) && (serial->num_ports ==
4)) {
- mos7840_port->SpRegOffset = 0xa;
- mos7840_port->ControlRegOffset = 0xb;
- mos7840_port->DcrRegOffset = 0x19;
- } else if ((mos7840_port->port_num == 4) && (serial->num_ports ==
4)) {
- mos7840_port->SpRegOffset = 0xc;
- mos7840_port->ControlRegOffset = 0xd;
- mos7840_port->DcrRegOffset = 0x1c;
+ } else {
+ u8 port_offset;
+
+ if ((mos7840_port->port_num == 2) && (serial->num_ports ==
2))
+ port_offset = 1;
+ else
+ port_offset = mos7840_port->port_num - 2;
+ mos7840_port->SpRegOffset = 0x8 + (2 * port_offset);
+ mos7840_port->ControlRegOffset = 0x9 + (2 * port_offset);
+ mos7840_port->DcrRegOffset = 0x16 + (3 * port_offset);
}
mos7840_dump_serial_port(port, mos7840_port); mos7840_set_port_private(port, mos7840_port);
drivers/usb/serial/mos7840.c +0 -0
@@ -298,15 +298,10 @@ static int mos7840_set_uart_reg(struct usb_serial_port
*port, __u16 reg,
val = val & 0x00ff;
/* For the UART control registers, the application number need
to be Or'ed */
- if (port->serial->num_ports == 4) {
+ if (port->serial->num_ports == 2 && port->port_number != 0)
+ val |= ((__u16)port->port_number + 2) << 8;
+ else
val |= ((__u16)port->port_number + 1) << 8;
- } else {
- if (port->port_number == 0) {
- val |= ((__u16)port->port_number + 1) << 8;
- } else {
- val |= ((__u16)port->port_number + 2) << 8;
- }
- }
dev_dbg(&port->dev, "%s application number is %x\n", __func__, val); return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
Johan Hovold
maintainerQuoted 2 lines · JackyChou
From: JackyChou <[email protected]>
Thanks for the update. This patch appears to have been corrupted (tabs replaced with spaces) so it cannot be applied. Try sending the patch to yourself first and make sure you can apply it with git am (and/or run checkpatch on the result).
Quoted 1 line
For now, pause to add PID
0x7843in the driver.
This doesn't belong in the commit message. But there's no reason not to include the patch adding the PID in the same series. Just send a two-part series with this patch as the first patch, and the PID one as the second patch (depending on the first).
Take a look at git-format-patch and git-send-email which can simply the process.
Also make sure each commit message is self-contained, and that the patch summary (Subject) reflects what each patch does.
Quoted 1 line
Simplify the processes of some functions.
Please be a bit more specific.
Quoted 2 lines
Such modifications will not affect the old devices and will make the addition of new product (
0x7843) more flexible in the future.
This can still stay here.
Quoted 16 lines
Signed-off-by JackyChou <[email protected]>--- drivers/usb/serial/mos7840.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)drivers/usb/serial/mos7840.c +1
-1@@ -298,15 +298,10 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, val = val &0x00ff ;/* For the UART control registers, the application number need to be Or'ed */ -if (port->serial->num_ports ==4 ) { +if (port->serial->num_ports ==2 && port->port_number !=0 )
drivers/usb/serial/mos7840.c static int mos7840_set_uart_reg(struct usb_serial_port · line 310
Quoted 10 lines
drivers/usb/serial/mos7840.c +2
-7+ val |= ((__u16 )port->port_number +2 ) <<8 ; + else val |= ((__u16)port->port_number + 1) << 8; - }else { -if (port->port_number ==0 ) { - val |= ((__u16 )port->port_number +1 ) <<8 ; - }else { - val |= ((__u16 )port->port_number +2 ) <<8 ; - } - }
Perhaps this would be more readable if you used a port offset here as well, and only make sure to map the second port in the two-port case to port offset three.
Thanks,
Johan