2005-04-17 06:20:36 +08:00
|
|
|
/*********************************************************************
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Filename: ircomm_param.c
|
|
|
|
* Version: 1.0
|
|
|
|
* Description: Parameter handling for the IrCOMM protocol
|
|
|
|
* Status: Experimental.
|
|
|
|
* Author: Dag Brattli <dagb@cs.uit.no>
|
|
|
|
* Created at: Mon Jun 7 10:25:11 1999
|
|
|
|
* Modified at: Sun Jan 30 14:32:03 2000
|
|
|
|
* Modified by: Dag Brattli <dagb@cs.uit.no>
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
2005-04-17 06:20:36 +08:00
|
|
|
* the License, or (at your option) any later version.
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2013-12-07 01:13:43 +08:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
********************************************************************/
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/gfp.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
|
|
|
#include <net/irda/irda.h>
|
|
|
|
#include <net/irda/parameters.h>
|
|
|
|
|
|
|
|
#include <net/irda/ircomm_core.h>
|
|
|
|
#include <net/irda/ircomm_tty_attach.h>
|
|
|
|
#include <net/irda/ircomm_tty.h>
|
|
|
|
|
|
|
|
#include <net/irda/ircomm_param.h>
|
|
|
|
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_service_type(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_port_type(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_port_name(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_service_type(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_data_rate(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_data_format(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_flow_control(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
|
|
|
static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get);
|
|
|
|
static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get);
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_line_status(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get);
|
|
|
|
static int ircomm_param_dte(void *instance, irda_param_t *param, int get);
|
|
|
|
static int ircomm_param_dce(void *instance, irda_param_t *param, int get);
|
|
|
|
static int ircomm_param_poll(void *instance, irda_param_t *param, int get);
|
|
|
|
|
2014-12-11 02:28:58 +08:00
|
|
|
static const pi_minor_info_t pi_minor_call_table_common[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{ ircomm_param_service_type, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_port_type, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_port_name, PV_STRING }
|
|
|
|
};
|
2014-12-11 02:28:58 +08:00
|
|
|
static const pi_minor_info_t pi_minor_call_table_non_raw[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{ ircomm_param_data_rate, PV_INT_32_BITS | PV_BIG_ENDIAN },
|
|
|
|
{ ircomm_param_data_format, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_flow_control, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_xon_xoff, PV_INT_16_BITS },
|
|
|
|
{ ircomm_param_enq_ack, PV_INT_16_BITS },
|
|
|
|
{ ircomm_param_line_status, PV_INT_8_BITS }
|
|
|
|
};
|
2014-12-11 02:28:58 +08:00
|
|
|
static const pi_minor_info_t pi_minor_call_table_9_wire[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{ ircomm_param_dte, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_dce, PV_INT_8_BITS },
|
|
|
|
{ ircomm_param_poll, PV_NO_VALUE },
|
|
|
|
};
|
|
|
|
|
2014-12-11 02:28:58 +08:00
|
|
|
static const pi_major_info_t pi_major_call_table[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{ pi_minor_call_table_common, 3 },
|
|
|
|
{ pi_minor_call_table_non_raw, 6 },
|
2007-02-09 22:24:53 +08:00
|
|
|
{ pi_minor_call_table_9_wire, 3 }
|
2005-04-17 06:20:36 +08:00
|
|
|
/* { pi_minor_call_table_centronics } */
|
|
|
|
};
|
|
|
|
|
|
|
|
pi_param_info_t ircomm_param_info = { pi_major_call_table, 3, 0x0f, 4 };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_request (self, pi, flush)
|
|
|
|
*
|
|
|
|
* Queue a parameter for the control channel
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
/* Make sure we don't send parameters for raw mode */
|
|
|
|
if (self->service_type == IRCOMM_3_WIRE_RAW)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&self->spinlock, flags);
|
|
|
|
|
2007-02-09 22:24:53 +08:00
|
|
|
skb = self->ctrl_skb;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!skb) {
|
2006-07-22 05:50:41 +08:00
|
|
|
skb = alloc_skb(256, GFP_ATOMIC);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!skb) {
|
|
|
|
spin_unlock_irqrestore(&self->spinlock, flags);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
skb_reserve(skb, self->max_header_size);
|
|
|
|
self->ctrl_skb = skb;
|
|
|
|
}
|
2007-02-09 22:24:53 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Inserting is a little bit tricky since we don't know how much
|
2007-02-09 22:24:53 +08:00
|
|
|
* room we will need. But this should hopefully work OK
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2007-04-20 11:29:13 +08:00
|
|
|
count = irda_param_insert(self, pi, skb_tail_pointer(skb),
|
|
|
|
skb_tailroom(skb), &ircomm_param_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (count < 0) {
|
2014-11-12 05:37:30 +08:00
|
|
|
net_warn_ratelimited("%s(), no room for parameter!\n",
|
|
|
|
__func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_unlock_irqrestore(&self->spinlock, flags);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
skb_put(skb, count);
|
2016-01-30 03:58:03 +08:00
|
|
|
pr_debug("%s(), skb->len=%d\n", __func__, skb->len);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&self->spinlock, flags);
|
|
|
|
|
|
|
|
if (flush) {
|
|
|
|
/* ircomm_tty_do_softint will take care of the rest */
|
|
|
|
schedule_work(&self->tqueue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_service_type (self, buf, len)
|
|
|
|
*
|
|
|
|
* Handle service type, this function will both be called after the LM-IAS
|
|
|
|
* query and then the remote device sends its initial parameters
|
|
|
|
*
|
|
|
|
*/
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_service_type(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
__u8 service_type = (__u8) param->pv.i;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
if (get) {
|
|
|
|
param->pv.i = self->settings.service_type;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find all common service types */
|
|
|
|
service_type &= self->service_type;
|
|
|
|
if (!service_type) {
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), No common service type to use!\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), services in common=%02x\n", __func__ ,
|
|
|
|
service_type);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now choose a preferred service type of those available
|
|
|
|
*/
|
|
|
|
if (service_type & IRCOMM_CENTRONICS)
|
|
|
|
self->settings.service_type = IRCOMM_CENTRONICS;
|
|
|
|
else if (service_type & IRCOMM_9_WIRE)
|
|
|
|
self->settings.service_type = IRCOMM_9_WIRE;
|
|
|
|
else if (service_type & IRCOMM_3_WIRE)
|
|
|
|
self->settings.service_type = IRCOMM_3_WIRE;
|
|
|
|
else if (service_type & IRCOMM_3_WIRE_RAW)
|
|
|
|
self->settings.service_type = IRCOMM_3_WIRE_RAW;
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), resulting service type=0x%02x\n", __func__ ,
|
|
|
|
self->settings.service_type);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-09 22:24:53 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Now the line is ready for some communication. Check if we are a
|
2007-02-09 22:24:53 +08:00
|
|
|
* server, and send over some initial parameters.
|
2005-04-17 06:20:36 +08:00
|
|
|
* Client do it in ircomm_tty_state_setup().
|
|
|
|
* Note : we may get called from ircomm_tty_getvalue_confirm(),
|
|
|
|
* therefore before we even have open any socket. And self->client
|
|
|
|
* is initialised to TRUE only later. So, we check if the link is
|
|
|
|
* really initialised. - Jean II
|
|
|
|
*/
|
|
|
|
if ((self->max_header_size != IRCOMM_TTY_HDR_UNINITIALISED) &&
|
|
|
|
(!self->client) &&
|
|
|
|
(self->settings.service_type != IRCOMM_3_WIRE_RAW))
|
|
|
|
{
|
|
|
|
/* Init connection */
|
|
|
|
ircomm_tty_send_initial_parameters(self);
|
|
|
|
ircomm_tty_link_established(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_port_type (self, param)
|
|
|
|
*
|
|
|
|
* The port type parameter tells if the devices are serial or parallel.
|
|
|
|
* Since we only advertise serial service, this parameter should only
|
|
|
|
* be equal to IRCOMM_SERIAL.
|
|
|
|
*/
|
|
|
|
static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (get)
|
|
|
|
param->pv.i = IRCOMM_SERIAL;
|
|
|
|
else {
|
|
|
|
self->settings.port_type = (__u8) param->pv.i;
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), port type=%d\n", __func__ ,
|
|
|
|
self->settings.port_type);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_port_name (self, param)
|
|
|
|
*
|
|
|
|
* Exchange port name
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
if (get) {
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), not imp!\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), port-name=%s\n", __func__ , param->pv.c);
|
2005-04-17 06:20:36 +08:00
|
|
|
strncpy(self->settings.port_name, param->pv.c, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_data_rate (self, param)
|
|
|
|
*
|
|
|
|
* Exchange data rate to be used in this settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
if (get)
|
|
|
|
param->pv.i = self->settings.data_rate;
|
|
|
|
else
|
|
|
|
self->settings.data_rate = param->pv.i;
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), data rate = %d\n", __func__ , param->pv.i);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_data_format (self, param)
|
|
|
|
*
|
|
|
|
* Exchange data format to be used in this settings
|
|
|
|
*
|
|
|
|
*/
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_data_format(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
if (get)
|
|
|
|
param->pv.i = self->settings.data_format;
|
|
|
|
else
|
|
|
|
self->settings.data_format = (__u8) param->pv.i;
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_flow_control (self, param)
|
|
|
|
*
|
|
|
|
* Exchange flow control settings to be used in this settings
|
|
|
|
*
|
|
|
|
*/
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_flow_control(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (get)
|
|
|
|
param->pv.i = self->settings.flow_control;
|
|
|
|
else
|
|
|
|
self->settings.flow_control = (__u8) param->pv.i;
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), flow control = 0x%02x\n", __func__ , (__u8)param->pv.i);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_xon_xoff (self, param)
|
|
|
|
*
|
|
|
|
* Exchange XON/XOFF characters
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (get) {
|
|
|
|
param->pv.i = self->settings.xonxoff[0];
|
|
|
|
param->pv.i |= self->settings.xonxoff[1] << 8;
|
|
|
|
} else {
|
|
|
|
self->settings.xonxoff[0] = (__u16) param->pv.i & 0xff;
|
|
|
|
self->settings.xonxoff[1] = (__u16) param->pv.i >> 8;
|
|
|
|
}
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), XON/XOFF = 0x%02x,0x%02x\n", __func__ ,
|
|
|
|
param->pv.i & 0xff, param->pv.i >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_enq_ack (self, param)
|
|
|
|
*
|
|
|
|
* Exchange ENQ/ACK characters
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (get) {
|
|
|
|
param->pv.i = self->settings.enqack[0];
|
|
|
|
param->pv.i |= self->settings.enqack[1] << 8;
|
|
|
|
} else {
|
|
|
|
self->settings.enqack[0] = (__u16) param->pv.i & 0xff;
|
|
|
|
self->settings.enqack[1] = (__u16) param->pv.i >> 8;
|
|
|
|
}
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), ENQ/ACK = 0x%02x,0x%02x\n", __func__ ,
|
|
|
|
param->pv.i & 0xff, param->pv.i >> 8);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_line_status (self, param)
|
|
|
|
*
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
*/
|
2007-02-09 22:24:53 +08:00
|
|
|
static int ircomm_param_line_status(void *instance, irda_param_t *param,
|
2005-04-17 06:20:36 +08:00
|
|
|
int get)
|
|
|
|
{
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), not impl.\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_dte (instance, param)
|
|
|
|
*
|
|
|
|
* If we get here, there must be some sort of null-modem connection, and
|
|
|
|
* we are probably working in server mode as well.
|
|
|
|
*/
|
|
|
|
static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
__u8 dte;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
if (get)
|
|
|
|
param->pv.i = self->settings.dte;
|
|
|
|
else {
|
|
|
|
dte = (__u8) param->pv.i;
|
|
|
|
|
|
|
|
self->settings.dce = 0;
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dte & IRCOMM_DELTA_DTR)
|
|
|
|
self->settings.dce |= (IRCOMM_DELTA_DSR|
|
|
|
|
IRCOMM_DELTA_RI |
|
|
|
|
IRCOMM_DELTA_CD);
|
|
|
|
if (dte & IRCOMM_DTR)
|
|
|
|
self->settings.dce |= (IRCOMM_DSR|
|
|
|
|
IRCOMM_RI |
|
|
|
|
IRCOMM_CD);
|
2007-02-09 22:24:53 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dte & IRCOMM_DELTA_RTS)
|
|
|
|
self->settings.dce |= IRCOMM_DELTA_CTS;
|
|
|
|
if (dte & IRCOMM_RTS)
|
|
|
|
self->settings.dce |= IRCOMM_CTS;
|
|
|
|
|
|
|
|
/* Take appropriate actions */
|
|
|
|
ircomm_tty_check_modem_status(self);
|
|
|
|
|
|
|
|
/* Null modem cable emulator */
|
|
|
|
self->settings.null_modem = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_dce (instance, param)
|
|
|
|
*
|
2007-02-09 22:24:53 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_dce(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
__u8 dce;
|
|
|
|
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), dce = 0x%02x\n", __func__ , (__u8)param->pv.i);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
dce = (__u8) param->pv.i;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
|
|
|
self->settings.dce = dce;
|
|
|
|
|
|
|
|
/* Check if any of the settings have changed */
|
|
|
|
if (dce & 0x0f) {
|
|
|
|
if (dce & IRCOMM_DELTA_CTS) {
|
2014-11-12 06:44:57 +08:00
|
|
|
pr_debug("%s(), CTS\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ircomm_tty_check_modem_status(self);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function ircomm_param_poll (instance, param)
|
|
|
|
*
|
|
|
|
* Called when the peer device is polling for the line settings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int ircomm_param_poll(void *instance, irda_param_t *param, int get)
|
|
|
|
{
|
|
|
|
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
|
|
|
|
|
|
|
|
IRDA_ASSERT(self != NULL, return -1;);
|
|
|
|
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
|
|
|
|
|
2007-12-21 06:00:51 +08:00
|
|
|
/* Poll parameters are always of length 0 (just a signal) */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!get) {
|
|
|
|
/* Respond with DTE line settings */
|
|
|
|
ircomm_param_request(self, IRCOMM_DTE, TRUE);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|