aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-12-08 10:57:40 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:40 +0000
commit755f02ebc5c177aa5e9358a87f6b2b54a9b5fb9a (patch)
tree31909a42578d2b1140816b2a3e3cce35b302cc7b
parentbc2913d077de652acbb53aec69ef5af0580228a5 (diff)
downloadmrst-s0i3-test-755f02ebc5c177aa5e9358a87f6b2b54a9b5fb9a.tar.gz
mrst-s0i3-test-755f02ebc5c177aa5e9358a87f6b2b54a9b5fb9a.tar.xz
mrst-s0i3-test-755f02ebc5c177aa5e9358a87f6b2b54a9b5fb9a.zip
pti_router_ldisc: Clean up
- Remove unit test mode - Prune lots of debug that isn't relevant for upstream - Shorten some slightly overkill debugging - if we know the function name we know enough - There is no guarantee that the ldisc data pointer will be NULL on open so remove the check - The ldisc_data object isn't used so remove the rest of this logic - Fix the comments to pass through kerneldoc (@return isn't valid multi-line headers confuse it)
-rw-r--r--drivers/char/Kconfig16
-rw-r--r--drivers/tty/ptirouter_ldisc.c193
2 files changed, 60 insertions, 149 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index f286f48d503..5a895c929e1 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -114,14 +114,14 @@ config PTI_ROUTER
tristate "Trace data router for MIPI P1149.7 cJTAG standard"
depends on INTEL_MID_PTI
---help---
- The PTI router uses the Linux tty line discipline framework to route
- trace data coming from a HW Modem to a PTI (Parallel Trace Inferface)
- port. This is part of a solution for the MIPI P1149.7, compact JTAG,
- standard, which is for debugging mobile devices. The PTI
- Driver is also needed for this solution.
-
- You should select this driver if the target kernel is meant for
- a mobile device containing a MIPI P1149.7 standard implementation.
+ The PTI router uses the Linux tty line discipline framework to route
+ trace data coming from a HW Modem to a PTI (Parallel Trace Inferface)
+ port. This is part of a solution for the MIPI P1149.7, compact JTAG,
+ standard, which is for debugging mobile devices. A PTI
+ driver is also needed for this solution.
+
+ You should select this driver if the target kernel is meant for
+ a mobile device containing a MIPI P1149.7 standard implementation.
config SERIAL_NONSTANDARD
bool "Non-standard serial port support"
diff --git a/drivers/tty/ptirouter_ldisc.c b/drivers/tty/ptirouter_ldisc.c
index 2417dca46ac..7e72d419091 100644
--- a/drivers/tty/ptirouter_ldisc.c
+++ b/drivers/tty/ptirouter_ldisc.c
@@ -45,110 +45,52 @@
* 'I can always accept 64k' and flow control is off.
* This number is deemed appropriate for this driver.
*/
-#define RECEIVE_ROOM 65536
-#define DRIVERNAME "ptirouter_ldisc"
-#define TTY2PTIR(tty) ((tty)->disc_data)
-/**
- * struct used to maintain stats of active ldisc connection.
- * Members could grow as the need is discovered.
- */
-struct ptirouter_data {
- struct tty_struct *tty;
-};
+#define RECEIVE_ROOM 65536
+#define DRIVERNAME "ptirouter_ldisc"
/**
* ptirouter_ldisc_open() - Called when a tty is opened by a SW entity.
- * @tty: terminal device to the ldisc. It's being
- * assumed it is always a valid pointer.
- * @return: 0 for success, any other value error
+ * @tty: terminal device to the ldisc.
+ *
+ * Return:
+ * 0 for success.
*/
+
static int ptirouter_ldisc_open(struct tty_struct *tty)
{
- int retval = -EINVAL;
- struct ptirouter_data *ptr;
-
- BUG_ON(tty == NULL);
- ptr = TTY2PTIR(tty);
-
- if (ptr != NULL) {
- pr_err("%s(%d): tty data already assigned!\n",
- __func__, __LINE__);
- retval = -EEXIST;
- } else {
- ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
- if (ptr == NULL) {
- pr_err("%s(%d): kmalloc() failed.\n",
- __func__, __LINE__);
- retval = -ENOMEM;
- } else {
- tty->disc_data = ptr;
- ptr->tty = tty;
- tty->receive_room = RECEIVE_ROOM;
- tty_driver_flush_buffer(tty);
-
- pr_debug("%s(%d): Successful operation.\n",
- __func__, __LINE__);
- retval = 0;
- }
- }
-
- return retval;
+ tty->receive_room = RECEIVE_ROOM;
+ tty_driver_flush_buffer(tty);
+ return 0;
}
/**
- * ptirouter_ldisc_close() - Called when a software entity wants to close
- * a connection.
- * @tty: terminal device to the ldisc. It's being
- * assumed it is always a valid pointer.
+ * ptirouter_ldisc_close() - close connection
+ * @tty: terminal device to the ldisc.
+ *
+ * Called when a software entity wants to close a connection.
*/
static void ptirouter_ldisc_close(struct tty_struct *tty)
{
- struct ptirouter_data *ptr;
-
- BUG_ON(tty == NULL);
- ptr = TTY2PTIR(tty);
-
- pr_debug("%s %s(%d) called (device=%s)\n\n", __FILE__,
- __func__, __LINE__, tty->name);
-
- if (ptr != NULL) {
- tty_driver_flush_buffer(tty);
- kfree(ptr);
- tty->disc_data = NULL;
- }
-}
-
-/**
- * This block of code is specifically for unit testing, putting
- * this driver in a unit test environment and not needing the
- * pti device driver to compile or function.
- */
-#ifdef PTIR_UT
-void pti_write(struct tty_struct *tty, const unsigned char *cp, int count)
-{
- pr_debug("%s %s(%d) called (device=%s)\n", __FILE__,
- __func__, __LINE__, tty->name);
- pr_debug(" data in buffer passed into %s: %s\n", __func__, cp);
- pr_debug(" # of bytes passed into %s: %d\n\n", __func__, count);
+ tty_driver_flush_buffer(tty);
}
-#endif
/**
- * ptirouter_ldisc_read() - function that allows read() functionality
- * in userspace.
+ * ptirouter_ldisc_read() - read request from user space
* @tty: terminal device passed into the ldisc.
* @file: pointer to open file object.
* @buf: pointer to the data buffer that gets eventually returned.
* @nr: number of bytes of the data buffer that is returned.
- * @return: -EINVAL
*
- * By default if this is not implemented it returns -EIO. This module
- * is functioning like a router via ptirouter_ldisc_receivebuf(),
- * and there is no real requirement to implement this function.
- * However, an error return value other than -EIO should be used
- * just to show that there was an intent not to have this function
- * implemented. Return value based on read() man pages.
+ * function that allows read() functionality in userspace. By default if this
+ * is not implemented it returns -EIO. This module is functioning like a
+ * router via ptirouter_ldisc_receivebuf(), and there is no real requirement
+ * to implement this function. However, an error return value other than
+ * -EIO should be used just to show that there was an intent not to have
+ * this function implemented. Return value based on read() man pages.
+ *
+ * Return:
+ * -EINVAL
*/
ssize_t ptirouter_ldisc_read(struct tty_struct *tty, struct file *file,
unsigned char *buf, size_t nr) {
@@ -161,7 +103,6 @@ ssize_t ptirouter_ldisc_read(struct tty_struct *tty, struct file *file,
* @file: pointer to open file object.
* @buf: pointer to the data buffer that gets eventually returned.
* @nr: number of bytes of the data buffer that is returned.
- * @return: -EINVAL
*
* By default if this is not implemented, it returns -EIO.
* This should not be implemented, ever, because
@@ -171,6 +112,9 @@ ssize_t ptirouter_ldisc_read(struct tty_struct *tty, struct file *file,
* However, an error return value other than -EIO should be used
* just to show that there was an intent not to have this function
* implemented. Return value based on write() man pages.
+ *
+ * Return:
+ * -EINVAL
*/
ssize_t ptirouter_ldisc_write(struct tty_struct *tty, struct file *file,
const unsigned char *buf, size_t nr) {
@@ -187,48 +131,22 @@ ssize_t ptirouter_ldisc_write(struct tty_struct *tty, struct file *file,
* @count: number of characters (aka, bytes) in cp.
*
* This function takes the input buffer, cp, and passes it to
- * an external API function for processing. Note it is being
- * assumed that the tty here is the same as the tty passed in
- * as open(). If this is not acceptable, then we would need
- * a ptirouter_data pointer variable whose member tty points
- * to the same tty that gets passed into the function.
+ * an external API function for processing.
*/
static void ptirouter_ldisc_receivebuf(struct tty_struct *tty,
const unsigned char *cp,
char *fp, int count)
{
- struct masterchannel mc;
-
- mc.master = 71; /* 71 is the master ID for modem messages */
- mc.channel = 0; /* Only channel 0 for now */
-
- BUG_ON(tty == NULL);
-
- if (cp != NULL) {
- pr_debug("======== PTIR buffer transfer start ========\n");
- pr_debug("%s %s(%d) called (device=%s)\n", __FILE__,
- __func__, __LINE__, tty->name);
-
- #ifdef PTIR_UT
- pti_write(tty, cp, count);
- #else
- mipi_pti_writedata((void *) &mc, (u8 *)cp, count);
- #endif
- pr_debug("\n%s %s(%d) ", __FILE__, __func__, __LINE__);
- pr_debug("%d bytes sent to pti driver's route() call.\n",
- count);
- pr_debug("buffer contents in pti router sent to pti driver: ");
- pr_debug("%s\n", cp);
- pr_debug("======== PTIR buffer transfer complete ========\n\n");
- } else
- pr_debug("%s(%d): buffer passed in was NULL.\n",
- __func__, __LINE__);
+ /* 71 is the master ID for modem messages */
+ /* Only channel 0 for now */
+ static struct masterchannel mc = {.master = 71, .channel = 0 };
+ mipi_pti_writedata((void *) &mc, (u8 *)cp, count);
}
-/* note it is not believed that flush_buffer() needs to be implemented
- * as tty_driver_flush_buffer() is being used and looks sufficient
- * for this driver's needs.
+/* Flush buffer is not impelemented as the ldisc has no internal buffering
+ * so the tty_driver_flush_buffer() is sufficient for this driver's needs.
*/
+
static struct tty_ldisc_ops tty_ptirouter_ldisc = {
.owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC,
@@ -237,12 +155,16 @@ static struct tty_ldisc_ops tty_ptirouter_ldisc = {
.close = ptirouter_ldisc_close,
.read = ptirouter_ldisc_read,
.write = ptirouter_ldisc_write,
- .receive_buf = ptirouter_ldisc_receivebuf,
+ .receive_buf = ptirouter_ldisc_receivebuf
};
/**
- * ptirouter_ldisc_init() - Registers this module as a line discipline driver.
- * @return: 0 for success, any other value error.
+ * ptirouter_ldisc_init - module initialisation
+ *
+ * Registers this module as a line discipline driver.
+ *
+ * Return:
+ * 0 for success, any other value error.
*/
static int __init ptirouter_ldisc_init(void)
{
@@ -250,36 +172,25 @@ static int __init ptirouter_ldisc_init(void)
/* Note N_PTIR is defined in linux/tty.h */
retval = tty_register_ldisc(N_PTIR, &tty_ptirouter_ldisc);
- if (retval == 0)
- pr_debug("%s(%d): Registration success of ptirouter_ldisc\n",
- __func__, __LINE__);
- else {
- pr_err("%s(%d): Registration failed of ptirouter_ldisc\n",
- __func__, __LINE__);
- pr_err("%s(%d): Error value returned: %d\n",
- __func__, __LINE__, retval);
- }
-
+ if (retval < 0)
+ pr_err("%s: Registration failed: %d\n",
+ __func__, retval);
return retval;
}
/**
- * ptirouter_ldisc_exit() - Removes this module as a line discipline driver.
+ * ptirouter_ldisc_exit - - module unload
+ *
+ * Removes this module as a line discipline driver.
*/
static void __exit ptirouter_ldisc_exit(void)
{
int retval;
retval = tty_unregister_ldisc(N_PTIR);
- if (retval == 0)
- pr_debug("%s(%d): Unregistration success of ptirouter_ldisc\n",
- __func__, __LINE__);
- else {
- pr_err("%s(%d): Unregistration failed of ptirouter_ldisc\n",
- __func__, __LINE__);
- pr_err("%s(%d): Error value returned: %d\n",
- __func__, __LINE__, retval);
- }
+ if (retval < 0)
+ pr_err("%s: Unregistration failed: %d\n",
+ __func__, retval);
}
module_init(ptirouter_ldisc_init);