diff options
author | J Freyensee <james_p_freyensee@linux.intel.com> | 2010-12-09 10:37:36 +0000 |
---|---|---|
committer | Alan Cox <alan@linux.intel.com> | 2010-12-09 10:37:36 +0000 |
commit | 06d9e71de05eea87b2498f58459b7274fc28f91e (patch) | |
tree | 8fadeeea4cdaa9ff3945ab4fcb9079783cd359de /drivers | |
parent | 45527ddb943b9a779b7e1283bf3e0909d54d9e22 (diff) | |
download | mrst-s0i3-test-06d9e71de05eea87b2498f58459b7274fc28f91e.tar.gz mrst-s0i3-test-06d9e71de05eea87b2498f58459b7274fc28f91e.tar.xz mrst-s0i3-test-06d9e71de05eea87b2498f58459b7274fc28f91e.zip |
pti: channel ID management rework
This patch fixes some issues with how channel ID was managed, like:
1. more efficiently utilize the array space keeping track of channel id's
2. simplify the getID() algorithm based on PTI simplification
3. re-manuver the mutex unlock where getID() is used
Signed-off-by: J Freyensee <james_p_freyensee@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/pti.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c index 8f4d9abf425..5fda02c8cf9 100644 --- a/drivers/misc/pti.c +++ b/drivers/misc/pti.c @@ -46,9 +46,9 @@ #define CHARNAME "pti" #define PTITTY_MINOR_START 0 #define PTITTY_MINOR_NUM 2 -#define MAX_APP_IDS 128 -#define MAX_OS_IDS 128 -#define MAX_MODEM_IDS 128 +#define MAX_APP_IDS 16 /* 128 channel ids / u8 bit size */ +#define MAX_OS_IDS 16 /* 128 channel ids / u8 bit size */ +#define MAX_MODEM_IDS 16 /* 128 channel ids / u8 bit size */ #define MODEM_BASE_ID 71 /* modem master ID address */ #define CONTROL_ID 72 /* control master ID address */ #define CONSOLE_ID 73 /* console master ID address */ @@ -243,7 +243,7 @@ static struct masterchannel *getID(u8 *IDarray, int max_IDS, int baseID) kfree(mc); return 0; } - /* find the bit */ + /* find the bit in the 128 possible channel opportunities */ mask = 0x80; for (j = 0; j < 8; j++) { if ((IDarray[i] & mask) == 0) @@ -253,7 +253,7 @@ static struct masterchannel *getID(u8 *IDarray, int max_IDS, int baseID) /* grab it */ IDarray[i] |= mask; - mc->master = (i>>4)+baseID; + mc->master = baseID; mc->channel = ((i & 0xf)<<3) + j; /* write new master Id / channel Id allocation to channel control */ pti_control_frame_built_and_sent(mc); @@ -297,9 +297,9 @@ struct masterchannel *mipi_request_masterchannel(u8 type) case 2: mc = getID(drv_data->IA_Modem, MAX_MODEM_IDS, MODEM_BASE_ID); + break; default: - mutex_unlock(&alloclock); - return 0; + mc = 0; } mutex_unlock(&alloclock); @@ -431,8 +431,10 @@ static int pti_tty_driver_open(struct tty_struct *tty, struct file *filp) mc = mipi_request_masterchannel(0); else mc = mipi_request_masterchannel(2); - if (mc == 0) - return -EBUSY; + + if (mc == 0) + return -ENXIO; + pti_tty_data->mc = mc; return ret; @@ -507,9 +509,7 @@ static void pti_tty_cleanup(struct tty_struct *tty) * master, channel write ID. * @param data: trace data to be written. * @param len: # of byte to write. - * @param ppose: Not used in this function implementation. - * @return int : # of bytes written, or error. -EMSGSIZE is - * returned if length is beyond 8k. + * @return int : # of bytes written, or error. */ int pti_tty_driver_write(struct tty_struct *tty, const unsigned char *buf, int len) |