aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r--drivers/isdn/gigaset/common.c134
1 files changed, 111 insertions, 23 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index e4141bf8b2f3..33dcd8d72b7c 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -22,6 +22,12 @@
22#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers" 22#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers"
23#define DRIVER_DESC "Driver for Gigaset 307x" 23#define DRIVER_DESC "Driver for Gigaset 307x"
24 24
25#ifdef CONFIG_GIGASET_DEBUG
26#define DRIVER_DESC_DEBUG " (debug build)"
27#else
28#define DRIVER_DESC_DEBUG ""
29#endif
30
25/* Module parameters */ 31/* Module parameters */
26int gigaset_debuglevel = DEBUG_DEFAULT; 32int gigaset_debuglevel = DEBUG_DEFAULT;
27EXPORT_SYMBOL_GPL(gigaset_debuglevel); 33EXPORT_SYMBOL_GPL(gigaset_debuglevel);
@@ -32,6 +38,17 @@ MODULE_PARM_DESC(debug, "debug level");
32#define VALID_MINOR 0x01 38#define VALID_MINOR 0x01
33#define VALID_ID 0x02 39#define VALID_ID 0x02
34 40
41/**
42 * gigaset_dbg_buffer() - dump data in ASCII and hex for debugging
43 * @level: debugging level.
44 * @msg: message prefix.
45 * @len: number of bytes to dump.
46 * @buf: data to dump.
47 *
48 * If the current debugging level includes one of the bits set in @level,
49 * @len bytes starting at @buf are logged to dmesg at KERN_DEBUG prio,
50 * prefixed by the text @msg.
51 */
35void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, 52void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
36 size_t len, const unsigned char *buf) 53 size_t len, const unsigned char *buf)
37{ 54{
@@ -274,6 +291,20 @@ static void clear_events(struct cardstate *cs)
274 spin_unlock_irqrestore(&cs->ev_lock, flags); 291 spin_unlock_irqrestore(&cs->ev_lock, flags);
275} 292}
276 293
294/**
295 * gigaset_add_event() - add event to device event queue
296 * @cs: device descriptor structure.
297 * @at_state: connection state structure.
298 * @type: event type.
299 * @ptr: pointer parameter for event.
300 * @parameter: integer parameter for event.
301 * @arg: pointer parameter for event.
302 *
303 * Allocate an event queue entry from the device's event queue, and set it up
304 * with the parameters given.
305 *
306 * Return value: added event
307 */
277struct event_t *gigaset_add_event(struct cardstate *cs, 308struct event_t *gigaset_add_event(struct cardstate *cs,
278 struct at_state_t *at_state, int type, 309 struct at_state_t *at_state, int type,
279 void *ptr, int parameter, void *arg) 310 void *ptr, int parameter, void *arg)
@@ -398,6 +429,15 @@ static void make_invalid(struct cardstate *cs, unsigned mask)
398 spin_unlock_irqrestore(&drv->lock, flags); 429 spin_unlock_irqrestore(&drv->lock, flags);
399} 430}
400 431
432/**
433 * gigaset_freecs() - free all associated ressources of a device
434 * @cs: device descriptor structure.
435 *
436 * Stops all tasklets and timers, unregisters the device from all
437 * subsystems it was registered to, deallocates the device structure
438 * @cs and all structures referenced from it.
439 * Operations on the device should be stopped before calling this.
440 */
401void gigaset_freecs(struct cardstate *cs) 441void gigaset_freecs(struct cardstate *cs)
402{ 442{
403 int i; 443 int i;
@@ -506,7 +546,12 @@ static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs,
506 inbuf->inputstate = inputstate; 546 inbuf->inputstate = inputstate;
507} 547}
508 548
509/* append received bytes to inbuf */ 549/**
550 * gigaset_fill_inbuf() - append received data to input buffer
551 * @inbuf: buffer structure.
552 * @src: received data.
553 * @numbytes: number of bytes received.
554 */
510int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, 555int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
511 unsigned numbytes) 556 unsigned numbytes)
512{ 557{
@@ -606,20 +651,22 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
606 return NULL; 651 return NULL;
607} 652}
608 653
609/* gigaset_initcs 654/**
655 * gigaset_initcs() - initialize device structure
656 * @drv: hardware driver the device belongs to
657 * @channels: number of B channels supported by device
658 * @onechannel: !=0 if B channel data and AT commands share one
659 * communication channel (M10x),
660 * ==0 if B channels have separate communication channels (base)
661 * @ignoreframes: number of frames to ignore after setting up B channel
662 * @cidmode: !=0: start in CallID mode
663 * @modulename: name of driver module for LL registration
664 *
610 * Allocate and initialize cardstate structure for Gigaset driver 665 * Allocate and initialize cardstate structure for Gigaset driver
611 * Calls hardware dependent gigaset_initcshw() function 666 * Calls hardware dependent gigaset_initcshw() function
612 * Calls B channel initialization function gigaset_initbcs() for each B channel 667 * Calls B channel initialization function gigaset_initbcs() for each B channel
613 * parameters: 668 *
614 * drv hardware driver the device belongs to 669 * Return value:
615 * channels number of B channels supported by device
616 * onechannel !=0: B channel data and AT commands share one
617 * communication channel
618 * ==0: B channels have separate communication channels
619 * ignoreframes number of frames to ignore after setting up B channel
620 * cidmode !=0: start in CallID mode
621 * modulename name of driver module (used for I4L registration)
622 * return value:
623 * pointer to cardstate structure 670 * pointer to cardstate structure
624 */ 671 */
625struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, 672struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
@@ -837,6 +884,17 @@ static void cleanup_cs(struct cardstate *cs)
837} 884}
838 885
839 886
887/**
888 * gigaset_start() - start device operations
889 * @cs: device descriptor structure.
890 *
891 * Prepares the device for use by setting up communication parameters,
892 * scheduling an EV_START event to initiate device initialization, and
893 * waiting for completion of the initialization.
894 *
895 * Return value:
896 * 1 - success, 0 - error
897 */
840int gigaset_start(struct cardstate *cs) 898int gigaset_start(struct cardstate *cs)
841{ 899{
842 unsigned long flags; 900 unsigned long flags;
@@ -879,9 +937,15 @@ error:
879} 937}
880EXPORT_SYMBOL_GPL(gigaset_start); 938EXPORT_SYMBOL_GPL(gigaset_start);
881 939
882/* gigaset_shutdown 940/**
883 * check if a device is associated to the cardstate structure and stop it 941 * gigaset_shutdown() - shut down device operations
884 * return value: 0 if ok, -1 if no device was associated 942 * @cs: device descriptor structure.
943 *
944 * Deactivates the device by scheduling an EV_SHUTDOWN event and
945 * waiting for completion of the shutdown.
946 *
947 * Return value:
948 * 0 - success, -1 - error (no device associated)
885 */ 949 */
886int gigaset_shutdown(struct cardstate *cs) 950int gigaset_shutdown(struct cardstate *cs)
887{ 951{
@@ -912,6 +976,13 @@ exit:
912} 976}
913EXPORT_SYMBOL_GPL(gigaset_shutdown); 977EXPORT_SYMBOL_GPL(gigaset_shutdown);
914 978
979/**
980 * gigaset_stop() - stop device operations
981 * @cs: device descriptor structure.
982 *
983 * Stops operations on the device by scheduling an EV_STOP event and
984 * waiting for completion of the shutdown.
985 */
915void gigaset_stop(struct cardstate *cs) 986void gigaset_stop(struct cardstate *cs)
916{ 987{
917 mutex_lock(&cs->mutex); 988 mutex_lock(&cs->mutex);
@@ -1020,6 +1091,14 @@ struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
1020 return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start); 1091 return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
1021} 1092}
1022 1093
1094/**
1095 * gigaset_freedriver() - free all associated ressources of a driver
1096 * @drv: driver descriptor structure.
1097 *
1098 * Unregisters the driver from the system and deallocates the driver
1099 * structure @drv and all structures referenced from it.
1100 * All devices should be shut down before calling this.
1101 */
1023void gigaset_freedriver(struct gigaset_driver *drv) 1102void gigaset_freedriver(struct gigaset_driver *drv)
1024{ 1103{
1025 unsigned long flags; 1104 unsigned long flags;
@@ -1035,14 +1114,16 @@ void gigaset_freedriver(struct gigaset_driver *drv)
1035} 1114}
1036EXPORT_SYMBOL_GPL(gigaset_freedriver); 1115EXPORT_SYMBOL_GPL(gigaset_freedriver);
1037 1116
1038/* gigaset_initdriver 1117/**
1118 * gigaset_initdriver() - initialize driver structure
1119 * @minor: First minor number
1120 * @minors: Number of minors this driver can handle
1121 * @procname: Name of the driver
1122 * @devname: Name of the device files (prefix without minor number)
1123 *
1039 * Allocate and initialize gigaset_driver structure. Initialize interface. 1124 * Allocate and initialize gigaset_driver structure. Initialize interface.
1040 * parameters: 1125 *
1041 * minor First minor number 1126 * Return value:
1042 * minors Number of minors this driver can handle
1043 * procname Name of the driver
1044 * devname Name of the device files (prefix without minor number)
1045 * return value:
1046 * Pointer to the gigaset_driver structure on success, NULL on failure. 1127 * Pointer to the gigaset_driver structure on success, NULL on failure.
1047 */ 1128 */
1048struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, 1129struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
@@ -1095,6 +1176,13 @@ error:
1095} 1176}
1096EXPORT_SYMBOL_GPL(gigaset_initdriver); 1177EXPORT_SYMBOL_GPL(gigaset_initdriver);
1097 1178
1179/**
1180 * gigaset_blockdriver() - block driver
1181 * @drv: driver descriptor structure.
1182 *
1183 * Prevents the driver from attaching new devices, in preparation for
1184 * deregistration.
1185 */
1098void gigaset_blockdriver(struct gigaset_driver *drv) 1186void gigaset_blockdriver(struct gigaset_driver *drv)
1099{ 1187{
1100 drv->blocked = 1; 1188 drv->blocked = 1;
@@ -1110,7 +1198,7 @@ static int __init gigaset_init_module(void)
1110 if (gigaset_debuglevel == 1) 1198 if (gigaset_debuglevel == 1)
1111 gigaset_debuglevel = DEBUG_DEFAULT; 1199 gigaset_debuglevel = DEBUG_DEFAULT;
1112 1200
1113 pr_info(DRIVER_DESC "\n"); 1201 pr_info(DRIVER_DESC DRIVER_DESC_DEBUG "\n");
1114 return 0; 1202 return 0;
1115} 1203}
1116 1204