blob: 3c4caa60c9265dd95f62d7a3aba84d40cdba0492 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +09002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Filename: ircomm_param.c
4 * Version: 1.0
5 * Description: Parameter handling for the IrCOMM protocol
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Mon Jun 7 10:25:11 1999
9 * Modified at: Sun Jan 30 14:32:03 2000
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090011 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090013 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * the License, or (at your option) any later version.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090018 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090023 *
24 * You should have received a copy of the GNU General Public License
Jeff Kirsherd3770502013-12-06 09:13:43 -080025 * along with this program; if not, see <http://www.gnu.org/licenses/>.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090026 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 ********************************************************************/
28
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/gfp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/workqueue.h>
31#include <linux/interrupt.h>
32
33#include <net/irda/irda.h>
34#include <net/irda/parameters.h>
35
36#include <net/irda/ircomm_core.h>
37#include <net/irda/ircomm_tty_attach.h>
38#include <net/irda/ircomm_tty.h>
39
40#include <net/irda/ircomm_param.h>
41
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090042static int ircomm_param_service_type(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090044static int ircomm_param_port_type(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090046static int ircomm_param_port_name(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090048static int ircomm_param_service_type(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090050static int ircomm_param_data_rate(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090052static int ircomm_param_data_format(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090054static int ircomm_param_flow_control(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 int get);
56static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get);
57static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090058static int ircomm_param_line_status(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 int get);
60static int ircomm_param_dte(void *instance, irda_param_t *param, int get);
61static int ircomm_param_dce(void *instance, irda_param_t *param, int get);
62static int ircomm_param_poll(void *instance, irda_param_t *param, int get);
63
Joe Perches785c20a2014-12-10 10:28:58 -080064static const pi_minor_info_t pi_minor_call_table_common[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 { ircomm_param_service_type, PV_INT_8_BITS },
66 { ircomm_param_port_type, PV_INT_8_BITS },
67 { ircomm_param_port_name, PV_STRING }
68};
Joe Perches785c20a2014-12-10 10:28:58 -080069static const pi_minor_info_t pi_minor_call_table_non_raw[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 { ircomm_param_data_rate, PV_INT_32_BITS | PV_BIG_ENDIAN },
71 { ircomm_param_data_format, PV_INT_8_BITS },
72 { ircomm_param_flow_control, PV_INT_8_BITS },
73 { ircomm_param_xon_xoff, PV_INT_16_BITS },
74 { ircomm_param_enq_ack, PV_INT_16_BITS },
75 { ircomm_param_line_status, PV_INT_8_BITS }
76};
Joe Perches785c20a2014-12-10 10:28:58 -080077static const pi_minor_info_t pi_minor_call_table_9_wire[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 { ircomm_param_dte, PV_INT_8_BITS },
79 { ircomm_param_dce, PV_INT_8_BITS },
80 { ircomm_param_poll, PV_NO_VALUE },
81};
82
Joe Perches785c20a2014-12-10 10:28:58 -080083static const pi_major_info_t pi_major_call_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 { pi_minor_call_table_common, 3 },
85 { pi_minor_call_table_non_raw, 6 },
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090086 { pi_minor_call_table_9_wire, 3 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070087/* { pi_minor_call_table_centronics } */
88};
89
90pi_param_info_t ircomm_param_info = { pi_major_call_table, 3, 0x0f, 4 };
91
92/*
93 * Function ircomm_param_request (self, pi, flush)
94 *
95 * Queue a parameter for the control channel
96 *
97 */
98int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
99{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 unsigned long flags;
101 struct sk_buff *skb;
102 int count;
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 IRDA_ASSERT(self != NULL, return -1;);
105 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 /* Make sure we don't send parameters for raw mode */
108 if (self->service_type == IRCOMM_3_WIRE_RAW)
109 return 0;
110
111 spin_lock_irqsave(&self->spinlock, flags);
112
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900113 skb = self->ctrl_skb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 if (!skb) {
Samuel Ortiz485fb2c2006-07-21 14:50:41 -0700115 skb = alloc_skb(256, GFP_ATOMIC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 if (!skb) {
117 spin_unlock_irqrestore(&self->spinlock, flags);
118 return -ENOMEM;
119 }
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 skb_reserve(skb, self->max_header_size);
122 self->ctrl_skb = skb;
123 }
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900124 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 * Inserting is a little bit tricky since we don't know how much
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900126 * room we will need. But this should hopefully work OK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 */
Arnaldo Carvalho de Melo27a884d2007-04-19 20:29:13 -0700128 count = irda_param_insert(self, pi, skb_tail_pointer(skb),
129 skb_tailroom(skb), &ircomm_param_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 if (count < 0) {
Joe Perches6c910232014-11-11 13:37:30 -0800131 net_warn_ratelimited("%s(), no room for parameter!\n",
132 __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 spin_unlock_irqrestore(&self->spinlock, flags);
134 return -1;
135 }
136 skb_put(skb, count);
137
138 spin_unlock_irqrestore(&self->spinlock, flags);
139
Joe Perches955a9d202014-11-11 14:44:57 -0800140 pr_debug("%s(), skb->len=%d\n", __func__ , skb->len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 if (flush) {
143 /* ircomm_tty_do_softint will take care of the rest */
144 schedule_work(&self->tqueue);
145 }
146
147 return count;
148}
149
150/*
151 * Function ircomm_param_service_type (self, buf, len)
152 *
153 * Handle service type, this function will both be called after the LM-IAS
154 * query and then the remote device sends its initial parameters
155 *
156 */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900157static int ircomm_param_service_type(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 int get)
159{
160 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
161 __u8 service_type = (__u8) param->pv.i;
162
163 IRDA_ASSERT(self != NULL, return -1;);
164 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
165
166 if (get) {
167 param->pv.i = self->settings.service_type;
168 return 0;
169 }
170
171 /* Find all common service types */
172 service_type &= self->service_type;
173 if (!service_type) {
Joe Perches955a9d202014-11-11 14:44:57 -0800174 pr_debug("%s(), No common service type to use!\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 return -1;
176 }
Joe Perches955a9d202014-11-11 14:44:57 -0800177 pr_debug("%s(), services in common=%02x\n", __func__ ,
178 service_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180 /*
181 * Now choose a preferred service type of those available
182 */
183 if (service_type & IRCOMM_CENTRONICS)
184 self->settings.service_type = IRCOMM_CENTRONICS;
185 else if (service_type & IRCOMM_9_WIRE)
186 self->settings.service_type = IRCOMM_9_WIRE;
187 else if (service_type & IRCOMM_3_WIRE)
188 self->settings.service_type = IRCOMM_3_WIRE;
189 else if (service_type & IRCOMM_3_WIRE_RAW)
190 self->settings.service_type = IRCOMM_3_WIRE_RAW;
191
Joe Perches955a9d202014-11-11 14:44:57 -0800192 pr_debug("%s(), resulting service type=0x%02x\n", __func__ ,
193 self->settings.service_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900195 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 * Now the line is ready for some communication. Check if we are a
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900197 * server, and send over some initial parameters.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 * Client do it in ircomm_tty_state_setup().
199 * Note : we may get called from ircomm_tty_getvalue_confirm(),
200 * therefore before we even have open any socket. And self->client
201 * is initialised to TRUE only later. So, we check if the link is
202 * really initialised. - Jean II
203 */
204 if ((self->max_header_size != IRCOMM_TTY_HDR_UNINITIALISED) &&
205 (!self->client) &&
206 (self->settings.service_type != IRCOMM_3_WIRE_RAW))
207 {
208 /* Init connection */
209 ircomm_tty_send_initial_parameters(self);
210 ircomm_tty_link_established(self);
211 }
212
213 return 0;
214}
215
216/*
217 * Function ircomm_param_port_type (self, param)
218 *
219 * The port type parameter tells if the devices are serial or parallel.
220 * Since we only advertise serial service, this parameter should only
221 * be equal to IRCOMM_SERIAL.
222 */
223static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
224{
225 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
226
227 IRDA_ASSERT(self != NULL, return -1;);
228 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 if (get)
231 param->pv.i = IRCOMM_SERIAL;
232 else {
233 self->settings.port_type = (__u8) param->pv.i;
234
Joe Perches955a9d202014-11-11 14:44:57 -0800235 pr_debug("%s(), port type=%d\n", __func__ ,
236 self->settings.port_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
238 return 0;
239}
240
241/*
242 * Function ircomm_param_port_name (self, param)
243 *
244 * Exchange port name
245 *
246 */
247static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
248{
249 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900250
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 IRDA_ASSERT(self != NULL, return -1;);
252 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
253
254 if (get) {
Joe Perches955a9d202014-11-11 14:44:57 -0800255 pr_debug("%s(), not imp!\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 } else {
Joe Perches955a9d202014-11-11 14:44:57 -0800257 pr_debug("%s(), port-name=%s\n", __func__ , param->pv.c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 strncpy(self->settings.port_name, param->pv.c, 32);
259 }
260
261 return 0;
262}
263
264/*
265 * Function ircomm_param_data_rate (self, param)
266 *
267 * Exchange data rate to be used in this settings
268 *
269 */
270static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
271{
272 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 IRDA_ASSERT(self != NULL, return -1;);
275 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
276
277 if (get)
278 param->pv.i = self->settings.data_rate;
279 else
280 self->settings.data_rate = param->pv.i;
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900281
Joe Perches955a9d202014-11-11 14:44:57 -0800282 pr_debug("%s(), data rate = %d\n", __func__ , param->pv.i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284 return 0;
285}
286
287/*
288 * Function ircomm_param_data_format (self, param)
289 *
290 * Exchange data format to be used in this settings
291 *
292 */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900293static int ircomm_param_data_format(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 int get)
295{
296 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
297
298 IRDA_ASSERT(self != NULL, return -1;);
299 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
300
301 if (get)
302 param->pv.i = self->settings.data_format;
303 else
304 self->settings.data_format = (__u8) param->pv.i;
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 return 0;
307}
308
309/*
310 * Function ircomm_param_flow_control (self, param)
311 *
312 * Exchange flow control settings to be used in this settings
313 *
314 */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900315static int ircomm_param_flow_control(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 int get)
317{
318 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
319
320 IRDA_ASSERT(self != NULL, return -1;);
321 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 if (get)
324 param->pv.i = self->settings.flow_control;
325 else
326 self->settings.flow_control = (__u8) param->pv.i;
327
Joe Perches955a9d202014-11-11 14:44:57 -0800328 pr_debug("%s(), flow control = 0x%02x\n", __func__ , (__u8)param->pv.i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330 return 0;
331}
332
333/*
334 * Function ircomm_param_xon_xoff (self, param)
335 *
336 * Exchange XON/XOFF characters
337 *
338 */
339static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
340{
341 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
342
343 IRDA_ASSERT(self != NULL, return -1;);
344 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 if (get) {
347 param->pv.i = self->settings.xonxoff[0];
348 param->pv.i |= self->settings.xonxoff[1] << 8;
349 } else {
350 self->settings.xonxoff[0] = (__u16) param->pv.i & 0xff;
351 self->settings.xonxoff[1] = (__u16) param->pv.i >> 8;
352 }
353
Joe Perches955a9d202014-11-11 14:44:57 -0800354 pr_debug("%s(), XON/XOFF = 0x%02x,0x%02x\n", __func__ ,
355 param->pv.i & 0xff, param->pv.i >> 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 return 0;
358}
359
360/*
361 * Function ircomm_param_enq_ack (self, param)
362 *
363 * Exchange ENQ/ACK characters
364 *
365 */
366static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
367{
368 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
369
370 IRDA_ASSERT(self != NULL, return -1;);
371 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 if (get) {
374 param->pv.i = self->settings.enqack[0];
375 param->pv.i |= self->settings.enqack[1] << 8;
376 } else {
377 self->settings.enqack[0] = (__u16) param->pv.i & 0xff;
378 self->settings.enqack[1] = (__u16) param->pv.i >> 8;
379 }
380
Joe Perches955a9d202014-11-11 14:44:57 -0800381 pr_debug("%s(), ENQ/ACK = 0x%02x,0x%02x\n", __func__ ,
382 param->pv.i & 0xff, param->pv.i >> 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
384 return 0;
385}
386
387/*
388 * Function ircomm_param_line_status (self, param)
389 *
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900390 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 *
392 */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900393static int ircomm_param_line_status(void *instance, irda_param_t *param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 int get)
395{
Joe Perches955a9d202014-11-11 14:44:57 -0800396 pr_debug("%s(), not impl.\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398 return 0;
399}
400
401/*
402 * Function ircomm_param_dte (instance, param)
403 *
404 * If we get here, there must be some sort of null-modem connection, and
405 * we are probably working in server mode as well.
406 */
407static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
408{
409 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
410 __u8 dte;
411
412 IRDA_ASSERT(self != NULL, return -1;);
413 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
414
415 if (get)
416 param->pv.i = self->settings.dte;
417 else {
418 dte = (__u8) param->pv.i;
419
420 self->settings.dce = 0;
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900421
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 if (dte & IRCOMM_DELTA_DTR)
423 self->settings.dce |= (IRCOMM_DELTA_DSR|
424 IRCOMM_DELTA_RI |
425 IRCOMM_DELTA_CD);
426 if (dte & IRCOMM_DTR)
427 self->settings.dce |= (IRCOMM_DSR|
428 IRCOMM_RI |
429 IRCOMM_CD);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 if (dte & IRCOMM_DELTA_RTS)
432 self->settings.dce |= IRCOMM_DELTA_CTS;
433 if (dte & IRCOMM_RTS)
434 self->settings.dce |= IRCOMM_CTS;
435
436 /* Take appropriate actions */
437 ircomm_tty_check_modem_status(self);
438
439 /* Null modem cable emulator */
440 self->settings.null_modem = TRUE;
441 }
442
443 return 0;
444}
445
446/*
447 * Function ircomm_param_dce (instance, param)
448 *
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900449 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 *
451 */
452static int ircomm_param_dce(void *instance, irda_param_t *param, int get)
453{
454 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
455 __u8 dce;
456
Joe Perches955a9d202014-11-11 14:44:57 -0800457 pr_debug("%s(), dce = 0x%02x\n", __func__ , (__u8)param->pv.i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459 dce = (__u8) param->pv.i;
460
461 IRDA_ASSERT(self != NULL, return -1;);
462 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
463
464 self->settings.dce = dce;
465
466 /* Check if any of the settings have changed */
467 if (dce & 0x0f) {
468 if (dce & IRCOMM_DELTA_CTS) {
Joe Perches955a9d202014-11-11 14:44:57 -0800469 pr_debug("%s(), CTS\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 }
471 }
472
473 ircomm_tty_check_modem_status(self);
474
475 return 0;
476}
477
478/*
479 * Function ircomm_param_poll (instance, param)
480 *
481 * Called when the peer device is polling for the line settings
482 *
483 */
484static int ircomm_param_poll(void *instance, irda_param_t *param, int get)
485{
486 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
487
488 IRDA_ASSERT(self != NULL, return -1;);
489 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
490
Joe Perchescc53ded2007-12-20 14:00:51 -0800491 /* Poll parameters are always of length 0 (just a signal) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 if (!get) {
493 /* Respond with DTE line settings */
494 ircomm_param_request(self, IRCOMM_DTE, TRUE);
495 }
496 return 0;
497}
498
499
500
501
502