summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-09-12 07:45:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-10-13 00:50:42 -0400
commit15cc7bad48977582a35c06f5afa0cfc1d4975bd9 (patch)
treee1251f4ae5bd0d944581fc2d7564cb13fe268806
parentfc6cc979e42264efbff6c01a8c6af144cc3e43e4 (diff)
usb_wwan: switch to ->[sg]et_serial()
Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/usb/serial/option.c3
-rw-r--r--drivers/usb/serial/usb-wwan.h6
-rw-r--r--drivers/usb/serial/usb_wwan.c63
3 files changed, 23 insertions, 49 deletions
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 0215b70c4efc..e6e811ac2331 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1962,7 +1962,8 @@ static struct usb_serial_driver option_1port_device = {
1962 .chars_in_buffer = usb_wwan_chars_in_buffer, 1962 .chars_in_buffer = usb_wwan_chars_in_buffer,
1963 .tiocmget = usb_wwan_tiocmget, 1963 .tiocmget = usb_wwan_tiocmget,
1964 .tiocmset = usb_wwan_tiocmset, 1964 .tiocmset = usb_wwan_tiocmset,
1965 .ioctl = usb_wwan_ioctl, 1965 .get_serial = usb_wwan_get_serial_info,
1966 .set_serial = usb_wwan_set_serial_info,
1966 .attach = option_attach, 1967 .attach = option_attach,
1967 .release = option_release, 1968 .release = option_release,
1968 .port_probe = usb_wwan_port_probe, 1969 .port_probe = usb_wwan_port_probe,
diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h
index d28dab4b9eff..1c120eaf4091 100644
--- a/drivers/usb/serial/usb-wwan.h
+++ b/drivers/usb/serial/usb-wwan.h
@@ -15,8 +15,10 @@ extern int usb_wwan_write_room(struct tty_struct *tty);
15extern int usb_wwan_tiocmget(struct tty_struct *tty); 15extern int usb_wwan_tiocmget(struct tty_struct *tty);
16extern int usb_wwan_tiocmset(struct tty_struct *tty, 16extern int usb_wwan_tiocmset(struct tty_struct *tty,
17 unsigned int set, unsigned int clear); 17 unsigned int set, unsigned int clear);
18extern int usb_wwan_ioctl(struct tty_struct *tty, 18extern int usb_wwan_get_serial_info(struct tty_struct *tty,
19 unsigned int cmd, unsigned long arg); 19 struct serial_struct *ss);
20extern int usb_wwan_set_serial_info(struct tty_struct *tty,
21 struct serial_struct *ss);
20extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 22extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
21 const unsigned char *buf, int count); 23 const unsigned char *buf, int count);
22extern int usb_wwan_chars_in_buffer(struct tty_struct *tty); 24extern int usb_wwan_chars_in_buffer(struct tty_struct *tty);
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 912472f26e4f..7e855c87e4f7 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -132,38 +132,32 @@ int usb_wwan_tiocmset(struct tty_struct *tty,
132} 132}
133EXPORT_SYMBOL(usb_wwan_tiocmset); 133EXPORT_SYMBOL(usb_wwan_tiocmset);
134 134
135static int get_serial_info(struct usb_serial_port *port, 135int usb_wwan_get_serial_info(struct tty_struct *tty,
136 struct serial_struct __user *retinfo) 136 struct serial_struct *ss)
137{ 137{
138 struct serial_struct tmp; 138 struct usb_serial_port *port = tty->driver_data;
139 139
140 memset(&tmp, 0, sizeof(tmp)); 140 ss->line = port->minor;
141 tmp.line = port->minor; 141 ss->port = port->port_number;
142 tmp.port = port->port_number; 142 ss->baud_base = tty_get_baud_rate(port->port.tty);
143 tmp.baud_base = tty_get_baud_rate(port->port.tty); 143 ss->close_delay = port->port.close_delay / 10;
144 tmp.close_delay = port->port.close_delay / 10; 144 ss->closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
145 tmp.closing_wait = port->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
146 ASYNC_CLOSING_WAIT_NONE : 145 ASYNC_CLOSING_WAIT_NONE :
147 port->port.closing_wait / 10; 146 port->port.closing_wait / 10;
148
149 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
150 return -EFAULT;
151 return 0; 147 return 0;
152} 148}
149EXPORT_SYMBOL(usb_wwan_get_serial_info);
153 150
154static int set_serial_info(struct usb_serial_port *port, 151int usb_wwan_set_serial_info(struct tty_struct *tty,
155 struct serial_struct __user *newinfo) 152 struct serial_struct *ss)
156{ 153{
157 struct serial_struct new_serial; 154 struct usb_serial_port *port = tty->driver_data;
158 unsigned int closing_wait, close_delay; 155 unsigned int closing_wait, close_delay;
159 int retval = 0; 156 int retval = 0;
160 157
161 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 158 close_delay = ss->close_delay * 10;
162 return -EFAULT; 159 closing_wait = ss->closing_wait == ASYNC_CLOSING_WAIT_NONE ?
163 160 ASYNC_CLOSING_WAIT_NONE : ss->closing_wait * 10;
164 close_delay = new_serial.close_delay * 10;
165 closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
166 ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
167 161
168 mutex_lock(&port->port.mutex); 162 mutex_lock(&port->port.mutex);
169 163
@@ -181,30 +175,7 @@ static int set_serial_info(struct usb_serial_port *port,
181 mutex_unlock(&port->port.mutex); 175 mutex_unlock(&port->port.mutex);
182 return retval; 176 return retval;
183} 177}
184 178EXPORT_SYMBOL(usb_wwan_set_serial_info);
185int usb_wwan_ioctl(struct tty_struct *tty,
186 unsigned int cmd, unsigned long arg)
187{
188 struct usb_serial_port *port = tty->driver_data;
189
190 dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
191
192 switch (cmd) {
193 case TIOCGSERIAL:
194 return get_serial_info(port,
195 (struct serial_struct __user *) arg);
196 case TIOCSSERIAL:
197 return set_serial_info(port,
198 (struct serial_struct __user *) arg);
199 default:
200 break;
201 }
202
203 dev_dbg(&port->dev, "%s arg not supported\n", __func__);
204
205 return -ENOIOCTLCMD;
206}
207EXPORT_SYMBOL(usb_wwan_ioctl);
208 179
209int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, 180int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
210 const unsigned char *buf, int count) 181 const unsigned char *buf, int count)